Show the number of subscribers in SubredditListingRecyclerViewAdapter.

This commit is contained in:
Docile-Alligator 2022-07-15 18:02:11 +08:00
parent 0265ac6227
commit 1cb79742c7
3 changed files with 41 additions and 18 deletions

View File

@ -141,6 +141,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
} }
((DataViewHolder) holder).subredditNameTextView.setText(subredditData.getName()); ((DataViewHolder) holder).subredditNameTextView.setText(subredditData.getName());
((DataViewHolder) holder).subscriberCountTextView.setText(activity.getString(R.string.subscribers_number_detail, subredditData.getNSubscribers()));
if (!isMultiSelection) { if (!isMultiSelection) {
CheckIsSubscribedToSubreddit.checkIsSubscribedToSubreddit(executor, new Handler(), CheckIsSubscribedToSubreddit.checkIsSubscribedToSubreddit(executor, new Handler(),
@ -260,6 +261,8 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
GifImageView iconGifImageView; GifImageView iconGifImageView;
@BindView(R.id.subreddit_name_text_view_item_subreddit_listing) @BindView(R.id.subreddit_name_text_view_item_subreddit_listing)
TextView subredditNameTextView; TextView subredditNameTextView;
@BindView(R.id.subscriber_count_text_view_item_subreddit_listing)
TextView subscriberCountTextView;
@BindView(R.id.subscribe_image_view_item_subreddit_listing) @BindView(R.id.subscribe_image_view_item_subreddit_listing)
ImageView subscribeButton; ImageView subscribeButton;
@BindView(R.id.checkbox_item_subreddit_listing) @BindView(R.id.checkbox_item_subreddit_listing)
@ -269,6 +272,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
super(itemView); super(itemView);
ButterKnife.bind(this, itemView); ButterKnife.bind(this, itemView);
subredditNameTextView.setTextColor(primaryTextColor); subredditNameTextView.setTextColor(primaryTextColor);
subscriberCountTextView.setTextColor(secondaryTextColor);
subscribeButton.setColorFilter(unsubscribed, android.graphics.PorterDuff.Mode.SRC_IN); subscribeButton.setColorFilter(unsubscribed, android.graphics.PorterDuff.Mode.SRC_IN);
if (isMultiSelection) { if (isMultiSelection) {
checkBox.setVisibility(View.VISIBLE); checkBox.setVisibility(View.VISIBLE);
@ -276,6 +280,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
if (activity.typeface != null) { if (activity.typeface != null) {
subredditNameTextView.setTypeface(activity.typeface); subredditNameTextView.setTypeface(activity.typeface);
subscriberCountTextView.setTypeface(activity.typeface);
} }
} }
} }

View File

@ -120,7 +120,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
Resources resources = getResources(); Resources resources = getResources();
if ((mActivity instanceof BaseActivity && ((BaseActivity) mActivity).isImmersiveInterface())) { if ((mActivity != null && ((BaseActivity) mActivity).isImmersiveInterface())) {
mSubredditListingRecyclerView.setPadding(0, 0, 0, ((BaseActivity) mActivity).getNavBarHeight()); mSubredditListingRecyclerView.setPadding(0, 0, 0, ((BaseActivity) mActivity).getNavBarHeight());
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
&& mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true)) { && mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true)) {

View File

@ -4,53 +4,71 @@
android:id="@+id/constraint_layout_item_subreddit_listing" android:id="@+id/constraint_layout_item_subreddit_listing"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp" android:background="?attr/selectableItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:background="?attr/selectableItemBackground"> android:padding="16dp">
<pl.droidsonroids.gif.GifImageView <pl.droidsonroids.gif.GifImageView
android:id="@+id/subreddit_icon_gif_image_view_item_subreddit_listing" android:id="@+id/subreddit_icon_gif_image_view_item_subreddit_listing"
android:layout_width="36dp" android:layout_width="36dp"
android:layout_height="36dp" android:layout_height="36dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintBottom_toBottomOf="parent"/>
<TextView <TextView
android:id="@+id/subreddit_name_text_view_item_subreddit_listing" android:id="@+id/subreddit_name_text_view_item_subreddit_listing"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="32dp" android:layout_marginStart="32dp"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
app:layout_constraintStart_toEndOf="@+id/subreddit_icon_gif_image_view_item_subreddit_listing"
app:layout_constraintEnd_toStartOf="@id/barrier3"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/subscriber_count_text_view_item_subreddit_listing"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/subreddit_icon_gif_image_view_item_subreddit_listing" app:layout_constraintStart_toEndOf="@+id/subreddit_icon_gif_image_view_item_subreddit_listing"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintEnd_toStartOf="@id/barrier3"
app:layout_constraintTop_toBottomOf="@id/subreddit_name_text_view_item_subreddit_listing" />
<ImageView <ImageView
android:id="@+id/subscribe_image_view_item_subreddit_listing" android:id="@+id/subscribe_image_view_item_subreddit_listing"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:src="@drawable/ic_add_24dp" android:background="?attr/selectableItemBackground"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:background="?attr/selectableItemBackground" android:src="@drawable/ic_add_24dp"
android:visibility="gone"/> android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.checkbox.MaterialCheckBox <com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/checkbox_item_subreddit_listing" android:id="@+id/checkbox_item_subreddit_listing"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent" android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
android:visibility="gone" /> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="start"
app:constraint_referenced_ids="subscribe_image_view_item_subreddit_listing,checkbox_item_subreddit_listing" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>