Adapt to new nx api
parent
9f466511eb
commit
f5daa0e557
|
@ -147,23 +147,35 @@ import java.net.URLDecoder
|
|||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun playVideoRemote(fileId: String?, urlsArray: String?) {
|
||||
if (fileId == null || urlsArray == null) return
|
||||
fun playVideo(auid: String?, fileid: String?, urlsArray: String?) {
|
||||
if (auid == null || fileid == null || urlsArray == null) return
|
||||
|
||||
Thread {
|
||||
// Get URI of remote videos
|
||||
val urls = JSONArray(urlsArray)
|
||||
val list = Array(urls.length()) {
|
||||
Uri.parse(urls.getString(it))
|
||||
}
|
||||
|
||||
// Get URI of local video
|
||||
val videos = query.getSystemImagesByAUIDs(arrayListOf(auid.toLong()))
|
||||
|
||||
// Play with exoplayer
|
||||
mCtx.runOnUiThread {
|
||||
mCtx.initializePlayer(list, fileId)
|
||||
if (!videos.isEmpty()) {
|
||||
mCtx.initializePlayer(arrayOf(videos[0].uri), fileid)
|
||||
} else {
|
||||
mCtx.initializePlayer(list, fileid)
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun destroyVideo(fileId: String?) {
|
||||
if (fileId == null) return;
|
||||
fun destroyVideo(fileid: String?) {
|
||||
if (fileid == null) return;
|
||||
mCtx.runOnUiThread {
|
||||
mCtx.destroyPlayer(fileId)
|
||||
mCtx.destroyPlayer(fileid)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,13 @@ class TimelineQuery(private val mCtx: MainActivity) {
|
|||
return observer
|
||||
}
|
||||
|
||||
fun getSystemImagesByAUIDs(auids: List<Long>): List<SystemImage> {
|
||||
val photos = mPhotoDao.getPhotosByAUIDs(auids)
|
||||
val fileIds = photos.map { it.localId }
|
||||
if (fileIds.isEmpty()) return listOf()
|
||||
return SystemImage.getByIds(mCtx, fileIds)
|
||||
}
|
||||
|
||||
@Throws(JSONException::class)
|
||||
fun getByDayId(dayId: Long): JSONArray {
|
||||
// Get the photos for the day from DB
|
||||
|
@ -183,19 +190,18 @@ class TimelineQuery(private val mCtx: MainActivity) {
|
|||
|
||||
try {
|
||||
// Get list of file IDs
|
||||
val photos = mPhotoDao.getPhotosByAUIDs(auids)
|
||||
val sysImgs = getSystemImagesByAUIDs(auids)
|
||||
|
||||
// Let the UI know how many files we are deleting
|
||||
response.put("count", photos.size)
|
||||
response.put("count", sysImgs.size)
|
||||
// Let the UI know if we are going to ask for confirmation
|
||||
response.put("confirms", Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
|
||||
|
||||
if (dry || photos.isEmpty()) return response
|
||||
|
||||
val fileIds = photos.map { it.localId }
|
||||
// Exit if dry or nothing to do
|
||||
if (dry || sysImgs.isEmpty()) return response
|
||||
|
||||
// List of URIs
|
||||
val uris = SystemImage.getByIds(mCtx, fileIds).map { it.uri }
|
||||
val uris = sysImgs.map { it.uri }
|
||||
if (uris.isEmpty()) return Response.OK
|
||||
|
||||
// Delete file with media store
|
||||
|
@ -226,7 +232,7 @@ class TimelineQuery(private val mCtx: MainActivity) {
|
|||
}
|
||||
|
||||
// Delete from database
|
||||
mPhotoDao.deleteFileIds(fileIds)
|
||||
mPhotoDao.deleteFileIds(sysImgs.map { it.fileId})
|
||||
} finally {
|
||||
synchronized(this) { deleting = false }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue