diff options
Diffstat (limited to 'app/src')
12 files changed, 3013 insertions, 343 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java index 38aa8b00..55a75184 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -1,14 +1,13 @@ package ml.docilealligator.infinityforreddit.Adapter; import android.content.Intent; +import android.content.SharedPreferences; import android.content.res.ColorStateList; import android.graphics.ColorFilter; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; -import android.text.Html; -import android.text.Spannable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -38,6 +37,8 @@ import com.bumptech.glide.load.engine.GlideException; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.Target; +import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; +import com.google.android.exoplayer2.ui.PlayerView; import com.google.android.material.card.MaterialCardView; import com.libRG.CustomTextView; @@ -45,6 +46,13 @@ import org.greenrobot.eventbus.EventBus; import butterknife.BindView; import butterknife.ButterKnife; +import im.ene.toro.CacheManager; +import im.ene.toro.ToroPlayer; +import im.ene.toro.ToroUtil; +import im.ene.toro.exoplayer.ExoCreator; +import im.ene.toro.exoplayer.ExoPlayerViewHelper; +import im.ene.toro.media.PlaybackInfo; +import im.ene.toro.widget.Container; import jp.wasabeef.glide.transformations.BlurTransformation; import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import ml.docilealligator.infinityforreddit.Activity.FilteredThingActivity; @@ -68,7 +76,6 @@ import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SaveThing; import ml.docilealligator.infinityforreddit.User.UserDao; -import ml.docilealligator.infinityforreddit.Utils.GlideImageGetter; import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.Utils; @@ -79,10 +86,16 @@ import retrofit2.Retrofit; * Created by alex on 2/25/18. */ -public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHolder> { - private static final int VIEW_TYPE_DATA = 0; - private static final int VIEW_TYPE_ERROR = 1; - private static final int VIEW_TYPE_LOADING = 2; +public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHolder> implements CacheManager { + private static final int VIEW_TYPE_POST_CARD_VIDEO_TYPE_AUTOPLAY = 1; + private static final int VIEW_TYPE_POST_CARD_GIF_TYPE = 2; + private static final int VIEW_TYPE_POST_CARD_IMAGE_TYPE = 3; + private static final int VIEW_TYPE_POST_CARD_LINK_TYPE = 4; + private static final int VIEW_TYPE_POST_CARD_NO_PREVIEW_LINK_TYPE = 5; + private static final int VIEW_TYPE_POST_CARD_TEXT_TYPE = 6; + private static final int VIEW_TYPE_POST_COMPACT = 7; + private static final int VIEW_TYPE_ERROR = 8; + private static final int VIEW_TYPE_LOADING = 9; private static final DiffUtil.ItemCallback<Post> DIFF_CALLBACK = new DiffUtil.ItemCallback<Post>() { @Override public boolean areItemsTheSame(@NonNull Post post, @NonNull Post t1) { @@ -140,8 +153,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView private boolean mShowElapsedTime; private boolean mShowDividerInCompactLayout; private boolean mShowAbsoluteNumberOfVotes; + private boolean mAutoplay = true; private Drawable mCommentIcon; private NetworkState networkState; + private ExoCreator mExoCreator; private Callback mCallback; private ShareLinkBottomSheetFragment mShareLinkBottomSheetFragment; @@ -149,6 +164,71 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView RedditDataRoomDatabase redditDataRoomDatabase, CustomThemeWrapper customThemeWrapper, String accessToken, int postType, int postLayout, boolean displaySubredditName, + SharedPreferences sharedPreferences, ExoCreator exoCreator, + Callback callback) { + super(DIFF_CALLBACK); + if (activity != null) { + mActivity = activity; + mOauthRetrofit = oauthRetrofit; + mRetrofit = retrofit; + mAccessToken = accessToken; + mPostType = postType; + mDisplaySubredditName = displaySubredditName; + mNeedBlurNSFW = sharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true); + mNeedBlurSpoiler = sharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false); + mVoteButtonsOnTheRight = sharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false); + mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false); + mShowDividerInCompactLayout = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT, true); + mShowAbsoluteNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true); + mPostLayout = postLayout; + + mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme(); + mColorAccent = customThemeWrapper.getColorAccent(); + mCardViewBackgroundColor = customThemeWrapper.getCardViewBackgroundColor(); + mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor(); + mPostTitleColor = customThemeWrapper.getPostTitleColor(); + mPostContentColor = customThemeWrapper.getPostContentColor(); + mStickiedPostIconTint = customThemeWrapper.getStickiedPostIconTint(); + mPostTypeBackgroundColor = customThemeWrapper.getPostTypeBackgroundColor(); + mPostTypeTextColor = customThemeWrapper.getPostTypeTextColor(); + mSubredditColor = customThemeWrapper.getSubreddit(); + mUsernameColor = customThemeWrapper.getUsername(); + mSpoilerBackgroundColor = customThemeWrapper.getSpoilerBackgroundColor(); + mSpoilerTextColor = customThemeWrapper.getSpoilerTextColor(); + mFlairBackgroundColor = customThemeWrapper.getFlairBackgroundColor(); + mFlairTextColor = customThemeWrapper.getFlairTextColor(); + mAwardsBackgroundColor = customThemeWrapper.getAwardsBackgroundColor(); + mAwardsTextColor = customThemeWrapper.getAwardsTextColor(); + mNSFWBackgroundColor = customThemeWrapper.getNsfwBackgroundColor(); + mNSFWTextColor = customThemeWrapper.getNsfwTextColor(); + mArchivedIconTint = customThemeWrapper.getArchivedIconTint(); + mLockedIconTint = customThemeWrapper.getLockedIconTint(); + mCrosspostIconTint = customThemeWrapper.getCrosspostIconTint(); + mNoPreviewLinkBackgroundColor = customThemeWrapper.getNoPreviewLinkBackgroundColor(); + mUpvotedColor = customThemeWrapper.getUpvoted(); + mDownvotedColor = customThemeWrapper.getDownvoted(); + mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableButtonColor(); + mButtonTextColor = customThemeWrapper.getButtonTextColor(); + mPostIconAndInfoColor = customThemeWrapper.getPostIconAndInfoColor(); + + mCommentIcon = activity.getDrawable(R.drawable.ic_comment_grey_24dp); + if (mCommentIcon != null) { + DrawableCompat.setTint(mCommentIcon, mPostIconAndInfoColor); + } + mScale = activity.getResources().getDisplayMetrics().density; + mGlide = Glide.with(mActivity); + mRedditDataRoomDatabase = redditDataRoomDatabase; + mUserDao = redditDataRoomDatabase.userDao(); + mExoCreator = exoCreator; + mCallback = callback; + mShareLinkBottomSheetFragment = new ShareLinkBottomSheetFragment(); + } + } + + /*public PostRecyclerViewAdapter(AppCompatActivity activity, Retrofit oauthRetrofit, Retrofit retrofit, + RedditDataRoomDatabase redditDataRoomDatabase, + CustomThemeWrapper customThemeWrapper, String accessToken, + int postType, int postLayout, boolean displaySubredditName, boolean needBlurNSFW, boolean needBlurSpoiler, boolean voteButtonsOnTheRight, boolean showElapsedTime, boolean showDividerInCompactLayout, boolean showAbsoluteNumberOfVotes, Callback callback) { @@ -208,21 +288,64 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView mCallback = callback; mShareLinkBottomSheetFragment = new ShareLinkBottomSheetFragment(); } - } + }*/ public void setCanStartActivity(boolean canStartActivity) { this.canStartActivity = canStartActivity; } - @NonNull @Override - public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - if (viewType == VIEW_TYPE_DATA) { + public int getItemViewType(int position) { + // Reached at the end + if (hasExtraRow() && position == getItemCount() - 1) { + if (networkState.getStatus() == NetworkState.Status.LOADING) { + return VIEW_TYPE_LOADING; + } else { + return VIEW_TYPE_ERROR; + } + } else { if (mPostLayout == SharedPreferencesUtils.POST_LAYOUT_CARD) { - return new PostViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post, parent, false)); + Post post = getItem(position); + if (post != null) { + switch (post.getPostType()) { + case Post.VIDEO_TYPE: + return VIEW_TYPE_POST_CARD_VIDEO_TYPE_AUTOPLAY; + case Post.GIF_TYPE: + return VIEW_TYPE_POST_CARD_GIF_TYPE; + case Post.IMAGE_TYPE: + return VIEW_TYPE_POST_CARD_IMAGE_TYPE; + case Post.LINK_TYPE: + return VIEW_TYPE_POST_CARD_LINK_TYPE; + case Post.NO_PREVIEW_LINK_TYPE: + return VIEW_TYPE_POST_CARD_NO_PREVIEW_LINK_TYPE; + default: + return VIEW_TYPE_POST_CARD_TEXT_TYPE; + } + } + return VIEW_TYPE_POST_CARD_TEXT_TYPE; } else { - return new PostCompactViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_compact, parent, false)); + return VIEW_TYPE_POST_COMPACT; } + } + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + if (viewType == VIEW_TYPE_POST_CARD_VIDEO_TYPE_AUTOPLAY) { + return new PostVideoAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_video_type_autoplay, parent, false)); + } else if (viewType == VIEW_TYPE_POST_CARD_GIF_TYPE) { + return new PostGifTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_gif_type, parent, false)); + } else if (viewType == VIEW_TYPE_POST_CARD_IMAGE_TYPE) { + return new PostImageTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_image_type, parent, false)); + } else if (viewType == VIEW_TYPE_POST_CARD_LINK_TYPE) { + return new PostLinkTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_link_type, parent, false)); + } else if (viewType == VIEW_TYPE_POST_CARD_NO_PREVIEW_LINK_TYPE) { + return new PostNoPreviewLinkTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_no_preview_link_type, parent, false)); + } else if (viewType == VIEW_TYPE_POST_CARD_TEXT_TYPE) { + return new PostTextTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_text_type, parent, false)); + } else if (viewType == VIEW_TYPE_POST_COMPACT) { + return new PostCompactViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_compact, parent, false)); } else if (viewType == VIEW_TYPE_ERROR) { return new ErrorViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_error, parent, false)); } else { @@ -232,7 +355,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView @Override public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) { - if (holder instanceof PostViewHolder) { + if (holder instanceof PostBaseViewHolder) { Post post = getItem(position); if (post != null) { final String fullName = post.getFullName(); @@ -240,16 +363,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView final String subredditNamePrefixed = post.getSubredditNamePrefixed(); String subredditName = subredditNamePrefixed.substring(2); String authorPrefixed = "u/" + post.getAuthor(); - final String postTime = post.getPostTime(); - final String title = post.getTitle(); - int voteType = post.getVoteType(); - boolean nsfw = post.isNSFW(); - boolean spoiler = post.isSpoiler(); String flair = post.getFlair(); int nAwards = post.getnAwards(); boolean isArchived = post.isArchived(); - ((PostViewHolder) holder).cardView.setOnClickListener(view -> { + ((PostBaseViewHolder) holder).cardView.setOnClickListener(view -> { if (canStartActivity) { canStartActivity = false; @@ -260,9 +378,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } }); - ((PostViewHolder) holder).subredditTextView.setText(subredditNamePrefixed); - ((PostViewHolder) holder).userTextView.setText(authorPrefixed); - ((PostViewHolder) holder).userTextView.setOnClickListener(view -> { + ((PostBaseViewHolder) holder).subredditTextView.setText(subredditNamePrefixed); + ((PostBaseViewHolder) holder).userTextView.setText(authorPrefixed); + ((PostBaseViewHolder) holder).userTextView.setOnClickListener(view -> { if (canStartActivity) { canStartActivity = false; Intent intent = new Intent(mActivity, ViewUserDetailActivity.class); @@ -279,13 +397,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView if (iconImageUrl == null || iconImageUrl.equals("")) { mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) - .into(((PostViewHolder) holder).iconGifImageView); + .into(((PostBaseViewHolder) holder).iconGifImageView); } else { mGlide.load(iconImageUrl) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) - .into(((PostViewHolder) holder).iconGifImageView); + .into(((PostBaseViewHolder) holder).iconGifImageView); } if (holder.getAdapterPosition() >= 0) { @@ -298,11 +416,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) - .into(((PostViewHolder) holder).iconGifImageView); + .into(((PostBaseViewHolder) holder).iconGifImageView); } else { mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) - .into(((PostViewHolder) holder).iconGifImageView); + .into(((PostBaseViewHolder) holder).iconGifImageView); } } else { if (post.getSubredditIconUrl() == null) { @@ -312,13 +430,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView if (iconImageUrl == null || iconImageUrl.equals("")) { mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) - .into(((PostViewHolder) holder).iconGifImageView); + .into(((PostBaseViewHolder) holder).iconGifImageView); } else { mGlide.load(iconImageUrl) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) - .into(((PostViewHolder) holder).iconGifImageView); + .into(((PostBaseViewHolder) holder).iconGifImageView); } if (holder.getAdapterPosition() >= 0) { @@ -331,15 +449,15 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) - .into(((PostViewHolder) holder).iconGifImageView); + .into(((PostBaseViewHolder) holder).iconGifImageView); } else { mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) - .into(((PostViewHolder) holder).iconGifImageView); + .into(((PostBaseViewHolder) holder).iconGifImageView); } } - ((PostViewHolder) holder).subredditTextView.setOnClickListener(view -> { + ((PostBaseViewHolder) holder).subredditTextView.setOnClickListener(view -> { if (canStartActivity) { canStartActivity = false; if (post.getSubredditNamePrefixed().startsWith("u/")) { @@ -356,8 +474,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } }); - ((PostViewHolder) holder).iconGifImageView.setOnClickListener(view -> - ((PostViewHolder) holder).subredditTextView.performClick()); + ((PostBaseViewHolder) holder).iconGifImageView.setOnClickListener(view -> + ((PostBaseViewHolder) holder).subredditTextView.performClick()); } else { if (post.getAuthorIconUrl() == null) { String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditNamePrefixed().substring(2) : post.getAuthor(); @@ -366,13 +484,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView if (iconImageUrl == null || iconImageUrl.equals("")) { mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) - .into(((PostViewHolder) holder).iconGifImageView); + .into(((PostBaseViewHolder) holder).iconGifImageView); } else { mGlide.load(iconImageUrl) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) - .into(((PostViewHolder) holder).iconGifImageView); + .into(((PostBaseViewHolder) holder).iconGifImageView); } if (holder.getAdapterPosition() >= 0) { @@ -385,14 +503,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) - .into(((PostViewHolder) holder).iconGifImageView); + .into(((PostBaseViewHolder) holder).iconGifImageView); } else { mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) - .into(((PostViewHolder) holder).iconGifImageView); + .into(((PostBaseViewHolder) holder).iconGifImageView); } - ((PostViewHolder) holder).subredditTextView.setOnClickListener(view -> { + ((PostBaseViewHolder) holder).subredditTextView.setOnClickListener(view -> { if (canStartActivity) { canStartActivity = false; if (post.getSubredditNamePrefixed().startsWith("u/")) { @@ -408,27 +526,27 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } }); - ((PostViewHolder) holder).iconGifImageView.setOnClickListener(view -> - ((PostViewHolder) holder).userTextView.performClick()); + ((PostBaseViewHolder) holder).iconGifImageView.setOnClickListener(view -> + ((PostBaseViewHolder) holder).userTextView.performClick()); } if (mShowElapsedTime) { - ((PostViewHolder) holder).postTimeTextView.setText( + ((PostBaseViewHolder) holder).postTimeTextView.setText( Utils.getElapsedTime(mActivity, post.getPostTimeMillis())); } else { - ((PostViewHolder) holder).postTimeTextView.setText(postTime); + ((PostBaseViewHolder) holder).postTimeTextView.setText(post.getPostTime()); } - ((PostViewHolder) holder).titleTextView.setText(title); - ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); + ((PostBaseViewHolder) holder).titleTextView.setText(post.getTitle()); + ((PostBaseViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); if (post.isLocked()) { - ((PostViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE); + ((PostBaseViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE); } - if (nsfw) { + if (post.isNSFW()) { if (!(mActivity instanceof FilteredThingActivity)) { - ((PostViewHolder) holder).nsfwTextView.setOnClickListener(view -> { + ((PostBaseViewHolder) holder).nsfwTextView.setOnClickListener(view -> { Intent intent = new Intent(mActivity, FilteredThingActivity.class); intent.putExtra(FilteredThingActivity.EXTRA_NAME, post.getSubredditNamePrefixed().substring(2)); intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT); @@ -436,176 +554,71 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView mActivity.startActivity(intent); }); } - ((PostViewHolder) holder).nsfwTextView.setVisibility(View.VISIBLE); + ((PostBaseViewHolder) holder).nsfwTextView.setVisibility(View.VISIBLE); } - if (spoiler) { - ((PostViewHolder) holder).spoilerTextView.setVisibility(View.VISIBLE); + if (post.isSpoiler()) { + ((PostBaseViewHolder) holder).spoilerTextView.setVisibility(View.VISIBLE); } if (flair != null && !flair.equals("")) { - ((PostViewHolder) holder).flairTextView.setVisibility(View.VISIBLE); - Spannable flairHTML; - GlideImageGetter glideImageGetter = new GlideImageGetter(((PostViewHolder) holder).flairTextView); - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { - flairHTML = (Spannable) Html.fromHtml(flair, Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null); - } else { - flairHTML = (Spannable) Html.fromHtml(flair, glideImageGetter, null); - } - ((PostViewHolder) holder).flairTextView.setText(flairHTML); + Utils.setHTMLWithImageToTextView(((PostBaseViewHolder) holder).flairTextView, flair); } if (nAwards > 0) { - ((PostViewHolder) holder).awardsTextView.setVisibility(View.VISIBLE); + ((PostBaseViewHolder) holder).awardsTextView.setVisibility(View.VISIBLE); if (nAwards == 1) { - ((PostViewHolder) holder).awardsTextView.setText(mActivity.getString(R.string.one_award)); + ((PostBaseViewHolder) holder).awardsTextView.setText(mActivity.getString(R.string.one_award)); } else { - ((PostViewHolder) holder).awardsTextView.setText(mActivity.getString(R.string.n_awards, nAwards)); + ((PostBaseViewHolder) holder).awardsTextView.setText(mActivity.getString(R.string.n_awards, nAwards)); } } - switch (voteType) { + switch (post.getVoteType()) { case 1: //Upvoted - ((PostViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); + ((PostBaseViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostBaseViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); break; case -1: //Downvoted - ((PostViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); + ((PostBaseViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostBaseViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); break; } - if (post.getPostType() != Post.TEXT_TYPE && post.getPostType() != Post.NO_PREVIEW_LINK_TYPE) { - ((PostViewHolder) holder).relativeLayout.setVisibility(View.VISIBLE); - ((PostViewHolder) holder).progressBar.setVisibility(View.VISIBLE); - ((PostViewHolder) holder).imageView.setVisibility(View.VISIBLE); - ((PostViewHolder) holder).imageView - .setRatio((float) post.getPreviewHeight() / post.getPreviewWidth()); - loadImage(holder, post); - } - if (mPostType == PostDataSource.TYPE_SUBREDDIT && !mDisplaySubredditName && post.isStickied()) { - ((PostViewHolder) holder).stickiedPostImageView.setVisibility(View.VISIBLE); - mGlide.load(R.drawable.ic_thumbtack_24dp).into(((PostViewHolder) holder).stickiedPostImageView); + ((PostBaseViewHolder) holder).stickiedPostImageView.setVisibility(View.VISIBLE); + mGlide.load(R.drawable.ic_thumbtack_24dp).into(((PostBaseViewHolder) holder).stickiedPostImageView); } if (isArchived) { - ((PostViewHolder) holder).archivedImageView.setVisibility(View.VISIBLE); + ((PostBaseViewHolder) holder).archivedImageView.setVisibility(View.VISIBLE); - ((PostViewHolder) holder).upvoteButton + ((PostBaseViewHolder) holder).upvoteButton .setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).downvoteButton + ((PostBaseViewHolder) holder).downvoteButton .setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, android.graphics.PorterDuff.Mode.SRC_IN); } if (post.isCrosspost()) { - ((PostViewHolder) holder).crosspostImageView.setVisibility(View.VISIBLE); + ((PostBaseViewHolder) holder).crosspostImageView.setVisibility(View.VISIBLE); } if (!(mActivity instanceof FilteredThingActivity)) { - ((PostViewHolder) holder).typeTextView.setOnClickListener(view -> mCallback.typeChipClicked(post.getPostType())); + ((PostBaseViewHolder) holder).typeTextView.setOnClickListener(view -> mCallback.typeChipClicked(post.getPostType())); } switch (post.getPostType()) { - case Post.IMAGE_TYPE: - ((PostViewHolder) holder).typeTextView.setText(R.string.image); - - final String imageUrl = post.getUrl(); - ((PostViewHolder) holder).imageView.setOnClickListener(view -> { - Intent intent = new Intent(mActivity, ViewImageActivity.class); - intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, imageUrl); - intent.putExtra(ViewImageActivity.FILE_NAME_KEY, subredditName - + "-" + id + ".jpg"); - intent.putExtra(ViewImageActivity.POST_TITLE_KEY, post.getTitle()); - mActivity.startActivity(intent); - }); - - if (post.getPreviewWidth() <= 0 || post.getPreviewHeight() <= 0) { - ((PostViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); - ((PostViewHolder) holder).imageView.getLayoutParams().height = (int) (400 * mScale); - } - break; - case Post.LINK_TYPE: - ((PostViewHolder) holder).typeTextView.setText(R.string.link); - - ((PostViewHolder) holder).linkTextView.setVisibility(View.VISIBLE); - String domain = Uri.parse(post.getUrl()).getHost(); - ((PostViewHolder) holder).linkTextView.setText(domain); - - ((PostViewHolder) holder).imageView.setOnClickListener(view -> { - Intent intent = new Intent(mActivity, LinkResolverActivity.class); - Uri uri = Uri.parse(post.getUrl()); - if (uri.getScheme() == null && uri.getHost() == null) { - intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl())); - } else { - intent.setData(uri); - } - mActivity.startActivity(intent); - }); - break; case Post.GIF_TYPE: - ((PostViewHolder) holder).typeTextView.setText(R.string.gif); - - final Uri gifVideoUri = Uri.parse(post.getVideoUrl()); - ((PostViewHolder) holder).imageView.setOnClickListener(view -> { - Intent intent = new Intent(mActivity, ViewGIFActivity.class); - intent.setData(gifVideoUri); - intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, subredditName - + "-" + id + ".gif"); - intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl()); - intent.putExtra(ViewGIFActivity.POST_TITLE_KEY, post.getTitle()); - mActivity.startActivity(intent); - }); - - ((PostViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE); + ((PostBaseViewHolder) holder).typeTextView.setText(R.string.gif); break; case Post.VIDEO_TYPE: - ((PostViewHolder) holder).typeTextView.setText(R.string.video); - - final Uri videoUri = Uri.parse(post.getVideoUrl()); - ((PostViewHolder) holder).imageView.setOnClickListener(view -> { - Intent intent = new Intent(mActivity, ViewVideoActivity.class); - intent.setData(videoUri); - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); - intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, subredditName); - intent.putExtra(ViewVideoActivity.EXTRA_ID, fullName); - intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle()); - mActivity.startActivity(intent); - }); - - ((PostViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE); - break; - case Post.NO_PREVIEW_LINK_TYPE: - ((PostViewHolder) holder).typeTextView.setText(R.string.link); - - String noPreviewLinkUrl = post.getUrl(); - ((PostViewHolder) holder).linkTextView.setVisibility(View.VISIBLE); - String noPreviewLinkDomain = Uri.parse(noPreviewLinkUrl).getHost(); - ((PostViewHolder) holder).linkTextView.setText(noPreviewLinkDomain); - ((PostViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE); - ((PostViewHolder) holder).noPreviewLinkImageView.setOnClickListener(view -> { - Intent intent = new Intent(mActivity, LinkResolverActivity.class); - Uri uri = Uri.parse(post.getUrl()); - if (uri.getScheme() == null && uri.getHost() == null) { - intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl())); - } else { - intent.setData(uri); - } - mActivity.startActivity(intent); - }); - break; - case Post.TEXT_TYPE: - ((PostViewHolder) holder).typeTextView.setText(R.string.text); - if (post.getSelfTextPlainTrimmed() != null && !post.getSelfTextPlainTrimmed().equals("")) { - ((PostViewHolder) holder).contentTextView.setVisibility(View.VISIBLE); - ((PostViewHolder) holder).contentTextView.setText(post.getSelfTextPlainTrimmed()); - } + ((PostBaseViewHolder) holder).typeTextView.setText(R.string.video); break; } - ((PostViewHolder) holder).upvoteButton.setOnClickListener(view -> { + ((PostBaseViewHolder) holder).upvoteButton.setOnClickListener(view -> { if (mAccessToken == null) { Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show(); return; @@ -616,48 +629,48 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView return; } - ColorFilter previousUpvoteButtonColorFilter = ((PostViewHolder) holder).upvoteButton.getColorFilter(); - ColorFilter previousDownvoteButtonColorFilter = ((PostViewHolder) holder).downvoteButton.getColorFilter(); - int previousScoreTextViewColor = ((PostViewHolder) holder).scoreTextView.getCurrentTextColor(); + ColorFilter previousUpvoteButtonColorFilter = ((PostBaseViewHolder) holder).upvoteButton.getColorFilter(); + ColorFilter previousDownvoteButtonColorFilter = ((PostBaseViewHolder) holder).downvoteButton.getColorFilter(); + int previousScoreTextViewColor = ((PostBaseViewHolder) holder).scoreTextView.getCurrentTextColor(); int previousVoteType = post.getVoteType(); String newVoteType; - ((PostViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostBaseViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); if (previousVoteType != 1) { //Not upvoted before post.setVoteType(1); newVoteType = RedditUtils.DIR_UPVOTE; - ((PostViewHolder) holder).upvoteButton + ((PostBaseViewHolder) holder).upvoteButton .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); + ((PostBaseViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); } else { //Upvoted before post.setVoteType(0); newVoteType = RedditUtils.DIR_UNVOTE; - ((PostViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor); + ((PostBaseViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostBaseViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor); } - ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); + ((PostBaseViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { @Override public void onVoteThingSuccess(int position1) { if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) { post.setVoteType(1); - ((PostViewHolder) holder).upvoteButton + ((PostBaseViewHolder) holder).upvoteButton .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); + ((PostBaseViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); } else { post.setVoteType(0); - ((PostViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor); + ((PostBaseViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostBaseViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor); } - ((PostViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); + ((PostBaseViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostBaseViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post)); } @@ -666,17 +679,17 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView public void onVoteThingFail(int position1) { Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show(); post.setVoteType(previousVoteType); - ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType)); - ((PostViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter); - ((PostViewHolder) holder).downvoteButton.setColorFilter(previousDownvoteButtonColorFilter); - ((PostViewHolder) holder).scoreTextView.setTextColor(previousScoreTextViewColor); + ((PostBaseViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType)); + ((PostBaseViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter); + ((PostBaseViewHolder) holder).downvoteButton.setColorFilter(previousDownvoteButtonColorFilter); + ((PostBaseViewHolder) holder).scoreTextView.setTextColor(previousScoreTextViewColor); EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post)); } }, fullName, newVoteType, holder.getAdapterPosition()); }); - ((PostViewHolder) holder).downvoteButton.setOnClickListener(view -> { + ((PostBaseViewHolder) holder).downvoteButton.setOnClickListener(view -> { if (mAccessToken == null) { Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show(); return; @@ -687,48 +700,48 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView return; } - ColorFilter previousUpvoteButtonColorFilter = ((PostViewHolder) holder).upvoteButton.getColorFilter(); - ColorFilter previousDownvoteButtonColorFilter = ((PostViewHolder) holder).downvoteButton.getColorFilter(); - int previousScoreTextViewColor = ((PostViewHolder) holder).scoreTextView.getCurrentTextColor(); + ColorFilter previousUpvoteButtonColorFilter = ((PostBaseViewHolder) holder).upvoteButton.getColorFilter(); + ColorFilter previousDownvoteButtonColorFilter = ((PostBaseViewHolder) holder).downvoteButton.getColorFilter(); + int previousScoreTextViewColor = ((PostBaseViewHolder) holder).scoreTextView.getCurrentTextColor(); int previousVoteType = post.getVoteType(); String newVoteType; - ((PostViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostBaseViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); if (previousVoteType != -1) { //Not downvoted before post.setVoteType(-1); newVoteType = RedditUtils.DIR_DOWNVOTE; - ((PostViewHolder) holder).downvoteButton + ((PostBaseViewHolder) holder).downvoteButton .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); + ((PostBaseViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); } else { //Downvoted before post.setVoteType(0); newVoteType = RedditUtils.DIR_UNVOTE; - ((PostViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor); + ((PostBaseViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostBaseViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor); } - ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); + ((PostBaseViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { @Override public void onVoteThingSuccess(int position1) { if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) { post.setVoteType(-1); - ((PostViewHolder) holder).downvoteButton + ((PostBaseViewHolder) holder).downvoteButton .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); + ((PostBaseViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); } else { post.setVoteType(0); - ((PostViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor); + ((PostBaseViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostBaseViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor); } - ((PostViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); + ((PostBaseViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostBaseViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post)); } @@ -737,38 +750,38 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView public void onVoteThingFail(int position1) { Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show(); post.setVoteType(previousVoteType); - ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType)); - ((PostViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter); - ((PostViewHolder) holder).downvoteButton.setColorFilter(previousDownvoteButtonColorFilter); - ((PostViewHolder) holder).scoreTextView.setTextColor(previousScoreTextViewColor); + ((PostBaseViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType)); + ((PostBaseViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter); + ((PostBaseViewHolder) holder).downvoteButton.setColorFilter(previousDownvoteButtonColorFilter); + ((PostBaseViewHolder) holder).scoreTextView.setTextColor(previousScoreTextViewColor); EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post)); } }, fullName, newVoteType, holder.getAdapterPosition()); }); - ((PostViewHolder) holder).commentsCountTextView.setText(Integer.toString(post.getNComments())); + ((PostBaseViewHolder) holder).commentsCountTextView.setText(Integer.toString(post.getNComments())); if (post.isSaved()) { - ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); + ((PostBaseViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); } else { - ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); + ((PostBaseViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); } - ((PostViewHolder) holder).saveButton.setOnClickListener(view -> { + ((PostBaseViewHolder) holder).saveButton.setOnClickListener(view -> { if (mAccessToken == null) { Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show(); return; } if (post.isSaved()) { - ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); + ((PostBaseViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, post.getFullName(), new SaveThing.SaveThingListener() { @Override public void success() { post.setSaved(false); - ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); + ((PostBaseViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); Toast.makeText(mActivity, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show(); EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post)); } @@ -776,19 +789,19 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView @Override public void failed() { post.setSaved(true); - ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); + ((PostBaseViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); Toast.makeText(mActivity, R.string.post_unsaved_failed, Toast.LENGTH_SHORT).show(); EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post)); } }); } else { - ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); + ((PostBaseViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); SaveThing.saveThing(mOauthRetrofit, mAccessToken, post.getFullName(), new SaveThing.SaveThingListener() { @Override public void success() { post.setSaved(true); - ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); + ((PostBaseViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); Toast.makeText(mActivity, R.string.post_saved_success, Toast.LENGTH_SHORT).show(); EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post)); } @@ -796,7 +809,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView @Override public void failed() { post.setSaved(false); - ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); + ((PostBaseViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); Toast.makeText(mActivity, R.string.post_saved_failed, Toast.LENGTH_SHORT).show(); EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post)); } @@ -804,7 +817,124 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } }); - ((PostViewHolder) holder).shareButton.setOnClickListener(view -> shareLink(post)); + ((PostBaseViewHolder) holder).shareButton.setOnClickListener(view -> shareLink(post)); + + if (holder instanceof PostVideoAutoplayViewHolder) { + /*final Uri gifVideoUri = Uri.parse(post.getVideoUrl()); + ((PostBaseViewHolder) holder).imageView.setOnClickListener(view -> { + Intent intent = new Intent(mActivity, ViewGIFActivity.class); + intent.setData(gifVideoUri); + intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, subredditName + + "-" + id + ".gif"); + intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl()); + intent.putExtra(ViewGIFActivity.POST_TITLE_KEY, post.getTitle()); + mActivity.startActivity(intent); + }); + + ((PostBaseViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE);*/ + + + /*final Uri videoUri = Uri.parse(post.getVideoUrl()); + ((PostBaseViewHolder) holder).imageView.setOnClickListener(view -> { + Intent intent = new Intent(mActivity, ViewVideoActivity.class); + intent.setData(videoUri); + intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); + intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, subredditName); + intent.putExtra(ViewVideoActivity.EXTRA_ID, fullName); + intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle()); + mActivity.startActivity(intent); + }); + + ((PostBaseViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE);*/ + /*((PostVideoAutoplayViewHolder) holder).videoPlayer.setRatio( + (float) post.getPreviewHeight() / post.getPreviewWidth() + );*/ + ((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) post.getPreviewWidth() / post.getPreviewHeight()); + ((PostVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl())); + } else if (holder instanceof PostGifTypeViewHolder) { + ((PostGifTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE); + ((PostGifTypeViewHolder) holder).imageView + .setRatio((float) post.getPreviewHeight() / post.getPreviewWidth()); + loadImage(holder, post); + + final String imageUrl = post.getUrl(); + ((PostGifTypeViewHolder) holder).imageView.setOnClickListener(view -> { + Intent intent = new Intent(mActivity, ViewImageActivity.class); + intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, imageUrl); + intent.putExtra(ViewImageActivity.FILE_NAME_KEY, subredditName + + "-" + id + ".jpg"); + intent.putExtra(ViewImageActivity.POST_TITLE_KEY, post.getTitle()); + mActivity.startActivity(intent); + }); + + if (post.getPreviewWidth() <= 0 || post.getPreviewHeight() <= 0) { + ((PostGifTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); + ((PostGifTypeViewHolder) holder).imageView.getLayoutParams().height = (int) (400 * mScale); + } + } else if (holder instanceof PostImageTypeViewHolder) { + ((PostImageTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE); + ((PostImageTypeViewHolder) holder).imageView + .setRatio((float) post.getPreviewHeight() / post.getPreviewWidth()); + loadImage(holder, post); + + final String imageUrl = post.getUrl(); + ((PostImageTypeViewHolder) holder).imageView.setOnClickListener(view -> { + Intent intent = new Intent(mActivity, ViewImageActivity.class); + intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, imageUrl); + intent.putExtra(ViewImageActivity.FILE_NAME_KEY, subredditName + + "-" + id + ".jpg"); + intent.putExtra(ViewImageActivity.POST_TITLE_KEY, post.getTitle()); + mActivity.startActivity(intent); + }); + + if (post.getPreviewWidth() <= 0 || post.getPreviewHeight() <= 0) { + ((PostImageTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); + ((PostImageTypeViewHolder) holder).imageView.getLayoutParams().height = (int) (400 * mScale); + } + } else if (holder instanceof PostLinkTypeViewHolder) { + ((PostLinkTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE); + ((PostLinkTypeViewHolder) holder).imageView + .setRatio((float) post.getPreviewHeight() / post.getPreviewWidth()); + loadImage(holder, post); + + ((PostLinkTypeViewHolder) holder).linkTextView.setVisibility(View.VISIBLE); + String domain = Uri.parse(post.getUrl()).getHost(); + ((PostLinkTypeViewHolder) holder).linkTextView.setText(domain); + + ((PostLinkTypeViewHolder) holder).imageView.setOnClickListener(view -> { + Intent intent = new Intent(mActivity, LinkResolverActivity.class); + Uri uri = Uri.parse(post.getUrl()); + if (uri.getScheme() == null && uri.getHost() == null) { + intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl())); + } else { + intent.setData(uri); + } + mActivity.startActivity(intent); + }); + } else if (holder instanceof PostNoPreviewLinkTypeViewHolder) { + String noPreviewLinkUrl = post.getUrl(); + ((PostNoPreviewLinkTypeViewHolder) holder).linkTextView.setVisibility(View.VISIBLE); + String noPreviewLinkDomain = Uri.parse(noPreviewLinkUrl).getHost(); + ((PostNoPreviewLinkTypeViewHolder) holder).linkTextView.setText(noPreviewLinkDomain); + ((PostNoPreviewLinkTypeViewHolder) holder).noPreviewLinkImageView.setOnClickListener(view -> { + Intent intent = new Intent(mActivity, LinkResolverActivity.class); + Uri uri = Uri.parse(post.getUrl()); + if (uri.getScheme() == null && uri.getHost() == null) { + intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl())); + } else { + intent.setData(uri); + } + mActivity.startActivity(intent); + }); + } else if (holder instanceof PostTextTypeViewHolder) { + if (post.getSelfTextPlainTrimmed() != null && !post.getSelfTextPlainTrimmed().equals("")) { + ((PostTextTypeViewHolder) holder).contentTextView.setVisibility(View.VISIBLE); + ((PostTextTypeViewHolder) holder).contentTextView.setText(post.getSelfTextPlainTrimmed()); + } + } + + + } } else if (holder instanceof PostCompactViewHolder) { Post post = getItem(position); @@ -1359,15 +1489,72 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } private void loadImage(final RecyclerView.ViewHolder holder, final Post post) { - if (holder instanceof PostViewHolder) { + if (holder instanceof PostImageTypeViewHolder) { + RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(post.getPreviewUrl()).listener(new RequestListener<Drawable>() { + @Override + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { + ((PostImageTypeViewHolder) holder).progressBar.setVisibility(View.GONE); + ((PostImageTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE); + ((PostImageTypeViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> { + ((PostImageTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE); + ((PostImageTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE); + loadImage(holder, post); + }); + return false; + } + + @Override + public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { + ((PostImageTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE); + ((PostImageTypeViewHolder) holder).progressBar.setVisibility(View.GONE); + return false; + } + }); + + if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) { + imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) + .into(((PostImageTypeViewHolder) holder).imageView); + } else { + imageRequestBuilder.into(((PostImageTypeViewHolder) holder).imageView); + } + } else if (holder instanceof PostGifTypeViewHolder) { + String url = mAutoplay ? post.getUrl() : post.getPreviewUrl(); + RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(new RequestListener<Drawable>() { + @Override + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { + ((PostGifTypeViewHolder) holder).progressBar.setVisibility(View.GONE); + ((PostGifTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE); + ((PostGifTypeViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> { + ((PostGifTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE); + ((PostGifTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE); + loadImage(holder, post); + }); + return false; + } + + @Override + public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { + ((PostGifTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE); + ((PostGifTypeViewHolder) holder).progressBar.setVisibility(View.GONE); + return false; + } + }); + + if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) { + imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) + .into(((PostGifTypeViewHolder) holder).imageView); + } else { + imageRequestBuilder.into(((PostGifTypeViewHolder) holder).imageView); + } + } else if (holder instanceof PostLinkTypeViewHolder) { RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(post.getPreviewUrl()).listener(new RequestListener<Drawable>() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { - ((PostViewHolder) holder).progressBar.setVisibility(View.GONE); - ((PostViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE); - ((PostViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> { - ((PostViewHolder) holder).progressBar.setVisibility(View.VISIBLE); - ((PostViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE); + ((PostLinkTypeViewHolder) holder).progressBar.setVisibility(View.GONE); + ((PostLinkTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE); + ((PostLinkTypeViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> { + ((PostLinkTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE); + ((PostLinkTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE); loadImage(holder, post); }); return false; @@ -1375,17 +1562,17 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView @Override public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { - ((PostViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE); - ((PostViewHolder) holder).progressBar.setVisibility(View.GONE); + ((PostLinkTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE); + ((PostLinkTypeViewHolder) holder).progressBar.setVisibility(View.GONE); return false; } }); if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) { imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) - .into(((PostViewHolder) holder).imageView); + .into(((PostLinkTypeViewHolder) holder).imageView); } else { - imageRequestBuilder.into(((PostViewHolder) holder).imageView); + imageRequestBuilder.into(((PostLinkTypeViewHolder) holder).imageView); } } else if (holder instanceof PostCompactViewHolder) { String previewUrl = post.getThumbnailPreviewUrl().equals("") ? post.getPreviewUrl() : post.getThumbnailPreviewUrl(); @@ -1435,20 +1622,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } @Override - public int getItemViewType(int position) { - // Reached at the end - if (hasExtraRow() && position == getItemCount() - 1) { - if (networkState.getStatus() == NetworkState.Status.LOADING) { - return VIEW_TYPE_LOADING; - } else { - return VIEW_TYPE_ERROR; - } - } else { - return VIEW_TYPE_DATA; - } - } - - @Override public int getItemCount() { if (hasExtraRow()) { return super.getItemCount() + 1; @@ -1515,32 +1688,36 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView @Override public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) { super.onViewRecycled(holder); - if (holder instanceof PostViewHolder) { - mGlide.clear(((PostViewHolder) holder).imageView); - mGlide.clear(((PostViewHolder) holder).iconGifImageView); - ((PostViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE); - ((PostViewHolder) holder).relativeLayout.setVisibility(View.GONE); - ((PostViewHolder) holder).crosspostImageView.setVisibility(View.GONE); - ((PostViewHolder) holder).archivedImageView.setVisibility(View.GONE); - ((PostViewHolder) holder).lockedImageView.setVisibility(View.GONE); - ((PostViewHolder) holder).nsfwTextView.setVisibility(View.GONE); - ((PostViewHolder) holder).spoilerTextView.setVisibility(View.GONE); - ((PostViewHolder) holder).flairTextView.setVisibility(View.GONE); - ((PostViewHolder) holder).flairTextView.setText(""); - ((PostViewHolder) holder).awardsTextView.setVisibility(View.GONE); - ((PostViewHolder) holder).awardsTextView.setText(""); - ((PostViewHolder) holder).linkTextView.setVisibility(View.GONE); - ((PostViewHolder) holder).progressBar.setVisibility(View.GONE); - ((PostViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.FIT_START); - ((PostViewHolder) holder).imageView.getLayoutParams().height = FrameLayout.LayoutParams.WRAP_CONTENT; - ((PostViewHolder) holder).imageView.setVisibility(View.GONE); - ((PostViewHolder) holder).playButtonImageView.setVisibility(View.GONE); - ((PostViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE); - ((PostViewHolder) holder).noPreviewLinkImageView.setVisibility(View.GONE); - ((PostViewHolder) holder).contentTextView.setVisibility(View.GONE); - ((PostViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor); - ((PostViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); + if (holder instanceof PostBaseViewHolder) { + if (holder instanceof PostVideoAutoplayViewHolder) { + } else if (holder instanceof PostImageTypeViewHolder) { + mGlide.clear(((PostImageTypeViewHolder) holder).imageView); + ((PostImageTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.FIT_START); + ((PostImageTypeViewHolder) holder).imageView.getLayoutParams().height = FrameLayout.LayoutParams.WRAP_CONTENT; + ((PostImageTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE); + } else if (holder instanceof PostLinkTypeViewHolder) { + mGlide.clear(((PostLinkTypeViewHolder) holder).imageView); + ((PostLinkTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.FIT_START); + ((PostLinkTypeViewHolder) holder).imageView.getLayoutParams().height = FrameLayout.LayoutParams.WRAP_CONTENT; + ((PostLinkTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE); + } else if (holder instanceof PostTextTypeViewHolder) { + ((PostTextTypeViewHolder) holder).contentTextView.setVisibility(View.GONE); + } + + mGlide.clear(((PostBaseViewHolder) holder).iconGifImageView); + ((PostBaseViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE); + ((PostBaseViewHolder) holder).crosspostImageView.setVisibility(View.GONE); + ((PostBaseViewHolder) holder).archivedImageView.setVisibility(View.GONE); + ((PostBaseViewHolder) holder).lockedImageView.setVisibility(View.GONE); + ((PostBaseViewHolder) holder).nsfwTextView.setVisibility(View.GONE); + ((PostBaseViewHolder) holder).spoilerTextView.setVisibility(View.GONE); + ((PostBaseViewHolder) holder).flairTextView.setVisibility(View.GONE); + ((PostBaseViewHolder) holder).flairTextView.setText(""); + ((PostBaseViewHolder) holder).awardsTextView.setVisibility(View.GONE); + ((PostBaseViewHolder) holder).awardsTextView.setText(""); + ((PostBaseViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostBaseViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor); + ((PostBaseViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); } else if (holder instanceof PostCompactViewHolder) { mGlide.clear(((PostCompactViewHolder) holder).imageView); mGlide.clear(((PostCompactViewHolder) holder).iconGifImageView); @@ -1566,77 +1743,104 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } } + @Nullable + @Override + public Object getKeyForOrder(int order) { + if (super.getItemCount() <= 0 || order >= super.getItemCount()) { + return null; + } + return getItem(order); + } + + @Nullable + @Override + public Integer getOrderForKey(@NonNull Object key) { + if (getCurrentList() != null && key instanceof Post) { + return getCurrentList().indexOf(key); + } + + return null; + } + public interface Callback { void retryLoadingMore(); void typeChipClicked(int filter); } - class PostViewHolder extends RecyclerView.ViewHolder { - @BindView(R.id.card_view_item_post) + class PostBaseViewHolder extends RecyclerView.ViewHolder { MaterialCardView cardView; - @BindView(R.id.icon_gif_image_view_item_post) AspectRatioGifImageView iconGifImageView; - @BindView(R.id.subreddit_name_text_view_item_post) TextView subredditTextView; - @BindView(R.id.user_text_view_item_post) TextView userTextView; - @BindView(R.id.stickied_post_image_view_item_post) ImageView stickiedPostImageView; - @BindView(R.id.post_time_text_view_best_item_post) TextView postTimeTextView; - @BindView(R.id.title_text_view_best_item_post) TextView titleTextView; - @BindView(R.id.type_text_view_item_post) CustomTextView typeTextView; - @BindView(R.id.archived_image_view_item_post) ImageView archivedImageView; - @BindView(R.id.locked_image_view_item_post) ImageView lockedImageView; - @BindView(R.id.crosspost_image_view_item_post) ImageView crosspostImageView; - @BindView(R.id.nsfw_text_view_item_post) CustomTextView nsfwTextView; - @BindView(R.id.spoiler_custom_text_view_item_post) CustomTextView spoilerTextView; - @BindView(R.id.flair_custom_text_view_item_post) CustomTextView flairTextView; - @BindView(R.id.awards_text_view_item_post) CustomTextView awardsTextView; - @BindView(R.id.link_text_view_item_post) - TextView linkTextView; - @BindView(R.id.image_view_wrapper_item_post) - RelativeLayout relativeLayout; - @BindView(R.id.progress_bar_item_post) - ProgressBar progressBar; - @BindView(R.id.image_view_best_post_item) - AspectRatioGifImageView imageView; - @BindView(R.id.play_button_image_view_item_post) - ImageView playButtonImageView; - @BindView(R.id.load_image_error_relative_layout_item_post) - RelativeLayout errorRelativeLayout; - @BindView(R.id.image_view_no_preview_link_item_post) - ImageView noPreviewLinkImageView; - @BindView(R.id.content_text_view_item_post) - TextView contentTextView; - @BindView(R.id.bottom_constraint_layout_item_post) ConstraintLayout bottomConstraintLayout; - @BindView(R.id.plus_button_item_post) ImageView upvoteButton; - @BindView(R.id.score_text_view_item_post) TextView scoreTextView; - @BindView(R.id.minus_button_item_post) ImageView downvoteButton; - @BindView(R.id.comments_count_item_post) TextView commentsCountTextView; - @BindView(R.id.save_button_item_post) ImageView saveButton; - @BindView(R.id.share_button_item_post) ImageView shareButton; - PostViewHolder(View itemView) { + PostBaseViewHolder(@NonNull View itemView) { super(itemView); - ButterKnife.bind(this, itemView); + } + + void setBaseView(MaterialCardView cardView, + AspectRatioGifImageView iconGifImageView, + TextView subredditTextView, + TextView userTextView, + ImageView stickiedPostImageView, + TextView postTimeTextView, + TextView titleTextView, + CustomTextView typeTextView, + ImageView archivedImageView, + ImageView lockedImageView, + ImageView crosspostImageView, + CustomTextView nsfwTextView, + CustomTextView spoilerTextView, + CustomTextView flairTextView, + CustomTextView awardsTextView, + ConstraintLayout bottomConstraintLayout, + ImageView upvoteButton, + TextView scoreTextView, + ImageView downvoteButton, + TextView commentsCountTextView, + ImageView saveButton, + ImageView shareButton) { + this.cardView = cardView; + this.iconGifImageView = iconGifImageView; + this.subredditTextView = subredditTextView; + this.userTextView = userTextView; + this.stickiedPostImageView = stickiedPostImageView; + this.postTimeTextView = postTimeTextView; + this.titleTextView = titleTextView; + this.typeTextView = typeTextView; + this.archivedImageView = archivedImageView; + this.lockedImageView = lockedImageView; + this.crosspostImageView = crosspostImageView; + this.nsfwTextView = nsfwTextView; + this.spoilerTextView = spoilerTextView; + this.flairTextView = flairTextView; + this.awardsTextView = awardsTextView; + this.bottomConstraintLayout = bottomConstraintLayout; + this.upvoteButton = upvoteButton; + this.scoreTextView = scoreTextView; + this.downvoteButton = downvoteButton; + this.commentsCountTextView = commentsCountTextView; + this.saveButton = saveButton; + this.shareButton = shareButton; + scoreTextView.setOnClickListener(view -> { //Do nothing in order to prevent clicking this to start ViewPostDetailActivity }); @@ -1665,7 +1869,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView userTextView.setTextColor(mUsernameColor); postTimeTextView.setTextColor(mSecondaryTextColor); titleTextView.setTextColor(mPostTitleColor); - contentTextView.setTextColor(mPostContentColor); stickiedPostImageView.setColorFilter(mStickiedPostIconTint, PorterDuff.Mode.SRC_IN); typeTextView.setBackgroundColor(mPostTypeBackgroundColor); typeTextView.setBorderColor(mPostTypeBackgroundColor); @@ -1685,9 +1888,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView archivedImageView.setColorFilter(mArchivedIconTint, PorterDuff.Mode.SRC_IN); lockedImageView.setColorFilter(mLockedIconTint, PorterDuff.Mode.SRC_IN); crosspostImageView.setColorFilter(mCrosspostIconTint, PorterDuff.Mode.SRC_IN); - linkTextView.setTextColor(mSecondaryTextColor); - progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); - noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor); upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); scoreTextView.setTextColor(mPostIconAndInfoColor); downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); @@ -1698,6 +1898,561 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } } + class PostVideoAutoplayViewHolder extends PostBaseViewHolder implements ToroPlayer { + @BindView(R.id.card_view_item_post_video_type_autoplay) + MaterialCardView cardView; + @BindView(R.id.icon_gif_image_view_item_post_video_type_autoplay) + AspectRatioGifImageView iconGifImageView; + @BindView(R.id.subreddit_name_text_view_item_post_video_type_autoplay) + TextView subredditTextView; + @BindView(R.id.user_text_view_item_post_video_type_autoplay) + TextView userTextView; + @BindView(R.id.stickied_post_image_view_item_post_video_type_autoplay) + ImageView stickiedPostImageView; + @BindView(R.id.post_time_text_view_best_item_post_video_type_autoplay) + TextView postTimeTextView; + @BindView(R.id.title_text_view_best_item_post_video_type_autoplay) + TextView titleTextView; + @BindView(R.id.type_text_view_item_post_video_type_autoplay) + CustomTextView typeTextView; + @BindView(R.id.archived_image_view_item_post_video_type_autoplay) + ImageView archivedImageView; + @BindView(R.id.locked_image_view_item_post_video_type_autoplay) + ImageView lockedImageView; + @BindView(R.id.crosspost_image_view_item_post_video_type_autoplay) + ImageView crosspostImageView; + @BindView(R.id.nsfw_text_view_item_post_video_type_autoplay) + CustomTextView nsfwTextView; + @BindView(R.id.spoiler_custom_text_view_item_post_video_type_autoplay) + CustomTextView spoilerTextView; + @BindView(R.id.flair_custom_text_view_item_post_video_type_autoplay) + CustomTextView flairTextView; + @BindView(R.id.awards_text_view_item_post_video_type_autoplay) + CustomTextView awardsTextView; + @BindView(R.id.aspect) + AspectRatioFrameLayout aspectRatioFrameLayout; + @BindView(R.id.player_view_item_post_video_type_autoplay) + PlayerView videoPlayer; + @BindView(R.id.bottom_constraint_layout_item_post_video_type_autoplay) + ConstraintLayout bottomConstraintLayout; + @BindView(R.id.plus_button_item_post_video_type_autoplay) + ImageView upvoteButton; + @BindView(R.id.score_text_view_item_post_video_type_autoplay) + TextView scoreTextView; + @BindView(R.id.minus_button_item_post_video_type_autoplay) + ImageView downvoteButton; + @BindView(R.id.comments_count_item_post_video_type_autoplay) + TextView commentsCountTextView; + @BindView(R.id.save_button_item_post_video_type_autoplay) + ImageView saveButton; + @BindView(R.id.share_button_item_post_video_type_autoplay) + ImageView shareButton; + + @Nullable + ExoPlayerViewHelper helper; + private Uri mediaUri; + + PostVideoAutoplayViewHolder(View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + setBaseView(cardView, + iconGifImageView, + subredditTextView, + userTextView, + stickiedPostImageView, + postTimeTextView, + titleTextView, + typeTextView, + archivedImageView, + lockedImageView, + crosspostImageView, + nsfwTextView, + spoilerTextView, + flairTextView, + awardsTextView, + bottomConstraintLayout, + upvoteButton, + scoreTextView, + downvoteButton, + commentsCountTextView, + saveButton, + shareButton); + + aspectRatioFrameLayout.setOnClickListener(null); + } + + void bindVideoUri(Uri videoUri) { + mediaUri = videoUri; + } + + @NonNull + @Override + public View getPlayerView() { + return videoPlayer; + } + + @NonNull + @Override + public PlaybackInfo getCurrentPlaybackInfo() { + return helper != null ? helper.getLatestPlaybackInfo() : new PlaybackInfo(); + } + + @Override + public void initialize(@NonNull Container container, @NonNull PlaybackInfo playbackInfo) { + if (helper == null) { + helper = new ExoPlayerViewHelper(this, mediaUri, null, mExoCreator); + } + helper.initialize(container, playbackInfo); + } + + @Override + public void play() { + if (helper != null) helper.play(); + } + + @Override + public void pause() { + if (helper != null) helper.pause(); + } + + @Override + public boolean isPlaying() { + return helper != null && helper.isPlaying(); + } + + @Override + public void release() { + if (helper != null) { + helper.release(); + helper = null; + } + } + + @Override + public boolean wantsToPlay() { + return ToroUtil.visibleAreaOffset(this, itemView.getParent()) >= 0.85; + } + + @Override + public int getPlayerOrder() { + return getAdapterPosition(); + } + } + + class PostGifTypeViewHolder extends PostBaseViewHolder { + @BindView(R.id.card_view_item_post_gif_type) + MaterialCardView cardView; + @BindView(R.id.icon_gif_image_view_item_post_gif_type) + AspectRatioGifImageView iconGifImageView; + @BindView(R.id.subreddit_name_text_view_item_post_gif_type) + TextView subredditTextView; + @BindView(R.id.user_text_view_item_post_gif_type) + TextView userTextView; + @BindView(R.id.stickied_post_image_view_item_post_gif_type) + ImageView stickiedPostImageView; + @BindView(R.id.post_time_text_view_best_item_post_gif_type) + TextView postTimeTextView; + @BindView(R.id.title_text_view_best_item_post_gif_type) + TextView titleTextView; + @BindView(R.id.type_text_view_item_post_gif_type) + CustomTextView typeTextView; + @BindView(R.id.archived_image_view_item_post_gif_type) + ImageView archivedImageView; + @BindView(R.id.locked_image_view_item_post_gif_type) + ImageView lockedImageView; + @BindView(R.id.crosspost_image_view_item_post_gif_type) + ImageView crosspostImageView; + @BindView(R.id.nsfw_text_view_item_post_gif_type) + CustomTextView nsfwTextView; + @BindView(R.id.spoiler_custom_text_view_item_post_gif_type) + CustomTextView spoilerTextView; + @BindView(R.id.flair_custom_text_view_item_post_gif_type) + CustomTextView flairTextView; + @BindView(R.id.awards_text_view_item_post_gif_type) + CustomTextView awardsTextView; + @BindView(R.id.image_view_wrapper_item_post_gif_type) + RelativeLayout relativeLayout; + @BindView(R.id.progress_bar_item_post_gif_type) + ProgressBar progressBar; + @BindView(R.id.image_view_best_post_item) + AspectRatioGifImageView imageView; + @BindView(R.id.load_image_error_relative_layout_item_post_gif_type) + RelativeLayout errorRelativeLayout; + @BindView(R.id.bottom_constraint_layout_item_post_gif_type) + ConstraintLayout bottomConstraintLayout; + @BindView(R.id.plus_button_item_post_gif_type) + ImageView upvoteButton; + @BindView(R.id.score_text_view_item_post_gif_type) + TextView scoreTextView; + @BindView(R.id.minus_button_item_post_gif_type) + ImageView downvoteButton; + @BindView(R.id.comments_count_item_post_gif_type) + TextView commentsCountTextView; + @BindView(R.id.save_button_item_post_gif_type) + ImageView saveButton; + @BindView(R.id.share_button_item_post_gif_type) + ImageView shareButton; + + PostGifTypeViewHolder(View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + setBaseView(cardView, + iconGifImageView, + subredditTextView, + userTextView, + stickiedPostImageView, + postTimeTextView, + titleTextView, + typeTextView, + archivedImageView, + lockedImageView, + crosspostImageView, + nsfwTextView, + spoilerTextView, + flairTextView, + awardsTextView, + bottomConstraintLayout, + upvoteButton, + scoreTextView, + downvoteButton, + commentsCountTextView, + saveButton, + shareButton); + + progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); + } + } + + class PostImageTypeViewHolder extends PostBaseViewHolder { + @BindView(R.id.card_view_item_post_image_type) + MaterialCardView cardView; + @BindView(R.id.icon_gif_image_view_item_post_image_type) + AspectRatioGifImageView iconGifImageView; + @BindView(R.id.subreddit_name_text_view_item_post_image_type) + TextView subredditTextView; + @BindView(R.id.user_text_view_item_post_image_type) + TextView userTextView; + @BindView(R.id.stickied_post_image_view_item_post_image_type) + ImageView stickiedPostImageView; + @BindView(R.id.post_time_text_view_best_item_post_image_type) + TextView postTimeTextView; + @BindView(R.id.title_text_view_best_item_post_image_type) + TextView titleTextView; + @BindView(R.id.type_text_view_item_post_image_type) + CustomTextView typeTextView; + @BindView(R.id.archived_image_view_item_post_image_type) + ImageView archivedImageView; + @BindView(R.id.locked_image_view_item_post_image_type) + ImageView lockedImageView; + @BindView(R.id.crosspost_image_view_item_post_image_type) + ImageView crosspostImageView; + @BindView(R.id.nsfw_text_view_item_post_image_type) + CustomTextView nsfwTextView; + @BindView(R.id.spoiler_custom_text_view_item_post_image_type) + CustomTextView spoilerTextView; + @BindView(R.id.flair_custom_text_view_item_post_image_type) + CustomTextView flairTextView; + @BindView(R.id.awards_text_view_item_post_image_type) + CustomTextView awardsTextView; + @BindView(R.id.image_view_wrapper_item_post_image_type) + RelativeLayout relativeLayout; + @BindView(R.id.progress_bar_item_post_image_type) + ProgressBar progressBar; + @BindView(R.id.image_view_best_post_item) + AspectRatioGifImageView imageView; + @BindView(R.id.load_image_error_relative_layout_item_post_image_type) + RelativeLayout errorRelativeLayout; + @BindView(R.id.bottom_constraint_layout_item_post_image_type) + ConstraintLayout bottomConstraintLayout; + @BindView(R.id.plus_button_item_post_image_type) + ImageView upvoteButton; + @BindView(R.id.score_text_view_item_post_image_type) + TextView scoreTextView; + @BindView(R.id.minus_button_item_post_image_type) + ImageView downvoteButton; + @BindView(R.id.comments_count_item_post_image_type) + TextView commentsCountTextView; + @BindView(R.id.save_button_item_post_image_type) + ImageView saveButton; + @BindView(R.id.share_button_item_post_image_type) + ImageView shareButton; + + PostImageTypeViewHolder(View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + setBaseView(cardView, + iconGifImageView, + subredditTextView, + userTextView, + stickiedPostImageView, + postTimeTextView, + titleTextView, + typeTextView, + archivedImageView, + lockedImageView, + crosspostImageView, + nsfwTextView, + spoilerTextView, + flairTextView, + awardsTextView, + bottomConstraintLayout, + upvoteButton, + scoreTextView, + downvoteButton, + commentsCountTextView, + saveButton, + shareButton); + + progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); + } + } + + class PostLinkTypeViewHolder extends PostBaseViewHolder { + @BindView(R.id.card_view_item_post_link_type) + MaterialCardView cardView; + @BindView(R.id.icon_gif_image_view_item_post_link_type) + AspectRatioGifImageView iconGifImageView; + @BindView(R.id.subreddit_name_text_view_item_post_link_type) + TextView subredditTextView; + @BindView(R.id.user_text_view_item_post_link_type) + TextView userTextView; + @BindView(R.id.stickied_post_image_view_item_post_link_type) + ImageView stickiedPostImageView; + @BindView(R.id.post_time_text_view_best_item_post_link_type) + TextView postTimeTextView; + @BindView(R.id.title_text_view_best_item_post_link_type) + TextView titleTextView; + @BindView(R.id.type_text_view_item_post_link_type) + CustomTextView typeTextView; + @BindView(R.id.archived_image_view_item_post_link_type) + ImageView archivedImageView; + @BindView(R.id.locked_image_view_item_post_link_type) + ImageView lockedImageView; + @BindView(R.id.crosspost_image_view_item_post_link_type) + ImageView crosspostImageView; + @BindView(R.id.nsfw_text_view_item_post_link_type) + CustomTextView nsfwTextView; + @BindView(R.id.spoiler_custom_text_view_item_post_link_type) + CustomTextView spoilerTextView; + @BindView(R.id.flair_custom_text_view_item_post_link_type) + CustomTextView flairTextView; + @BindView(R.id.awards_text_view_item_post_link_type) + CustomTextView awardsTextView; + @BindView(R.id.link_text_view_item_post_link_type) + TextView linkTextView; + @BindView(R.id.image_view_wrapper_item_post_link_type) + RelativeLayout relativeLayout; + @BindView(R.id.progress_bar_item_post_link_type) + ProgressBar progressBar; + @BindView(R.id.image_view_best_post_item) + AspectRatioGifImageView imageView; + @BindView(R.id.load_image_error_relative_layout_item_post_link_type) + RelativeLayout errorRelativeLayout; + @BindView(R.id.bottom_constraint_layout_item_post_link_type) + ConstraintLayout bottomConstraintLayout; + @BindView(R.id.plus_button_item_post_link_type) + ImageView upvoteButton; + @BindView(R.id.score_text_view_item_post_link_type) + TextView scoreTextView; + @BindView(R.id.minus_button_item_post_link_type) + ImageView downvoteButton; + @BindView(R.id.comments_count_item_post_link_type) + TextView commentsCountTextView; + @BindView(R.id.save_button_item_post_link_type) + ImageView saveButton; + @BindView(R.id.share_button_item_post_link_type) + ImageView shareButton; + + PostLinkTypeViewHolder(View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + setBaseView(cardView, + iconGifImageView, + subredditTextView, + userTextView, + stickiedPostImageView, + postTimeTextView, + titleTextView, + typeTextView, + archivedImageView, + lockedImageView, + crosspostImageView, + nsfwTextView, + spoilerTextView, + flairTextView, + awardsTextView, + bottomConstraintLayout, + upvoteButton, + scoreTextView, + downvoteButton, + commentsCountTextView, + saveButton, + shareButton); + + linkTextView.setTextColor(mSecondaryTextColor); + progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); + } + } + + class PostNoPreviewLinkTypeViewHolder extends PostBaseViewHolder { + @BindView(R.id.card_view_item_post_no_preview_link_type) + MaterialCardView cardView; + @BindView(R.id.icon_gif_image_view_item_post_no_preview_link_type) + AspectRatioGifImageView iconGifImageView; + @BindView(R.id.subreddit_name_text_view_item_post_no_preview_link_type) + TextView subredditTextView; + @BindView(R.id.user_text_view_item_post_no_preview_link_type) + TextView userTextView; + @BindView(R.id.stickied_post_image_view_item_post_no_preview_link_type) + ImageView stickiedPostImageView; + @BindView(R.id.post_time_text_view_best_item_post_no_preview_link_type) + TextView postTimeTextView; + @BindView(R.id.title_text_view_best_item_post_no_preview_link_type) + TextView titleTextView; + @BindView(R.id.type_text_view_item_post_no_preview_link_type) + CustomTextView typeTextView; + @BindView(R.id.archived_image_view_item_post_no_preview_link_type) + ImageView archivedImageView; + @BindView(R.id.locked_image_view_item_post_no_preview_link_type) + ImageView lockedImageView; + @BindView(R.id.crosspost_image_view_item_post_no_preview_link_type) + ImageView crosspostImageView; + @BindView(R.id.nsfw_text_view_item_post_no_preview_link_type) + CustomTextView nsfwTextView; + @BindView(R.id.spoiler_custom_text_view_item_post_no_preview_link_type) + CustomTextView spoilerTextView; + @BindView(R.id.flair_custom_text_view_item_post_no_preview_link_type) + CustomTextView flairTextView; + @BindView(R.id.awards_text_view_item_post_no_preview_link_type) + CustomTextView awardsTextView; + @BindView(R.id.link_text_view_item_post_no_preview_link_type) + TextView linkTextView; + @BindView(R.id.image_view_no_preview_link_item_post_no_preview_link_type) + ImageView noPreviewLinkImageView; + @BindView(R.id.bottom_constraint_layout_item_post_no_preview_link_type) + ConstraintLayout bottomConstraintLayout; + @BindView(R.id.plus_button_item_post_no_preview_link_type) + ImageView upvoteButton; + @BindView(R.id.score_text_view_item_post_no_preview_link_type) + TextView scoreTextView; + @BindView(R.id.minus_button_item_post_no_preview_link_type) + ImageView downvoteButton; + @BindView(R.id.comments_count_item_post_no_preview_link_type) + TextView commentsCountTextView; + @BindView(R.id.save_button_item_post_no_preview_link_type) + ImageView saveButton; + @BindView(R.id.share_button_item_post_no_preview_link_type) + ImageView shareButton; + + PostNoPreviewLinkTypeViewHolder(View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + setBaseView(cardView, + iconGifImageView, + subredditTextView, + userTextView, + stickiedPostImageView, + postTimeTextView, + titleTextView, + typeTextView, + archivedImageView, + lockedImageView, + crosspostImageView, + nsfwTextView, + spoilerTextView, + flairTextView, + awardsTextView, + bottomConstraintLayout, + upvoteButton, + scoreTextView, + downvoteButton, + commentsCountTextView, + saveButton, + shareButton); + + linkTextView.setTextColor(mSecondaryTextColor); + noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor); + } + } + + class PostTextTypeViewHolder extends PostBaseViewHolder { + @BindView(R.id.card_view_item_post_text_type) + MaterialCardView cardView; + @BindView(R.id.icon_gif_image_view_item_post_text_type) + AspectRatioGifImageView iconGifImageView; + @BindView(R.id.subreddit_name_text_view_item_post_text_type) + TextView subredditTextView; + @BindView(R.id.user_text_view_item_post_text_type) + TextView userTextView; + @BindView(R.id.stickied_post_image_view_item_post_text_type) + ImageView stickiedPostImageView; + @BindView(R.id.post_time_text_view_best_item_post_text_type) + TextView postTimeTextView; + @BindView(R.id.title_text_view_best_item_post_text_type) + TextView titleTextView; + @BindView(R.id.type_text_view_item_post_text_type) + CustomTextView typeTextView; + @BindView(R.id.archived_image_view_item_post_text_type) + ImageView archivedImageView; + @BindView(R.id.locked_image_view_item_post_text_type) + ImageView lockedImageView; + @BindView(R.id.crosspost_image_view_item_post_text_type) + ImageView crosspostImageView; + @BindView(R.id.nsfw_text_view_item_post_text_type) + CustomTextView nsfwTextView; + @BindView(R.id.spoiler_custom_text_view_item_post_text_type) + CustomTextView spoilerTextView; + @BindView(R.id.flair_custom_text_view_item_post_text_type) + CustomTextView flairTextView; + @BindView(R.id.awards_text_view_item_post_text_type) + CustomTextView awardsTextView; + @BindView(R.id.content_text_view_item_post_text_type) + TextView contentTextView; + @BindView(R.id.bottom_constraint_layout_item_post_text_type) + ConstraintLayout bottomConstraintLayout; + @BindView(R.id.plus_button_item_post_text_type) + ImageView upvoteButton; + @BindView(R.id.score_text_view_item_post_text_type) + TextView scoreTextView; + @BindView(R.id.minus_button_item_post_text_type) + ImageView downvoteButton; + @BindView(R.id.comments_count_item_post_text_type) + TextView commentsCountTextView; + @BindView(R.id.save_button_item_post_text_type) + ImageView saveButton; + @BindView(R.id.share_button_item_post_text_type) + ImageView shareButton; + + PostTextTypeViewHolder (View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + setBaseView(cardView, + iconGifImageView, + subredditTextView, + userTextView, + stickiedPostImageView, + postTimeTextView, + titleTextView, + typeTextView, + archivedImageView, + lockedImageView, + crosspostImageView, + nsfwTextView, + spoilerTextView, + flairTextView, + awardsTextView, + bottomConstraintLayout, + upvoteButton, + scoreTextView, + downvoteButton, + commentsCountTextView, + saveButton, + shareButton); + + contentTextView.setTextColor(mPostContentColor); + } + } + class PostCompactViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.icon_gif_image_view_item_post_compact) AspectRatioGifImageView iconGifImageView; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java index fe483c3c..a15c01ab 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java @@ -6,6 +6,11 @@ import android.content.SharedPreferences; import androidx.preference.PreferenceManager; +import com.google.android.exoplayer2.database.ExoDatabaseProvider; +import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor; +import com.google.android.exoplayer2.upstream.cache.SimpleCache; + +import java.io.File; import java.util.concurrent.TimeUnit; import javax.inject.Named; @@ -13,6 +18,10 @@ import javax.inject.Singleton; import dagger.Module; import dagger.Provides; +import im.ene.toro.exoplayer.Config; +import im.ene.toro.exoplayer.ExoCreator; +import im.ene.toro.exoplayer.MediaSourceBuilder; +import im.ene.toro.exoplayer.ToroExo; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.RedditUtils; @@ -147,4 +156,14 @@ class AppModule { @Named("amoled_theme") SharedPreferences amoledThemeSharedPreferences) { return new CustomThemeWrapper(lightThemeSharedPreferences, darkThemeSharedPreferences, amoledThemeSharedPreferences); } + + @Provides + @Singleton + ExoCreator provideExoCreator() { + SimpleCache cache = new SimpleCache(new File(mApplication.getCacheDir(), "/toro_cache"), + new LeastRecentlyUsedCacheEvictor(200 * 1024 * 1024), new ExoDatabaseProvider(mApplication)); + Config config = new Config.Builder(mApplication).setMediaSourceBuilder(MediaSourceBuilder.LOOPING).setCache(cache) + .build(); + return ToroExo.with(mApplication).getCreator(config); + } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java index 07ef965a..50e622ba 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java @@ -46,6 +46,8 @@ import javax.inject.Named; import butterknife.BindView; import butterknife.ButterKnife; +import im.ene.toro.exoplayer.ExoCreator; +import im.ene.toro.widget.Container; import ml.docilealligator.infinityforreddit.Activity.BaseActivity; import ml.docilealligator.infinityforreddit.Activity.FilteredThingActivity; import ml.docilealligator.infinityforreddit.Activity.MainActivity; @@ -94,7 +96,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { @BindView(R.id.swipe_refresh_layout_post_fragment) SwipeRefreshLayout mSwipeRefreshLayout; @BindView(R.id.recycler_view_post_fragment) - RecyclerView mPostRecyclerView; + Container mPostRecyclerView; @BindView(R.id.fetch_post_info_linear_layout_post_fragment) LinearLayout mFetchPostInfoLinearLayout; @BindView(R.id.fetch_post_info_image_view_post_fragment) @@ -121,6 +123,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator { SharedPreferences mPostLayoutSharedPreferences; @Inject CustomThemeWrapper customThemeWrapper; + @Inject + ExoCreator exoCreator; private RequestManager mGlide; private AppCompatActivity activity; private LinearLayoutManager mLinearLayoutManager; @@ -323,12 +327,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { int filter = getArguments().getInt(EXTRA_FILTER); String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN); boolean nsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_KEY, false); - boolean needBlurNsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true); - boolean needBlurSpoiler = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false); - boolean voteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false); - boolean showElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false); - boolean showDividerInCompactLayout = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT, true); - boolean showAbsoluteNumberOfVotes = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true); int defaultPostLayout = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY, "0")); if (postType == PostDataSource.TYPE_SEARCH) { @@ -342,9 +340,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase, customThemeWrapper, accessToken, postType, postLayout, true, - needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime, - showDividerInCompactLayout, showAbsoluteNumberOfVotes, - new PostRecyclerViewAdapter.Callback() { + mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() { @Override public void retryLoadingMore() { mPostViewModel.retryLoadingMore(); @@ -407,9 +403,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase, customThemeWrapper, accessToken, postType, postLayout, displaySubredditName, - needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime, - showDividerInCompactLayout, showAbsoluteNumberOfVotes, - new PostRecyclerViewAdapter.Callback() { + mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() { @Override public void retryLoadingMore() { mPostViewModel.retryLoadingMore(); @@ -457,9 +451,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase, customThemeWrapper, accessToken, postType, postLayout, true, - needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime, - showDividerInCompactLayout, showAbsoluteNumberOfVotes, - new PostRecyclerViewAdapter.Callback() { + mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() { @Override public void retryLoadingMore() { mPostViewModel.retryLoadingMore(); @@ -505,9 +497,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase, customThemeWrapper, accessToken, postType, postLayout, true, - needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime, - showDividerInCompactLayout, showAbsoluteNumberOfVotes, - new PostRecyclerViewAdapter.Callback() { + mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() { @Override public void retryLoadingMore() { mPostViewModel.retryLoadingMore(); @@ -546,9 +536,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase, customThemeWrapper, accessToken, postType, postLayout, true, - needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime, - showDividerInCompactLayout, showAbsoluteNumberOfVotes, - new PostRecyclerViewAdapter.Callback() { + mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() { @Override public void retryLoadingMore() { mPostViewModel.retryLoadingMore(); @@ -569,6 +557,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } mPostRecyclerView.setAdapter(mAdapter); + mPostRecyclerView.setCacheManager(mAdapter); mPostViewModel.getPosts().observe(this, posts -> mAdapter.submitList(posts)); mPostViewModel.hasPost().observe(this, hasPost -> { diff --git a/app/src/main/res/drawable/exo_player_autoplay_button_background.xml b/app/src/main/res/drawable/exo_player_autoplay_button_background.xml new file mode 100644 index 00000000..0ad9af8e --- /dev/null +++ b/app/src/main/res/drawable/exo_player_autoplay_button_background.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > + <item> + <shape android:shape="oval"> + <solid android:color="#02EEE6" /> + </shape> + </item> + +</layer-list>
\ No newline at end of file diff --git a/app/src/main/res/layout/exo_autoplay_playback_control_view.xml b/app/src/main/res/layout/exo_autoplay_playback_control_view.xml new file mode 100644 index 00000000..99cab8e2 --- /dev/null +++ b/app/src/main/res/layout/exo_autoplay_playback_control_view.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/linear_layout_exo_playback_control_view" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="bottom" + android:gravity="bottom" + android:paddingStart="16dp" + android:paddingEnd="16dp" + android:paddingBottom="16dp" + android:background="@color/transparentActionBarAndExoPlayerControllerColor" + android:orientation="vertical"> + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="4dp" + android:orientation="horizontal"> + + <ImageButton android:id="@id/exo_play" + style="@style/ExoMediaButton.Play" + android:layout_centerInParent="true" /> + + <ImageButton android:id="@id/exo_pause" + style="@style/ExoMediaButton.Pause" + android:layout_centerInParent="true" /> + + <ImageButton + android:id="@+id/mute_exo_playback_control_view" + style="@style/ExoMediaButton" + android:layout_alignParentEnd="true"/> + + </RelativeLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="4dp" + android:gravity="center_vertical" + android:orientation="horizontal"> + + <TextView android:id="@id/exo_position" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="14sp" + android:textStyle="bold" + android:paddingLeft="4dp" + android:paddingRight="4dp" + android:includeFontPadding="false" + android:textColor="#FFBEBEBE"/> + + <com.google.android.exoplayer2.ui.DefaultTimeBar + android:id="@id/exo_progress" + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="26dp"/> + + <TextView android:id="@id/exo_duration" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="14sp" + android:textStyle="bold" + android:paddingLeft="4dp" + android:paddingRight="4dp" + android:includeFontPadding="false" + android:textColor="#FFBEBEBE"/> + + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/fragment_post.xml b/app/src/main/res/layout/fragment_post.xml index 7862ba25..dc3248b5 100644 --- a/app/src/main/res/layout/fragment_post.xml +++ b/app/src/main/res/layout/fragment_post.xml @@ -10,7 +10,13 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - <androidx.recyclerview.widget.RecyclerView + <!--<androidx.recyclerview.widget.RecyclerView + android:id="@+id/recycler_view_post_fragment" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:clipToPadding="false" />--> + + <im.ene.toro.widget.Container android:id="@+id/recycler_view_post_fragment" android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/app/src/main/res/layout/item_post_gif_type.xml b/app/src/main/res/layout/item_post_gif_type.xml new file mode 100644 index 00000000..3c6b7389 --- /dev/null +++ b/app/src/main/res/layout/item_post_gif_type.xml @@ -0,0 +1,314 @@ +<?xml version="1.0" encoding="utf-8"?> +<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" + android:id="@+id/card_view_item_post_gif_type" + app:cardBackgroundColor="?attr/cardViewBackgroundColor" + app:cardElevation="2dp" + app:cardCornerRadius="16dp"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp"> + + <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView + android:id="@+id/icon_gif_image_view_item_post_gif_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_gravity="center" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/subreddit_name_text_view_item_post_gif_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_default" + app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_gif_type" + app:layout_constraintStart_toEndOf="@id/icon_gif_image_view_item_post_gif_type" + app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_gif_type" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/user_text_view_item_post_gif_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_default" + android:maxLines="2" + android:ellipsize="end" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_gif_type" + app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_gif_type" + app:layout_constraintTop_toBottomOf="@+id/subreddit_name_text_view_item_post_gif_type" + app:layout_constraintHorizontal_bias="0" /> + + <ImageView + android:id="@+id/stickied_post_image_view_item_post_gif_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_marginEnd="8dp" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/subreddit_name_text_view_item_post_gif_type" + app:layout_constraintEnd_toStartOf="@+id/guideline2" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/post_time_text_view_best_item_post_gif_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:gravity="end" + android:textSize="?attr/font_default" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@id/guideline2" + app:layout_constraintTop_toTopOf="parent" /> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical" + app:layout_constraintGuide_percent="0.6" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + <TextView + android:id="@+id/title_text_view_best_item_post_gif_type" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingStart="16dp" + android:paddingEnd="16dp" + android:textSize="?attr/title_font_18" /> + + <com.nex3z.flowlayout.FlowLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + app:flChildSpacing="16dp" + app:flChildSpacingForLastRow="align" + app:flRowSpacing="8dp"> + + <com.libRG.CustomTextView + android:id="@+id/type_text_view_item_post_gif_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:text="@string/gif" + android:textSize="?attr/font_12" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/spoiler_custom_text_view_item_post_gif_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:text="@string/spoiler" + android:textSize="?attr/font_12" + android:padding="4dp" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/nsfw_text_view_item_post_gif_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:text="@string/nsfw" + android:textSize="?attr/font_12" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/flair_custom_text_view_item_post_gif_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:textSize="?attr/font_12" + android:padding="4dp" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/awards_text_view_item_post_gif_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:textSize="?attr/font_12" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <ImageView + android:id="@+id/archived_image_view_item_post_gif_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/ic_archive_outline" + android:visibility="gone" /> + + <ImageView + android:id="@+id/locked_image_view_item_post_gif_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/ic_outline_lock_24dp" + android:visibility="gone" /> + + <ImageView + android:id="@+id/crosspost_image_view_item_post_gif_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/crosspost" + android:visibility="gone" /> + + </com.nex3z.flowlayout.FlowLayout> + + <RelativeLayout + android:id="@+id/image_view_wrapper_item_post_gif_type" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView + android:id="@+id/image_view_best_post_item" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:adjustViewBounds="true" + android:scaleType="fitStart" /> + + <ProgressBar + android:id="@+id/progress_bar_item_post_gif_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true" /> + + <RelativeLayout + android:id="@+id/load_image_error_relative_layout_item_post_gif_type" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_centerInParent="true" + android:visibility="gone"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:drawableTop="@drawable/ic_error_outline_black_24dp" + android:layout_gravity="center" + android:gravity="center" + android:text="@string/error_loading_image_tap_to_retry" + android:textSize="?attr/font_default" /> + + </RelativeLayout> + + </RelativeLayout> + + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/bottom_constraint_layout_item_post_gif_type" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <ImageView + android:id="@+id/plus_button_item_post_gif_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_arrow_upward_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" /> + + <TextView + android:id="@+id/score_text_view_item_post_gif_type" + android:layout_width="64dp" + android:layout_height="wrap_content" + android:gravity="center" + android:textSize="?attr/font_12" + android:textStyle="bold" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/plus_button_item_post_gif_type" /> + + <ImageView + android:id="@+id/minus_button_item_post_gif_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_arrow_downward_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_gif_type" /> + + <TextView + android:id="@+id/comments_count_item_post_gif_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:gravity="center_vertical" + android:textSize="?attr/font_12" + android:textStyle="bold" + android:drawableStart="@drawable/ic_comment_grey_24dp" + android:drawablePadding="12dp" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/minus_button_item_post_gif_type" /> + + <ImageView + android:id="@+id/save_button_item_post_gif_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintHorizontal_bias="1" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/comments_count_item_post_gif_type" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_gif_type" /> + + <ImageView + android:id="@+id/share_button_item_post_gif_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_share_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + </LinearLayout> + +</com.google.android.material.card.MaterialCardView>
\ No newline at end of file diff --git a/app/src/main/res/layout/item_post_image_type.xml b/app/src/main/res/layout/item_post_image_type.xml new file mode 100644 index 00000000..6ca140d3 --- /dev/null +++ b/app/src/main/res/layout/item_post_image_type.xml @@ -0,0 +1,314 @@ +<?xml version="1.0" encoding="utf-8"?> +<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" + android:id="@+id/card_view_item_post_image_type" + app:cardBackgroundColor="?attr/cardViewBackgroundColor" + app:cardElevation="2dp" + app:cardCornerRadius="16dp"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp"> + + <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView + android:id="@+id/icon_gif_image_view_item_post_image_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_gravity="center" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/subreddit_name_text_view_item_post_image_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_default" + app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_image_type" + app:layout_constraintStart_toEndOf="@id/icon_gif_image_view_item_post_image_type" + app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_image_type" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/user_text_view_item_post_image_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_default" + android:maxLines="2" + android:ellipsize="end" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_image_type" + app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_image_type" + app:layout_constraintTop_toBottomOf="@+id/subreddit_name_text_view_item_post_image_type" + app:layout_constraintHorizontal_bias="0" /> + + <ImageView + android:id="@+id/stickied_post_image_view_item_post_image_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_marginEnd="8dp" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/subreddit_name_text_view_item_post_image_type" + app:layout_constraintEnd_toStartOf="@+id/guideline2" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/post_time_text_view_best_item_post_image_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:gravity="end" + android:textSize="?attr/font_default" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@id/guideline2" + app:layout_constraintTop_toTopOf="parent" /> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical" + app:layout_constraintGuide_percent="0.6" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + <TextView + android:id="@+id/title_text_view_best_item_post_image_type" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingStart="16dp" + android:paddingEnd="16dp" + android:textSize="?attr/title_font_18" /> + + <com.nex3z.flowlayout.FlowLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + app:flChildSpacing="16dp" + app:flChildSpacingForLastRow="align" + app:flRowSpacing="8dp"> + + <com.libRG.CustomTextView + android:id="@+id/type_text_view_item_post_image_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:text="@string/image" + android:textSize="?attr/font_12" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/spoiler_custom_text_view_item_post_image_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:text="@string/spoiler" + android:textSize="?attr/font_12" + android:padding="4dp" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/nsfw_text_view_item_post_image_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:text="@string/nsfw" + android:textSize="?attr/font_12" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/flair_custom_text_view_item_post_image_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:textSize="?attr/font_12" + android:padding="4dp" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/awards_text_view_item_post_image_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:textSize="?attr/font_12" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <ImageView + android:id="@+id/archived_image_view_item_post_image_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/ic_archive_outline" + android:visibility="gone" /> + + <ImageView + android:id="@+id/locked_image_view_item_post_image_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/ic_outline_lock_24dp" + android:visibility="gone" /> + + <ImageView + android:id="@+id/crosspost_image_view_item_post_image_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/crosspost" + android:visibility="gone" /> + + </com.nex3z.flowlayout.FlowLayout> + + <RelativeLayout + android:id="@+id/image_view_wrapper_item_post_image_type" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView + android:id="@+id/image_view_best_post_item" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:adjustViewBounds="true" + android:scaleType="fitStart" /> + + <ProgressBar + android:id="@+id/progress_bar_item_post_image_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true" /> + + <RelativeLayout + android:id="@+id/load_image_error_relative_layout_item_post_image_type" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_centerInParent="true" + android:visibility="gone"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:drawableTop="@drawable/ic_error_outline_black_24dp" + android:layout_gravity="center" + android:gravity="center" + android:text="@string/error_loading_image_tap_to_retry" + android:textSize="?attr/font_default" /> + + </RelativeLayout> + + </RelativeLayout> + + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/bottom_constraint_layout_item_post_image_type" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <ImageView + android:id="@+id/plus_button_item_post_image_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_arrow_upward_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" /> + + <TextView + android:id="@+id/score_text_view_item_post_image_type" + android:layout_width="64dp" + android:layout_height="wrap_content" + android:gravity="center" + android:textSize="?attr/font_12" + android:textStyle="bold" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/plus_button_item_post_image_type" /> + + <ImageView + android:id="@+id/minus_button_item_post_image_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_arrow_downward_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_image_type" /> + + <TextView + android:id="@+id/comments_count_item_post_image_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:gravity="center_vertical" + android:textSize="?attr/font_12" + android:textStyle="bold" + android:drawableStart="@drawable/ic_comment_grey_24dp" + android:drawablePadding="12dp" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/minus_button_item_post_image_type" /> + + <ImageView + android:id="@+id/save_button_item_post_image_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintHorizontal_bias="1" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/comments_count_item_post_image_type" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_image_type" /> + + <ImageView + android:id="@+id/share_button_item_post_image_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_share_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + </LinearLayout> + +</com.google.android.material.card.MaterialCardView>
\ No newline at end of file diff --git a/app/src/main/res/layout/item_post_link_type.xml b/app/src/main/res/layout/item_post_link_type.xml new file mode 100644 index 00000000..43f51b10 --- /dev/null +++ b/app/src/main/res/layout/item_post_link_type.xml @@ -0,0 +1,324 @@ +<?xml version="1.0" encoding="utf-8"?> +<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" + android:id="@+id/card_view_item_post_link_type" + app:cardBackgroundColor="?attr/cardViewBackgroundColor" + app:cardElevation="2dp" + app:cardCornerRadius="16dp"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp"> + + <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView + android:id="@+id/icon_gif_image_view_item_post_link_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_gravity="center" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/subreddit_name_text_view_item_post_link_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_default" + app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_link_type" + app:layout_constraintStart_toEndOf="@id/icon_gif_image_view_item_post_link_type" + app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_link_type" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/user_text_view_item_post_link_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_default" + android:maxLines="2" + android:ellipsize="end" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_link_type" + app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_link_type" + app:layout_constraintTop_toBottomOf="@+id/subreddit_name_text_view_item_post_link_type" + app:layout_constraintHorizontal_bias="0" /> + + <ImageView + android:id="@+id/stickied_post_image_view_item_post_link_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_marginEnd="8dp" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/subreddit_name_text_view_item_post_link_type" + app:layout_constraintEnd_toStartOf="@+id/guideline2" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/post_time_text_view_best_item_post_link_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:gravity="end" + android:textSize="?attr/font_default" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@id/guideline2" + app:layout_constraintTop_toTopOf="parent" /> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical" + app:layout_constraintGuide_percent="0.6" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + <TextView + android:id="@+id/title_text_view_best_item_post_link_type" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingStart="16dp" + android:paddingEnd="16dp" + android:textSize="?attr/title_font_18" /> + + <com.nex3z.flowlayout.FlowLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + app:flChildSpacing="16dp" + app:flChildSpacingForLastRow="align" + app:flRowSpacing="8dp"> + + <com.libRG.CustomTextView + android:id="@+id/type_text_view_item_post_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:text="@string/link" + android:textSize="?attr/font_12" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/spoiler_custom_text_view_item_post_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:text="@string/spoiler" + android:textSize="?attr/font_12" + android:padding="4dp" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/nsfw_text_view_item_post_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:text="@string/nsfw" + android:textSize="?attr/font_12" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/flair_custom_text_view_item_post_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:textSize="?attr/font_12" + android:padding="4dp" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/awards_text_view_item_post_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:textSize="?attr/font_12" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <ImageView + android:id="@+id/archived_image_view_item_post_link_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/ic_archive_outline" + android:visibility="gone" /> + + <ImageView + android:id="@+id/locked_image_view_item_post_link_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/ic_outline_lock_24dp" + android:visibility="gone" /> + + <ImageView + android:id="@+id/crosspost_image_view_item_post_link_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/crosspost" + android:visibility="gone" /> + + </com.nex3z.flowlayout.FlowLayout> + + <TextView + android:id="@+id/link_text_view_item_post_link_type" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="16dp" + android:paddingStart="16dp" + android:paddingEnd="16dp" + android:textSize="?attr/font_12" + android:visibility="gone" /> + + <RelativeLayout + android:id="@+id/image_view_wrapper_item_post_link_type" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView + android:id="@+id/image_view_best_post_item" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:adjustViewBounds="true" + android:scaleType="fitStart" /> + + <ProgressBar + android:id="@+id/progress_bar_item_post_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true" /> + + <RelativeLayout + android:id="@+id/load_image_error_relative_layout_item_post_link_type" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_centerInParent="true" + android:visibility="gone"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:drawableTop="@drawable/ic_error_outline_black_24dp" + android:layout_gravity="center" + android:gravity="center" + android:text="@string/error_loading_image_tap_to_retry" + android:textSize="?attr/font_default" /> + + </RelativeLayout> + + </RelativeLayout> + + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/bottom_constraint_layout_item_post_link_type" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <ImageView + android:id="@+id/plus_button_item_post_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_arrow_upward_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" /> + + <TextView + android:id="@+id/score_text_view_item_post_link_type" + android:layout_width="64dp" + android:layout_height="wrap_content" + android:gravity="center" + android:textSize="?attr/font_12" + android:textStyle="bold" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/plus_button_item_post_link_type" /> + + <ImageView + android:id="@+id/minus_button_item_post_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_arrow_downward_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_link_type" /> + + <TextView + android:id="@+id/comments_count_item_post_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:gravity="center_vertical" + android:textSize="?attr/font_12" + android:textStyle="bold" + android:drawableStart="@drawable/ic_comment_grey_24dp" + android:drawablePadding="12dp" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/minus_button_item_post_link_type" /> + + <ImageView + android:id="@+id/save_button_item_post_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintHorizontal_bias="1" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/comments_count_item_post_link_type" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_link_type" /> + + <ImageView + android:id="@+id/share_button_item_post_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_share_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + </LinearLayout> + +</com.google.android.material.card.MaterialCardView>
\ No newline at end of file diff --git a/app/src/main/res/layout/item_post_no_preview_link_type.xml b/app/src/main/res/layout/item_post_no_preview_link_type.xml new file mode 100644 index 00000000..a6ef9eeb --- /dev/null +++ b/app/src/main/res/layout/item_post_no_preview_link_type.xml @@ -0,0 +1,293 @@ +<?xml version="1.0" encoding="utf-8"?> +<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" + android:id="@+id/card_view_item_post_no_preview_link_type" + app:cardBackgroundColor="?attr/cardViewBackgroundColor" + app:cardElevation="2dp" + app:cardCornerRadius="16dp"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp"> + + <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView + android:id="@+id/icon_gif_image_view_item_post_no_preview_link_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_gravity="center" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/subreddit_name_text_view_item_post_no_preview_link_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_default" + app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_no_preview_link_type" + app:layout_constraintStart_toEndOf="@id/icon_gif_image_view_item_post_no_preview_link_type" + app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_no_preview_link_type" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/user_text_view_item_post_no_preview_link_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_default" + android:maxLines="2" + android:ellipsize="end" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_no_preview_link_type" + app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_no_preview_link_type" + app:layout_constraintTop_toBottomOf="@+id/subreddit_name_text_view_item_post_no_preview_link_type" + app:layout_constraintHorizontal_bias="0" /> + + <ImageView + android:id="@+id/stickied_post_image_view_item_post_no_preview_link_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_marginEnd="8dp" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/subreddit_name_text_view_item_post_no_preview_link_type" + app:layout_constraintEnd_toStartOf="@+id/guideline2" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/post_time_text_view_best_item_post_no_preview_link_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:gravity="end" + android:textSize="?attr/font_default" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@id/guideline2" + app:layout_constraintTop_toTopOf="parent" /> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical" + app:layout_constraintGuide_percent="0.6" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + <TextView + android:id="@+id/title_text_view_best_item_post_no_preview_link_type" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingStart="16dp" + android:paddingEnd="16dp" + android:textSize="?attr/title_font_18" /> + + <com.nex3z.flowlayout.FlowLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + app:flChildSpacing="16dp" + app:flChildSpacingForLastRow="align" + app:flRowSpacing="8dp"> + + <com.libRG.CustomTextView + android:id="@+id/type_text_view_item_post_no_preview_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:text="@string/link" + android:textSize="?attr/font_12" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/spoiler_custom_text_view_item_post_no_preview_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:text="@string/spoiler" + android:textSize="?attr/font_12" + android:padding="4dp" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/nsfw_text_view_item_post_no_preview_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:text="@string/nsfw" + android:textSize="?attr/font_12" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/flair_custom_text_view_item_post_no_preview_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:textSize="?attr/font_12" + android:padding="4dp" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/awards_text_view_item_post_no_preview_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:textSize="?attr/font_12" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <ImageView + android:id="@+id/archived_image_view_item_post_no_preview_link_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/ic_archive_outline" + android:visibility="gone" /> + + <ImageView + android:id="@+id/locked_image_view_item_post_no_preview_link_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/ic_outline_lock_24dp" + android:visibility="gone" /> + + <ImageView + android:id="@+id/crosspost_image_view_item_post_no_preview_link_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/crosspost" + android:visibility="gone" /> + + </com.nex3z.flowlayout.FlowLayout> + + <TextView + android:id="@+id/link_text_view_item_post_no_preview_link_type" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="16dp" + android:paddingStart="16dp" + android:paddingEnd="16dp" + android:textSize="?attr/font_12" /> + + <ImageView + android:id="@+id/image_view_no_preview_link_item_post_no_preview_link_type" + android:layout_width="match_parent" + android:layout_height="150dp" + android:scaleType="center" + android:src="@drawable/ic_link" + android:tint="@android:color/tab_indicator_text" /> + + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/bottom_constraint_layout_item_post_no_preview_link_type" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <ImageView + android:id="@+id/plus_button_item_post_no_preview_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_arrow_upward_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" /> + + <TextView + android:id="@+id/score_text_view_item_post_no_preview_link_type" + android:layout_width="64dp" + android:layout_height="wrap_content" + android:gravity="center" + android:textSize="?attr/font_12" + android:textStyle="bold" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/plus_button_item_post_no_preview_link_type" /> + + <ImageView + android:id="@+id/minus_button_item_post_no_preview_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_arrow_downward_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_no_preview_link_type" /> + + <TextView + android:id="@+id/comments_count_item_post_no_preview_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:gravity="center_vertical" + android:textSize="?attr/font_12" + android:textStyle="bold" + android:drawableStart="@drawable/ic_comment_grey_24dp" + android:drawablePadding="12dp" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/minus_button_item_post_no_preview_link_type" /> + + <ImageView + android:id="@+id/save_button_item_post_no_preview_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintHorizontal_bias="1" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/comments_count_item_post_no_preview_link_type" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_no_preview_link_type" /> + + <ImageView + android:id="@+id/share_button_item_post_no_preview_link_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_share_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + </LinearLayout> + +</com.google.android.material.card.MaterialCardView>
\ No newline at end of file diff --git a/app/src/main/res/layout/item_post_text_type.xml b/app/src/main/res/layout/item_post_text_type.xml new file mode 100644 index 00000000..cc7a3bb9 --- /dev/null +++ b/app/src/main/res/layout/item_post_text_type.xml @@ -0,0 +1,288 @@ +<?xml version="1.0" encoding="utf-8"?> +<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" + android:id="@+id/card_view_item_post_text_type" + app:cardBackgroundColor="?attr/cardViewBackgroundColor" + app:cardElevation="2dp" + app:cardCornerRadius="16dp"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp"> + + <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView + android:id="@+id/icon_gif_image_view_item_post_text_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_gravity="center" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/subreddit_name_text_view_item_post_text_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_default" + app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_text_type" + app:layout_constraintStart_toEndOf="@id/icon_gif_image_view_item_post_text_type" + app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_text_type" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/user_text_view_item_post_text_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_default" + android:maxLines="2" + android:ellipsize="end" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_text_type" + app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_text_type" + app:layout_constraintTop_toBottomOf="@+id/subreddit_name_text_view_item_post_text_type" + app:layout_constraintHorizontal_bias="0" /> + + <ImageView + android:id="@+id/stickied_post_image_view_item_post_text_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_marginEnd="8dp" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/subreddit_name_text_view_item_post_text_type" + app:layout_constraintEnd_toStartOf="@+id/guideline2" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/post_time_text_view_best_item_post_text_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:gravity="end" + android:textSize="?attr/font_default" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@id/guideline2" + app:layout_constraintTop_toTopOf="parent" /> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical" + app:layout_constraintGuide_percent="0.6" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + <TextView + android:id="@+id/title_text_view_best_item_post_text_type" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingStart="16dp" + android:paddingEnd="16dp" + android:textSize="?attr/title_font_18" /> + + <TextView + android:id="@+id/content_text_view_item_post_text_type" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="16dp" + android:paddingStart="16dp" + android:paddingEnd="16dp" + android:maxLines="4" + android:visibility="gone" + android:textSize="?attr/content_font_default" + android:ellipsize="end" /> + + <com.nex3z.flowlayout.FlowLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + app:flChildSpacing="16dp" + app:flChildSpacingForLastRow="align" + app:flRowSpacing="8dp"> + + <com.libRG.CustomTextView + android:id="@+id/type_text_view_item_post_text_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:text="@string/text" + android:textSize="?attr/font_12" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/spoiler_custom_text_view_item_post_text_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:text="@string/spoiler" + android:textSize="?attr/font_12" + android:padding="4dp" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/nsfw_text_view_item_post_text_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:text="@string/nsfw" + android:textSize="?attr/font_12" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/flair_custom_text_view_item_post_text_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:textSize="?attr/font_12" + android:padding="4dp" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/awards_text_view_item_post_text_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:textSize="?attr/font_12" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <ImageView + android:id="@+id/archived_image_view_item_post_text_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/ic_archive_outline" + android:visibility="gone" /> + + <ImageView + android:id="@+id/locked_image_view_item_post_text_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/ic_outline_lock_24dp" + android:visibility="gone" /> + + <ImageView + android:id="@+id/crosspost_image_view_item_post_text_type" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/crosspost" + android:visibility="gone" /> + + </com.nex3z.flowlayout.FlowLayout> + + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/bottom_constraint_layout_item_post_text_type" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <ImageView + android:id="@+id/plus_button_item_post_text_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_arrow_upward_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" /> + + <TextView + android:id="@+id/score_text_view_item_post_text_type" + android:layout_width="64dp" + android:layout_height="wrap_content" + android:gravity="center" + android:textSize="?attr/font_12" + android:textStyle="bold" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/plus_button_item_post_text_type" /> + + <ImageView + android:id="@+id/minus_button_item_post_text_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_arrow_downward_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_text_type" /> + + <TextView + android:id="@+id/comments_count_item_post_text_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:gravity="center_vertical" + android:textSize="?attr/font_12" + android:textStyle="bold" + android:drawableStart="@drawable/ic_comment_grey_24dp" + android:drawablePadding="12dp" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/minus_button_item_post_text_type" /> + + <ImageView + android:id="@+id/save_button_item_post_text_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintHorizontal_bias="1" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/comments_count_item_post_text_type" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_text_type" /> + + <ImageView + android:id="@+id/share_button_item_post_text_type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_share_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + </LinearLayout> + +</com.google.android.material.card.MaterialCardView>
\ No newline at end of file diff --git a/app/src/main/res/layout/item_post_video_type_autoplay.xml b/app/src/main/res/layout/item_post_video_type_autoplay.xml new file mode 100644 index 00000000..2f1c078a --- /dev/null +++ b/app/src/main/res/layout/item_post_video_type_autoplay.xml @@ -0,0 +1,289 @@ +<?xml version="1.0" encoding="utf-8"?> +<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" + android:id="@+id/card_view_item_post_video_type_autoplay" + app:cardBackgroundColor="?attr/cardViewBackgroundColor" + app:cardElevation="2dp" + app:cardCornerRadius="16dp"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp"> + + <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView + android:id="@+id/icon_gif_image_view_item_post_video_type_autoplay" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_gravity="center" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/subreddit_name_text_view_item_post_video_type_autoplay" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_default" + app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_video_type_autoplay" + app:layout_constraintStart_toEndOf="@id/icon_gif_image_view_item_post_video_type_autoplay" + app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_video_type_autoplay" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/user_text_view_item_post_video_type_autoplay" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_default" + android:maxLines="2" + android:ellipsize="end" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_video_type_autoplay" + app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_video_type_autoplay" + app:layout_constraintTop_toBottomOf="@+id/subreddit_name_text_view_item_post_video_type_autoplay" + app:layout_constraintHorizontal_bias="0" /> + + <ImageView + android:id="@+id/stickied_post_image_view_item_post_video_type_autoplay" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_marginEnd="8dp" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/subreddit_name_text_view_item_post_video_type_autoplay" + app:layout_constraintEnd_toStartOf="@+id/guideline2" + app:layout_constraintTop_toTopOf="parent"/> + + <TextView + android:id="@+id/post_time_text_view_best_item_post_video_type_autoplay" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:gravity="end" + android:textSize="?attr/font_default" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@id/guideline2" + app:layout_constraintTop_toTopOf="parent" /> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical" + app:layout_constraintGuide_percent="0.6" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + <TextView + android:id="@+id/title_text_view_best_item_post_video_type_autoplay" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingStart="16dp" + android:paddingEnd="16dp" + android:textSize="?attr/title_font_18" /> + + <com.nex3z.flowlayout.FlowLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + app:flChildSpacing="16dp" + app:flChildSpacingForLastRow="align" + app:flRowSpacing="8dp"> + + <com.libRG.CustomTextView + android:id="@+id/type_text_view_item_post_video_type_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:textSize="?attr/font_12" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/spoiler_custom_text_view_item_post_video_type_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:text="@string/spoiler" + android:textSize="?attr/font_12" + android:padding="4dp" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/nsfw_text_view_item_post_video_type_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:text="@string/nsfw" + android:textSize="?attr/font_12" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/flair_custom_text_view_item_post_video_type_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:textSize="?attr/font_12" + android:padding="4dp" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/awards_text_view_item_post_video_type_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:textSize="?attr/font_12" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <ImageView + android:id="@+id/archived_image_view_item_post_video_type_autoplay" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/ic_archive_outline" + android:visibility="gone" /> + + <ImageView + android:id="@+id/locked_image_view_item_post_video_type_autoplay" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/ic_outline_lock_24dp" + android:visibility="gone" /> + + <ImageView + android:id="@+id/crosspost_image_view_item_post_video_type_autoplay" + android:layout_width="24dp" + android:layout_height="24dp" + android:src="@drawable/crosspost" + android:visibility="gone" /> + + </com.nex3z.flowlayout.FlowLayout> + + <com.google.android.exoplayer2.ui.AspectRatioFrameLayout + android:id="@+id/aspect" + android:layout_width="match_parent" + android:layout_height="0dp" + app:resize_mode="fixed_width"> + + <com.google.android.exoplayer2.ui.PlayerView + android:id="@+id/player_view_item_post_video_type_autoplay" + android:layout_width="match_parent" + android:layout_height="match_parent" + app:controller_layout_id="@layout/exo_autoplay_playback_control_view"/> + + </com.google.android.exoplayer2.ui.AspectRatioFrameLayout> + + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/bottom_constraint_layout_item_post_video_type_autoplay" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <ImageView + android:id="@+id/plus_button_item_post_video_type_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_arrow_upward_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" /> + + <TextView + android:id="@+id/score_text_view_item_post_video_type_autoplay" + android:layout_width="64dp" + android:layout_height="wrap_content" + android:gravity="center" + android:textSize="?attr/font_12" + android:textStyle="bold" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/plus_button_item_post_video_type_autoplay" /> + + <ImageView + android:id="@+id/minus_button_item_post_video_type_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_arrow_downward_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_video_type_autoplay" /> + + <TextView + android:id="@+id/comments_count_item_post_video_type_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:gravity="center_vertical" + android:textSize="?attr/font_12" + android:textStyle="bold" + android:drawableStart="@drawable/ic_comment_grey_24dp" + android:drawablePadding="12dp" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/minus_button_item_post_video_type_autoplay" /> + + <ImageView + android:id="@+id/save_button_item_post_video_type_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintHorizontal_bias="1" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/comments_count_item_post_video_type_autoplay" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_video_type_autoplay" /> + + <ImageView + android:id="@+id/share_button_item_post_video_type_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_share_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + </LinearLayout> + +</com.google.android.material.card.MaterialCardView>
\ No newline at end of file |