Add days API

pull/653/merge
Varun Patil 2023-05-07 20:02:37 -07:00
parent 93350812a3
commit 01d4bd8489
2 changed files with 26 additions and 3 deletions

View File

@ -27,6 +27,11 @@ public class NativeX {
return true;
}
@JavascriptInterface
public void getLocalDays(final String call, final long _ignore) {
mJsService.runAsync(call, () -> mQuery.getDays().toString().getBytes());
}
@JavascriptInterface
public void getLocalByDayId(final String call, final long dayId) {
mJsService.runAsync(call, () -> mQuery.getByDayId(dayId).toString().getBytes());

View File

@ -128,9 +128,27 @@ public class TimelineQuery {
return new JSONArray(files);
}
// public JSONArray getDays(final long dayId) {
//
// }
public JSONArray getDays() {
try (Cursor cursor = mDb.rawQuery(
"SELECT dayid, COUNT(local_id) FROM images GROUP BY dayid",
null
)) {
JSONArray days = new JSONArray();
while (cursor.moveToNext()) {
long id = cursor.getLong(0);
long count = cursor.getLong(1);
days.put(new JSONObject()
.put("dayid", id)
.put("count", count)
);
}
return days;
} catch (JSONException e) {
Log.e(TAG, "JSON error");
return new JSONArray();
}
}
protected void fullSyncDb() {
Uri collection = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;