mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
Fixed lint issue CheckResult
This commit is contained in:
parent
30773dad42
commit
f473e7f92e
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.language.viewmodel
|
package org.kiwix.kiwixmobile.language.viewmodel
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import io.reactivex.Flowable
|
import io.reactivex.Flowable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
@ -24,6 +25,7 @@ import org.kiwix.kiwixmobile.core.base.SideEffect
|
|||||||
import org.kiwix.kiwixmobile.core.dao.NewLanguagesDao
|
import org.kiwix.kiwixmobile.core.dao.NewLanguagesDao
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.Language
|
import org.kiwix.kiwixmobile.core.zim_manager.Language
|
||||||
|
|
||||||
|
@SuppressLint("CheckResult")
|
||||||
data class SaveLanguagesAndFinish(
|
data class SaveLanguagesAndFinish(
|
||||||
val languages: List<Language>,
|
val languages: List<Language>,
|
||||||
val languageDao: NewLanguagesDao
|
val languageDao: NewLanguagesDao
|
||||||
|
@ -245,6 +245,7 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
|
|||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
|
availableSpaceCalculator.dispose()
|
||||||
fragmentDestinationDownloadBinding?.libraryList?.adapter = null
|
fragmentDestinationDownloadBinding?.libraryList?.adapter = null
|
||||||
fragmentDestinationDownloadBinding = null
|
fragmentDestinationDownloadBinding = null
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.webserver
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import io.reactivex.Flowable
|
import io.reactivex.Flowable
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
import io.reactivex.disposables.Disposable
|
||||||
import org.kiwix.kiwixmobile.core.utils.DEFAULT_PORT
|
import org.kiwix.kiwixmobile.core.utils.DEFAULT_PORT
|
||||||
import org.kiwix.kiwixmobile.core.utils.ServerUtils
|
import org.kiwix.kiwixmobile.core.utils.ServerUtils
|
||||||
import org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP
|
import org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP
|
||||||
@ -40,6 +41,7 @@ class WebServerHelper @Inject constructor(
|
|||||||
) {
|
) {
|
||||||
private var kiwixServer: KiwixServer? = null
|
private var kiwixServer: KiwixServer? = null
|
||||||
private var isServerStarted = false
|
private var isServerStarted = false
|
||||||
|
private var validIpAddressDisposable: Disposable? = null
|
||||||
|
|
||||||
fun startServerHelper(selectedBooksPath: ArrayList<String>): Boolean {
|
fun startServerHelper(selectedBooksPath: ArrayList<String>): Boolean {
|
||||||
val ip = getIpAddress()
|
val ip = getIpAddress()
|
||||||
@ -79,7 +81,7 @@ class WebServerHelper @Inject constructor(
|
|||||||
// If no ip is found after 15 seconds, dismisses the progress dialog
|
// If no ip is found after 15 seconds, dismisses the progress dialog
|
||||||
@Suppress("MagicNumber")
|
@Suppress("MagicNumber")
|
||||||
fun pollForValidIpAddress() {
|
fun pollForValidIpAddress() {
|
||||||
Flowable.interval(1, TimeUnit.SECONDS)
|
validIpAddressDisposable = Flowable.interval(1, TimeUnit.SECONDS)
|
||||||
.map { getIp() }
|
.map { getIp() }
|
||||||
.filter { s: String? -> s != INVALID_IP }
|
.filter { s: String? -> s != INVALID_IP }
|
||||||
.timeout(15, TimeUnit.SECONDS)
|
.timeout(15, TimeUnit.SECONDS)
|
||||||
@ -96,6 +98,10 @@ class WebServerHelper @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun dispose() {
|
||||||
|
validIpAddressDisposable?.dispose()
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "WebServerHelper"
|
private const val TAG = "WebServerHelper"
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ class HotspotService :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
webServerHelper?.dispose()
|
||||||
hotspotStateReceiver?.let(this@HotspotService::unregisterReceiver)
|
hotspotStateReceiver?.let(this@HotspotService::unregisterReceiver)
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.zimManager
|
package org.kiwix.kiwixmobile.zimManager
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.os.FileObserver
|
import android.os.FileObserver
|
||||||
import io.reactivex.Flowable
|
import io.reactivex.Flowable
|
||||||
import io.reactivex.functions.BiFunction
|
import io.reactivex.functions.BiFunction
|
||||||
@ -32,6 +33,7 @@ import org.kiwix.kiwixmobile.zimManager.FileSystemCapability.CAN_WRITE_4GB
|
|||||||
import org.kiwix.kiwixmobile.zimManager.FileSystemCapability.INCONCLUSIVE
|
import org.kiwix.kiwixmobile.zimManager.FileSystemCapability.INCONCLUSIVE
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
@SuppressLint("CheckResult")
|
||||||
class Fat32Checker constructor(
|
class Fat32Checker constructor(
|
||||||
sharedPreferenceUtil: SharedPreferenceUtil,
|
sharedPreferenceUtil: SharedPreferenceUtil,
|
||||||
private val fileSystemCheckers: List<FileSystemChecker>
|
private val fileSystemCheckers: List<FileSystemChecker>
|
||||||
|
@ -246,12 +246,14 @@ class ZimManageViewModel @Inject constructor(
|
|||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
{
|
{
|
||||||
kiwixService.library
|
compositeDisposable?.add(
|
||||||
.retry(5)
|
kiwixService.library
|
||||||
.subscribe(library::onNext) {
|
.retry(5)
|
||||||
it.printStackTrace()
|
.subscribe(library::onNext) {
|
||||||
library.onNext(LibraryNetworkEntity().apply { book = LinkedList() })
|
it.printStackTrace()
|
||||||
}
|
library.onNext(LibraryNetworkEntity().apply { book = LinkedList() })
|
||||||
|
}
|
||||||
|
)
|
||||||
},
|
},
|
||||||
Throwable::printStackTrace
|
Throwable::printStackTrace
|
||||||
)
|
)
|
||||||
|
@ -21,6 +21,7 @@ package org.kiwix.kiwixmobile.zimManager.libraryView
|
|||||||
import eu.mhutti1.utils.storage.Bytes
|
import eu.mhutti1.utils.storage.Bytes
|
||||||
import eu.mhutti1.utils.storage.Kb
|
import eu.mhutti1.utils.storage.Kb
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
import io.reactivex.disposables.Disposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import org.kiwix.kiwixmobile.core.dao.FetchDownloadDao
|
import org.kiwix.kiwixmobile.core.dao.FetchDownloadDao
|
||||||
import org.kiwix.kiwixmobile.core.downloader.model.DownloadModel
|
import org.kiwix.kiwixmobile.core.downloader.model.DownloadModel
|
||||||
@ -32,12 +33,13 @@ class AvailableSpaceCalculator @Inject constructor(
|
|||||||
private val downloadDao: FetchDownloadDao,
|
private val downloadDao: FetchDownloadDao,
|
||||||
private val storageCalculator: StorageCalculator
|
private val storageCalculator: StorageCalculator
|
||||||
) {
|
) {
|
||||||
|
private var availableSpaceCalculatorDisposable: Disposable? = null
|
||||||
fun hasAvailableSpaceFor(
|
fun hasAvailableSpaceFor(
|
||||||
bookItem: LibraryListItem.BookItem,
|
bookItem: LibraryListItem.BookItem,
|
||||||
successAction: (LibraryListItem.BookItem) -> Unit,
|
successAction: (LibraryListItem.BookItem) -> Unit,
|
||||||
failureAction: (String) -> Unit
|
failureAction: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
downloadDao.allDownloads()
|
availableSpaceCalculatorDisposable = downloadDao.allDownloads()
|
||||||
.map { it.map(DownloadModel::bytesRemaining).sum() }
|
.map { it.map(DownloadModel::bytesRemaining).sum() }
|
||||||
.map { bytesToBeDownloaded -> storageCalculator.availableBytes() - bytesToBeDownloaded }
|
.map { bytesToBeDownloaded -> storageCalculator.availableBytes() - bytesToBeDownloaded }
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
@ -50,4 +52,8 @@ class AvailableSpaceCalculator @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun dispose() {
|
||||||
|
availableSpaceCalculatorDisposable?.dispose()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,6 @@ class AllProjectConfigurer {
|
|||||||
"GoogleAppIndexingApiWarning",
|
"GoogleAppIndexingApiWarning",
|
||||||
"LockedOrientationActivity",
|
"LockedOrientationActivity",
|
||||||
//TODO stop ignoring below this
|
//TODO stop ignoring below this
|
||||||
"CheckResult",
|
|
||||||
"LabelFor",
|
"LabelFor",
|
||||||
"LogConditional",
|
"LogConditional",
|
||||||
"ConvertToWebp",
|
"ConvertToWebp",
|
||||||
|
@ -30,6 +30,7 @@ import eu.mhutti1.utils.storage.adapter.StorageAdapter
|
|||||||
import eu.mhutti1.utils.storage.adapter.StorageDelegate
|
import eu.mhutti1.utils.storage.adapter.StorageDelegate
|
||||||
import io.reactivex.Flowable
|
import io.reactivex.Flowable
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
import io.reactivex.disposables.Disposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import org.kiwix.kiwixmobile.core.CoreApp
|
import org.kiwix.kiwixmobile.core.CoreApp
|
||||||
import org.kiwix.kiwixmobile.core.databinding.StorageSelectDialogBinding
|
import org.kiwix.kiwixmobile.core.databinding.StorageSelectDialogBinding
|
||||||
@ -44,6 +45,7 @@ class StorageSelectDialog : DialogFragment() {
|
|||||||
@Inject lateinit var sharedPreferenceUtil: SharedPreferenceUtil
|
@Inject lateinit var sharedPreferenceUtil: SharedPreferenceUtil
|
||||||
private var aTitle: String? = null
|
private var aTitle: String? = null
|
||||||
private var storageSelectDialogViewBinding: StorageSelectDialogBinding? = null
|
private var storageSelectDialogViewBinding: StorageSelectDialogBinding? = null
|
||||||
|
private var storageDisposable: Disposable? = null
|
||||||
|
|
||||||
private val storageAdapter: StorageAdapter by lazy {
|
private val storageAdapter: StorageAdapter by lazy {
|
||||||
StorageAdapter(
|
StorageAdapter(
|
||||||
@ -73,13 +75,14 @@ class StorageSelectDialog : DialogFragment() {
|
|||||||
setHasFixedSize(true)
|
setHasFixedSize(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flowable.fromCallable { StorageDeviceUtils.getWritableStorage(requireActivity()) }
|
storageDisposable =
|
||||||
.subscribeOn(Schedulers.io())
|
Flowable.fromCallable { StorageDeviceUtils.getWritableStorage(requireActivity()) }
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.subscribeOn(Schedulers.io())
|
||||||
.subscribe(
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
{ storageAdapter.items = it },
|
.subscribe(
|
||||||
Throwable::printStackTrace
|
{ storageAdapter.items = it },
|
||||||
)
|
Throwable::printStackTrace
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun show(fm: FragmentManager, text: String?) {
|
override fun show(fm: FragmentManager, text: String?) {
|
||||||
@ -89,6 +92,7 @@ class StorageSelectDialog : DialogFragment() {
|
|||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
|
storageDisposable?.dispose()
|
||||||
storageSelectDialogViewBinding = null
|
storageSelectDialogViewBinding = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.core
|
package org.kiwix.kiwixmobile.core
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
@ -24,6 +25,7 @@ import org.kiwix.kiwixmobile.core.NightModeConfig.Mode.SYSTEM
|
|||||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@SuppressLint("CheckResult")
|
||||||
class NightModeConfig @Inject constructor(
|
class NightModeConfig @Inject constructor(
|
||||||
val sharedPreferenceUtil: SharedPreferenceUtil,
|
val sharedPreferenceUtil: SharedPreferenceUtil,
|
||||||
val context: Context
|
val context: Context
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.downloader
|
package org.kiwix.kiwixmobile.core.downloader
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import org.kiwix.kiwixmobile.core.dao.FetchDownloadDao
|
import org.kiwix.kiwixmobile.core.dao.FetchDownloadDao
|
||||||
import org.kiwix.kiwixmobile.core.data.remote.KiwixService
|
import org.kiwix.kiwixmobile.core.data.remote.KiwixService
|
||||||
@ -31,6 +32,7 @@ class DownloaderImpl @Inject constructor(
|
|||||||
private val kiwixService: KiwixService
|
private val kiwixService: KiwixService
|
||||||
) : Downloader {
|
) : Downloader {
|
||||||
|
|
||||||
|
@SuppressLint("CheckResult")
|
||||||
override fun download(book: LibraryNetworkEntity.Book) {
|
override fun download(book: LibraryNetworkEntity.Book) {
|
||||||
urlProvider(book)
|
urlProvider(book)
|
||||||
.take(1)
|
.take(1)
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.core.downloader.fetch
|
package org.kiwix.kiwixmobile.core.downloader.fetch
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import com.tonyodev.fetch2.Download
|
import com.tonyodev.fetch2.Download
|
||||||
import com.tonyodev.fetch2.Error
|
import com.tonyodev.fetch2.Error
|
||||||
import com.tonyodev.fetch2.Fetch
|
import com.tonyodev.fetch2.Fetch
|
||||||
@ -28,6 +29,7 @@ import org.kiwix.kiwixmobile.core.dao.FetchDownloadDao
|
|||||||
import org.kiwix.kiwixmobile.core.downloader.DownloadMonitor
|
import org.kiwix.kiwixmobile.core.downloader.DownloadMonitor
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@SuppressLint("CheckResult")
|
||||||
class FetchDownloadMonitor @Inject constructor(fetch: Fetch, fetchDownloadDao: FetchDownloadDao) :
|
class FetchDownloadMonitor @Inject constructor(fetch: Fetch, fetchDownloadDao: FetchDownloadDao) :
|
||||||
DownloadMonitor {
|
DownloadMonitor {
|
||||||
private val updater = PublishSubject.create<() -> Unit>()
|
private val updater = PublishSubject.create<() -> Unit>()
|
||||||
|
@ -439,6 +439,7 @@ class AddNoteDialog : DialogFragment() {
|
|||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
|
mainRepositoryActions.dispose()
|
||||||
dialogNoteAddNoteBinding = null
|
dialogNoteAddNoteBinding = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -802,6 +802,7 @@ abstract class CoreReaderFragment :
|
|||||||
val activity = requireActivity() as AppCompatActivity?
|
val activity = requireActivity() as AppCompatActivity?
|
||||||
activity?.setSupportActionBar(null)
|
activity?.setSupportActionBar(null)
|
||||||
}
|
}
|
||||||
|
repositoryActions?.dispose()
|
||||||
safeDispose()
|
safeDispose()
|
||||||
tabCallback = null
|
tabCallback = null
|
||||||
hideBackToTopTimer?.cancel()
|
hideBackToTopTimer?.cancel()
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package org.kiwix.kiwixmobile.core.main
|
package org.kiwix.kiwixmobile.core.main
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import io.reactivex.disposables.Disposable
|
||||||
import org.kiwix.kiwixmobile.core.data.DataSource
|
import org.kiwix.kiwixmobile.core.data.DataSource
|
||||||
import org.kiwix.kiwixmobile.core.di.ActivityScope
|
import org.kiwix.kiwixmobile.core.di.ActivityScope
|
||||||
import org.kiwix.kiwixmobile.core.page.bookmark.adapter.BookmarkItem
|
import org.kiwix.kiwixmobile.core.page.bookmark.adapter.BookmarkItem
|
||||||
@ -29,14 +30,18 @@ private const val TAG = "MainPresenter"
|
|||||||
|
|
||||||
@ActivityScope
|
@ActivityScope
|
||||||
class MainRepositoryActions @Inject constructor(private val dataSource: DataSource) {
|
class MainRepositoryActions @Inject constructor(private val dataSource: DataSource) {
|
||||||
|
private var saveHistoryDisposable: Disposable? = null
|
||||||
|
private var saveBookmarkDisposable: Disposable? = null
|
||||||
|
private var saveNoteDisposable: Disposable? = null
|
||||||
|
private var deleteNoteDisposable: Disposable? = null
|
||||||
|
|
||||||
fun saveHistory(history: HistoryItem) {
|
fun saveHistory(history: HistoryItem) {
|
||||||
dataSource.saveHistory(history)
|
saveHistoryDisposable = dataSource.saveHistory(history)
|
||||||
.subscribe({}, { e -> Log.e(TAG, "Unable to save history", e) })
|
.subscribe({}, { e -> Log.e(TAG, "Unable to save history", e) })
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveBookmark(bookmark: BookmarkItem) {
|
fun saveBookmark(bookmark: BookmarkItem) {
|
||||||
dataSource.saveBookmark(bookmark)
|
saveBookmarkDisposable = dataSource.saveBookmark(bookmark)
|
||||||
.subscribe({}, { e -> Log.e(TAG, "Unable to save bookmark", e) })
|
.subscribe({}, { e -> Log.e(TAG, "Unable to save bookmark", e) })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,12 +52,19 @@ class MainRepositoryActions @Inject constructor(private val dataSource: DataSour
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun saveNote(note: NoteListItem) {
|
fun saveNote(note: NoteListItem) {
|
||||||
dataSource.saveNote(note)
|
saveNoteDisposable = dataSource.saveNote(note)
|
||||||
.subscribe({}, { e -> Log.e(TAG, "Unable to save note", e) })
|
.subscribe({}, { e -> Log.e(TAG, "Unable to save note", e) })
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteNote(noteUniqueKey: String) {
|
fun deleteNote(noteUniqueKey: String) {
|
||||||
dataSource.deleteNote(noteUniqueKey)
|
deleteNoteDisposable = dataSource.deleteNote(noteUniqueKey)
|
||||||
.subscribe({}, { e -> Log.e(TAG, "Unable to delete note", e) })
|
.subscribe({}, { e -> Log.e(TAG, "Unable to delete note", e) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun dispose() {
|
||||||
|
saveHistoryDisposable?.dispose()
|
||||||
|
saveBookmarkDisposable?.dispose()
|
||||||
|
saveNoteDisposable?.dispose()
|
||||||
|
deleteNoteDisposable?.dispose()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.core.reader
|
package org.kiwix.kiwixmobile.core.reader
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.res.AssetFileDescriptor
|
import android.content.res.AssetFileDescriptor
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.ParcelFileDescriptor
|
import android.os.ParcelFileDescriptor
|
||||||
@ -173,6 +174,7 @@ class ZimFileReader constructor(
|
|||||||
|
|
||||||
private fun getContent(url: String) = getContentAndMimeType(url).let { (content, _) -> content }
|
private fun getContent(url: String) = getContentAndMimeType(url).let { (content, _) -> content }
|
||||||
|
|
||||||
|
@SuppressLint("CheckResult")
|
||||||
private fun streamZimContentToPipe(uri: String, outputStream: OutputStream) {
|
private fun streamZimContentToPipe(uri: String, outputStream: OutputStream) {
|
||||||
Completable.fromAction {
|
Completable.fromAction {
|
||||||
try {
|
try {
|
||||||
|
@ -127,6 +127,11 @@ abstract class CorePrefsFragment :
|
|||||||
.unregisterOnSharedPreferenceChangeListener(this)
|
.unregisterOnSharedPreferenceChangeListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
presenter?.dispose()
|
||||||
|
super.onDestroyView()
|
||||||
|
}
|
||||||
|
|
||||||
private fun setUpSettings() {
|
private fun setUpSettings() {
|
||||||
setAppVersionNumber()
|
setAppVersionNumber()
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package org.kiwix.kiwixmobile.core.settings
|
package org.kiwix.kiwixmobile.core.settings
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import io.reactivex.disposables.Disposable
|
||||||
import org.kiwix.kiwixmobile.core.base.BasePresenter
|
import org.kiwix.kiwixmobile.core.base.BasePresenter
|
||||||
import org.kiwix.kiwixmobile.core.data.DataSource
|
import org.kiwix.kiwixmobile.core.data.DataSource
|
||||||
import org.kiwix.kiwixmobile.core.settings.SettingsContract.Presenter
|
import org.kiwix.kiwixmobile.core.settings.SettingsContract.Presenter
|
||||||
@ -26,12 +27,17 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
internal class SettingsPresenter @Inject constructor(private val dataSource: DataSource) :
|
internal class SettingsPresenter @Inject constructor(private val dataSource: DataSource) :
|
||||||
BasePresenter<View?>(), Presenter {
|
BasePresenter<View?>(), Presenter {
|
||||||
|
private var dataSourceDisposable: Disposable? = null
|
||||||
override fun clearHistory() {
|
override fun clearHistory() {
|
||||||
dataSource.clearHistory()
|
dataSourceDisposable = dataSource.clearHistory()
|
||||||
.subscribe({
|
.subscribe({
|
||||||
// TODO
|
// TODO
|
||||||
}, { e ->
|
}, { e ->
|
||||||
Log.e("SettingsPresenter", e.message, e)
|
Log.e("SettingsPresenter", e.message, e)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun dispose() {
|
||||||
|
dataSourceDisposable?.dispose()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.dao
|
package org.kiwix.kiwixmobile.core.dao
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import io.mockk.CapturingSlot
|
import io.mockk.CapturingSlot
|
||||||
import io.mockk.clearAllMocks
|
import io.mockk.clearAllMocks
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
@ -63,6 +64,7 @@ internal class NewBookDaoTest {
|
|||||||
newBookDao.books().test().assertValues(listOf(BookOnDisk(expectedEntity)))
|
newBookDao.books().test().assertValues(listOf(BookOnDisk(expectedEntity)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("CheckResult")
|
||||||
@Test
|
@Test
|
||||||
fun `books deletes entities whose file does not exist`() {
|
fun `books deletes entities whose file does not exist`() {
|
||||||
val (_, deletedEntity) = expectEmissionOfExistingAndNotExistingBook()
|
val (_, deletedEntity) = expectEmissionOfExistingAndNotExistingBook()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user