Search in sources :

Example 1 with FetchStatCountTask

use of com.odysee.app.tasks.lbryinc.FetchStatCountTask in project odysee-android by OdyseeTeam.

the class FileViewFragment method loadViewCount.

private void loadViewCount() {
    Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
    if (actualClaim != null) {
        FetchStatCountTask task = new FetchStatCountTask(FetchStatCountTask.STAT_VIEW_COUNT, actualClaim.getClaimId(), null, new FetchStatCountTask.FetchStatCountHandler() {

            @Override
            public void onSuccess(int count) {
                try {
                    String displayText = getResources().getQuantityString(R.plurals.view_count, count, NumberFormat.getInstance().format(count));
                    View root = getView();
                    if (root != null) {
                        TextView textViewCount = root.findViewById(R.id.file_view_view_count);
                        Helper.setViewText(textViewCount, displayText);
                        Helper.setViewVisibility(textViewCount, View.VISIBLE);
                    }
                } catch (IllegalStateException ex) {
                // pass
                }
            }

            @Override
            public void onError(Exception error) {
            // pass
            }
        });
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
}
Also used : FetchStatCountTask(com.odysee.app.tasks.lbryinc.FetchStatCountTask) TextView(android.widget.TextView) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) SolidIconView(com.odysee.app.ui.controls.SolidIconView) PlayerView(com.google.android.exoplayer2.ui.PlayerView) NestedScrollView(androidx.core.widget.NestedScrollView) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) PhotoView(com.github.chrisbanes.photoview.PhotoView) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) Claim(com.odysee.app.model.Claim) SuppressLint(android.annotation.SuppressLint) 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 2 with FetchStatCountTask

use of com.odysee.app.tasks.lbryinc.FetchStatCountTask in project odysee-android by OdyseeTeam.

the class ChannelFragment method loadSubCount.

private void loadSubCount() {
    if (claim != null) {
        FetchStatCountTask task = new FetchStatCountTask(FetchStatCountTask.STAT_SUB_COUNT, claim.getClaimId(), null, new FetchStatCountTask.FetchStatCountHandler() {

            @Override
            public void onSuccess(int count) {
                try {
                    String displayText = getResources().getQuantityString(R.plurals.follower_count, count, NumberFormat.getInstance().format(count));
                    Helper.setViewText(textFollowerCount, displayText);
                    Helper.setViewVisibility(textFollowerCount, View.VISIBLE);
                } catch (IllegalStateException ex) {
                // pass
                }
            }

            @Override
            public void onError(Exception error) {
            // pass
            }
        });
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
}
Also used : FetchStatCountTask(com.odysee.app.tasks.lbryinc.FetchStatCountTask) LbryUriException(com.odysee.app.exceptions.LbryUriException)

Aggregations

LbryUriException (com.odysee.app.exceptions.LbryUriException)2 FetchStatCountTask (com.odysee.app.tasks.lbryinc.FetchStatCountTask)2 SuppressLint (android.annotation.SuppressLint)1 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 PlayerView (com.google.android.exoplayer2.ui.PlayerView)1 ApiCallException (com.odysee.app.exceptions.ApiCallException)1 LbryRequestException (com.odysee.app.exceptions.LbryRequestException)1 LbryResponseException (com.odysee.app.exceptions.LbryResponseException)1 LbryioRequestException (com.odysee.app.exceptions.LbryioRequestException)1 LbryioResponseException (com.odysee.app.exceptions.LbryioResponseException)1 Claim (com.odysee.app.model.Claim)1 SolidIconView (com.odysee.app.ui.controls.SolidIconView)1