Commit 7602108d authored by wanglei's avatar wanglei

Merge remote-tracking branch 'origin/master'

parents b3324d55 0ff270d3
......@@ -16,7 +16,7 @@ import java.io.File
/**
* Observer MediaContent add
*/
class MediaContentObserver(val context: Context, val handler: Handler? = null) : ContentObserver(null) {
class MediaContentObserver(val context: Context) : ContentObserver(null) {
private val TAG = "MediaContentObserver"
......@@ -84,7 +84,6 @@ class MediaContentObserver(val context: Context, val handler: Handler? = null) :
binFile.createNewFile()
binFile.writeText(Gson().toJson(binBean))
LogEx.logDebug(TAG, "RecycleBin backup")
handler?.sendEmptyMessage(99)
}
}
}
......@@ -13,7 +13,7 @@ import com.google.gson.Gson
import java.io.File
@RequiresApi(Build.VERSION_CODES.Q)
class MyFileObserver(val handler: Handler? = null, files: List<File>) : FileObserver(files, ALL_EVENTS) {
class MyFileObserver(files: List<File>) : FileObserver(files, ALL_EVENTS) {
private val TAG = "MyFileObserver"
......@@ -75,7 +75,6 @@ class MyFileObserver(val handler: Handler? = null, files: List<File>) : FileObse
val wJson = Gson().toJson(bean)
recycleBinJsonFile.writeText(wJson)
LogEx.logDebug(TAG, "writeText wJson=$wJson")
handler?.sendEmptyMessage(100)
}
}
......
......@@ -111,7 +111,9 @@ class RecycleBinFragment : BaseFragment<FragmentRecycleBinBinding>() {
super.onResume()
LogEx.logDebug(TAG, "onResume")
if (requireContext().checkStorePermission()) {
initData()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
initData()
}
}
}
......
......@@ -46,7 +46,6 @@ class StayNotificationService : Service() {
const val FILE_OBSERVER_ACTION = "file_observer_action"
var isRunning = false
var mainHandler: Handler? = null
fun Context.startStayNotification() {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) {
......@@ -88,7 +87,7 @@ class StayNotificationService : Service() {
private fun observerMediaContentObserver() {
if (mediaContentObserver == null) {
LogEx.logDebug(TAG, "observerMediaContentObserver")
mediaContentObserver = MediaContentObserver(this, mainHandler)
mediaContentObserver = MediaContentObserver(this)
mediaContentObserver?.let {
this.contentResolver.registerContentObserver(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, true, it
......@@ -122,7 +121,7 @@ class StayNotificationService : Service() {
watchList.forEach {
LogEx.logDebug(TAG, "watchList=${it.absolutePath}")
}
myFileObserver = MyFileObserver(handler = mainHandler, watchList)
myFileObserver = MyFileObserver(watchList)
LogEx.logDebug(TAG, "watchList=${dcimList.size}")
myFileObserver?.startWatching()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment