Skip to content

Commit

Permalink
fix expand more or expand less not working correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
kazemcodes committed Feb 10, 2022
1 parent b291f6c commit 6aa3dde
Show file tree
Hide file tree
Showing 73 changed files with 670 additions and 371 deletions.
17 changes: 0 additions & 17 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ dependencies {
implementation(AndroidX.browser)
implementation(AndroidX.material)
implementation(AndroidX.activity)
implementation(AndroidX.appStartUpRuntime)

testImplementation(Testing.junit4)
androidTestImplementation(Testing.extJunit)
Expand Down
20 changes: 17 additions & 3 deletions app/src/main/java/org/ireader/infinity/MyApplication.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package org.ireader.infinity

import android.app.Application
import android.content.Context
import android.webkit.WebView
import androidx.hilt.work.HiltWorkerFactory
import androidx.startup.Initializer
import androidx.work.Configuration
import androidx.work.WorkManager
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import dagger.hilt.android.HiltAndroidApp
import okhttp3.OkHttpClient
import org.ireader.domain.feature_services.notification.Notifications
Expand Down Expand Up @@ -46,7 +50,7 @@ class MyApplication : Application(), Configuration.Provider {
Timber.plant(Timber.DebugTree())
}
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this)

FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(!BuildConfig.DEBUG)

val appModule = module {
single<NetworkHelper> { networkHelper }
Expand All @@ -60,8 +64,6 @@ class MyApplication : Application(), Configuration.Provider {
startKoin {
modules(appModule)
}


setupNotificationChannels()
}

Expand All @@ -78,7 +80,19 @@ class MyApplication : Application(), Configuration.Provider {
.setWorkerFactory(workerFactory)
.build()


}

class WorkManagerInitializer : Initializer<WorkManager> {
override fun create(context: Context): WorkManager {
val configuration = Configuration.Builder().build()
WorkManager.initialize(context, configuration)
return WorkManager.getInstance(context)
}

override fun dependencies(): List<Class<out Initializer<*>>> {
return emptyList()
}
}


6 changes: 1 addition & 5 deletions app/src/main/java/org/ireader/infinity/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ import org.ireader.domain.local.dao.LibraryBookDao
import org.ireader.domain.local.dao.LibraryChapterDao
import org.ireader.domain.local.dao.RemoteKeysDao
import org.ireader.domain.local.dao.SourceTowerDao
import org.ireader.domain.repository.LocalChapterRepository
import org.ireader.domain.repository.LocalSourceRepository
import org.ireader.domain.repository.PreferencesHelper
import org.ireader.domain.repository.Repository
import org.ireader.infinity.core.domain.repository.LocalBookRepository
import org.ireader.domain.repository.*
import org.ireader.infinity.core.domain.repository.RemoteRepository
import javax.inject.Singleton

Expand Down
10 changes: 4 additions & 6 deletions app/src/main/java/org/ireader/infinity/di/LocalModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ import org.ireader.domain.local.dao.LibraryBookDao
import org.ireader.domain.local.dao.LibraryChapterDao
import org.ireader.domain.local.dao.RemoteKeysDao
import org.ireader.domain.local.dao.SourceTowerDao
import org.ireader.domain.repository.LocalBookRepository
import org.ireader.domain.repository.LocalChapterRepository
import org.ireader.domain.source.Extensions
import org.ireader.domain.use_cases.local.LocalGetBookUseCases
import org.ireader.domain.use_cases.local.LocalGetChapterUseCase
import org.ireader.domain.use_cases.local.book_usecases.GetAllInDownloadsPagingData
import org.ireader.domain.use_cases.local.book_usecases.GetAllInLibraryBooks
import org.ireader.domain.use_cases.local.book_usecases.GetAllInLibraryPagingSource
import org.ireader.domain.use_cases.local.book_usecases.GetBookById
import org.ireader.domain.use_cases.local.book_usecases.*
import org.ireader.domain.use_cases.local.chapter_usecases.GetLastReadChapter
import org.ireader.infinity.core.domain.repository.LocalBookRepository
import org.ireader.infinity.core.domain.use_cases.local.DeleteUseCase
import org.ireader.infinity.core.domain.use_cases.local.LocalInsertUseCases
import org.ireader.infinity.core.domain.use_cases.local.book_usecases.*
Expand Down Expand Up @@ -149,7 +146,8 @@ class LocalModule {
GetInLibraryBooksPagingData = GetInLibraryBooksPagingData(localBookRepository),
getAllExploredBookPagingData = GetAllExploredBookPagingData(localBookRepository = localBookRepository),
getAllInDownloadsPagingData = GetAllInDownloadsPagingData(
localBookRepository = localBookRepository)
localBookRepository = localBookRepository),
getBookByIdDirectly = GetBookByIdDirectly(localBookRepository)
)
}

