use of com.odysee.app.model.ViewHistory in project odysee-android by OdyseeTeam.
the class DatabaseHelper method getViewHistory.
public static List<ViewHistory> getViewHistory(String lastTimestamp, int pageLimit, SQLiteDatabase db) {
List<ViewHistory> history = new ArrayList<>();
Cursor cursor = null;
try {
String arg = lastTimestamp == null ? "" : lastTimestamp;
cursor = db.rawQuery(String.format(SQL_GET_VIEW_HISTORY, pageLimit), new String[] { arg, arg });
while (cursor.moveToNext()) {
ViewHistory item = new ViewHistory();
int cursorIndex = 0;
item.setUri(LbryUri.tryParse(cursor.getString(cursorIndex++)));
item.setClaimId(cursor.getString(cursorIndex++));
item.setClaimName(cursor.getString(cursorIndex++));
item.setCost(new BigDecimal(cursor.getDouble(cursorIndex++)));
item.setCurrency(cursor.getString(cursorIndex++));
item.setTitle(cursor.getString(cursorIndex++));
item.setPublisherClaimId(cursor.getString(cursorIndex++));
item.setPublisherName(cursor.getString(cursorIndex++));
item.setPublisherTitle(cursor.getString(cursorIndex++));
item.setThumbnailUrl(cursor.getString(cursorIndex++));
item.setDevice(cursor.getString(cursorIndex++));
item.setReleaseTime(cursor.getLong(cursorIndex++));
try {
item.setTimestamp(new SimpleDateFormat(Helper.ISO_DATE_FORMAT_PATTERN).parse(cursor.getString(cursorIndex)));
} catch (ParseException ex) {
// invalid timestamp (which shouldn't happen). Skip this item
continue;
}
history.add(item);
}
} finally {
Helper.closeCursor(cursor);
}
return history;
}
use of com.odysee.app.model.ViewHistory in project odysee-android by OdyseeTeam.
the class Helper method saveViewHistory.
public static void saveViewHistory(String url, Claim claim) {
DatabaseHelper dbHelper = DatabaseHelper.getInstance();
if (dbHelper != null) {
ViewHistory viewHistory = ViewHistory.fromClaimWithUrlAndDeviceName(claim, url, getDeviceName());
new SaveViewHistoryTask(viewHistory, dbHelper, null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
use of com.odysee.app.model.ViewHistory in project odysee-android by OdyseeTeam.
the class LibraryFragment method loadRecent.
private void loadRecent() {
contentListLoading = true;
Helper.setViewVisibility(layoutListEmpty, View.GONE);
DatabaseHelper dbHelper = DatabaseHelper.getInstance();
if (dbHelper != null) {
FetchViewHistoryTask task = new FetchViewHistoryTask(lastDate, PAGE_SIZE, dbHelper, new FetchViewHistoryTask.FetchViewHistoryHandler() {
@Override
public void onSuccess(List<ViewHistory> history, boolean hasReachedEnd) {
listReachedEnd = hasReachedEnd;
if (history.size() > 0) {
lastDate = history.get(history.size() - 1).getTimestamp();
}
List<Claim> claims = Helper.claimsFromViewHistory(history);
if (contentListAdapter == null) {
initRecentAdapter(claims);
}
if (contentListAdapter != null && recentList.getAdapter() == null) {
recentList.setAdapter(contentListAdapter);
}
checkListEmpty();
contentListLoading = false;
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
checkListEmpty();
contentListLoading = false;
}
}
Aggregations