Search in sources :

Example 91 with Claim

use of com.odysee.app.model.Claim 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 92 with Claim

use of com.odysee.app.model.Claim 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 93 with Claim

use of com.odysee.app.model.Claim 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 94 with Claim

use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.

the class ChannelFilterListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ChannelFilterListAdapter.ViewHolder vh, int position) {
    Claim claim = items.get(position);
    vh.alphaView.setVisibility(claim.isPlaceholder() ? View.GONE : View.VISIBLE);
    vh.titleView.setVisibility(claim.isPlaceholder() ? View.INVISIBLE : View.VISIBLE);
    vh.allView.setVisibility(claim.isPlaceholder() ? View.VISIBLE : View.GONE);
    vh.titleView.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
    String thumbnailUrl = claim.getThumbnailUrl(vh.thumbnailView.getLayoutParams().width, vh.thumbnailView.getLayoutParams().height, 85);
    if (!Helper.isNullOrEmpty(thumbnailUrl) && context != null) {
        Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
    }
    vh.alphaContainer.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.VISIBLE : View.GONE);
    vh.thumbnailView.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.GONE : View.VISIBLE);
    vh.alphaView.setText(claim.isPlaceholder() ? null : claim.getName() != null ? claim.getName().substring(1, 2).toUpperCase() : "");
    int bgColor = Helper.generateRandomColorForValue(claim.getClaimId());
    Helper.setIconViewBackgroundColor(vh.alphaContainer, bgColor, claim.isPlaceholder(), context);
    vh.itemView.setSelected(isClaimSelected(claim));
    vh.itemView.setOnClickListener(view -> {
        if (claim.isPlaceholder()) {
            selectedItem = null;
            if (listener != null) {
                listener.onChannelSelectionCleared();
            }
        } else if (!claim.equals(selectedItem)) {
            selectedItem = claim;
            if (listener != null) {
                listener.onChannelItemSelected(claim);
            }
        }
        notifyDataSetChanged();
    });
}
Also used : Claim(com.odysee.app.model.Claim)

Example 95 with Claim

use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.

the class ClaimListAdapter method updateFileForClaimByIdOrUrl.

public void updateFileForClaimByIdOrUrl(LbryFile file, String claimId, String url, boolean skipNotFound) {
    if (!skipNotFound) {
        if (notFoundClaimIdMap.containsKey(claimId) && notFoundClaimUrlMap.containsKey(url)) {
            return;
        }
    }
    if (quickClaimIdMap.containsKey(claimId)) {
        quickClaimIdMap.get(claimId).setFile(file);
        notifyDataSetChanged();
        return;
    }
    if (quickClaimUrlMap.containsKey(claimId)) {
        quickClaimUrlMap.get(claimId).setFile(file);
        notifyDataSetChanged();
        return;
    }
    boolean claimFound = false;
    for (int i = 0; i < items.size(); i++) {
        Claim claim = items.get(i);
        if (claimId.equalsIgnoreCase(claim.getClaimId()) || url.equalsIgnoreCase(claim.getPermanentUrl())) {
            quickClaimIdMap.put(claimId, claim);
            quickClaimUrlMap.put(url, claim);
            claim.setFile(file);
            notifyDataSetChanged();
            claimFound = true;
            break;
        }
    }
    if (!claimFound) {
        notFoundClaimIdMap.put(claimId, true);
        notFoundClaimUrlMap.put(url, true);
    }
}
Also used : SuppressLint(android.annotation.SuppressLint) Claim(com.odysee.app.model.Claim)

Aggregations

Claim (com.odysee.app.model.Claim)133 Context (android.content.Context)51 MainActivity (com.odysee.app.MainActivity)44 JSONException (org.json.JSONException)42 View (android.view.View)41 TextView (android.widget.TextView)37 RecyclerView (androidx.recyclerview.widget.RecyclerView)36 ApiCallException (com.odysee.app.exceptions.ApiCallException)36 ArrayList (java.util.ArrayList)32 ImageView (android.widget.ImageView)31 AdapterView (android.widget.AdapterView)29 NestedScrollView (androidx.core.widget.NestedScrollView)28 ClaimListResultHandler (com.odysee.app.tasks.claim.ClaimListResultHandler)26 JSONObject (org.json.JSONObject)26 ExecutionException (java.util.concurrent.ExecutionException)25 TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)24 LbryUriException (com.odysee.app.exceptions.LbryUriException)24 SolidIconView (com.odysee.app.ui.controls.SolidIconView)24 WebView (android.webkit.WebView)23 PhotoView (com.github.chrisbanes.photoview.PhotoView)23