Search in sources :

Example 1 with ResolveTask

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

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

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

Example 4 with ResolveTask

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

the class LibraryFragment method resolveMissingChannelNames.

private void resolveMissingChannelNames(List<String> urls) {
    if (urls.size() > 0) {
        ResolveTask task = new ResolveTask(urls, Lbry.API_CONNECTION_STRING, null, new ClaimListResultHandler() {

            @Override
            public void onSuccess(List<Claim> claims) {
                boolean updated = false;
                for (Claim claim : claims) {
                    if (claim.getClaimId() == null) {
                        continue;
                    }
                    if (contentListAdapter != null) {
                        contentListAdapter.updateSigningChannelForClaim(claim);
                        updated = true;
                    }
                }
                if (updated) {
                    contentListAdapter.notifyDataSetChanged();
                }
            }

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

Example 5 with ResolveTask

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

the class FileViewFragment method resolveCommentPosters.

private void resolveCommentPosters() {
    if (commentListAdapter != null) {
        long st = System.currentTimeMillis();
        List<String> urlsToResolve = new ArrayList<>(commentListAdapter.getClaimUrlsToResolve());
        if (urlsToResolve.size() > 0) {
            ResolveTask task = new ResolveTask(urlsToResolve, Lbry.API_CONNECTION_STRING, null, new ClaimListResultHandler() {

                @Override
                public void onSuccess(List<Claim> claims) {
                    if (commentListAdapter != null) {
                        for (Claim claim : claims) {
                            if (claim.getClaimId() != null) {
                                commentListAdapter.updatePosterForComment(claim.getClaimId(), claim);
                            }
                        }
                        // filter for blocked comments
                        commentListAdapter.filterBlockedChannels(Lbryio.blockedChannels);
                        commentListAdapter.notifyDataSetChanged();
                    }
                }

                @Override
                public void onError(Exception error) {
                // pass
                }
            });
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
    }
}
Also used : ClaimListResultHandler(com.odysee.app.tasks.claim.ClaimListResultHandler) ArrayList(java.util.ArrayList) 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)

Aggregations

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