Search in sources :

Example 36 with Claim

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

the class FileViewFragment method deleteCurrentClaim.

private void deleteCurrentClaim() {
    Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
    if (actualClaim != null) {
        Helper.setViewVisibility(layoutDisplayArea, View.INVISIBLE);
        Helper.setViewVisibility(layoutLoadingState, View.VISIBLE);
        Helper.setViewVisibility(layoutNothingAtLocation, View.GONE);
        AbandonStreamTask task = new AbandonStreamTask(Arrays.asList(actualClaim.getClaimId()), layoutResolving, new AbandonHandler() {

            @Override
            public void onComplete(List<String> successfulClaimIds, List<String> failedClaimIds, List<Exception> errors) {
                Context context = getContext();
                if (context instanceof MainActivity) {
                    if (failedClaimIds.size() == 0) {
                        MainActivity activity = (MainActivity) context;
                        activity.showMessage(R.string.content_deleted);
                        activity.onBackPressed();
                    } else {
                        showError(getString(R.string.content_failed_delete));
                    }
                }
            }
        });
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
}
Also used : AttributeProviderContext(org.commonmark.renderer.html.AttributeProviderContext) Context(android.content.Context) AbandonStreamTask(com.odysee.app.tasks.claim.AbandonStreamTask) AbandonHandler(com.odysee.app.tasks.claim.AbandonHandler) 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)

Example 37 with Claim

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

the class FileViewFragment method doFollowUnfollow.

