Search in sources :

Example 71 with Claim

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

the class FileViewFragment method validateAndCheckPostComment.

private void validateAndCheckPostComment() {
    String comment = Helper.getValue(inputComment.getText());
    Claim channel = (Claim) commentChannelSpinner.getSelectedItem();
    if (Helper.isNullOrEmpty(comment)) {
        showError(getString(R.string.please_enter_comment));
        return;
    }
    if (channel == null || Helper.isNullOrEmpty(channel.getClaimId())) {
        showError(getString(R.string.please_select_channel));
        return;
    }
    postComment();
}
Also used : Claim(com.odysee.app.model.Claim)

Example 72 with Claim

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

the class PublishesFragment method fetchPublishes.

private void fetchPublishes() {
    Helper.setViewVisibility(emptyView, View.GONE);
    ClaimListTask task = new ClaimListTask(Arrays.asList(Claim.TYPE_STREAM, Claim.TYPE_REPOST), getLoading(), new ClaimListResultHandler() {

        @Override
        public void onSuccess(List<Claim> claims) {
            Lbry.ownClaims = Helper.filterDeletedClaims(new ArrayList<>(claims));
            if (adapter == null) {
                Context context = getContext();
                if (context != null) {
                    adapter = new ClaimListAdapter(claims, context);
                    adapter.setCanEnterSelectionMode(true);
                    adapter.setSelectionModeListener(PublishesFragment.this);
                    adapter.setListener(new ClaimListAdapter.ClaimListItemListener() {

                        @Override
                        public void onClaimClicked(Claim claim, int position) {
                            if (context instanceof MainActivity) {
                                MainActivity activity = (MainActivity) context;
                                if (claim.getName().startsWith("@")) {
                                    activity.openChannelClaim(claim);
                                } else {
                                    activity.openFileClaim(claim);
                                }
                            }
                        }
                    });
                    if (contentList != null) {
                        contentList.setAdapter(adapter);
                    }
                }
            } else {
                adapter.setItems(claims);
            }
            checkNoPublishes();
        }

        @Override
        public void onError(Exception error) {
            checkNoPublishes();
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : Context(android.content.Context) ClaimListResultHandler(com.odysee.app.tasks.claim.ClaimListResultHandler) ClaimListTask(com.odysee.app.tasks.claim.ClaimListTask) MainActivity(com.odysee.app.MainActivity) ClaimListAdapter(com.odysee.app.adapter.ClaimListAdapter) Claim(com.odysee.app.model.Claim)

Example 73 with Claim

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

the class PublishFormFragment method checkParams.

private void checkParams() {
    Map<String, Object> params = getParams();
    if (params != null) {
        if (params.containsKey("claim")) {
            Claim claim = (Claim) params.get("claim");
            if (claim != null && !claim.equals(this.currentClaim)) {
                this.currentClaim = claim;
                editFieldsLoaded = false;
            }
        } else if (params.containsKey("galleryItem")) {
            currentGalleryItem = (GalleryItem) params.get("galleryItem");
        } else if (params.containsKey("directFilePath")) {
            currentFilePath = (String) params.get("directFilePath");
        }
        if (this.currentClaim == null && params.containsKey("suggestedUrl")) {
            String suggestedUrl = (String) params.get("suggestedUrl");
            if (!Helper.isNullOrEmpty(suggestedUrl) && Helper.isNullOrEmpty(Helper.getValue(inputAddress.getText()))) {
                Helper.setViewText(inputAddress, (String) params.get("suggestedUrl"));
            }
        }
    } else {
        // shouldn't actually happen
        cancelOnFatalCondition(getString(R.string.no_file_found));
    }
}
Also used : JSONObject(org.json.JSONObject) GalleryItem(com.odysee.app.model.GalleryItem) Claim(com.odysee.app.model.Claim)

Example 74 with Claim

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

the class FileViewFragment method renderClaim.

private void renderClaim() {
    Claim claimToRender = collectionClaimItem != null ? collectionClaimItem : fileClaim;
    if (claimToRender == null) {
        return;
    }
    if (!claimToRender.hasSource()) {
    // TODO See if the "publisher is not live yet" UI must be shown
    }
    if (claimToRender.isPlayable() && MainActivity.appPlayer != null) {
        MainActivity.appPlayer.setPlayWhenReady(isPlaying);
    }
    Helper.setViewVisibility(layoutLoadingState, View.GONE);
    Helper.setViewVisibility(layoutNothingAtLocation, View.GONE);
    /*
        if (claim.getTags().contains("disable-support") || claim.getSigningChannel().getTags().contains("disable-support"))
            Helper.setViewVisibility(tipButton, View.GONE);
        else
            Helper.setViewVisibility(tipButton, View.VISIBLE);
*/
    loadViewCount();
    loadReactions(claimToRender);
    checkIsFollowing();
    View root = getView();
    if (root != null) {
        Context context = getContext();
        root.findViewById(R.id.file_view_scroll_view).scrollTo(0, 0);
        Helper.setViewVisibility(layoutDisplayArea, View.VISIBLE);
        ImageView descIndicator = root.findViewById(R.id.file_view_desc_toggle_arrow);
        descIndicator.setImageResource(R.drawable.ic_arrow_dropdown);
        boolean hasDescription = !Helper.isNullOrEmpty(claimToRender.getDescription());
        boolean hasTags = claimToRender.getTags() != null && claimToRender.getTags().size() > 0;
        root.findViewById(R.id.file_view_description).setVisibility(hasDescription ? View.VISIBLE : View.GONE);
        root.findViewById(R.id.file_view_tag_area).setVisibility(hasTags ? View.VISIBLE : View.GONE);
        if (hasTags && !hasDescription) {
            root.findViewById(R.id.file_view_tag_area).setPadding(0, 0, 0, 0);
        }
        root.findViewById(R.id.file_view_description_area).setVisibility(View.GONE);
        ((TextView) root.findViewById(R.id.file_view_title)).setText(claimToRender.getTitle());
        ((TextView) root.findViewById(R.id.file_view_description)).setText(claimToRender.getDescription());
        ((TextView) root.findViewById(R.id.file_view_publisher_name)).setText(Helper.isNullOrEmpty(claimToRender.getPublisherName()) ? getString(R.string.anonymous) : claimToRender.getPublisherName());
        Claim signingChannel = claimToRender.getSigningChannel();
        boolean hasPublisher = signingChannel != null;
        boolean hasPublisherThumbnail = hasPublisher && !Helper.isNullOrEmpty(signingChannel.getThumbnailUrl());
        root.findViewById(R.id.file_view_publisher_avatar).setVisibility(hasPublisher ? View.VISIBLE : View.GONE);
        root.findViewById(R.id.file_view_publisher_thumbnail).setVisibility(hasPublisherThumbnail ? View.VISIBLE : View.INVISIBLE);
        root.findViewById(R.id.file_view_publisher_no_thumbnail).setVisibility(!hasPublisherThumbnail ? View.VISIBLE : View.INVISIBLE);
        if (hasPublisher) {
            int bgColor = Helper.generateRandomColorForValue(signingChannel.getClaimId());
            Helper.setIconViewBackgroundColor(root.findViewById(R.id.file_view_publisher_no_thumbnail), bgColor, false, context);
            if (hasPublisherThumbnail && context != null) {
                ViewGroup.LayoutParams lp = root.findViewById(R.id.file_view_publisher_thumbnail).getLayoutParams();
                Glide.with(context.getApplicationContext()).load(signingChannel.getThumbnailUrl(lp.width, lp.height, 85)).apply(RequestOptions.circleCropTransform()).into((ImageView) root.findViewById(R.id.file_view_publisher_thumbnail));
            }
            ((TextView) root.findViewById(R.id.file_view_publisher_thumbnail_alpha)).setText(signingChannel.getName() != null ? signingChannel.getName().substring(1, 2).toUpperCase() : null);
        }
        String publisherTitle = signingChannel != null ? signingChannel.getTitle() : null;
        TextView textPublisherTitle = root.findViewById(R.id.file_view_publisher_title);
        textPublisherTitle.setVisibility(Helper.isNullOrEmpty(publisherTitle) ? View.GONE : View.VISIBLE);
        textPublisherTitle.setText(publisherTitle);
        RecyclerView descTagsList = root.findViewById(R.id.file_view_tag_list);
        FlexboxLayoutManager flm = new FlexboxLayoutManager(context);
        descTagsList.setLayoutManager(flm);
        List<Tag> tags = claimToRender.getTagObjects();
        TagListAdapter tagListAdapter = new TagListAdapter(tags, context);
        tagListAdapter.setClickListener(new TagListAdapter.TagClickListener() {

            @Override
            public void onTagClicked(Tag tag, int customizeMode) {
                if (customizeMode == TagListAdapter.CUSTOMIZE_MODE_NONE) {
                    Context ctx = getContext();
                    if (ctx instanceof MainActivity) {
                        ((MainActivity) ctx).openAllContentFragmentWithTag(tag.getName());
                    }
                }
            }
        });
        descTagsList.setAdapter(tagListAdapter);
        root.findViewById(R.id.file_view_tag_area).setVisibility(tags.size() > 0 ? View.VISIBLE : View.GONE);
        root.findViewById(R.id.file_view_exoplayer_container).setVisibility(View.GONE);
        root.findViewById(R.id.file_view_unsupported_container).setVisibility(View.GONE);
        root.findViewById(R.id.file_view_media_meta_container).setVisibility(View.VISIBLE);
        Claim.GenericMetadata metadata = claimToRender.getValue();
        if (!Helper.isNullOrEmpty(claimToRender.getThumbnailUrl())) {
            ImageView thumbnailView = root.findViewById(R.id.file_view_thumbnail);
            Glide.with(context.getApplicationContext()).asBitmap().load(claimToRender.getThumbnailUrl(context.getResources().getDisplayMetrics().widthPixels, thumbnailView.getLayoutParams().height, 85)).centerCrop().into(thumbnailView);
        } else {
        // display first x letters of claim name, with random background
        }
        root.findViewById(R.id.file_view_main_action_button).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                onMainActionButtonClicked();
            }
        });
        root.findViewById(R.id.file_view_media_meta_container).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                onMainActionButtonClicked();
            }
        });
        root.findViewById(R.id.file_view_open_external_button).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                openClaimExternally(claimToRender, claimToRender.getMediaType());
            }
        });
        if (metadata instanceof Claim.StreamMetadata) {
            Claim.StreamMetadata streamMetadata = (Claim.StreamMetadata) metadata;
            long publishTime = streamMetadata.getReleaseTime() > 0 ? streamMetadata.getReleaseTime() * 1000 : claimToRender.getTimestamp() * 1000;
            ((TextView) root.findViewById(R.id.file_view_publish_time)).setText(DateUtils.getRelativeTimeSpanString(publishTime, System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_RELATIVE));
            Fee fee = streamMetadata.getFee();
            if (fee != null && Helper.parseDouble(fee.getAmount(), 0) > 0) {
                root.findViewById(R.id.file_view_fee_container).setVisibility(View.VISIBLE);
                ((TextView) root.findViewById(R.id.file_view_fee)).setText(Helper.shortCurrencyFormat(claimToRender.getActualCost(Lbryio.LBCUSDRate).doubleValue()));
            }
        }
        boolean isAnonymous = claimToRender.getSigningChannel() == null;
        View iconFollow = root.findViewById(R.id.file_view_icon_follow);
        View iconUnfollow = root.findViewById(R.id.file_view_icon_unfollow);
        if (isAnonymous) {
            if (iconFollow.getVisibility() == View.VISIBLE) {
                iconFollow.setVisibility(View.INVISIBLE);
            }
            if (iconUnfollow.getVisibility() == View.VISIBLE) {
                iconUnfollow.setVisibility(View.INVISIBLE);
            }
        }
        MaterialButton mainActionButton = root.findViewById(R.id.file_view_main_action_button);
        if (claimToRender.isPlayable()) {
            mainActionButton.setText(R.string.play);
        } else if (claimToRender.isViewable()) {
            mainActionButton.setText(R.string.view);
        } else {
            mainActionButton.setText(R.string.download);
        }
    }
    if (claimToRender.isFree() && Helper.isNullOrEmpty(commentHash)) {
        if (claimToRender.isPlayable() || (!Lbry.SDK_READY && Lbryio.isSignedIn())) {
            if (MainActivity.nowPlayingClaim != null && MainActivity.nowPlayingClaim.getClaimId().equalsIgnoreCase(claimToRender.getClaimId())) {
                // claim already playing
                showExoplayerView();
                playMedia();
            } else {
                onMainActionButtonClicked();
            }
        } else if (claimToRender.isViewable() && Lbry.SDK_READY) {
            onMainActionButtonClicked();
        } else if (!Lbry.SDK_READY) {
            restoreMainActionButton();
        }
    } else {
        restoreMainActionButton();
    }
    /*if (Lbry.SDK_READY && !claimToRender.isPlayable() && !claimToRender.isViewable() && Helper.isNullOrEmpty(commentHash)) {
            if (claimToRender.getFile() == null) {
                loadFile();
            } else {
                // file already loaded, but it's unsupported
                showUnsupportedView();
            }
        }*/
    checkRewardsDriver();
    checkOwnClaim();
}
Also used : FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) MainActivity(com.odysee.app.MainActivity) MaterialButton(com.google.android.material.button.MaterialButton) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) AttributeProviderContext(org.commonmark.renderer.html.AttributeProviderContext) Context(android.content.Context) TagListAdapter(com.odysee.app.adapter.TagListAdapter) ViewGroup(android.view.ViewGroup) Fee(com.odysee.app.model.Fee) 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) SuppressLint(android.annotation.SuppressLint) RecyclerView(androidx.recyclerview.widget.RecyclerView) Tag(com.odysee.app.model.Tag) Claim(com.odysee.app.model.Claim)

Example 75 with Claim

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

the class FileViewFragment method buildPostComment.

private Comment buildPostComment() {
    Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
    Comment comment = new Comment();
    Claim channel = (Claim) commentChannelSpinner.getSelectedItem();
    comment.setClaimId(actualClaim.getClaimId());
    comment.setChannelId(channel.getClaimId());
    comment.setChannelName(channel.getName());
    comment.setText(Helper.getValue(inputComment.getText()));
    comment.setPoster(channel);
    if (replyToComment != null) {
        comment.setParentId(replyToComment.getId());
    }
    return comment;
}
Also used : Comment(com.odysee.app.model.Comment) ReactToComment(com.odysee.app.runnable.ReactToComment) 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