Compare commits

...

7 Commits

Author SHA1 Message Date
Balazs Toldi
0ea491bcfc
Fix issue with changing comment sort type on post page 2023-08-12 21:54:29 +02:00
Balazs Toldi
946d35b5d9
Show account qualified name in the navigation drawer.
Closes #24
2023-08-12 21:47:38 +02:00
Balazs Toldi
5098cb698d
Show account qualified name in the navigation drawer.
Closes #24
2023-08-12 21:25:30 +02:00
Balazs Toldi
47a06c372e
Merge remote-tracking branch 'codeberg/master' 2023-08-12 21:02:49 +02:00
Balazs Toldi
7877001533
Fix bugs related to fetching blocked users 2023-08-12 21:02:44 +02:00
Balazs Toldi
23d41846d0
Fix dialog title on blocking community page 2023-08-12 20:44:24 +02:00
Balazs Toldi
dc4dc17b6c
Block user/community on post detail view 2023-08-12 20:43:07 +02:00
10 changed files with 149 additions and 54 deletions

View File

@ -40,7 +40,10 @@ public class FetchBlockedThings {
JSONObject blockedUserJson = blockedUsersJson.getJSONObject(i).getJSONObject("target");
int id = blockedUserJson.getInt("id");
String name = blockedUserJson.getString("name");
String avatar = blockedUserJson.getString("avatar");
String avatar = "";
if (blockedUserJson.has("avatar"))
avatar = blockedUserJson.getString("avatar");
String qualifiedName = LemmyUtils.actorID2FullName(blockedUserJson.getString("actor_id"));
BlockedUserData blockedUserData = new BlockedUserData(id, name, avatar, qualifiedName, accountName);

View File

@ -807,17 +807,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
adapter = new NavigationDrawerRecyclerViewMergedAdapter(this, mSharedPreferences,
mNsfwAndSpoilerSharedPreferences, mNavigationDrawerSharedPreferences, mSecuritySharedPreferences,
mCustomThemeWrapper, mAccountName, new NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener() {
@Override
public void onMenuClick(int stringId) {
Intent intent = null;
if (stringId == R.string.profile) {
intent = new Intent(MainActivity.this, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mAccountQualifiedName);
} else if (stringId == R.string.subscriptions) {
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
} else if (stringId == R.string.multi_reddit) {
mCustomThemeWrapper, mAccountName, mAccountQualifiedName, new NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener() {
@Override
public void onMenuClick(int stringId) {
Intent intent = null;
if (stringId == R.string.profile) {
intent = new Intent(MainActivity.this, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mAccountQualifiedName);
} else if (stringId == R.string.subscriptions) {
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
} else if (stringId == R.string.multi_reddit) {
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
intent.putExtra(SubscribedThingListingActivity.EXTRA_SHOW_MULTIREDDITS, true);
} else if (stringId == R.string.history) {

View File

@ -1182,20 +1182,30 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
//startActivity(intent);
return true;
} else if (itemId == R.id.block_community_view_subreddit_detail_activity) {
BlockCommunity.INSTANCE.blockCommunity(mRetrofit.getRetrofit(), communityId, mAccessToken, new BlockCommunity.BlockCommunityListener() {
@Override
public void onBlockCommunitySuccess() {
communityData.setBlocked(true);
Toast.makeText(ViewSubredditDetailActivity.this, R.string.block_community_success, Toast.LENGTH_SHORT).show();
ViewSubredditDetailActivity.this.invalidateOptionsMenu();
sectionsPagerAdapter.refresh(false);
}
if (mAccessToken == null) {
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
return true;
}
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.block_community)
.setMessage(R.string.are_you_sure)
.setPositiveButton(R.string.yes, (dialogInterface, i)
-> BlockCommunity.INSTANCE.blockCommunity(mRetrofit.getRetrofit(), communityId, mAccessToken, new BlockCommunity.BlockCommunityListener() {
@Override
public void onBlockCommunitySuccess() {
communityData.setBlocked(true);
Toast.makeText(ViewSubredditDetailActivity.this, R.string.block_community_success, Toast.LENGTH_SHORT).show();
ViewSubredditDetailActivity.this.invalidateOptionsMenu();
sectionsPagerAdapter.refresh(false);
}
@Override
public void onBlockCommunityError() {
Toast.makeText(ViewSubredditDetailActivity.this, R.string.block_community_failed, Toast.LENGTH_SHORT).show();
}
});
@Override
public void onBlockCommunityError() {
Toast.makeText(ViewSubredditDetailActivity.this, R.string.block_community_failed, Toast.LENGTH_SHORT).show();
}
}))
.setNegativeButton(R.string.no, null)
.show();
return true;
} else if (itemId == R.id.unblock_community_view_subreddit_detail_activity) {
BlockCommunity.INSTANCE.unBlockCommunity(mRetrofit.getRetrofit(), communityId, mAccessToken, new BlockCommunity.BlockCommunityListener() {

View File

@ -1094,8 +1094,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
mUserData = userData;
username = userData.getName();
setupVisibleElements();
new ViewUserDetailActivity.InsertUserDataAsyncTask(mRedditDataRoomDatabase.userDao(), userData,
() -> mFetchUserInfoSuccess = true).execute();
FetchBlockedThings.fetchBlockedThings(mRetrofit.getRetrofit(), mAccessToken, mAccountQualifiedName, new FetchBlockedThings.FetchBlockedThingsListener() {
@Override
@ -1108,13 +1106,15 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
}
isBlocked = false;
invalidateOptionsMenu();
}
@Override
public void onFetchBlockedThingsFailure() {
}
});
new ViewUserDetailActivity.InsertUserDataAsyncTask(mRedditDataRoomDatabase.userDao(), userData,
() -> mFetchUserInfoSuccess = true).execute();
}
@Override

View File

@ -126,6 +126,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
private boolean mAlwaysShowChildCommentCount;
private boolean mHideTheNumberOfVotes;
private boolean mSeperateUpandDownvote;
private boolean mHideDownvotes;
private int mDepthThreshold;
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
private boolean isInitiallyLoading;
@ -168,6 +169,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
Post post, Locale locale, Integer singleCommentId,
boolean isSingleCommentThreadMode,
SharedPreferences sharedPreferences,
SharedPreferences currentAccountSharedPreferences,
CommentRecyclerViewAdapterCallback commentRecyclerViewAdapterCallback) {
mActivity = activity;
mFragment = fragment;
@ -239,7 +241,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mShowAuthorAvatar = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AUTHOR_AVATAR, false);
mAlwaysShowChildCommentCount = sharedPreferences.getBoolean(SharedPreferencesUtils.ALWAYS_SHOW_CHILD_COMMENT_COUNT, false);
mHideTheNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES_IN_COMMENTS, false);
mSeperateUpandDownvote = sharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_SEPARATE_UP_AND_DOWN_VOTES, true);
mHideDownvotes = !currentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true);
mSeperateUpandDownvote = sharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_SEPARATE_UP_AND_DOWN_VOTES, true) && !mHideDownvotes;
mDepthThreshold = sharedPreferences.getInt(SharedPreferencesUtils.SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD, 5);
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
@ -437,6 +440,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
((CommentViewHolder) holder).mMarkwonAdapter.setMarkdown(mCommentMarkwon, comment.getCommentMarkdown());
// noinspection NotifyDataSetChanged
((CommentViewHolder) holder).mMarkwonAdapter.notifyDataSetChanged();
if (mHideDownvotes) {
((CommentViewHolder) holder).downvoteButton.setVisibility(View.GONE);
((CommentViewHolder) holder).downvoteTextView.setVisibility(View.GONE);
}
if (!mHideTheNumberOfVotes) {
String commentText = "";
@ -448,14 +455,14 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
comment.getScore() + comment.getVoteType()));
if(mSeperateUpandDownvote){
int upvotes = (comment.getVoteType() == 1) ? comment.getUpvotes()+1 : comment.getUpvotes();
int downvotes = (comment.getVoteType() == -1) ? comment.getDownvotes()+1 : comment.getDownvotes();
if (mSeperateUpandDownvote) {
int upvotes = (comment.getVoteType() == 1) ? comment.getUpvotes() + 1 : comment.getUpvotes();
int downvotes = (comment.getVoteType() == -1) ? comment.getDownvotes() + 1 : comment.getDownvotes();
((CommentViewHolder) holder).downvoteTextView.setVisibility(View.VISIBLE);
((CommentViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
((CommentViewHolder) holder).downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
((CommentViewHolder) holder).scoreTextView.setGravity(Gravity.START);
((CommentViewHolder) holder).scoreTextView.getLayoutParams().width = (int) (32 * mActivity.getResources().getDisplayMetrics().density);
((CommentViewHolder) holder).scoreTextView.getLayoutParams().width = (int) (32 * mActivity.getResources().getDisplayMetrics().density);
((CommentViewHolder) holder).scoreTextView.setPadding(0, 0, 6, 0);
((CommentViewHolder) holder).downvoteButton.setPadding(24, 0, 12, 0);

View File

@ -176,6 +176,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private boolean mSeperateUpvoteAndDownvote;
private boolean mHideTheNumberOfComments;
private boolean mSeparatePostAndComments;
private boolean mHideDownvotes;
private boolean mLegacyAutoplayVideoControllerUI;
private boolean mEasierToWatchInFullScreen;
private PostDetailRecyclerViewAdapterCallback mPostDetailRecyclerViewAdapterCallback;
@ -344,7 +345,8 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mHideTheNumberOfAwards = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS, false);
mHideSubredditAndUserPrefix = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX, false);
mHideTheNumberOfVotes = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES, false);
mSeperateUpvoteAndDownvote = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.POST_DETAIL_SEPARATE_UP_AND_DOWN_VOTES, true);
mHideDownvotes = !currentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true);
mSeperateUpvoteAndDownvote = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.POST_DETAIL_SEPARATE_UP_AND_DOWN_VOTES, true) && !mHideDownvotes;
mHideTheNumberOfComments = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_COMMENTS, false);
mPostDetailRecyclerViewAdapterCallback = postDetailRecyclerViewAdapterCallback;

