Search in sources :

Example 6 with ClaimSearchTask

use of com.odysee.app.tasks.claim.ClaimSearchTask 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

ClaimSearchResultHandler (com.odysee.app.tasks.claim.ClaimSearchResultHandler)6 ClaimSearchTask (com.odysee.app.tasks.claim.ClaimSearchTask)6 ClaimListAdapter (com.odysee.app.adapter.ClaimListAdapter)5 Claim (com.odysee.app.model.Claim)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 JSONException (org.json.JSONException)5 Context (android.content.Context)4 MainActivity (com.odysee.app.MainActivity)4 JSONObject (org.json.JSONObject)4 LbryUriException (com.odysee.app.exceptions.LbryUriException)3 View (android.view.View)1 WebView (android.webkit.WebView)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 NestedScrollView (androidx.core.widget.NestedScrollView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 PhotoView (com.github.chrisbanes.photoview.PhotoView)1 TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)1