Search in sources :

Example 1 with FetchViewHistoryTask

use of com.odysee.app.tasks.localdata.FetchViewHistoryTask 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;
    }
}
Also used : FetchViewHistoryTask(com.odysee.app.tasks.localdata.FetchViewHistoryTask) DatabaseHelper(com.odysee.app.data.DatabaseHelper) ViewHistory(com.odysee.app.model.ViewHistory) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

DatabaseHelper (com.odysee.app.data.DatabaseHelper)1 ViewHistory (com.odysee.app.model.ViewHistory)1 FetchViewHistoryTask (com.odysee.app.tasks.localdata.FetchViewHistoryTask)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1