View File

@ -229,6 +229,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private boolean mHideTheNumberOfVotes;
private boolean mSeparateUpandDownVotes;
private boolean mHideDownvotes;
private boolean mHideTheNumberOfComments;
private boolean mLegacyAutoplayVideoControllerUI;
private boolean mFixedHeightPreviewInCard;
@ -311,7 +313,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mHideTheNumberOfAwards = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS, false);
mHideSubredditAndUserPrefix = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX, false);
mHideTheNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES, false);
mSeparateUpandDownVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.POST_SEPARATE_UP_AND_DOWN_VOTES, true);
mHideDownvotes = !currentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true);
mSeparateUpandDownVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.POST_SEPARATE_UP_AND_DOWN_VOTES, true) && !mHideDownvotes;
mHideTheNumberOfComments = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_COMMENTS, false);
mLegacyAutoplayVideoControllerUI = sharedPreferences.getBoolean(SharedPreferencesUtils.LEGACY_AUTOPLAY_VIDEO_CONTROLLER_UI, false);
mFixedHeightPreviewInCard = sharedPreferences.getBoolean(SharedPreferencesUtils.FIXED_HEIGHT_PREVIEW_IN_CARD, false);
@ -2423,7 +2426,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
this.shareButton = shareButton;
scoreTextView.setOnClickListener(null);
if(!mCurrentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE,true)){
if (mHideDownvotes) {
downvoteButton.setVisibility(View.GONE);
}

View File

@ -39,6 +39,7 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
private Resources resources;
private RequestManager glide;
private String accountName;
private String accountQualifiedName;
private String profileImageUrl;
private String bannerImageUrl;
private int karma;
@ -50,7 +51,7 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
private boolean hideKarma;
public HeaderSectionRecyclerViewAdapter(BaseActivity baseActivity, CustomThemeWrapper customThemeWrapper,
RequestManager glide, String accountName,
RequestManager glide, String accountName, String accountQualifiedName,
SharedPreferences sharedPreferences,
SharedPreferences navigationDrawerSharedPreferences,
SharedPreferences securitySharedPreferences,
@ -62,6 +63,7 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
this.accountName = accountName;
isLoggedIn = accountName != null;
this.pageToggle = pageToggle;
this.accountQualifiedName = accountQualifiedName;
requireAuthToAccountSection = securitySharedPreferences.getBoolean(SharedPreferencesUtils.REQUIRE_AUTHENTICATION_TO_GO_TO_ACCOUNT_SECTION_IN_NAVIGATION_DRAWER, false);
showAvatarOnTheRightInTheNavigationDrawer = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT, false);
showAvatarOnTheRightInTheNavigationDrawer = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT, false);
@ -86,15 +88,11 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
}
((NavHeaderViewHolder) holder).profileImageView.setLayoutParams(params);
if (isLoggedIn) {
if (hideKarma) {
int karmaTextHeight = ((NavHeaderViewHolder) holder).karmaTextView.getHeight();
((NavHeaderViewHolder) holder).karmaTextView.setVisibility(View.GONE);
((NavHeaderViewHolder) holder).accountNameTextView.setTranslationY(karmaTextHeight / 2);
} else {
((NavHeaderViewHolder) holder).karmaTextView.setVisibility(View.VISIBLE);
((NavHeaderViewHolder) holder).karmaTextView.setText(baseActivity.getString(R.string.karma_info, karma));
((NavHeaderViewHolder) holder).accountNameTextView.setTranslationY(0);
}
((NavHeaderViewHolder) holder).karmaTextView.setVisibility(View.VISIBLE);
((NavHeaderViewHolder) holder).karmaTextView.setText(accountQualifiedName);
((NavHeaderViewHolder) holder).accountNameTextView.setTranslationY(0);
((NavHeaderViewHolder) holder).accountNameTextView.setText(accountName);
if (profileImageUrl != null && !profileImageUrl.equals("")) {
glide.load(profileImageUrl)

View File

@ -29,12 +29,12 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
SharedPreferences navigationDrawerSharedPreferences,
SharedPreferences securitySharedPreferences,
CustomThemeWrapper customThemeWrapper,
String accountName,
String accountName, String accountQualifiedName,
ItemClickListener itemClickListener) {
RequestManager glide = Glide.with(baseActivity);
headerSectionRecyclerViewAdapter = new HeaderSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
glide, accountName, sharedPreferences, navigationDrawerSharedPreferences, securitySharedPreferences,
glide, accountName, accountQualifiedName, sharedPreferences, navigationDrawerSharedPreferences, securitySharedPreferences,
new HeaderSectionRecyclerViewAdapter.PageToggle() {
@Override
public void openAccountSection() {

View File

@ -79,7 +79,6 @@ import eu.toldi.infinityforlemmy.SortType;
import eu.toldi.infinityforlemmy.activities.CommentActivity;
import eu.toldi.infinityforlemmy.activities.EditPostActivity;
import eu.toldi.infinityforlemmy.activities.PostFilterPreferenceActivity;
import eu.toldi.infinityforlemmy.activities.ReportActivity;
import eu.toldi.infinityforlemmy.activities.SubmitCrosspostActivity;
import eu.toldi.infinityforlemmy.activities.ViewPostDetailActivity;
import eu.toldi.infinityforlemmy.adapters.CommentsRecyclerViewAdapter;
@ -87,12 +86,12 @@ import eu.toldi.infinityforlemmy.adapters.PostDetailRecyclerViewAdapter;
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
import eu.toldi.infinityforlemmy.asynctasks.LoadUserData;
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
import eu.toldi.infinityforlemmy.bottomsheetfragments.PostCommentSortTypeBottomSheetFragment;
import eu.toldi.infinityforlemmy.comment.Comment;
import eu.toldi.infinityforlemmy.comment.FetchComment;
import eu.toldi.infinityforlemmy.comment.FetchRemovedComment;
import eu.toldi.infinityforlemmy.comment.FetchRemovedCommentReveddit;
import eu.toldi.infinityforlemmy.community.BlockCommunity;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.customviews.CustomToroContainer;
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
@ -112,6 +111,9 @@ import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
import eu.toldi.infinityforlemmy.user.BlockUser;
import eu.toldi.infinityforlemmy.user.FetchUserData;
import eu.toldi.infinityforlemmy.user.UserData;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
@ -221,6 +223,10 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
boolean mRespectSubredditRecommendedSortType;
@State
long viewPostDetailFragmentId;
@State
boolean isCommunityBlocked;
private ViewPostDetailActivity activity;
private RequestManager mGlide;
private Locale mLocale;
@ -610,7 +616,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
this, mCustomThemeWrapper, mExecutor, mRetrofit.getRetrofit(),
mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId
, isSingleCommentThreadMode, mSharedPreferences,
, isSingleCommentThreadMode, mSharedPreferences, mCurrentAccountSharedPreferences,
new CommentsRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@Override
public void retryFetchingComments() {
@ -785,6 +791,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mGlide.clear(mFetchPostInfoImageView);
if (children != null) {
children.clear();
pages_loaded = 0;
mCommentsAdapter.clearLoadedComments();
}
this.sortType = sortType.getType();
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_SORT_TYPE, true)) {
@ -1071,10 +1079,74 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
} else if (itemId == R.id.action_spoiler_view_post_detail_fragment) {
return true;
} else if (itemId == R.id.action_block_user_view_post_detail_fragment) {
Toast.makeText(activity, R.string.not_implemented, Toast.LENGTH_SHORT).show();
if (mAccessToken == null) {
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
return true;
}
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.block_user)
.setMessage(R.string.are_you_sure)
.setPositiveButton(R.string.yes, (dialogInterface, i)
-> FetchUserData.fetchUserData(mRetrofit.getRetrofit(), mPost.getAuthorNamePrefixed(), new FetchUserData.FetchUserDataListener() {
@Override
public void onFetchUserDataSuccess(UserData userData, int inboxCount) {
BlockUser.blockUser(mRetrofit.getRetrofit(), mAccessToken, userData.getId(), true, new BlockUser.BlockUserListener() {
@Override
public void success() {
Toast.makeText(activity, R.string.block_user_success, Toast.LENGTH_SHORT).show();
activity.finish();
}
@Override
public void failed() {
Toast.makeText(activity, R.string.block_user_failed, Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onFetchUserDataFailed() {
Toast.makeText(activity, R.string.block_user_failed, Toast.LENGTH_SHORT).show();
}
}))
.setNegativeButton(R.string.no, null)
.show();
return true;
} else if (itemId == R.id.action_block_community_view_post_detail_fragment) {
Toast.makeText(activity, R.string.not_implemented, Toast.LENGTH_SHORT).show();
if (mAccessToken == null) {
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
return true;
}
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.block_community)
.setMessage(R.string.are_you_sure)
.setPositiveButton(R.string.yes, (dialogInterface, i)
-> FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), mPost.getSubredditNamePrefixed(), mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
@Override
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
BlockCommunity.INSTANCE.blockCommunity(mRetrofit.getRetrofit(), subredditData.getId(), mAccessToken, new BlockCommunity.BlockCommunityListener() {
@Override
public void onBlockCommunitySuccess() {
Toast.makeText(activity, R.string.block_community_success, Toast.LENGTH_SHORT).show();
activity.finish();
}
@Override
public void onBlockCommunityError() {
Toast.makeText(activity, R.string.block_community_failed, Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onFetchSubredditDataFail(boolean isQuarantined) {
Toast.makeText(activity, R.string.block_community_failed, Toast.LENGTH_SHORT).show();
}
}))
.setNegativeButton(R.string.no, null)
.show();
return true;
} else if (itemId == R.id.action_report_view_post_detail_fragment) {
if (mAccessToken == null) {
@ -1238,7 +1310,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
ViewPostDetailFragment.this, mCustomThemeWrapper, mExecutor,
mRetrofit.getRetrofit(), mAccessToken, mAccountName, mPost, mLocale,
mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences,
mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences, mCurrentAccountSharedPreferences,
new CommentsRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@Override
public void retryFetchingComments() {