Show instance for community listings

This commit is contained in:
Balazs Toldi 2023-09-12 08:43:56 +02:00
parent 9406f29562
commit af63bba54a
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
5 changed files with 67 additions and 9 deletions

View File

@ -15,6 +15,7 @@ import com.bumptech.glide.request.RequestOptions;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.regex.Pattern;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -186,6 +187,10 @@ public class BlockedCommunitiesRecyclerViewAdapter extends RecyclerView.Adapter<
.into(((SubredditViewHolder) viewHolder).iconGifImageView);
}
((SubredditViewHolder) viewHolder).subredditNameTextView.setText(name);
if (fullname.contains("@")) {
((SubredditViewHolder) viewHolder).communityInstanceTextView.setText("@" + fullname.split(Pattern.quote("@"), 2)[1]);
((SubredditViewHolder) viewHolder).communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(primaryTextColor, 0.7f));
}
} else if (viewHolder instanceof FavoriteSubredditViewHolder) {
int offset;
if (itemClickListener != null) {
@ -318,6 +323,9 @@ public class BlockedCommunitiesRecyclerViewAdapter extends RecyclerView.Adapter<
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
TextView subredditNameTextView;
@BindView(R.id.thing_instance_text_view_item_subscribed_thing)
TextView communityInstanceTextView;
SubredditViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);

View File

@ -141,7 +141,8 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
.into(((DataViewHolder) holder).iconGifImageView);
}
((DataViewHolder) holder).subredditNameTextView.setText(subredditData.getName());
((DataViewHolder) holder).subredditNameTextView.setText(subredditData.getTitle());
((DataViewHolder) holder).communityInstanceTextView.setText('@' + LemmyUtils.actorID2FullName(subredditData.getActorId()).split("@")[1]);
((DataViewHolder) holder).subscriberCountTextView.setText(activity.getString(R.string.subscribers_number_detail, subredditData.getNSubscribers()));
if (!isMultiSelection) {
@ -262,6 +263,9 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
GifImageView iconGifImageView;
@BindView(R.id.subreddit_name_text_view_item_subreddit_listing)
TextView subredditNameTextView;
@BindView(R.id.community_instance_text_view_item_subreddit_listing)
TextView communityInstanceTextView;
@BindView(R.id.subscriber_count_text_view_item_subreddit_listing)
TextView subscriberCountTextView;
@BindView(R.id.subscribe_image_view_item_subreddit_listing)
@ -273,6 +277,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
super(itemView);
ButterKnife.bind(this, itemView);
subredditNameTextView.setTextColor(primaryTextColor);
communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(primaryTextColor, 0.7f));
subscriberCountTextView.setTextColor(secondaryTextColor);
subscribeButton.setColorFilter(unsubscribed, android.graphics.PorterDuff.Mode.SRC_IN);
if (isMultiSelection) {

View File

@ -220,6 +220,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
.into(((SubredditViewHolder) viewHolder).iconGifImageView);
}
((SubredditViewHolder) viewHolder).subredditNameTextView.setText(name);
if (fullname.contains("@")) {
((SubredditViewHolder) viewHolder).communityInstanceTextView.setText(fullname.substring(fullname.indexOf("@")));
}
} else if (viewHolder instanceof FavoriteSubredditViewHolder) {
int offset;
if (itemClickListener != null) {
@ -233,6 +236,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
}
SubscribedSubredditData communityData = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset);
String name = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
String fullname = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getQualified_name();
String iconUrl = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
if (mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).isFavorite()) {
@ -278,6 +282,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
.into(((FavoriteSubredditViewHolder) viewHolder).iconGifImageView);
}
((FavoriteSubredditViewHolder) viewHolder).subredditNameTextView.setText(name);
if (fullname.contains("@")) {
((FavoriteSubredditViewHolder) viewHolder).communityInstanceTextView.setText(fullname.substring(fullname.indexOf("@")));
}
}
}
@ -382,6 +389,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
GifImageView iconGifImageView;
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
TextView subredditNameTextView;
@BindView(R.id.thing_instance_text_view_item_subscribed_thing)
TextView communityInstanceTextView;
@BindView(R.id.favorite_image_view_item_subscribed_thing)
ImageView favoriteImageView;
@ -390,8 +400,10 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
subredditNameTextView.setTypeface(mActivity.typeface);
communityInstanceTextView.setTypeface(mActivity.typeface);
}
subredditNameTextView.setTextColor(primaryTextColor);
communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(primaryTextColor, 0.7f));
}
}
@ -400,6 +412,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
GifImageView iconGifImageView;
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
TextView subredditNameTextView;
@BindView(R.id.thing_instance_text_view_item_subscribed_thing)
TextView communityInstanceTextView;
@BindView(R.id.favorite_image_view_item_subscribed_thing)
ImageView favoriteImageView;
@ -409,8 +424,10 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
subredditNameTextView.setTypeface(mActivity.typeface);
communityInstanceTextView.setTypeface(mActivity.typeface);
}
subredditNameTextView.setTextColor(primaryTextColor);
communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(primaryTextColor, 0.7f));
}
}

View File

@ -20,15 +20,24 @@
<TextView
android:id="@+id/subreddit_name_text_view_item_subreddit_listing"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
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/community_instance_text_view_item_subreddit_listing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
app:layout_constraintStart_toEndOf="@+id/subreddit_name_text_view_item_subreddit_listing"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/subscriber_count_text_view_item_subreddit_listing"
android:layout_width="0dp"

View File

@ -15,14 +15,33 @@
android:layout_gravity="center_vertical"
android:layout_marginEnd="32dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/thing_name_text_view_item_subscribed_thing"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="?attr/font_default"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:fontFamily="?attr/font_family"
android:layout_gravity="center_vertical" />
android:gravity="start"
android:maxLines="1"
android:textSize="?attr/font_default" />
<TextView
android:id="@+id/thing_instance_text_view_item_subscribed_thing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:fontFamily="?attr/font_family"
android:maxLines="1"
android:textSize="?attr/font_default" />
</LinearLayout>
<ImageView
android:id="@+id/favorite_image_view_item_subscribed_thing"