mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-13 09:26:52 -04:00
Fixed: Application crashing below API level 29 when we select the external storage.
* The issue was with the `FileObserver` class constructor we used, which is introduced in SDK 29. As a result, it is not available for older versions, leading to a `NoSuchMethodError` when attempting to access it. This caused the application to crash below API level 29 when selecting external storage.
This commit is contained in:
parent
7a73eb797a
commit
24e10caf19
@ -18,6 +18,7 @@
|
||||
package org.kiwix.kiwixmobile.zimManager
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Build
|
||||
import android.os.FileObserver
|
||||
import io.reactivex.Flowable
|
||||
import io.reactivex.functions.BiFunction
|
||||
@ -63,11 +64,20 @@ class Fat32Checker constructor(
|
||||
}
|
||||
|
||||
private fun fileObserver(it: String): FileObserver =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
object : FileObserver(File(it), MOVED_FROM or DELETE) {
|
||||
override fun onEvent(event: Int, path: String?) {
|
||||
requestCheckSystemFileType.onNext(Unit)
|
||||
}
|
||||
}.apply { startWatching() }
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
object : FileObserver(it, MOVED_FROM or DELETE) {
|
||||
override fun onEvent(event: Int, path: String?) {
|
||||
requestCheckSystemFileType.onNext(Unit)
|
||||
}
|
||||
}.apply { startWatching() }
|
||||
}
|
||||
|
||||
private fun toFileSystemState(it: String) =
|
||||
when {
|
||||
|
Loading…
x
Reference in New Issue
Block a user