Search in sources :

Example 1 with SuggestedChannelGridAdapter

use of com.odysee.app.adapter.SuggestedChannelGridAdapter in project odysee-android by OdyseeTeam.

the class FollowingFragment method fetchSuggestedChannels.

private void fetchSuggestedChannels() {
    if (suggestedClaimSearchLoading) {
        return;
    }
    suggestedClaimSearchLoading = true;
    if (discoverDialog != null) {
        discoverDialog.setLoading(true);
    }
    Helper.setViewVisibility(noContentView, View.GONE);
    suggestedChannelClaimSearchTask = new ClaimSearchTask(buildSuggestedOptions(), Lbry.API_CONNECTION_STRING, suggestedChannelAdapter == null || suggestedChannelAdapter.getItemCount() == 0 ? bigContentLoading : contentLoading, new ClaimSearchResultHandler() {

        @Override
        public void onSuccess(List<Claim> claims, boolean hasReachedEnd) {
            suggestedHasReachedEnd = hasReachedEnd;
            suggestedClaimSearchLoading = false;
            if (discoverDialog != null) {
                discoverDialog.setLoading(false);
            }
            if (suggestedChannelAdapter == null) {
                suggestedChannelAdapter = new SuggestedChannelGridAdapter(claims, getContext());
                suggestedChannelAdapter.setListener(FollowingFragment.this);
                if (suggestedChannelGrid != null) {
                    suggestedChannelGrid.setAdapter(suggestedChannelAdapter);
                }
                if (discoverDialog != null) {
                    discoverDialog.setAdapter(suggestedChannelAdapter);
                }
            } else {
                suggestedChannelAdapter.addClaims(claims);
            }
            if (discoverDialog == null || !discoverDialog.isVisible()) {
                checkNoContent(true);
            }
        }

        @Override
        public void onError(Exception error) {
            suggestedClaimSearchLoading = false;
            if (discoverDialog != null) {
                discoverDialog.setLoading(false);
            }
            if (discoverDialog == null || !discoverDialog.isVisible()) {
                checkNoContent(true);
            }
        }
    });
    suggestedChannelClaimSearchTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : ClaimSearchTask(com.odysee.app.tasks.claim.ClaimSearchTask) ClaimSearchResultHandler(com.odysee.app.tasks.claim.ClaimSearchResultHandler) SuggestedChannelGridAdapter(com.odysee.app.adapter.SuggestedChannelGridAdapter) List(java.util.List) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException) LbryUriException(com.odysee.app.exceptions.LbryUriException)

Aggregations

SuggestedChannelGridAdapter (com.odysee.app.adapter.SuggestedChannelGridAdapter)1 LbryUriException (com.odysee.app.exceptions.LbryUriException)1 ClaimSearchResultHandler (com.odysee.app.tasks.claim.ClaimSearchResultHandler)1 ClaimSearchTask (com.odysee.app.tasks.claim.ClaimSearchTask)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 JSONException (org.json.JSONException)1