mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Add: Paging Ktx Library
Add: Resource.kt sealed class for future async loading
This commit is contained in:
parent
8ddaedc64d
commit
ab5c26bec4
@ -53,7 +53,7 @@ android {
|
||||
}
|
||||
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion "1.1.0-rc02"
|
||||
kotlinCompilerExtensionVersion "1.2.0-alpha01"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@ -177,6 +177,9 @@ dependencies {
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0'
|
||||
|
||||
// Paging
|
||||
implementation 'androidx.paging:paging-runtime-ktx:3.1.0'
|
||||
|
||||
// Room
|
||||
implementation 'androidx.room:room-runtime:2.4.1'
|
||||
implementation 'androidx.room:room-ktx:2.4.1'
|
||||
|
7
src/main/kotlin/com/looker/droidify/Resource.kt
Normal file
7
src/main/kotlin/com/looker/droidify/Resource.kt
Normal file
@ -0,0 +1,7 @@
|
||||
package com.looker.droidify
|
||||
|
||||
sealed class Resource<T>(val data: T? = null, val message: String? = null) {
|
||||
class Loading<T>(data: T? = null) : Resource<T>(data)
|
||||
class Success<T>(data: T?) : Resource<T>(data)
|
||||
class Error<T>(message: String, data: T? = null) : Resource<T>(data, message)
|
||||
}
|
@ -13,7 +13,6 @@ import com.looker.droidify.database.Product
|
||||
import com.looker.droidify.entity.ProductItem
|
||||
import com.looker.droidify.ui.fragments.Request
|
||||
import com.looker.droidify.ui.fragments.Source
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
@ -109,7 +108,7 @@ class MainNavFragmentViewModelX(val db: DatabaseX, source: Source) : ViewModel()
|
||||
}
|
||||
|
||||
fun fillList(source: Source) {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
// productsList = query(request(source))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user