Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

完成数据层 #23

Merged
merged 8 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .idea/androidTestResultsUserPreferences.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/dictionaries/NightFish.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 30 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ plugins {
id("org.jetbrains.kotlin.android")
id("kotlin-kapt")
id("com.google.dagger.hilt.android")
id("com.google.devtools.ksp")
}

android {
namespace = "indi.dmzz_yyhyy.lightnovelreader"
compileSdk = 34

defaultConfig {
multiDexEnabled = true
applicationId = "indi.dmzz_yyhyy.lightnovelreader"
minSdk = 24
targetSdk = 34
Expand All @@ -32,6 +34,7 @@ android {
}
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
Expand All @@ -52,10 +55,13 @@ android {
}

dependencies {
// desugaring support
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
// android lib
implementation("androidx.core:core-ktx:1.13.1")
implementation ("androidx.core:core-splashscreen:1.0.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.3")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.3")
// compose
implementation("androidx.activity:activity-compose:1.9.0")
implementation(platform("androidx.compose:compose-bom:2024.06.00"))
Expand All @@ -72,9 +78,15 @@ dependencies {
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
// hilt
val hilt = "2.44"
val hilt = "2.49"
implementation("com.google.dagger:hilt-android:$hilt")
kapt("com.google.dagger:hilt-android-compiler:$hilt")
val androidXHilt = "1.2.0"
implementation("androidx.hilt:hilt-common:$androidXHilt")
implementation("androidx.hilt:hilt-compiler:$androidXHilt")
implementation("androidx.hilt:hilt-work:$androidXHilt")
implementation("androidx.hilt:hilt-navigation-compose:$androidXHilt")
// navigation
val navVersion = "2.7.7"
implementation("androidx.navigation:navigation-fragment-ktx:$navVersion")
implementation("androidx.navigation:navigation-ui-ktx:$navVersion")
Expand All @@ -83,9 +95,25 @@ dependencies {
implementation("androidx.navigation:navigation-compose:$navVersion")
// coil
implementation("io.coil-kt:coil-compose:2.6.0")

// jsoup
implementation("org.jsoup:jsoup:1.18.1")
// room
val roomVersion = "2.6.1"
implementation("androidx.room:room-runtime:$roomVersion")
annotationProcessor("androidx.room:room-compiler:$roomVersion")
ksp("androidx.room:room-compiler:$roomVersion")
implementation("androidx.room:room-ktx:$roomVersion")
implementation("androidx.room:room-rxjava2:$roomVersion")
implementation("androidx.room:room-rxjava3:$roomVersion")
implementation("androidx.room:room-guava:$roomVersion")
testImplementation("androidx.room:room-testing:$roomVersion")
implementation("androidx.room:room-paging:$roomVersion")
}

kapt {
correctErrorTypes = true
}

configurations.implementation{
exclude(group = "com.intellij", module = "annotations")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package indi.dmzz_yyhyy.lightnovelreader

import androidx.test.ext.junit.runners.AndroidJUnit4
import javax.inject.Inject
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class BookRepositoryTest @Inject constructor(
) {
@Test
@Throws(Exception::class)
fun getBookInformation() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package indi.dmzz_yyhyy.lightnovelreader

import androidx.room.Room
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import indi.dmzz_yyhyy.lightnovelreader.data.local.room.LightNovelReaderDatabase
import indi.dmzz_yyhyy.lightnovelreader.data.local.room.dao.BookInformationDao
import indi.dmzz_yyhyy.lightnovelreader.data.local.room.dao.BookVolumesDao
import indi.dmzz_yyhyy.lightnovelreader.data.location.TestBookData
import java.io.IOException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class DatabaseTest {

private lateinit var bookInformationDao: BookInformationDao
private lateinit var volumesDao: BookVolumesDao
private lateinit var db: LightNovelReaderDatabase

@Before
fun createDb() {
val context = InstrumentationRegistry.getInstrumentation().targetContext
db = Room.inMemoryDatabaseBuilder(context, LightNovelReaderDatabase::class.java)
.allowMainThreadQueries()
.build()
bookInformationDao = db.bookInformationDao()
volumesDao = db.bookVolumesDao()
}

@After
@Throws(IOException::class)
fun closeDb() {
db.close()
}



@Test
@Throws(Exception::class)
fun insertAndGet() {

CoroutineScope(Dispatchers.Default).launch {
bookInformationDao.update(TestBookData.bookInformation)
println(bookInformationDao.get(0))

volumesDao.update(0, TestBookData.bookVolumes)
println(volumesDao.getBookVolumes(0))
}
}
}

This file was deleted.

Loading
Loading