aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-09-01 06:32:24 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-09-01 06:32:24 +0000
commitc9c4b7fc58622743d452a4e0c4f0da6633096575 (patch)
tree3d07e7cc0070472b4131529ad6a4828d9a004bb8 /app
parentb34fcf1c6d44950c0c714cdfdab65b760744f890 (diff)
downloadinfinity-for-reddit-c9c4b7fc58622743d452a4e0c4f0da6633096575.tar
infinity-for-reddit-c9c4b7fc58622743d452a4e0c4f0da6633096575.tar.gz
infinity-for-reddit-c9c4b7fc58622743d452a4e0c4f0da6633096575.tar.bz2
infinity-for-reddit-c9c4b7fc58622743d452a4e0c4f0da6633096575.tar.lz
infinity-for-reddit-c9c4b7fc58622743d452a4e0c4f0da6633096575.tar.xz
infinity-for-reddit-c9c4b7fc58622743d452a4e0c4f0da6633096575.tar.zst
infinity-for-reddit-c9c4b7fc58622743d452a4e0c4f0da6633096575.zip
Minor bugs fixed related to marking and unmarking spoiler and nsfw.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java64
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java2
6 files changed, 81 insertions, 13 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
index 17314525..753c7259 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
@@ -980,6 +980,10 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
} else if(holder instanceof PostDetailViewHolder) {
((PostDetailViewHolder) holder).mUpvoteButton.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);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
index 57b94e00..05061989 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
@@ -819,7 +819,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
private PostFragment allPostFragment;
SectionsPagerAdapter(FragmentManager fm) {
- super(fm);
+ super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
}
@NonNull
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java
index b5996f54..e1cf8f22 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java
@@ -195,8 +195,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
ArrayList<Post> singlePostList = new ArrayList<>();
singlePostList.add(post);
hasPostLiveData.postValue(true);
- callback.onResult(singlePostList, null, null);
initialLoadStateLiveData.postValue(NetworkState.LOADED);
+ callback.onResult(singlePostList, null, null);
}
@Override
@@ -226,8 +226,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
hasPostLiveData.postValue(false);
}
- callback.onResult(newPosts, null, nextPageKey);
initialLoadStateLiveData.postValue(NetworkState.LOADED);
+ callback.onResult(newPosts, null, nextPageKey);
}
@Override
@@ -268,8 +268,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
if(newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
loadBestPostsAfter(params, callback, lastItem);
} else {
- callback.onResult(newPosts, lastItem);
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
+ callback.onResult(newPosts, lastItem);
}
}
@@ -313,8 +313,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
ArrayList<Post> singlePostList = new ArrayList<>();
singlePostList.add(post);
hasPostLiveData.postValue(true);
- callback.onResult(singlePostList, null, null);
initialLoadStateLiveData.postValue(NetworkState.LOADED);
+ callback.onResult(singlePostList, null, null);
}
@Override
@@ -344,8 +344,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
hasPostLiveData.postValue(false);
}
- callback.onResult(newPosts, null, nextPageKey);
initialLoadStateLiveData.postValue(NetworkState.LOADED);
+ callback.onResult(newPosts, null, nextPageKey);
}
@Override
@@ -392,8 +392,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
if(newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
loadSubredditPostsAfter(params, callback, lastItem);
} else {
- callback.onResult(newPosts, lastItem);
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
+ callback.onResult(newPosts, lastItem);
}
}
@@ -451,8 +451,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
hasPostLiveData.postValue(false);
}
- callback.onResult(newPosts, null, nextPageKey);
initialLoadStateLiveData.postValue(NetworkState.LOADED);
+ callback.onResult(newPosts, null, nextPageKey);
}
@Override
@@ -498,8 +498,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
if(newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
loadUserPostsAfter(params, callback, lastItem);
} else {
- callback.onResult(newPosts, lastItem);
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
+ callback.onResult(newPosts, lastItem);
}
}
@@ -566,8 +566,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
hasPostLiveData.postValue(false);
}
- callback.onResult(newPosts, null, nextPageKey);
initialLoadStateLiveData.postValue(NetworkState.LOADED);
+ callback.onResult(newPosts, null, nextPageKey);
}
@Override
@@ -622,8 +622,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
if(newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
loadSearchPostsAfter(params, callback, lastItem);
} else {
- callback.onResult(newPosts, lastItem);
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
+ callback.onResult(newPosts, lastItem);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java
index ed78ac0a..9a6652c5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java
@@ -271,7 +271,7 @@ public class SearchResultActivity extends AppCompatActivity implements SearchPos
private UserListingFragment userListingFragment;
public SectionsPagerAdapter(FragmentManager fm) {
- super(fm);
+ super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
}
@NonNull
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
index fc2cab68..06487bcb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
@@ -673,6 +673,10 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
}
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<>();
params.put(RedditUtils.ID_KEY, mPost.getFullName());
mOauthRetrofit.create(RedditAPI.class).markNSFW(RedditUtils.getOAuthHeader(mAccessToken), params)
@@ -680,21 +684,37 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
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);
showMessage(R.string.mark_nsfw_success);
} 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);
}
}
@Override
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);
}
});
}
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<>();
params.put(RedditUtils.ID_KEY, mPost.getFullName());
mOauthRetrofit.create(RedditAPI.class).unmarkNSFW(RedditUtils.getOAuthHeader(mAccessToken), params)
@@ -702,21 +722,37 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
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);
showMessage(R.string.unmark_nsfw_success);
} 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);
}
}
@Override
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);
}
});
}
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<>();
params.put(RedditUtils.ID_KEY, mPost.getFullName());
mOauthRetrofit.create(RedditAPI.class).markSpoiler(RedditUtils.getOAuthHeader(mAccessToken), params)
@@ -724,21 +760,37 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
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);
showMessage(R.string.mark_spoiler_success);
} 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);
}
}
@Override
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);
}
});
}
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<>();
params.put(RedditUtils.ID_KEY, mPost.getFullName());
mOauthRetrofit.create(RedditAPI.class).unmarkSpoiler(RedditUtils.getOAuthHeader(mAccessToken), params)
@@ -746,15 +798,27 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
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);
showMessage(R.string.unmark_spoiler_success);
} 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);
}
}
@Override
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);
}
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java
index f062585f..e929a101 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java
@@ -645,7 +645,7 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
private CommentsListingFragment commentsListingFragment;
SectionsPagerAdapter(FragmentManager fm) {
- super(fm);
+ super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
}
@NonNull