New marking API
parent
d4765fef1a
commit
5ab50fe85d
|
@ -172,8 +172,12 @@ class NativeX(private val mCtx: MainActivity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
fun setServerId(auid: Long, serverId: Long) {
|
fun setHasRemote(auids: String, value: Boolean) {
|
||||||
Thread { query.setServerId(auid, serverId) }.start()
|
Thread {
|
||||||
|
val parsed = JSONArray(auids)
|
||||||
|
val list = List(parsed.length()) { parsed.getLong(it) }
|
||||||
|
query.setHasRemote(list, value)
|
||||||
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleRequest(request: WebResourceRequest): WebResourceResponse {
|
fun handleRequest(request: WebResourceRequest): WebResourceResponse {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import gallery.memories.R
|
||||||
import gallery.memories.mapper.Photo
|
import gallery.memories.mapper.Photo
|
||||||
|
|
||||||
|
|
||||||
@Database(entities = [Photo::class], version = 10)
|
@Database(entities = [Photo::class], version = 11)
|
||||||
abstract class AppDatabase : RoomDatabase() {
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
abstract fun photoDao(): PhotoDao
|
abstract fun photoDao(): PhotoDao
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,10 @@ interface PhotoDao {
|
||||||
@Query("SELECT 1")
|
@Query("SELECT 1")
|
||||||
fun ping(): Int
|
fun ping(): Int
|
||||||
|
|
||||||
@Query("SELECT dayid, COUNT(local_id) AS count FROM photos WHERE bucket_id IN (:bucketIds) AND server_id = 0 GROUP BY dayid ORDER BY dayid DESC")
|
@Query("SELECT dayid, COUNT(local_id) AS count FROM photos WHERE bucket_id IN (:bucketIds) AND has_remote = 0 GROUP BY dayid ORDER BY dayid DESC")
|
||||||
fun getDays(bucketIds: List<String>): List<Day>
|
fun getDays(bucketIds: List<String>): List<Day>
|
||||||
|
|
||||||
@Query("SELECT * FROM photos WHERE dayid=:dayId AND bucket_id IN (:buckets) AND server_id = 0 ORDER BY date_taken DESC")
|
@Query("SELECT * FROM photos WHERE dayid=:dayId AND bucket_id IN (:buckets) AND has_remote = 0 ORDER BY date_taken DESC")
|
||||||
fun getPhotosByDay(dayId: Long, buckets: List<String>): List<Photo>
|
fun getPhotosByDay(dayId: Long, buckets: List<String>): List<Photo>
|
||||||
|
|
||||||
@Query("DELETE FROM photos WHERE local_id IN (:fileIds)")
|
@Query("DELETE FROM photos WHERE local_id IN (:fileIds)")
|
||||||
|
@ -42,6 +42,6 @@ interface PhotoDao {
|
||||||
@Query("SELECT bucket_id, bucket_name FROM photos GROUP BY bucket_id")
|
@Query("SELECT bucket_id, bucket_name FROM photos GROUP BY bucket_id")
|
||||||
fun getBuckets(): List<Bucket>
|
fun getBuckets(): List<Bucket>
|
||||||
|
|
||||||
@Query("UPDATE photos SET server_id=:serverId WHERE auid=:auid")
|
@Query("UPDATE photos SET has_remote=:v WHERE auid IN (:auids)")
|
||||||
fun setServerId(auid: Long, serverId: Long)
|
fun setHasRemote(auids: List<Long>, v: Boolean)
|
||||||
}
|
}
|
|
@ -12,13 +12,12 @@ import androidx.room.PrimaryKey
|
||||||
Index(value = ["dayid"]),
|
Index(value = ["dayid"]),
|
||||||
Index(value = ["flag"]),
|
Index(value = ["flag"]),
|
||||||
Index(value = ["bucket_id"]),
|
Index(value = ["bucket_id"]),
|
||||||
Index(value = ["bucket_id", "dayid", "server_id"])
|
Index(value = ["bucket_id", "dayid", "has_remote"])
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
data class Photo(
|
data class Photo(
|
||||||
@PrimaryKey(autoGenerate = true) val id: Int? = null,
|
@PrimaryKey(autoGenerate = true) val id: Int? = null,
|
||||||
@ColumnInfo(name = "local_id") val localId: Long,
|
@ColumnInfo(name = "local_id") val localId: Long,
|
||||||
@ColumnInfo(name = "server_id") val serverId: Long,
|
|
||||||
@ColumnInfo(name = "auid") val auid: Long,
|
@ColumnInfo(name = "auid") val auid: Long,
|
||||||
@ColumnInfo(name = "mtime") val mtime: Long,
|
@ColumnInfo(name = "mtime") val mtime: Long,
|
||||||
@ColumnInfo(name = "date_taken") val dateTaken: Long,
|
@ColumnInfo(name = "date_taken") val dateTaken: Long,
|
||||||
|
@ -26,5 +25,6 @@ data class Photo(
|
||||||
@ColumnInfo(name = "basename") val baseName: String,
|
@ColumnInfo(name = "basename") val baseName: String,
|
||||||
@ColumnInfo(name = "bucket_id") val bucketId: Long,
|
@ColumnInfo(name = "bucket_id") val bucketId: Long,
|
||||||
@ColumnInfo(name = "bucket_name") val bucketName: String,
|
@ColumnInfo(name = "bucket_name") val bucketName: String,
|
||||||
|
@ColumnInfo(name = "has_remote") val hasRemote: Boolean,
|
||||||
@ColumnInfo(name = "flag") val flag: Int
|
@ColumnInfo(name = "flag") val flag: Int
|
||||||
)
|
)
|
|
@ -227,7 +227,7 @@ class SystemImage {
|
||||||
bucketId = bucketId,
|
bucketId = bucketId,
|
||||||
bucketName = bucketName,
|
bucketName = bucketName,
|
||||||
flag = 0,
|
flag = 0,
|
||||||
serverId = 0
|
hasRemote = false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -412,12 +412,12 @@ class TimelineQuery(private val mCtx: MainActivity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set server ID for local file.
|
* Set has_remote for list of AUIDs
|
||||||
* @param auid AUID
|
* @param auids List of AUIDs
|
||||||
* @param serverId Server ID
|
* @param value Value to set
|
||||||
*/
|
*/
|
||||||
fun setServerId(auid: Long, serverId: Long) {
|
fun setHasRemote(auids: List<Long>, value: Boolean) {
|
||||||
mPhotoDao.setServerId(auid, serverId)
|
mPhotoDao.setHasRemote(auids, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue