mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Display both the subreddit and the user name in ViewPostDetailActivity.
This commit is contained in:
parent
453501b1ba
commit
f07f01ce63
@ -171,11 +171,11 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||
.into(((PostDetailViewHolder) holder).mSubredditIconGifImageView);
|
||||
.into(((PostDetailViewHolder) holder).mIconGifImageView);
|
||||
} else {
|
||||
mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.into(((PostDetailViewHolder) holder).mSubredditIconGifImageView);
|
||||
.into(((PostDetailViewHolder) holder).mIconGifImageView);
|
||||
}
|
||||
|
||||
if(holder.getAdapterPosition() >= 0) {
|
||||
@ -188,11 +188,11 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||
.into(((PostDetailViewHolder) holder).mSubredditIconGifImageView);
|
||||
.into(((PostDetailViewHolder) holder).mIconGifImageView);
|
||||
} else {
|
||||
mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.into(((PostDetailViewHolder) holder).mSubredditIconGifImageView);
|
||||
.into(((PostDetailViewHolder) holder).mIconGifImageView);
|
||||
}
|
||||
} else {
|
||||
if(mPost.getSubredditIconUrl() == null) {
|
||||
@ -207,11 +207,11 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||
.into(((PostDetailViewHolder) holder).mSubredditIconGifImageView);
|
||||
.into(((PostDetailViewHolder) holder).mIconGifImageView);
|
||||
} else {
|
||||
mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.into(((PostDetailViewHolder) holder).mSubredditIconGifImageView);
|
||||
.into(((PostDetailViewHolder) holder).mIconGifImageView);
|
||||
}
|
||||
|
||||
mPost.setSubredditIconUrl(iconImageUrl);
|
||||
@ -223,11 +223,11 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||
.into(((PostDetailViewHolder) holder).mSubredditIconGifImageView);
|
||||
.into(((PostDetailViewHolder) holder).mIconGifImageView);
|
||||
} else {
|
||||
mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.into(((PostDetailViewHolder) holder).mSubredditIconGifImageView);
|
||||
.into(((PostDetailViewHolder) holder).mIconGifImageView);
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,6 +260,7 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
}
|
||||
|
||||
((PostDetailViewHolder) holder).mSubredditTextView.setText(mPost.getSubredditNamePrefixed());
|
||||
((PostDetailViewHolder) holder).mUserTextView.setText(mPost.getAuthorNamePrefixed());
|
||||
|
||||
((PostDetailViewHolder) holder).mPostTimeTextView.setText(mPost.getPostTime());
|
||||
|
||||
@ -643,9 +644,9 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
}
|
||||
|
||||
class PostDetailViewHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.subreddit_icon_name_linear_layout_item_post_detail) LinearLayout mSubredditIconNameLinearLayout;
|
||||
@BindView(R.id.subreddit_icon_gif_image_view_item_post_detail) AspectRatioGifImageView mSubredditIconGifImageView;
|
||||
@BindView(R.id.icon_gif_image_view_item_post_detail) AspectRatioGifImageView mIconGifImageView;
|
||||
@BindView(R.id.subreddit_text_view_item_post_detail) TextView mSubredditTextView;
|
||||
@BindView(R.id.user_text_view_item_post_detail) TextView mUserTextView;
|
||||
@BindView(R.id.post_time_text_view_item_post_detail) TextView mPostTimeTextView;
|
||||
@BindView(R.id.title_text_view_item_post_detail) TextView mTitleTextView;
|
||||
@BindView(R.id.content_markdown_view_item_post_detail) CustomMarkwonView mContentMarkdownView;
|
||||
@ -673,7 +674,9 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
|
||||
mSubredditIconNameLinearLayout.setOnClickListener(view -> {
|
||||
mIconGifImageView.setOnClickListener(view -> mSubredditTextView.performClick());
|
||||
|
||||
mSubredditTextView.setOnClickListener(view -> {
|
||||
Intent intent;
|
||||
if(mPost.getSubredditNamePrefixed().equals("u/" + mPost.getAuthor())) {
|
||||
intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||
@ -686,6 +689,12 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
|
||||
mUserTextView.setOnClickListener(view -> {
|
||||
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mPost.getAuthor());
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
|
||||
mShareButton.setOnClickListener(view -> {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.setType("text/plain");
|
||||
|
@ -20,6 +20,7 @@ class Post implements Parcelable {
|
||||
private String subredditNamePrefixed;
|
||||
private String subredditIconUrl;
|
||||
private String author;
|
||||
private String authorNamePrefixed;
|
||||
private String authorIconUrl;
|
||||
private String postTime;
|
||||
private String title;
|
||||
@ -51,6 +52,7 @@ class Post implements Parcelable {
|
||||
this.fullName = fullName;
|
||||
this.subredditNamePrefixed = subredditNamePrefixed;
|
||||
this.author = author;
|
||||
this.authorNamePrefixed = "u/" + author;
|
||||
this.postTime = postTime;
|
||||
this.title = title;
|
||||
this.previewUrl = previewUrl;
|
||||
@ -75,6 +77,7 @@ class Post implements Parcelable {
|
||||
this.fullName = fullName;
|
||||
this.subredditNamePrefixed = subredditNamePrefixed;
|
||||
this.author = author;
|
||||
this.authorNamePrefixed = "u/" + author;
|
||||
this.postTime = postTime;
|
||||
this.title = title;
|
||||
this.previewUrl = previewUrl;
|
||||
@ -98,6 +101,7 @@ class Post implements Parcelable {
|
||||
this.fullName = fullName;
|
||||
this.subredditNamePrefixed = subredditNamePrefixed;
|
||||
this.author = author;
|
||||
this.authorNamePrefixed = "u/" + author;
|
||||
this.postTime = postTime;
|
||||
this.title = title;
|
||||
this.permalink = RedditUtils.API_BASE_URI + permalink;
|
||||
@ -118,6 +122,7 @@ class Post implements Parcelable {
|
||||
subredditNamePrefixed = in.readString();
|
||||
subredditIconUrl = in.readString();
|
||||
author = in.readString();
|
||||
authorNamePrefixed = in.readString();
|
||||
authorIconUrl = in.readString();
|
||||
postTime = in.readString();
|
||||
title = in.readString();
|
||||
@ -178,6 +183,10 @@ class Post implements Parcelable {
|
||||
return author;
|
||||
}
|
||||
|
||||
String getAuthorNamePrefixed() {
|
||||
return authorNamePrefixed;
|
||||
}
|
||||
|
||||
String getAuthorIconUrl() {
|
||||
return authorIconUrl;
|
||||
}
|
||||
@ -318,6 +327,7 @@ class Post implements Parcelable {
|
||||
parcel.writeString(subredditNamePrefixed);
|
||||
parcel.writeString(subredditIconUrl);
|
||||
parcel.writeString(author);
|
||||
parcel.writeString(authorNamePrefixed);
|
||||
parcel.writeString(authorIconUrl);
|
||||
parcel.writeString(postTime);
|
||||
parcel.writeString(title);
|
||||
|
@ -179,7 +179,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
String query = getArguments().getString(EXTRA_QUERY);
|
||||
|
||||
mAdapter = new PostRecyclerViewAdapter(activity, mRetrofit,
|
||||
mSharedPreferences, postType, () -> mPostViewModel.retryLoadingMore());
|
||||
mSharedPreferences, postType, true, () -> mPostViewModel.retryLoadingMore());
|
||||
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||
getResources().getConfiguration().locale, subredditName, query, postType, sortType, new PostDataSource.OnPostFetchedCallback() {
|
||||
@Override
|
||||
@ -198,8 +198,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
} else if(postType == PostDataSource.TYPE_SUBREDDIT) {
|
||||
String subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME);
|
||||
|
||||
boolean displaySubredditName = subredditName.equals("popular");
|
||||
mAdapter = new PostRecyclerViewAdapter(activity, mRetrofit,
|
||||
mSharedPreferences, postType, () -> mPostViewModel.retryLoadingMore());
|
||||
mSharedPreferences, postType, displaySubredditName, () -> mPostViewModel.retryLoadingMore());
|
||||
|
||||
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||
getResources().getConfiguration().locale, subredditName, postType, sortType, new PostDataSource.OnPostFetchedCallback() {
|
||||
@ -224,7 +225,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
String subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME);
|
||||
|
||||
mAdapter = new PostRecyclerViewAdapter(activity, mRetrofit,
|
||||
mSharedPreferences, postType, () -> mPostViewModel.retryLoadingMore());
|
||||
mSharedPreferences, postType, true, () -> mPostViewModel.retryLoadingMore());
|
||||
|
||||
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||
getResources().getConfiguration().locale, subredditName, postType, sortType,
|
||||
@ -244,7 +245,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
});
|
||||
} else {
|
||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit,
|
||||
mSharedPreferences, postType, () -> mPostViewModel.retryLoadingMore());
|
||||
mSharedPreferences, postType, true, () -> mPostViewModel.retryLoadingMore());
|
||||
|
||||
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||
getResources().getConfiguration().locale, postType, sortType, new PostDataSource.OnPostFetchedCallback() {
|
||||
|
@ -65,6 +65,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
|
||||
private UserDao userDao;
|
||||
private boolean canStartActivity = true;
|
||||
private int postType;
|
||||
private boolean displaySubredditName;
|
||||
|
||||
private static final int VIEW_TYPE_DATA = 0;
|
||||
private static final int VIEW_TYPE_ERROR = 1;
|
||||
@ -78,13 +79,14 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
|
||||
}
|
||||
|
||||
PostRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, SharedPreferences sharedPreferences, int postType,
|
||||
RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
||||
boolean displaySubredditName, RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
||||
super(DIFF_CALLBACK);
|
||||
if(context != null) {
|
||||
mContext = context;
|
||||
mOauthRetrofit = oauthRetrofit;
|
||||
mSharedPreferences = sharedPreferences;
|
||||
this.postType = postType;
|
||||
this.displaySubredditName = displaySubredditName;
|
||||
glide = Glide.with(mContext.getApplicationContext());
|
||||
subredditDao = SubredditRoomDatabase.getDatabase(mContext.getApplicationContext()).subredditDao();
|
||||
userDao = UserRoomDatabase.getDatabase(mContext.getApplicationContext()).userDao();
|
||||
@ -154,7 +156,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
|
||||
}
|
||||
});
|
||||
|
||||
if(postType != PostDataSource.TYPE_SUBREDDIT) {
|
||||
if(displaySubredditName) {
|
||||
if(author.equals(subredditNamePrefixed)) {
|
||||
if(post.getAuthorIconUrl() == null) {
|
||||
new LoadUserDataAsyncTask(userDao, post.getAuthor(), mOauthRetrofit, iconImageUrl -> {
|
||||
|
@ -14,8 +14,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/subreddit_icon_name_linear_layout_item_post_detail"
|
||||
<RelativeLayout
|
||||
android:id="@+id/subreddit_icon_name_relative_layout_item_post_detail"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
@ -26,20 +26,31 @@
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<CustomView.AspectRatioGifImageView
|
||||
android:id="@+id/subreddit_icon_gif_image_view_item_post_detail"
|
||||
android:id="@+id/icon_gif_image_view_item_post_detail"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"/>
|
||||
android:layout_centerVertical="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subreddit_text_view_item_post_detail"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_gravity="center"
|
||||
android:textColor="#E91E63" />
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toEndOf="@id/icon_gif_image_view_item_post_detail"
|
||||
android:textColor="@color/colorAccent" />
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/user_text_view_item_post_detail"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_below="@id/subreddit_text_view_item_post_detail"
|
||||
android:layout_toEndOf="@id/icon_gif_image_view_item_post_detail"
|
||||
android:textColor="@color/textColorPrimaryDark" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/post_time_text_view_item_post_detail"
|
||||
@ -48,7 +59,7 @@
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/subreddit_icon_name_linear_layout_item_post_detail"
|
||||
app:layout_constraintStart_toEndOf="@id/subreddit_icon_name_relative_layout_item_post_detail"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user