Expand Down
Binary file modified buildSrc/build/classes/kotlin/main/AndroidX.class
Binary file not shown.
Binary file modified buildSrc/build/classes/kotlin/main/Datastore.class
Binary file not shown.
Binary file modified buildSrc/build/classes/kotlin/main/FlowPreferences.class
Binary file not shown.
Binary file modified buildSrc/build/kotlin/compileKotlin/build-history.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
24
26
0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified buildSrc/build/kotlin/compileKotlin/last-build.bin
Binary file not shown.
Binary file modified buildSrc/build/libs/buildSrc.jar
Binary file not shown.
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/AndroidX.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ object AndroidX {
const val browser = "androidx.browser:browser:1.4.0"
const val material = "com.google.android.material:material:1.5.0"
const val activity = "androidx.activity:activity-ktx:1.4.0"
const val appStartUpRuntime = "androidx.startup:startup-runtime:1.1.1"
}
6 changes: 6 additions & 0 deletions buildSrc/src/main/kotlin/Datastore.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
object Datastore {
const val datastore = "androidx.datastore:datastore-preferences:1.0.0"
const val core = "androidx.datastore:datastore-preferences-core:1.0.0"

private const val preference_version = "1.2.0"

// Java language implementation
// Kotlin
const val preferenceKtx = "androidx.preference:preference-ktx:$preference_version"
}