private void doFollowUnfollow(boolean isFollowing, View view) {
    Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
    if (actualClaim != null && actualClaim.getSigningChannel() != null) {
        Claim publisher = actualClaim.getSigningChannel();
        Subscription subscription = Subscription.fromClaim(publisher);
        view.setEnabled(false);
        Context context = getContext();
        new ChannelSubscribeTask(context, publisher.getClaimId(), subscription, isFollowing, new ChannelSubscribeTask.ChannelSubscribeHandler() {

            @Override
            public void onSuccess() {
                if (isFollowing) {
                    Lbryio.removeSubscription(subscription);
                    Lbryio.removeCachedResolvedSubscription(publisher);
                } else {
                    Lbryio.addSubscription(subscription);
                    Lbryio.addCachedResolvedSubscription(publisher);
                }
                view.setEnabled(true);
                checkIsFollowing();
                FollowingFragment.resetClaimSearchContent = true;
                // Save shared user state
                if (context != null) {
                    context.sendBroadcast(new Intent(MainActivity.ACTION_SAVE_SHARED_USER_STATE));
                }
            }

            @Override
            public void onError(Exception exception) {
                view.setEnabled(true);
            }
        }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
}
Also used : AttributeProviderContext(org.commonmark.renderer.html.AttributeProviderContext) Context(android.content.Context) ChannelSubscribeTask(com.odysee.app.tasks.lbryinc.ChannelSubscribeTask) CustomTabsIntent(androidx.browser.customtabs.CustomTabsIntent) Intent(android.content.Intent) Subscription(com.odysee.app.model.lbryinc.Subscription) 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 38 with Claim

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

the class FileViewFragment method startDownload.

public void startDownload() {
    downloadInProgress = true;
    View root = getView();
    if (root != null) {
        Helper.setViewVisibility(root.findViewById(R.id.file_view_download_progress), View.VISIBLE);
        ((ImageView) root.findViewById(R.id.file_view_action_download_icon)).setImageResource(R.drawable.ic_stop);
    }
    Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
    if (!actualClaim.isFree()) {
        downloadRequested = true;
        onMainActionButtonClicked();
    } else {
        // download the file
        fileGet(true);
    }
}
Also used : ImageView(android.widget.ImageView) 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)

Example 39 with Claim

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

the class FileViewFragment method checkAndLoadComments.

private void checkAndLoadComments(boolean forceReload) {
    View root = getView();
    if (root != null) {
        Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
        View expandCommentArea = root.findViewById(R.id.expand_commentarea_button);
        View commentsDisabledText = root.findViewById(R.id.file_view_disabled_comments);
        RecyclerView commentsList = root.findViewById(R.id.file_view_comments_list);
        commentLoadingArea.setVisibility(View.VISIBLE);
        commentEnabledCheck.checkCommentStatus(actualClaim.getSigningChannel().getClaimId(), actualClaim.getSigningChannel().getName(), (CommentEnabledCheck.CommentStatus) isEnabled -> {
            Activity activity = getActivity();
            if (activity != null) {
                activity.runOnUiThread(() -> {
                    if (isEnabled) {
                        showComments(expandCommentArea, commentsDisabledText, commentsList);
                        if ((commentsList != null && forceReload) || (commentsList == null || commentsList.getAdapter() == null || commentsList.getAdapter().getItemCount() == 0)) {
                            loadComments();
                        }
                    } else {
                        hideComments(expandCommentArea, commentsDisabledText, commentsList);
                    }
                    commentLoadingArea.setVisibility(View.GONE);
                });
            }
        });
    }
}
Also used : Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull) LbryRequestException(com.odysee.app.exceptions.LbryRequestException) ChannelCreateDialogFragment(com.odysee.app.ui.channel.ChannelCreateDialogFragment) JSONException(org.json.JSONException) Future(java.util.concurrent.Future) Handler(android.os.Handler) Map(java.util.Map) Search(com.odysee.app.callable.Search) CreateSupportDialogFragment(com.odysee.app.dialog.CreateSupportDialogFragment) SimpleCache(com.google.android.exoplayer2.upstream.cache.SimpleCache) ContextCompat(androidx.core.content.ContextCompat) Log(android.util.Log) C(com.google.android.exoplayer2.C) ConnectivityManager(android.net.ConnectivityManager) Request(okhttp3.Request) Account(android.accounts.Account) AbandonHandler(com.odysee.app.tasks.claim.AbandonHandler) Helper(com.odysee.app.utils.Helper) Lbryio(com.odysee.app.utils.Lbryio) CommentListHandler(com.odysee.app.tasks.CommentListHandler) CommentItemDecoration(com.odysee.app.adapter.CommentItemDecoration) UrlSuggestion(com.odysee.app.model.UrlSuggestion) SolidIconView(com.odysee.app.ui.controls.SolidIconView) ClaimRewardTask(com.odysee.app.tasks.lbryinc.ClaimRewardTask) PlaybackParameters(com.google.android.exoplayer2.PlaybackParameters) ReadTextFileTask(com.odysee.app.tasks.ReadTextFileTask) PlayerView(com.google.android.exoplayer2.ui.PlayerView) LbryUriException(com.odysee.app.exceptions.LbryUriException) Supplier(java.util.function.Supplier) LinkedHashMap(java.util.LinkedHashMap) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) WebSettings(android.webkit.WebSettings) WebResourceRequest(android.webkit.WebResourceRequest) Comment(com.odysee.app.model.Comment) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) LbryUri(com.odysee.app.utils.LbryUri) Response(okhttp3.Response) InlineChannelSpinnerAdapter(com.odysee.app.adapter.InlineChannelSpinnerAdapter) ClaimSearchResultHandler(com.odysee.app.tasks.claim.ClaimSearchResultHandler) Predefined(com.odysee.app.utils.Predefined) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) OkHttpClient(okhttp3.OkHttpClient) SharedPreferences(android.content.SharedPreferences) PreferenceManager(androidx.preference.PreferenceManager) TagListAdapter(com.odysee.app.adapter.TagListAdapter) ImageButton(android.widget.ImageButton) LinearLayout(android.widget.LinearLayout) NestedScrollView(androidx.core.widget.NestedScrollView) FileListTask(com.odysee.app.tasks.file.FileListTask) ChannelSubscribeTask(com.odysee.app.tasks.lbryinc.ChannelSubscribeTask) WindowManager(android.view.WindowManager) Player(com.google.android.exoplayer2.Player) CustomTabsIntent(androidx.browser.customtabs.CustomTabsIntent) JSONObject(org.json.JSONObject) ActivityInfo(android.content.pm.ActivityInfo) WebViewClient(android.webkit.WebViewClient) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) Reactions(com.odysee.app.model.Reactions) MediaSource(com.google.android.exoplayer2.source.MediaSource) BufferEventTask(com.odysee.app.tasks.BufferEventTask) MediaItem(com.google.android.exoplayer2.MediaItem) AsyncTask(android.os.AsyncTask) DeleteFileTask(com.odysee.app.tasks.file.DeleteFileTask) TrackGroup(com.google.android.exoplayer2.source.TrackGroup) LbryResponseException(com.odysee.app.exceptions.LbryResponseException) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) GenericTaskHandler(com.odysee.app.tasks.GenericTaskHandler) TrackSelectionOverrides(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides) Claim(com.odysee.app.model.Claim) PorterDuff(android.graphics.PorterDuff) DisplayMetrics(android.util.DisplayMetrics) WebViewFeature(androidx.webkit.WebViewFeature) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) CommentListTask(com.odysee.app.tasks.CommentListTask) DefaultHttpDataSource(com.google.android.exoplayer2.upstream.DefaultHttpDataSource) LeastRecentlyUsedCacheEvictor(com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor) TextInputEditText(com.google.android.material.textfield.TextInputEditText) AlertDialog(androidx.appcompat.app.AlertDialog) AbandonStreamTask(com.odysee.app.tasks.claim.AbandonStreamTask) ResolveTask(com.odysee.app.tasks.claim.ResolveTask) ProgressiveMediaSource(com.google.android.exoplayer2.source.ProgressiveMediaSource) ClaimListResultHandler(com.odysee.app.tasks.claim.ClaimListResultHandler) Lbry(com.odysee.app.utils.Lbry) CompletableFuture(java.util.concurrent.CompletableFuture) MenuItem(android.view.MenuItem) InputMethodManager(android.view.inputmethod.InputMethodManager) LighthouseSearch(com.odysee.app.callable.LighthouseSearch) MaterialButton(com.google.android.material.button.MaterialButton) LbryioRequestException(com.odysee.app.exceptions.LbryioRequestException) Build(android.os.Build) ExecutorService(java.util.concurrent.ExecutorService) LbryioResponseException(com.odysee.app.exceptions.LbryioResponseException) CustomTabColorSchemeParams(androidx.browser.customtabs.CustomTabColorSchemeParams) ApiCallException(com.odysee.app.exceptions.ApiCallException) LayoutInflater(android.view.LayoutInflater) PhotoView(com.github.chrisbanes.photoview.PhotoView) Tag(com.odysee.app.model.Tag) DecimalFormat(java.text.DecimalFormat) ClaimListAdapter(com.odysee.app.adapter.ClaimListAdapter) Color(android.graphics.Color) Fee(com.odysee.app.model.Fee) Base64(android.util.Base64) LbryAnalytics(com.odysee.app.utils.LbryAnalytics) Comparator(java.util.Comparator) Activity(android.app.Activity) AttributeProviderFactory(org.commonmark.renderer.html.AttributeProviderFactory) R(com.odysee.app.R) ClaimSearchTask(com.odysee.app.tasks.claim.ClaimSearchTask) Arrays(java.util.Arrays) Uri(android.net.Uri) ImageView(android.widget.ImageView) AppCompatSpinner(androidx.appcompat.widget.AppCompatSpinner) Parser(org.commonmark.parser.Parser) Manifest(android.Manifest) Looper(android.os.Looper) WebSettingsCompat(androidx.webkit.WebSettingsCompat) AccountManager(android.accounts.AccountManager) DefaultLoadErrorHandlingPolicy(com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy) TrackGroupInfo(com.google.android.exoplayer2.TracksInfo.TrackGroupInfo) Executors(java.util.concurrent.Executors) ReactToComment(com.odysee.app.runnable.ReactToComment) StringRes(androidx.annotation.StringRes) ClaimCacheKey(com.odysee.app.model.ClaimCacheKey) PurchaseListTask(com.odysee.app.tasks.claim.PurchaseListTask) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout) Subscription(com.odysee.app.model.lbryinc.Subscription) DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) StoragePermissionListener(com.odysee.app.listener.StoragePermissionListener) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) TextWatcher(android.text.TextWatcher) HlsMediaSource(com.google.android.exoplayer2.source.hls.HlsMediaSource) GestureDetector(android.view.GestureDetector) FetchClaimsListener(com.odysee.app.listener.FetchClaimsListener) FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) Callable(java.util.concurrent.Callable) GetFileTask(com.odysee.app.tasks.file.GetFileTask) Editable(android.text.Editable) NumberFormat(java.text.NumberFormat) ScreenOrientationListener(com.odysee.app.listener.ScreenOrientationListener) ArrayList(java.util.ArrayList) Node(org.commonmark.node.Node) PIPModeListener(com.odysee.app.listener.PIPModeListener) Code(org.commonmark.node.Code) RequestOptions(com.bumptech.glide.request.RequestOptions) CommentListAdapter(com.odysee.app.adapter.CommentListAdapter) TextUtils(android.text.TextUtils) AnyThread(androidx.annotation.AnyThread) AttributeProviderContext(org.commonmark.renderer.html.AttributeProviderContext) File(java.io.File) TracksInfo(com.google.android.exoplayer2.TracksInfo) DownloadActionListener(com.odysee.app.listener.DownloadActionListener) HtmlRenderer(org.commonmark.renderer.html.HtmlRenderer) Configuration(android.content.res.Configuration) Util(com.google.android.exoplayer2.util.Util) DateUtils(android.text.format.DateUtils) ScheduledFuture(java.util.concurrent.ScheduledFuture) ClaimListTask(com.odysee.app.tasks.claim.ClaimListTask) LinkMovementMethod(android.text.method.LinkMovementMethod) CommentCreateTask(com.odysee.app.tasks.CommentCreateTask) Comments(com.odysee.app.utils.Comments) CommentEnabledCheck(com.odysee.app.checkers.CommentEnabledCheck) View(android.view.View) WebView(android.webkit.WebView) OdyseeCollection(com.odysee.app.model.OdyseeCollection) HtmlCompat(androidx.core.text.HtmlCompat) ViewGroup(android.view.ViewGroup) List(java.util.List) TextView(android.widget.TextView) Reward(com.odysee.app.model.lbryinc.Reward) BaseFragment(com.odysee.app.ui.BaseFragment) RelativeLayout(android.widget.RelativeLayout) NotNull(org.jetbrains.annotations.NotNull) AudioAttributes(com.google.android.exoplayer2.audio.AudioAttributes) Snackbar(com.google.android.material.snackbar.Snackbar) Typeface(android.graphics.Typeface) Context(android.content.Context) ContextMenu(android.view.ContextMenu) ExoDatabaseProvider(com.google.android.exoplayer2.database.ExoDatabaseProvider) Intent(android.content.Intent) HashMap(java.util.HashMap) SuppressLint(android.annotation.SuppressLint) MainActivity(com.odysee.app.MainActivity) MotionEvent(android.view.MotionEvent) LbryFile(com.odysee.app.model.LbryFile) DialogInterface(android.content.DialogInterface) BuildCommentReactOptions(com.odysee.app.callable.BuildCommentReactOptions) CacheDataSource(com.google.android.exoplayer2.upstream.cache.CacheDataSource) AttributeProvider(org.commonmark.renderer.html.AttributeProvider) Iterator(java.util.Iterator) FetchStatCountTask(com.odysee.app.tasks.lbryinc.FetchStatCountTask) TimeUnit(java.util.concurrent.TimeUnit) Glide(com.bumptech.glide.Glide) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) Collections(java.util.Collections) RepostClaimDialogFragment(com.odysee.app.dialog.RepostClaimDialogFragment) Activity(android.app.Activity) MainActivity(com.odysee.app.MainActivity) RecyclerView(androidx.recyclerview.widget.RecyclerView) CommentEnabledCheck(com.odysee.app.checkers.CommentEnabledCheck) 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)

Example 40 with Claim

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

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