mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-24 00:44:43 +01:00
Minor bugs fixed related to marking and unmarking spoiler and nsfw.
This commit is contained in:
parent
b34fcf1c6d
commit
c9c4b7fc58
@ -980,6 +980,10 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||||||
} else if(holder instanceof PostDetailViewHolder) {
|
} else if(holder instanceof PostDetailViewHolder) {
|
||||||
((PostDetailViewHolder) holder).mUpvoteButton.clearColorFilter();
|
((PostDetailViewHolder) holder).mUpvoteButton.clearColorFilter();
|
||||||
((PostDetailViewHolder) holder).mDownvoteButton.clearColorFilter();
|
((PostDetailViewHolder) holder).mDownvoteButton.clearColorFilter();
|
||||||
|
((PostDetailViewHolder) holder).spoilerFlairlinearLayout.setVisibility(View.GONE);
|
||||||
|
((PostDetailViewHolder) holder).flairTextView.setVisibility(View.GONE);
|
||||||
|
((PostDetailViewHolder) holder).spoilerTextView.setVisibility(View.GONE);
|
||||||
|
((PostDetailViewHolder) holder).mNSFWChip.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -819,7 +819,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
private PostFragment allPostFragment;
|
private PostFragment allPostFragment;
|
||||||
|
|
||||||
SectionsPagerAdapter(FragmentManager fm) {
|
SectionsPagerAdapter(FragmentManager fm) {
|
||||||
super(fm);
|
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -195,8 +195,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
ArrayList<Post> singlePostList = new ArrayList<>();
|
ArrayList<Post> singlePostList = new ArrayList<>();
|
||||||
singlePostList.add(post);
|
singlePostList.add(post);
|
||||||
hasPostLiveData.postValue(true);
|
hasPostLiveData.postValue(true);
|
||||||
callback.onResult(singlePostList, null, null);
|
|
||||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||||
|
callback.onResult(singlePostList, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -226,8 +226,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
hasPostLiveData.postValue(false);
|
hasPostLiveData.postValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.onResult(newPosts, null, nextPageKey);
|
|
||||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||||
|
callback.onResult(newPosts, null, nextPageKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -268,8 +268,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
if(newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
|
if(newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
|
||||||
loadBestPostsAfter(params, callback, lastItem);
|
loadBestPostsAfter(params, callback, lastItem);
|
||||||
} else {
|
} else {
|
||||||
callback.onResult(newPosts, lastItem);
|
|
||||||
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
|
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
|
||||||
|
callback.onResult(newPosts, lastItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,8 +313,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
ArrayList<Post> singlePostList = new ArrayList<>();
|
ArrayList<Post> singlePostList = new ArrayList<>();
|
||||||
singlePostList.add(post);
|
singlePostList.add(post);
|
||||||
hasPostLiveData.postValue(true);
|
hasPostLiveData.postValue(true);
|
||||||
callback.onResult(singlePostList, null, null);
|
|
||||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||||
|
callback.onResult(singlePostList, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -344,8 +344,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
hasPostLiveData.postValue(false);
|
hasPostLiveData.postValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.onResult(newPosts, null, nextPageKey);
|
|
||||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||||
|
callback.onResult(newPosts, null, nextPageKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -392,8 +392,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
if(newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
|
if(newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
|
||||||
loadSubredditPostsAfter(params, callback, lastItem);
|
loadSubredditPostsAfter(params, callback, lastItem);
|
||||||
} else {
|
} else {
|
||||||
callback.onResult(newPosts, lastItem);
|
|
||||||
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
|
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
|
||||||
|
callback.onResult(newPosts, lastItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,8 +451,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
hasPostLiveData.postValue(false);
|
hasPostLiveData.postValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.onResult(newPosts, null, nextPageKey);
|
|
||||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||||
|
callback.onResult(newPosts, null, nextPageKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -498,8 +498,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
if(newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
|
if(newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
|
||||||
loadUserPostsAfter(params, callback, lastItem);
|
loadUserPostsAfter(params, callback, lastItem);
|
||||||
} else {
|
} else {
|
||||||
callback.onResult(newPosts, lastItem);
|
|
||||||
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
|
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
|
||||||
|
callback.onResult(newPosts, lastItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,8 +566,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
hasPostLiveData.postValue(false);
|
hasPostLiveData.postValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.onResult(newPosts, null, nextPageKey);
|
|
||||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||||
|
callback.onResult(newPosts, null, nextPageKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -622,8 +622,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
if(newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
|
if(newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
|
||||||
loadSearchPostsAfter(params, callback, lastItem);
|
loadSearchPostsAfter(params, callback, lastItem);
|
||||||
} else {
|
} else {
|
||||||
callback.onResult(newPosts, lastItem);
|
|
||||||
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
|
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
|
||||||
|
callback.onResult(newPosts, lastItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ public class SearchResultActivity extends AppCompatActivity implements SearchPos
|
|||||||
private UserListingFragment userListingFragment;
|
private UserListingFragment userListingFragment;
|
||||||
|
|
||||||
public SectionsPagerAdapter(FragmentManager fm) {
|
public SectionsPagerAdapter(FragmentManager fm) {
|
||||||
super(fm);
|
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -673,6 +673,10 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void markNSFW() {
|
private void markNSFW() {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_nsfw_view_post_detail_activity).setTitle(R.string.action_unmark_nsfw);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ID_KEY, mPost.getFullName());
|
params.put(RedditUtils.ID_KEY, mPost.getFullName());
|
||||||
mOauthRetrofit.create(RedditAPI.class).markNSFW(RedditUtils.getOAuthHeader(mAccessToken), params)
|
mOauthRetrofit.create(RedditAPI.class).markNSFW(RedditUtils.getOAuthHeader(mAccessToken), params)
|
||||||
@ -680,21 +684,37 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_nsfw_view_post_detail_activity).setTitle(R.string.action_unmark_nsfw);
|
||||||
|
}
|
||||||
|
|
||||||
refresh(true, false);
|
refresh(true, false);
|
||||||
showMessage(R.string.mark_nsfw_success);
|
showMessage(R.string.mark_nsfw_success);
|
||||||
} else {
|
} else {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_nsfw_view_post_detail_activity).setTitle(R.string.action_mark_nsfw);
|
||||||
|
}
|
||||||
|
|
||||||
showMessage(R.string.mark_nsfw_failed);
|
showMessage(R.string.mark_nsfw_failed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_nsfw_view_post_detail_activity).setTitle(R.string.action_mark_nsfw);
|
||||||
|
}
|
||||||
|
|
||||||
showMessage(R.string.mark_nsfw_failed);
|
showMessage(R.string.mark_nsfw_failed);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unmarkNSFW() {
|
private void unmarkNSFW() {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_nsfw_view_post_detail_activity).setTitle(R.string.action_mark_nsfw);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ID_KEY, mPost.getFullName());
|
params.put(RedditUtils.ID_KEY, mPost.getFullName());
|
||||||
mOauthRetrofit.create(RedditAPI.class).unmarkNSFW(RedditUtils.getOAuthHeader(mAccessToken), params)
|
mOauthRetrofit.create(RedditAPI.class).unmarkNSFW(RedditUtils.getOAuthHeader(mAccessToken), params)
|
||||||
@ -702,21 +722,37 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_nsfw_view_post_detail_activity).setTitle(R.string.action_mark_nsfw);
|
||||||
|
}
|
||||||
|
|
||||||
refresh(true, false);
|
refresh(true, false);
|
||||||
showMessage(R.string.unmark_nsfw_success);
|
showMessage(R.string.unmark_nsfw_success);
|
||||||
} else {
|
} else {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_nsfw_view_post_detail_activity).setTitle(R.string.action_unmark_nsfw);
|
||||||
|
}
|
||||||
|
|
||||||
showMessage(R.string.unmark_nsfw_failed);
|
showMessage(R.string.unmark_nsfw_failed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_nsfw_view_post_detail_activity).setTitle(R.string.action_unmark_nsfw);
|
||||||
|
}
|
||||||
|
|
||||||
showMessage(R.string.unmark_nsfw_failed);
|
showMessage(R.string.unmark_nsfw_failed);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void markSpoiler() {
|
private void markSpoiler() {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_spoiler_view_post_detail_activity).setTitle(R.string.action_unmark_spoiler);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ID_KEY, mPost.getFullName());
|
params.put(RedditUtils.ID_KEY, mPost.getFullName());
|
||||||
mOauthRetrofit.create(RedditAPI.class).markSpoiler(RedditUtils.getOAuthHeader(mAccessToken), params)
|
mOauthRetrofit.create(RedditAPI.class).markSpoiler(RedditUtils.getOAuthHeader(mAccessToken), params)
|
||||||
@ -724,21 +760,37 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_spoiler_view_post_detail_activity).setTitle(R.string.action_unmark_spoiler);
|
||||||
|
}
|
||||||
|
|
||||||
refresh(true, false);
|
refresh(true, false);
|
||||||
showMessage(R.string.mark_spoiler_success);
|
showMessage(R.string.mark_spoiler_success);
|
||||||
} else {
|
} else {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_spoiler_view_post_detail_activity).setTitle(R.string.action_mark_spoiler);
|
||||||
|
}
|
||||||
|
|
||||||
showMessage(R.string.mark_spoiler_failed);
|
showMessage(R.string.mark_spoiler_failed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_spoiler_view_post_detail_activity).setTitle(R.string.action_mark_spoiler);
|
||||||
|
}
|
||||||
|
|
||||||
showMessage(R.string.mark_spoiler_failed);
|
showMessage(R.string.mark_spoiler_failed);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unmarkSpoiler() {
|
private void unmarkSpoiler() {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_spoiler_view_post_detail_activity).setTitle(R.string.action_mark_spoiler);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ID_KEY, mPost.getFullName());
|
params.put(RedditUtils.ID_KEY, mPost.getFullName());
|
||||||
mOauthRetrofit.create(RedditAPI.class).unmarkSpoiler(RedditUtils.getOAuthHeader(mAccessToken), params)
|
mOauthRetrofit.create(RedditAPI.class).unmarkSpoiler(RedditUtils.getOAuthHeader(mAccessToken), params)
|
||||||
@ -746,15 +798,27 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_spoiler_view_post_detail_activity).setTitle(R.string.action_mark_spoiler);
|
||||||
|
}
|
||||||
|
|
||||||
refresh(true, false);
|
refresh(true, false);
|
||||||
showMessage(R.string.unmark_spoiler_success);
|
showMessage(R.string.unmark_spoiler_success);
|
||||||
} else {
|
} else {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_spoiler_view_post_detail_activity).setTitle(R.string.action_unmark_spoiler);
|
||||||
|
}
|
||||||
|
|
||||||
showMessage(R.string.unmark_spoiler_failed);
|
showMessage(R.string.unmark_spoiler_failed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||||
|
if(mMenu != null) {
|
||||||
|
mMenu.findItem(R.id.action_spoiler_view_post_detail_activity).setTitle(R.string.action_unmark_spoiler);
|
||||||
|
}
|
||||||
|
|
||||||
showMessage(R.string.unmark_spoiler_failed);
|
showMessage(R.string.unmark_spoiler_failed);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -645,7 +645,7 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
|
|||||||
private CommentsListingFragment commentsListingFragment;
|
private CommentsListingFragment commentsListingFragment;
|
||||||
|
|
||||||
SectionsPagerAdapter(FragmentManager fm) {
|
SectionsPagerAdapter(FragmentManager fm) {
|
||||||
super(fm);
|
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
Loading…
x
Reference in New Issue
Block a user