object FlowPreferences {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.ireader.core_ui.ui

import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.ireader.core.prefs.Preference

class PreferenceMutableState<T>(
private val preference: Preference<T>,
scope: CoroutineScope,
) : MutableState<T> {

private val state = mutableStateOf(preference.get())

init {
preference.changes()
.onEach { state.value = it }
.launchIn(scope)
}

override var value: T
get() = state.value
set(value) {
preference.set(value)
}

override fun component1(): T {
return state.value
}

override fun component2(): (T) -> Unit {
return { preference.set(it) }
}

}

fun <T> Preference<T>.asStateIn(scope: CoroutineScope): PreferenceMutableState<T> {
return PreferenceMutableState(this, scope)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import org.ireader.domain.local.dao.LibraryChapterDao
import org.ireader.domain.local.dao.RemoteKeysDao
import org.ireader.domain.models.SortType
import org.ireader.domain.models.entities.Book
import org.ireader.domain.repository.LocalBookRepository
import org.ireader.domain.utils.Resource
import org.ireader.infinity.core.domain.repository.LocalBookRepository
import timber.log.Timber

class LocalBookRepositoryImpl(
Expand Down Expand Up @@ -41,6 +41,20 @@ class LocalBookRepositoryImpl(

}

override fun getBookByIdDirectly(id: Int): Flow<Book?> = flow {
bookDao.getBookById(bookId = id)
.first { book ->
if (book != null) {
emit(book)
true
} else {
emit(null)
true
}
}
Timber.d("Timber: GetExploreBookByIdUseCase was Finished Successfully")
}

override fun getAllInLibraryPagingSource(
sortType: SortType,
isAsc: Boolean,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.ireader.data.repository

import org.ireader.domain.local.BookDatabase
import org.ireader.domain.repository.LocalBookRepository
import org.ireader.domain.repository.LocalChapterRepository
import org.ireader.domain.repository.PreferencesHelper
import org.ireader.domain.repository.Repository
import org.ireader.infinity.core.domain.repository.LocalBookRepository
import org.ireader.infinity.core.domain.repository.RemoteRepository
import javax.inject.Inject

Expand Down
3 changes: 3 additions & 0 deletions domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies {
"implementation"(project(Modules.source))

"implementation"(Compose.ui)
"implementation"(Compose.runtime)
"implementation"(Compose.navigation)
"implementation"(Worker.runtimeKtx)
"implementation"(DaggerHilt.worker)
Expand Down Expand Up @@ -40,5 +41,7 @@ dependencies {
"implementation"(Compose.paging)
"implementation"(Jsoup.jsoup)
"implementation"(Jsonpathkt.jsonpathkt)
"implementation"(Datastore.datastore)
"implementation"(Datastore.preferenceKtx)

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import org.ireader.domain.feature_services.notification.Notifications.CHANNEL_DO
import org.ireader.domain.feature_services.notification.Notifications.ID_DOWNLOAD_CHAPTER_COMPLETE
import org.ireader.domain.feature_services.notification.Notifications.ID_DOWNLOAD_CHAPTER_ERROR
import org.ireader.domain.feature_services.notification.Notifications.ID_DOWNLOAD_CHAPTER_PROGRESS
import org.ireader.domain.repository.LocalBookRepository
import org.ireader.domain.repository.LocalChapterRepository
import org.ireader.domain.source.Extensions
import org.ireader.infinity.core.domain.repository.LocalBookRepository
import org.ireader.infinity.core.domain.use_cases.local.LocalInsertUseCases
import org.ireader.use_cases.remote.RemoteUseCases
import timber.log.Timber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import kotlinx.coroutines.flow.flowOn
import org.ireader.domain.R
import org.ireader.domain.models.entities.Book
import org.ireader.domain.models.entities.Chapter
import org.ireader.domain.repository.LocalBookRepository
import org.ireader.domain.repository.LocalChapterRepository
import org.ireader.infinity.core.domain.repository.LocalBookRepository
import org.ireader.infinity.feature_services.flags
import timber.log.Timber

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.ireader.infinity.core.domain.repository
package org.ireader.domain.repository

import androidx.paging.PagingSource
import kotlinx.coroutines.flow.Flow
Expand All @@ -13,6 +13,8 @@ interface LocalBookRepository {

fun getBookById(id: Int): Flow<Resource<Book>>

fun getBookByIdDirectly(id: Int): Flow<Book?>

fun getAllInLibraryBooks(): Flow<List<Book>?>

fun getBooksByQueryByPagingSource(query: String): PagingSource<Int, Book>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.ireader.domain.repository

import org.ireader.domain.local.BookDatabase
import org.ireader.infinity.core.domain.repository.LocalBookRepository
import org.ireader.infinity.core.domain.repository.RemoteRepository

interface Repository {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package org.ireader.domain.use_cases.local

import org.ireader.domain.use_cases.local.book_usecases.GetAllInDownloadsPagingData
import org.ireader.domain.use_cases.local.book_usecases.GetAllInLibraryBooks
import org.ireader.domain.use_cases.local.book_usecases.GetAllInLibraryPagingSource
import org.ireader.domain.use_cases.local.book_usecases.GetBookById
import org.ireader.domain.use_cases.local.book_usecases.*
import org.ireader.infinity.core.domain.use_cases.local.book_usecases.*

data class LocalGetBookUseCases(
val getBookById: GetBookById,
val getBookByIdDirectly: GetBookByIdDirectly,
val GetInLibraryBooksPagingData: GetInLibraryBooksPagingData,
val getAllInLibraryPagingSource: GetAllInLibraryPagingSource,
val getAllInLibraryBooks: GetAllInLibraryBooks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.paging.PagingSource
import kotlinx.coroutines.flow.Flow
import org.ireader.core.utils.Constants
import org.ireader.domain.models.entities.Book
import org.ireader.infinity.core.domain.repository.LocalBookRepository
import org.ireader.domain.repository.LocalBookRepository

class GetAllExploredBookPagingSource(private val localBookRepository: LocalBookRepository) {
operator fun invoke(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import kotlinx.coroutines.flow.flow
import org.ireader.core.utils.UiText
import org.ireader.domain.R
import org.ireader.domain.models.entities.Book
import org.ireader.domain.repository.LocalBookRepository
import org.ireader.domain.utils.Resource
import org.ireader.infinity.core.domain.repository.LocalBookRepository
import retrofit2.HttpException
import java.io.IOException

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kotlinx.coroutines.flow.Flow
import org.ireader.core.utils.Constants
import org.ireader.domain.models.SortType
import org.ireader.domain.models.entities.Book
import org.ireader.infinity.core.domain.repository.LocalBookRepository
import org.ireader.domain.repository.LocalBookRepository


class GetAllInLibraryPagingSource(private val localBookRepository: LocalBookRepository) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package org.ireader.domain.use_cases.local.book_usecases

import kotlinx.coroutines.flow.Flow
import org.ireader.domain.models.entities.Book
import org.ireader.domain.repository.LocalBookRepository
import org.ireader.domain.utils.Resource
import org.ireader.infinity.core.domain.repository.LocalBookRepository

/**
* return a book from id
Expand All @@ -14,3 +14,10 @@ class GetBookById(private val localBookRepository: LocalBookRepository) {
}
}

class GetBookByIdDirectly(private val localBookRepository: LocalBookRepository) {
operator fun invoke(id: Int): Flow<Book?> {
return localBookRepository.getBookByIdDirectly(id = id)
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.paging.PagingData
import kotlinx.coroutines.flow.Flow
import org.ireader.core.utils.Constants
import org.ireader.domain.models.entities.Book
import org.ireader.infinity.core.domain.repository.LocalBookRepository
import org.ireader.domain.repository.LocalBookRepository

/**
* get a paging data that is used in library screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.ireader.infinity.core.domain.use_cases.local.book_usecases

import androidx.paging.PagingSource
import org.ireader.domain.models.entities.Book
import org.ireader.infinity.core.domain.repository.LocalBookRepository
import org.ireader.domain.repository.LocalBookRepository

class GetBooksByQueryPagingSource(private val localBookRepository: LocalBookRepository) {
operator fun invoke(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.ireader.core.utils.Constants
import org.ireader.domain.models.FilterType
import org.ireader.domain.models.SortType
import org.ireader.domain.models.entities.Book
import org.ireader.infinity.core.domain.repository.LocalBookRepository
import org.ireader.domain.repository.LocalBookRepository

/**
* Get Books that are in library and explore mode is false.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.ireader.infinity.core.domain.use_cases.local.delete_usecases.book

import org.ireader.infinity.core.domain.repository.LocalBookRepository
import org.ireader.domain.repository.LocalBookRepository

/**
* Delete All Book from database
Expand Down
Loading

0 comments on commit 6aa3dde

Please sign in to comment.