Search in sources :

Example 1 with PurchaseListTask

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

the class FileViewFragment method checkAndConfirmPurchaseUrl.

private void checkAndConfirmPurchaseUrl() {
    Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
    if (actualClaim != null) {
        PurchaseListTask task = new PurchaseListTask(actualClaim.getClaimId(), null, new ClaimSearchResultHandler() {

            @Override
            public void onSuccess(List<Claim> claims, boolean hasReachedEnd) {
                boolean purchased = false;
                if (claims.size() == 1) {
                    Claim purchasedClaim = claims.get(0);
                    if (actualClaim.getClaimId().equalsIgnoreCase(purchasedClaim.getClaimId())) {
                        // already purchased
                        purchased = true;
                    }
                }
                if (purchased) {
                    handleMainActionForClaim();
                } else {
                    restoreMainActionButton();
                    confirmPurchaseUrl();
                }
            }

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

Example 2 with PurchaseListTask

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

the class LibraryFragment method fetchPurchases.

private void fetchPurchases() {
    contentListLoading = true;
    Helper.setViewVisibility(linkStats, View.GONE);
    Helper.setViewVisibility(layoutListEmpty, View.GONE);
    PurchaseListTask task = new PurchaseListTask(currentPage, PAGE_SIZE, listLoading, new ClaimSearchResultHandler() {

        @Override
        public void onSuccess(List<Claim> claims, boolean hasReachedEnd) {
            listReachedEnd = hasReachedEnd;
            if (contentListAdapter == null) {
                initContentListAdapter(claims);
            } else {
                contentListAdapter.addItems(claims);
            }
            if (contentListAdapter != null && contentList.getAdapter() == null) {
                contentList.setAdapter(contentListAdapter);
            }
            checkListEmpty();
            contentListLoading = false;
        }

        @Override
        public void onError(Exception error) {
            checkStatsLink();
            checkListEmpty();
            contentListLoading = false;
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : ClaimSearchResultHandler(com.odysee.app.tasks.claim.ClaimSearchResultHandler) Claim(com.odysee.app.model.Claim) JSONException(org.json.JSONException) ApiCallException(com.odysee.app.exceptions.ApiCallException) PurchaseListTask(com.odysee.app.tasks.claim.PurchaseListTask)

Aggregations

ApiCallException (com.odysee.app.exceptions.ApiCallException)2 Claim (com.odysee.app.model.Claim)2 ClaimSearchResultHandler (com.odysee.app.tasks.claim.ClaimSearchResultHandler)2 PurchaseListTask (com.odysee.app.tasks.claim.PurchaseListTask)2 JSONException (org.json.JSONException)2 TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)1 LbryRequestException (com.odysee.app.exceptions.LbryRequestException)1 LbryResponseException (com.odysee.app.exceptions.LbryResponseException)1 LbryUriException (com.odysee.app.exceptions.LbryUriException)1 LbryioRequestException (com.odysee.app.exceptions.LbryioRequestException)1 LbryioResponseException (com.odysee.app.exceptions.LbryioResponseException)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1