Search in sources :

Example 1 with ClaimListResultHandler

use of com.odysee.app.tasks.claim.ClaimListResultHandler in project odysee-android by OdyseeTeam.

the class InvitesFragment method fetchChannels.

private void fetchChannels() {
    if (Lbry.ownChannels != null && Lbry.ownChannels.size() > 0) {
        updateChannelList(Lbry.ownChannels);
        return;
    }
    fetchingChannels = true;
    disableChannelSpinner();
    ClaimListTask task = new ClaimListTask(Claim.TYPE_CHANNEL, progressLoadingChannels, new ClaimListResultHandler() {

        @Override
        public void onSuccess(List<Claim> claims) {
            Lbry.ownChannels = new ArrayList<>(claims);
            updateChannelList(Lbry.ownChannels);
            if (Lbry.ownChannels == null || Lbry.ownChannels.size() == 0) {
                fetchDefaultInviteLink();
            }
            enableChannelSpinner();
            fetchingChannels = false;
        }

        @Override
        public void onError(Exception error) {
            fetchDefaultInviteLink();
            enableChannelSpinner();
            fetchingChannels = false;
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : ClaimListResultHandler(com.odysee.app.tasks.claim.ClaimListResultHandler) ArrayList(java.util.ArrayList) ClaimListTask(com.odysee.app.tasks.claim.ClaimListTask) Claim(com.odysee.app.model.Claim)

Example 2 with ClaimListResultHandler

use of com.odysee.app.tasks.claim.ClaimListResultHandler in project odysee-android by OdyseeTeam.

the class MainActivity method fetchOwnClaims.

public void fetchOwnClaims() {
    ClaimListTask task = new ClaimListTask(Arrays.asList(Claim.TYPE_STREAM, Claim.TYPE_REPOST), null, new ClaimListResultHandler() {

        @Override
        public void onSuccess(List<Claim> claims) {
            Lbry.ownClaims = Helper.filterDeletedClaims(new ArrayList<>(claims));
            for (FetchClaimsListener listener : fetchClaimsListeners) {
                listener.onClaimsFetched(claims);
            }
        }

        @Override
        public void onError(Exception error) {
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : ClaimListResultHandler(com.odysee.app.tasks.claim.ClaimListResultHandler) FetchClaimsListener(com.odysee.app.listener.FetchClaimsListener) ClaimListTask(com.odysee.app.tasks.claim.ClaimListTask) Claim(com.odysee.app.model.Claim) JSONException(org.json.JSONException) LbryUriException(com.odysee.app.exceptions.LbryUriException) ExecutionException(java.util.concurrent.ExecutionException) SQLiteException(android.database.sqlite.SQLiteException) LbryioRequestException(com.odysee.app.exceptions.LbryioRequestException) LbryioResponseException(com.odysee.app.exceptions.LbryioResponseException) ApiCallException(com.odysee.app.exceptions.ApiCallException) AuthTokenInvalidatedException(com.odysee.app.exceptions.AuthTokenInvalidatedException) ParseException(java.text.ParseException)

Example 3 with ClaimListResultHandler

use of com.odysee.app.tasks.claim.ClaimListResultHandler in project odysee-android by OdyseeTeam.

the class FileViewFragment method resolveUrl.

private void resolveUrl(String url) {
    // resolving = true;
    Helper.setViewVisibility(layoutDisplayArea, View.INVISIBLE);
    Helper.setViewVisibility(layoutLoadingState, View.VISIBLE);
    Helper.setViewVisibility(layoutNothingAtLocation, View.GONE);
    ResolveTask task = new ResolveTask(url, Lbry.API_CONNECTION_STRING, layoutResolving, new ClaimListResultHandler() {

        @Override
        public void onSuccess(List<Claim> claims) {
            if (!claims.isEmpty() && !Helper.isNullOrEmpty(claims.get(0).getClaimId())) {
                fileClaim = claims.get(0);
                if (Claim.TYPE_REPOST.equalsIgnoreCase(fileClaim.getValueType())) {
                    fileClaim = fileClaim.getRepostedClaim();
                    // cache the reposted claim too for subsequent loads
                    Lbry.addClaimToCache(fileClaim);
                    if (fileClaim.getName().startsWith("@")) {
                        // this is a reposted channel, so finish this activity and launch the channel url
                        Context context = getContext();
                        if (context instanceof MainActivity) {
                            MainActivity activity = (MainActivity) context;
                            activity.getSupportFragmentManager().popBackStack();
                            activity.openChannelUrl(!Helper.isNullOrEmpty(fileClaim.getShortUrl()) ? fileClaim.getShortUrl() : fileClaim.getPermanentUrl());
                        }
                        return;
                    }
                } else {
                    Lbry.addClaimToCache(fileClaim);
                }
                if (Claim.TYPE_COLLECTION.equalsIgnoreCase(fileClaim.getValueType()) && fileClaim.getClaimIds() != null && fileClaim.getClaimIds().size() > 0) {
                    collectionClaimItem = null;
                }
                Helper.saveUrlHistory(url, fileClaim.getTitle(), UrlSuggestion.TYPE_FILE);
                // do not save collections to view history
                if (!Claim.TYPE_COLLECTION.equalsIgnoreCase(fileClaim.getType())) {
                    // also save view history
                    Helper.saveViewHistory(url, fileClaim);
                }
                checkAndResetNowPlayingClaim();
                if (Helper.isClaimBlocked(fileClaim)) {
                    renderClaimBlocked();
                } else {
                    loadFile();
                    checkAndLoadRelatedContent();
                    checkAndLoadComments();
                    renderClaim();
                }
            } else {
                // render nothing at location
                renderNothingAtLocation();
            }
        }

        @Override
        public void onError(Exception error) {
        // resolving = false;
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : AttributeProviderContext(org.commonmark.renderer.html.AttributeProviderContext) Context(android.content.Context) ClaimListResultHandler(com.odysee.app.tasks.claim.ClaimListResultHandler) MainActivity(com.odysee.app.MainActivity) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) Claim(com.odysee.app.model.Claim) LbryRequestException(com.odysee.app.exceptions.LbryRequestException) JSONException(org.json.JSONException) LbryUriException(com.odysee.app.exceptions.LbryUriException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) LbryResponseException(com.odysee.app.exceptions.LbryResponseException) LbryioRequestException(com.odysee.app.exceptions.LbryioRequestException) LbryioResponseException(com.odysee.app.exceptions.LbryioResponseException) ApiCallException(com.odysee.app.exceptions.ApiCallException) ResolveTask(com.odysee.app.tasks.claim.ResolveTask)

Example 4 with ClaimListResultHandler

use of com.odysee.app.tasks.claim.ClaimListResultHandler in project odysee-android by OdyseeTeam.

the class ChannelFragment method resolveUrl.

private void resolveUrl() {
    Helper.setViewVisibility(layoutDisplayArea, View.INVISIBLE);
    Helper.setViewVisibility(layoutLoadingState, View.VISIBLE);
    ResolveTask task = new ResolveTask(currentUrl, Lbry.API_CONNECTION_STRING, layoutResolving, new ClaimListResultHandler() {

        @Override
        public void onSuccess(List<Claim> claims) {
            if (claims.size() > 0 && !Helper.isNullOrEmpty(claims.get(0).getClaimId())) {
                claim = claims.get(0);
                if (!Helper.isNullOrEmpty(currentUrl)) {
                    Helper.saveUrlHistory(currentUrl, claim.getTitle(), UrlSuggestion.TYPE_CHANNEL);
                }
                renderClaim();
                checkOwnChannel();
            } else {
                renderNothingAtLocation();
            }
        }

        @Override
        public void onError(Exception error) {
            renderNothingAtLocation();
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : ClaimListResultHandler(com.odysee.app.tasks.claim.ClaimListResultHandler) Claim(com.odysee.app.model.Claim) LbryUriException(com.odysee.app.exceptions.LbryUriException) ResolveTask(com.odysee.app.tasks.claim.ResolveTask)

Example 5 with ClaimListResultHandler

use of com.odysee.app.tasks.claim.ClaimListResultHandler in project odysee-android by OdyseeTeam.

the class FollowingFragment method fetchAndResolveChannelList.

private void fetchAndResolveChannelList() {
    buildChannelIdsAndUrls();
    if (!channelIds.isEmpty()) {
        ResolveTask resolveSubscribedTask = new ResolveTask(channelUrls, Lbry.API_CONNECTION_STRING, channelListLoading, new ClaimListResultHandler() {

            @Override
            public void onSuccess(List<Claim> claims) {
                updateChannelFilterListAdapter(claims, true);
                Lbryio.cacheResolvedSubscriptions = claims;
            }

            @Override
            public void onError(Exception error) {
                handler.postDelayed(FollowingFragment.this::fetchAndResolveChannelList, 5_000);
            }
        });
        resolveSubscribedTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        fetchClaimSearchContent();
    }
}
Also used : ClaimListResultHandler(com.odysee.app.tasks.claim.ClaimListResultHandler) Claim(com.odysee.app.model.Claim) JSONException(org.json.JSONException) LbryUriException(com.odysee.app.exceptions.LbryUriException) ResolveTask(com.odysee.app.tasks.claim.ResolveTask)

Aggregations

Claim (com.odysee.app.model.Claim)20 ClaimListResultHandler (com.odysee.app.tasks.claim.ClaimListResultHandler)20 JSONException (org.json.JSONException)12 ApiCallException (com.odysee.app.exceptions.ApiCallException)11 ClaimListTask (com.odysee.app.tasks.claim.ClaimListTask)11 LbryUriException (com.odysee.app.exceptions.LbryUriException)9 ResolveTask (com.odysee.app.tasks.claim.ResolveTask)9 LbryioRequestException (com.odysee.app.exceptions.LbryioRequestException)8 LbryioResponseException (com.odysee.app.exceptions.LbryioResponseException)8 ExecutionException (java.util.concurrent.ExecutionException)8 ArrayList (java.util.ArrayList)7 Context (android.content.Context)5 SQLiteException (android.database.sqlite.SQLiteException)5 MainActivity (com.odysee.app.MainActivity)5 AuthTokenInvalidatedException (com.odysee.app.exceptions.AuthTokenInvalidatedException)4 IOException (java.io.IOException)4 ParseException (java.text.ParseException)4 TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)3 ClaimListAdapter (com.odysee.app.adapter.ClaimListAdapter)3 LbryRequestException (com.odysee.app.exceptions.LbryRequestException)3