From 477f88543a09b48585b68be89a7a378726a038f8 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Mon, 22 Feb 2021 15:31:10 +0800 Subject: Continue adding Card Layout 2. --- .../adapters/PostRecyclerViewAdapter.java | 182 +++++++++++--- app/src/main/res/layout/item_post_card_2_text.xml | 269 +++++++++++++++++++++ .../res/layout/item_post_card_2_with_preview.xml | 34 +-- app/src/main/res/layout/item_post_text.xml | 1 - .../res/layout/item_post_video_type_autoplay.xml | 1 - app/src/main/res/layout/item_post_with_preview.xml | 1 - 6 files changed, 423 insertions(+), 65 deletions(-) create mode 100644 app/src/main/res/layout/item_post_card_2_text.xml (limited to 'app/src/main') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index 76a561c5..3b9af3ca 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -49,7 +49,6 @@ import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; 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; import org.greenrobot.eventbus.EventBus; @@ -115,9 +114,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter DIFF_CALLBACK = new DiffUtil.ItemCallback() { @Override @@ -381,7 +382,28 @@ public class PostRecyclerViewAdapter extends PagedListAdapter { + noPreviewImageView.setOnClickListener(view -> { imageView.performClick(); }); } } + class PostCard2TextTypeViewHolder extends PostBaseViewHolder { + @BindView(R.id.icon_gif_image_view_item_post_card_2_text) + AspectRatioGifImageView iconGifImageView; + @BindView(R.id.subreddit_name_text_view_item_post_card_2_text) + TextView subredditTextView; + @BindView(R.id.user_text_view_item_post_card_2_text) + TextView userTextView; + @BindView(R.id.stickied_post_image_view_item_post_card_2_text) + ImageView stickiedPostImageView; + @BindView(R.id.post_time_text_view_item_post_card_2_text) + TextView postTimeTextView; + @BindView(R.id.title_text_view_item_post_card_2_text) + TextView titleTextView; + @BindView(R.id.content_text_view_item_post_card_2_text) + TextView contentTextView; + @BindView(R.id.type_text_view_item_post_card_2_text) + CustomTextView typeTextView; + @BindView(R.id.archived_image_view_item_post_card_2_text) + ImageView archivedImageView; + @BindView(R.id.locked_image_view_item_post_card_2_text) + ImageView lockedImageView; + @BindView(R.id.crosspost_image_view_item_post_card_2_text) + ImageView crosspostImageView; + @BindView(R.id.nsfw_text_view_item_post_card_2_text) + CustomTextView nsfwTextView; + @BindView(R.id.spoiler_custom_text_view_item_post_card_2_text) + CustomTextView spoilerTextView; + @BindView(R.id.flair_custom_text_view_item_post_card_2_text) + CustomTextView flairTextView; + @BindView(R.id.awards_text_view_item_post_card_2_text) + CustomTextView awardsTextView; + @BindView(R.id.bottom_constraint_layout_item_post_card_2_text) + ConstraintLayout bottomConstraintLayout; + @BindView(R.id.plus_button_item_post_card_2_text) + ImageView upvoteButton; + @BindView(R.id.score_text_view_item_post_card_2_text) + TextView scoreTextView; + @BindView(R.id.minus_button_item_post_card_2_text) + ImageView downvoteButton; + @BindView(R.id.comments_count_item_post_card_2_text) + TextView commentsCountTextView; + @BindView(R.id.save_button_item_post_card_2_text) + ImageView saveButton; + @BindView(R.id.share_button_item_post_card_2_text) + ImageView shareButton; + @BindView(R.id.divider_item_post_card_2_text) + View divider; + + PostCard2TextTypeViewHolder(@NonNull View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + setBaseView( + iconGifImageView, + subredditTextView, + userTextView, + stickiedPostImageView, + postTimeTextView, + titleTextView, + typeTextView, + archivedImageView, + lockedImageView, + crosspostImageView, + nsfwTextView, + spoilerTextView, + flairTextView, + awardsTextView, + bottomConstraintLayout, + upvoteButton, + scoreTextView, + downvoteButton, + commentsCountTextView, + saveButton, + shareButton); + + contentTextView.setTextColor(mPostContentColor); + divider.setBackgroundColor(mDividerColor); + } + } + class ErrorViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.error_text_view_item_footer_error) TextView errorTextView; diff --git a/app/src/main/res/layout/item_post_card_2_text.xml b/app/src/main/res/layout/item_post_card_2_text.xml new file mode 100644 index 00000000..35daac06 --- /dev/null +++ b/app/src/main/res/layout/item_post_card_2_text.xml @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_post_card_2_with_preview.xml b/app/src/main/res/layout/item_post_card_2_with_preview.xml index 8955cb61..351fd1d7 100644 --- a/app/src/main/res/layout/item_post_card_2_with_preview.xml +++ b/app/src/main/res/layout/item_post_card_2_with_preview.xml @@ -4,23 +4,20 @@ android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:tools="http://schemas.android.com/tools" - android:layout_marginTop="8dp" + android:paddingTop="8dp" android:layout_marginBottom="8dp" - android:id="@+id/card_view_item_post_card_2_with_preview" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground" android:orientation="vertical"> + app:cardCornerRadius="8dp"> - + - + - - 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 index 9573d808..3b78eb27 100644 --- a/app/src/main/res/layout/item_post_video_type_autoplay.xml +++ b/app/src/main/res/layout/item_post_video_type_autoplay.xml @@ -6,7 +6,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_marginTop="8dp" android:layout_marginBottom="8dp" - android:id="@+id/card_view_item_post_video_type_autoplay" app:cardElevation="2dp" app:cardCornerRadius="16dp"> diff --git a/app/src/main/res/layout/item_post_with_preview.xml b/app/src/main/res/layout/item_post_with_preview.xml index 5782403c..3d2f09b3 100644 --- a/app/src/main/res/layout/item_post_with_preview.xml +++ b/app/src/main/res/layout/item_post_with_preview.xml @@ -6,7 +6,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_marginTop="8dp" android:layout_marginBottom="8dp" - android:id="@+id/card_view_item_post_with_preview" app:cardElevation="2dp" app:cardCornerRadius="16dp"> -- cgit v1.2.3