Search in sources :

Example 11 with ClaimListResultHandler

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

the class MainActivity method resolveUrlSuggestions.

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

        @Override
        public void onSuccess(List<Claim> claims) {
            if (findViewById(R.id.url_suggestions_container).getVisibility() == View.VISIBLE) {
                for (int i = 0; i < claims.size(); i++) {
                    // build a simple url from the claim for matching
                    Claim claim = claims.get(i);
                    Claim actualClaim = claim;
                    boolean isRepost = false;
                    if (Claim.TYPE_REPOST.equalsIgnoreCase(claim.getValueType())) {
                        actualClaim = claim.getRepostedClaim();
                        isRepost = true;
                    }
                    if (Helper.isNullOrEmpty(claim.getName())) {
                        continue;
                    }
                    LbryUri simpleUrl = new LbryUri();
                    if (actualClaim.getName().startsWith("@") && !isRepost) {
                        // channel
                        simpleUrl.setChannelName(actualClaim.getName());
                    } else {
                        simpleUrl.setStreamName(claim.getName());
                    }
                    urlSuggestionListAdapter.setClaimForUrl(simpleUrl, actualClaim);
                }
                urlSuggestionListAdapter.notifyDataSetChanged();
            }
        }

        @Override
        public void onError(Exception error) {
        }
    });
    task.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
}
Also used : ClaimListResultHandler(com.odysee.app.tasks.claim.ClaimListResultHandler) LbryUri(com.odysee.app.utils.LbryUri) 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) ResolveTask(com.odysee.app.tasks.claim.ResolveTask)

Example 12 with ClaimListResultHandler

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

the class MainActivity method fetchOwnChannels.

public void fetchOwnChannels() {
    ClaimListTask task = new ClaimListTask(Claim.TYPE_CHANNEL, null, Lbryio.AUTH_TOKEN, new ClaimListResultHandler() {

        @Override
        public void onSuccess(List<Claim> claims) {
            Lbry.ownChannels = Helper.filterDeletedClaims(new ArrayList<>(claims));
            for (FetchChannelsListener listener : fetchChannelsListeners) {
                listener.onChannelsFetched(claims);
            }
        }

        @Override
        public void onError(Exception error) {
            Log.e("FetchingChannels", "onError: ".concat(error.getLocalizedMessage()));
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : ClaimListResultHandler(com.odysee.app.tasks.claim.ClaimListResultHandler) ClaimListTask(com.odysee.app.tasks.claim.ClaimListTask) FetchChannelsListener(com.odysee.app.listener.FetchChannelsListener) 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 13 with ClaimListResultHandler

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

the class MainActivity method resolveCommentAuthors.

private void resolveCommentAuthors(List<String> urls) {
    if (urls != null && !urls.isEmpty()) {
        ResolveTask task = new ResolveTask(urls, Lbry.API_CONNECTION_STRING, null, new ClaimListResultHandler() {

            @Override
            public void onSuccess(List<Claim> claims) {
                if (notificationListAdapter != null) {
                    notificationListAdapter.updateAuthorClaims(claims);
                }
            }

            @Override
            public void onError(Exception error) {
            // pass
            }
        });
        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) 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) ResolveTask(com.odysee.app.tasks.claim.ResolveTask)

Example 14 with ClaimListResultHandler

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

the class FileViewFragment method fetchChannels.

private void fetchChannels() {
    if (Lbry.ownChannels != null && !Lbry.ownChannels.isEmpty()) {
        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);
            enableChannelSpinner();
            fetchingChannels = false;
        }

        @Override
        public void onError(Exception error) {
            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) 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)

Example 15 with ClaimListResultHandler

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

the class CreateSupportDialogFragment method fetchChannels.

private void fetchChannels() {
    if (Lbry.ownChannels != null && !Lbry.ownChannels.isEmpty()) {
        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);
            enableChannelSpinner();
            fetchingChannels = false;
        }

        @Override
        public void onError(Exception error) {
            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) ApiCallException(com.odysee.app.exceptions.ApiCallException) ExecutionException(java.util.concurrent.ExecutionException)

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