More refactor
parent
bd5113e6b1
commit
6f7e68ad17
|
@ -0,0 +1,11 @@
|
||||||
|
package gallery.memories.mapper
|
||||||
|
|
||||||
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
class Response {
|
||||||
|
companion object {
|
||||||
|
val OK get(): JSONObject {
|
||||||
|
return JSONObject().put("message", "ok")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,9 +9,9 @@ import gallery.memories.mapper.Day
|
||||||
import gallery.memories.mapper.Photo
|
import gallery.memories.mapper.Photo
|
||||||
import gallery.memories.mapper.SystemImage
|
import gallery.memories.mapper.SystemImage
|
||||||
|
|
||||||
class DbService(val context: Context) : SQLiteOpenHelper(context, "memories", null, 42) {
|
class DbService(val context: Context) : SQLiteOpenHelper(context, "memories", null, 45) {
|
||||||
companion object {
|
companion object {
|
||||||
val MEMORIES = "images"
|
val MEMORIES = "memories"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(db: SQLiteDatabase) {
|
override fun onCreate(db: SQLiteDatabase) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import androidx.media3.common.util.UnstableApi
|
||||||
import gallery.memories.MainActivity
|
import gallery.memories.MainActivity
|
||||||
import gallery.memories.R
|
import gallery.memories.R
|
||||||
import gallery.memories.mapper.Fields
|
import gallery.memories.mapper.Fields
|
||||||
|
import gallery.memories.mapper.Response
|
||||||
import gallery.memories.mapper.SystemImage
|
import gallery.memories.mapper.SystemImage
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
|
@ -39,12 +40,6 @@ import java.util.concurrent.CountDownLatch
|
||||||
var videoObserver: ContentObserver? = null
|
var videoObserver: ContentObserver? = null
|
||||||
var refreshPending: Boolean = false
|
var refreshPending: Boolean = false
|
||||||
|
|
||||||
companion object {
|
|
||||||
val okResponse get(): JSONObject {
|
|
||||||
return JSONObject().put("message", "ok")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Register intent launcher for callback
|
// Register intent launcher for callback
|
||||||
deleteIntentLauncher = mCtx.registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result: ActivityResult? ->
|
deleteIntentLauncher = mCtx.registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result: ActivityResult? ->
|
||||||
|
@ -178,12 +173,12 @@ import java.util.concurrent.CountDownLatch
|
||||||
try {
|
try {
|
||||||
// Get list of file IDs
|
// Get list of file IDs
|
||||||
val photos = mDbService.getPhotosByAUIDs(auids)
|
val photos = mDbService.getPhotosByAUIDs(auids)
|
||||||
if (photos.isEmpty()) return okResponse
|
if (photos.isEmpty()) return Response.OK
|
||||||
val fileIds = photos.map { it.localId }
|
val fileIds = photos.map { it.localId }
|
||||||
|
|
||||||
// List of URIs
|
// List of URIs
|
||||||
val uris = SystemImage.getByIds(mCtx, fileIds).map { it.uri }
|
val uris = SystemImage.getByIds(mCtx, fileIds).map { it.uri }
|
||||||
if (uris.isEmpty()) return okResponse
|
if (uris.isEmpty()) return Response.OK
|
||||||
|
|
||||||
// Delete file with media store
|
// Delete file with media store
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
@ -216,7 +211,7 @@ import java.util.concurrent.CountDownLatch
|
||||||
synchronized(this) { deleting = false }
|
synchronized(this) { deleting = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
return okResponse
|
return Response.OK
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun syncDb(startTime: Long): Int {
|
private fun syncDb(startTime: Long): Int {
|
||||||
|
|
Loading…
Reference in New Issue