Skip to content

Commit

Permalink
fix the issue where items weren't deleted when search mode is enable
Browse files Browse the repository at this point in the history
  • Loading branch information
kazemcodes committed Apr 24, 2022
1 parent 3b16397 commit 3dfcc8f
Show file tree
Hide file tree
Showing 25 changed files with 289 additions and 252 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<receiver
android:name="org.ireader.domain.services.broadcast_receiver.AppBroadcastReceiver"
android:exported="false" />

</application>

</manifest>
4 changes: 0 additions & 4 deletions app/src/main/java/org/ireader/infinity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,5 @@ class MainActivity : ComponentActivity() {
}
}

override fun onDestroy() {
super.onDestroy()
}

}

50 changes: 0 additions & 50 deletions app/src/main/java/org/ireader/infinity/di/AppModule.kt

This file was deleted.

14 changes: 1 addition & 13 deletions app/src/main/java/org/ireader/infinity/di/CatalogModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,15 @@ import org.ireader.data.catalog.AndroidCatalogInstallationChanges
import org.ireader.data.catalog.AndroidCatalogInstaller
import org.ireader.data.catalog.AndroidCatalogLoader
import org.ireader.data.catalog.CatalogGithubApi
import org.ireader.data.local.AppDatabase
import org.ireader.data.local.dao.CatalogDao
import org.ireader.data.repository.CatalogRemoteRepositoryImpl
import org.ireader.domain.catalog.service.*
import javax.inject.Singleton

@InstallIn(SingletonComponent::class)
@Module
class CatalogModule {

@Provides
@Singleton
fun provideCatalogRemoteRepository(catalogDao: CatalogDao): CatalogRemoteRepository {
return CatalogRemoteRepositoryImpl(dao = catalogDao)
}

@Provides
@Singleton
fun provideCatalogDao(db: AppDatabase): CatalogDao {
return db.catalogDao
}


@Provides
@Singleton
Expand Down
85 changes: 0 additions & 85 deletions app/src/main/java/org/ireader/infinity/di/LocalModule.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.ireader.infinity.di

import android.content.Context
import androidx.room.Room
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand All @@ -11,97 +10,13 @@ import okio.FileSystem
import okio.Path.Companion.toOkioPath
import org.ireader.core_api.prefs.AndroidPreferenceStore
import org.ireader.core_api.prefs.PreferenceStore
import org.ireader.data.local.AppDatabase
import org.ireader.data.local.MIGRATION_11_12
import org.ireader.data.local.MIGRATION_8_9
import org.ireader.data.local.dao.*
import org.ireader.data.repository.DownloadRepositoryImpl
import org.ireader.data.repository.UpdatesRepositoryImpl
import org.ireader.domain.feature_service.io.LibraryCovers
import org.ireader.domain.repository.DownloadRepository
import org.ireader.domain.repository.UpdatesRepository
import java.io.File
import javax.inject.Singleton

@InstallIn(SingletonComponent::class)
@Module
class LocalModule {


@Provides
@Singleton
fun provideBookDatabase(
@ApplicationContext app: Context,
): AppDatabase {
return Room.databaseBuilder(
app,
AppDatabase::class.java,
AppDatabase.DATABASE_NAME
)
.addMigrations(
MIGRATION_8_9,
MIGRATION_11_12
)
.fallbackToDestructiveMigration()
.build()
}
@Provides
@Singleton
fun providesBookDao(db: AppDatabase): LibraryBookDao {
return db.libraryBookDao
}


@Provides
@Singleton
fun provideChapterDao(db: AppDatabase): chapterDao {
return db.chapterDao
}

@Provides
@Singleton
fun provideRemoteKeyDao(db: AppDatabase): RemoteKeysDao {
return db.remoteKeysDao
}

@Provides
@Singleton
fun provideHistoryDao(db: AppDatabase): HistoryDao {
return db.historyDao
}

@Provides
@Singleton
fun provideUpdatesDao(db: AppDatabase): UpdatesDao {
return db.updatesDao
}


@Singleton
@Provides
fun provideDownloadRepository(
downloadDao: DownloadDao,
): DownloadRepository {
return DownloadRepositoryImpl(downloadDao)
}

@Singleton
@Provides
fun provideUpdatesRepository(
updatesDao: UpdatesDao,
): UpdatesRepository {
return UpdatesRepositoryImpl(updatesDao)
}

@Singleton
@Provides
fun provideDownloadDao(
database: AppDatabase,
): DownloadDao {
return database.downloadDao
}


@Provides
@Singleton
fun provideLibraryCovers(
Expand Down
33 changes: 0 additions & 33 deletions app/src/main/java/org/ireader/infinity/di/NetworkModule.kt

This file was deleted.

75 changes: 75 additions & 0 deletions app/src/main/java/org/ireader/infinity/di/RepositoryInject.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package org.ireader.infinity.di

import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import org.ireader.data.local.dao.*
import org.ireader.data.repository.*
import org.ireader.domain.catalog.service.CatalogRemoteRepository
import org.ireader.domain.repository.*
import javax.inject.Singleton


@InstallIn(SingletonComponent::class)
@Module
class RepositoryInject {

@Provides
@Singleton
fun provideRemoteKeyRepository(
remoteKeysDao: RemoteKeysDao,
): RemoteKeyRepository {
return RemoteKeyRepositoryImpl(
dao = remoteKeysDao,
)
}

@Singleton
@Provides
fun provideDownloadRepository(
downloadDao: DownloadDao,
): DownloadRepository {
return DownloadRepositoryImpl(downloadDao)
}

@Singleton
@Provides
fun provideUpdatesRepository(
updatesDao: UpdatesDao,
): UpdatesRepository {
return UpdatesRepositoryImpl(updatesDao)
}

@Provides
@Singleton
fun provideCatalogRemoteRepository(catalogDao: CatalogDao): CatalogRemoteRepository {
return CatalogRemoteRepositoryImpl(dao = catalogDao)
}

@Provides
@Singleton
fun providesLocalChapterRepository(chapterDao: chapterDao): LocalChapterRepository {
return LocalChapterRepositoryImpl(chapterDao)
}


@Provides
@Singleton
fun providesLibraryRepository(
libraryBookDao: LibraryBookDao,
remoteKeysDao: RemoteKeysDao,
): LocalBookRepository {
return LocalBookRepositoryImpl(libraryBookDao,
remoteKeysDao = remoteKeysDao)
}

@Provides
@Singleton
fun providesHistoryRepository(
historyDao: HistoryDao,
): HistoryRepository {
return HistoryRepositoryImpl(historyDao)
}

}
5 changes: 5 additions & 0 deletions core/src/main/java/org/ireader/core/utils/ExceptionExt.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.ireader.core.utils

import org.ireader.core.R
import org.ireader.core.exceptions.EmptyQuery
import org.ireader.core.exceptions.SourceNotFoundException
import org.jsoup.select.Selector
import timber.log.Timber
import java.io.IOException
Expand All @@ -27,6 +29,9 @@ fun exceptionHandler(e: Throwable): UiText? {
is java.lang.ClassCastException -> {
null
}
is EmptyQuery -> UiText.StringResource(R.string.query_must_not_be_empty)

is SourceNotFoundException -> UiText.StringResource(R.string.the_source_is_not_found)
else -> {
UiText.ExceptionString(e)
}
Expand Down
Loading

0 comments on commit 3dfcc8f

Please sign in to comment.