mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-16 10:56:50 -04:00
Merge pull request #3358 from kiwix/Issue#3341
Fixed deprecated constructor of `FileObserver`
This commit is contained in:
commit
2e749b41cd
@ -18,6 +18,7 @@
|
|||||||
package org.kiwix.kiwixmobile.zimManager
|
package org.kiwix.kiwixmobile.zimManager
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.os.Build
|
||||||
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
|
||||||
@ -62,12 +63,20 @@ class Fat32Checker constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fileObserver(it: String?): FileObserver {
|
private fun fileObserver(it: String): FileObserver {
|
||||||
return object : FileObserver(it, MOVED_FROM or DELETE) {
|
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
override fun onEvent(event: Int, path: String?) {
|
return object : FileObserver(File(it), MOVED_FROM or DELETE) {
|
||||||
requestCheckSystemFileType.onNext(Unit)
|
override fun onEvent(event: Int, path: String?) {
|
||||||
}
|
requestCheckSystemFileType.onNext(Unit)
|
||||||
}.apply { startWatching() }
|
}
|
||||||
|
}.apply { startWatching() }
|
||||||
|
} else {
|
||||||
|
object : FileObserver(it, FileObserver.MOVED_FROM or FileObserver.DELETE) {
|
||||||
|
override fun onEvent(event: Int, path: String?) {
|
||||||
|
requestCheckSystemFileType.onNext(Unit)
|
||||||
|
}
|
||||||
|
}.apply { startWatching() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toFileSystemState(it: String) =
|
private fun toFileSystemState(it: String) =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user