diff options
Diffstat (limited to 'app/src/main/java')
7 files changed, 217 insertions, 39 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/HidePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/HidePost.java new file mode 100644 index 00000000..ec6770d2 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/HidePost.java @@ -0,0 +1,60 @@ +package ml.docilealligator.infinityforreddit; + +import androidx.annotation.NonNull; + +import java.util.HashMap; +import java.util.Map; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; +import retrofit2.Retrofit; + +class HidePost { + interface HidePostListener { + void success(); + void failed(); + } + + static void hidePost(Retrofit oauthRetrofit, String accessToken, String fullname, + HidePostListener hidePostListener) { + Map<String, String> params = new HashMap<>(); + params.put(RedditUtils.ID_KEY, fullname); + oauthRetrofit.create(RedditAPI.class).hide(RedditUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() { + @Override + public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { + if(response.isSuccessful()) { + hidePostListener.success(); + } else { + hidePostListener.failed(); + } + } + + @Override + public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) { + hidePostListener.failed(); + } + }); + } + + static void unhidePost(Retrofit oauthRetrofit, String accessToken, String fullname, + HidePostListener hidePostListener) { + Map<String, String> params = new HashMap<>(); + params.put(RedditUtils.ID_KEY, fullname); + oauthRetrofit.create(RedditAPI.class).unhide(RedditUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() { + @Override + public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { + if(response.isSuccessful()) { + hidePostListener.success(); + } else { + hidePostListener.failed(); + } + } + + @Override + public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) { + hidePostListener.failed(); + } + }); + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java index 91d67096..4346ccbe 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java @@ -84,4 +84,5 @@ public class JSONUtils { static final String WAS_COMMENT_KEY = "was_comment"; static final String NEW_KEY = "new"; static final String NUM_COMMENTS_KEY = "num_comments"; + static final String HIDDEN_KEY = "hidden"; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java index 1cae9ee3..efe58ff0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java @@ -163,6 +163,7 @@ class ParsePost { int score = data.getInt(JSONUtils.SCORE_KEY); int voteType; int gilded = data.getInt(JSONUtils.GILDED_KEY); + boolean hidden = data.getBoolean(JSONUtils.HIDDEN_KEY); boolean spoiler = data.getBoolean(JSONUtils.SPOILER_KEY); boolean nsfw = data.getBoolean(JSONUtils.NSFW_KEY); boolean stickied = data.getBoolean(JSONUtils.STICKIED_KEY); @@ -204,15 +205,15 @@ class ParsePost { Post crosspostParent = parseBasicData(data, locale); Post post = parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, title, previewUrl, previewWidth, previewHeight, - score, voteType, gilded, flair, spoiler, nsfw, stickied, archived, locked, saved, - true); + score, voteType, gilded, flair, hidden, spoiler, nsfw, stickied, archived, locked, + saved, true); post.setCrosspostParentId(crosspostParent.getId()); return post; } else { return parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, title, previewUrl, previewWidth, previewHeight, - score, voteType, gilded, flair, spoiler, nsfw, stickied, archived, locked, saved, - false); + score, voteType, gilded, flair, hidden, spoiler, nsfw, stickied, archived, locked, + saved, false); } } @@ -220,8 +221,8 @@ class ParsePost { String subredditName, String subredditNamePrefixed, String author, String formattedPostTime, String title, String previewUrl, int previewWidth, int previewHeight, int score, int voteType, int gilded, String flair, - boolean spoiler, boolean nsfw, boolean stickied, boolean archived, - boolean locked, boolean saved, boolean isCrosspost) throws JSONException { + boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, + boolean archived, boolean locked, boolean saved, boolean isCrosspost) throws JSONException { Post post; boolean isVideo = data.getBoolean(JSONUtils.IS_VIDEO_KEY); @@ -232,7 +233,7 @@ class ParsePost { //Text post int postType = Post.TEXT_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, - title, permalink, score, postType, voteType, gilded, flair, spoiler, nsfw, + title, permalink, score, postType, voteType, gilded, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); if(data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); @@ -243,8 +244,8 @@ class ParsePost { //No preview link post int postType = Post.NO_PREVIEW_LINK_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, - title, previewUrl, url, permalink, score, postType, - voteType, gilded, flair, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); + title, previewUrl, url, permalink, score, postType, voteType, gilded, flair, + hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); if(data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); } else { @@ -264,8 +265,8 @@ class ParsePost { String videoUrl = Html.fromHtml(redditVideoObject.getString(JSONUtils.DASH_URL_KEY)).toString(); post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, - title, previewUrl, permalink, score, postType, voteType, - gilded, flair, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, true); + title, previewUrl, permalink, score, postType, voteType, gilded, flair, hidden, + spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, true); post.setPreviewWidth(previewWidth); post.setPreviewHeight(previewHeight); @@ -279,9 +280,10 @@ class ParsePost { String videoUrl = Html.fromHtml(variations.getJSONObject(JSONUtils.VARIANTS_KEY).getJSONObject(JSONUtils.MP4_KEY).getJSONObject(JSONUtils.SOURCE_KEY).getString(JSONUtils.URL_KEY)).toString(); String gifDownloadUrl = Html.fromHtml(variations.getJSONObject(JSONUtils.VARIANTS_KEY).getJSONObject(JSONUtils.GIF_KEY).getJSONObject(JSONUtils.SOURCE_KEY).getString(JSONUtils.URL_KEY)).toString(); - post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, title, - previewUrl, permalink, score, postType, voteType, - gilded, flair, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, false); + post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, + formattedPostTime, title, previewUrl, permalink, score, postType, voteType, + gilded, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, + isCrosspost, false); post.setPreviewWidth(previewWidth); post.setPreviewHeight(previewHeight); post.setVideoUrl(videoUrl); @@ -293,9 +295,10 @@ class ParsePost { String videoUrl = Html.fromHtml(data.getJSONObject(JSONUtils.PREVIEW_KEY) .getJSONObject(JSONUtils.REDDIT_VIDEO_PREVIEW_KEY).getString(JSONUtils.DASH_URL_KEY)).toString(); - post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, title, - previewUrl, permalink, score, postType, voteType, - gilded, flair, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, true); + post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, + formattedPostTime, title, previewUrl, permalink, score, postType, voteType, + gilded, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, + isCrosspost, true); post.setPreviewWidth(previewWidth); post.setPreviewHeight(previewHeight); post.setVideoUrl(videoUrl); @@ -305,9 +308,10 @@ class ParsePost { //Image post int postType = Post.IMAGE_TYPE; - post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, - title, url, url, permalink, score, postType, - voteType, gilded, flair, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); + post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, + formattedPostTime, title, url, url, permalink, score, postType, + voteType, gilded, flair, hidden, spoiler, nsfw, stickied, archived, + locked, saved, isCrosspost); post.setPreviewWidth(previewWidth); post.setPreviewHeight(previewHeight); @@ -316,9 +320,10 @@ class ParsePost { //Text post but with a preview int postType = Post.TEXT_TYPE; - post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, - title, permalink, score, postType, voteType, gilded, flair, spoiler, - nsfw, stickied, archived, locked, saved, isCrosspost); + post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, + formattedPostTime, title, permalink, score, postType, voteType, + gilded, flair, hidden, spoiler, nsfw, stickied, archived, locked, + saved, isCrosspost); post.setPreviewWidth(previewWidth); post.setPreviewHeight(previewHeight); @@ -332,9 +337,10 @@ class ParsePost { //Link post int postType = Post.LINK_TYPE; - post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, - title, previewUrl, url, permalink, score, postType, voteType, gilded, - flair, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); + post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, + formattedPostTime, title, previewUrl, url, permalink, score, postType, + voteType, gilded, flair, hidden, spoiler, nsfw, stickied, archived, + locked, saved, isCrosspost); if(data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); } else { @@ -351,18 +357,20 @@ class ParsePost { //Image post int postType = Post.IMAGE_TYPE; - post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, - title, previewUrl, url, permalink, score, postType, - voteType, gilded, flair, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); + post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, + formattedPostTime, title, previewUrl, url, permalink, score, postType, + voteType, gilded, flair, hidden, spoiler, nsfw, stickied, archived, + locked, saved, isCrosspost); post.setPreviewWidth(previewWidth); post.setPreviewHeight(previewHeight); } else { //CP No Preview Link post int postType = Post.NO_PREVIEW_LINK_TYPE; - post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, title, - url, url, permalink, score, postType, voteType, - gilded, flair, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); + post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, + formattedPostTime, title, url, url, permalink, score, postType, voteType, + gilded, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, + isCrosspost); } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java index 9a5371c2..8d9fd436 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java @@ -39,6 +39,7 @@ class Post implements Parcelable { private int gilded; private int previewWidth; private int previewHeight; + private boolean hidden; private boolean spoiler; private boolean nsfw; private boolean stickied; @@ -52,8 +53,9 @@ class Post implements Parcelable { Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author, String postTime, String title, String previewUrl, String permalink, int score, int postType, - int voteType, int gilded, String flair, boolean spoiler, boolean nsfw, boolean stickied, - boolean archived, boolean locked, boolean saved, boolean isCrosspost, boolean isDashVideo) { + int voteType, int gilded, String flair, boolean hidden, boolean spoiler, boolean nsfw, + boolean stickied, boolean archived, boolean locked, boolean saved, boolean isCrosspost, + boolean isDashVideo) { this.id = id; this.fullName = fullName; this.subredditName = subredditName; @@ -69,6 +71,7 @@ class Post implements Parcelable { this.voteType = voteType; this.gilded = gilded; this.flair = flair; + this.hidden = hidden; this.spoiler = spoiler; this.nsfw = nsfw; this.stickied = stickied; @@ -81,8 +84,8 @@ class Post implements Parcelable { Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author, String postTime, String title, String previewUrl, String url, String permalink, int score, - int postType, int voteType, int gilded, String flair, boolean spoiler, boolean nsfw, boolean stickied, - boolean archived, boolean locked, boolean saved, boolean isCrosspost) { + int postType, int voteType, int gilded, String flair, boolean hidden, boolean spoiler, + boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, boolean isCrosspost) { this.id = id; this.fullName = fullName; this.subredditName = subredditName; @@ -99,6 +102,7 @@ class Post implements Parcelable { this.voteType = voteType; this.gilded = gilded; this.flair = flair; + this.hidden = hidden; this.spoiler = spoiler; this.nsfw = nsfw; this.stickied = stickied; @@ -110,8 +114,8 @@ class Post implements Parcelable { Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author, String postTime, String title, String permalink, int score, int postType, int voteType, int gilded, - String flair, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, - boolean saved, boolean isCrosspost) { + String flair, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, + boolean locked, boolean saved, boolean isCrosspost) { this.id = id; this.fullName = fullName; this.subredditName = subredditName; @@ -126,6 +130,7 @@ class Post implements Parcelable { this.voteType = voteType; this.gilded = gilded; this.flair = flair; + this.hidden = hidden; this.spoiler = spoiler; this.nsfw = nsfw; this.stickied = stickied; @@ -159,6 +164,7 @@ class Post implements Parcelable { gilded = in.readInt(); previewWidth = in.readInt(); previewHeight = in.readInt(); + hidden = in.readByte() != 0; spoiler = in.readByte() != 0; nsfw = in.readByte() != 0; stickied = in.readByte() != 0; @@ -319,6 +325,14 @@ class Post implements Parcelable { return previewHeight; } + boolean isHidden() { + return hidden; + } + + void setHidden(boolean hidden) { + this.hidden = hidden; + } + boolean isSpoiler() { return spoiler; } @@ -409,6 +423,7 @@ class Post implements Parcelable { parcel.writeInt(gilded); parcel.writeInt(previewWidth); parcel.writeInt(previewHeight); + parcel.writeByte((byte) (hidden ? 1 : 0)); parcel.writeByte((byte) (spoiler ? 1 : 0)); parcel.writeByte((byte) (nsfw ? 1 : 0)); parcel.writeByte((byte) (stickied ? 1 : 0)); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java index e6e6fb12..2bb47053 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java @@ -544,6 +544,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { post.setVoteType(event.post.getVoteType()); post.setScore(event.post.getScore()); post.setNSFW(event.post.isNSFW()); + post.setHidden(event.post.isHidden()); post.setSpoiler(event.post.isSpoiler()); post.setFlair(event.post.getFlair()); post.setSaved(event.post.isSaved()); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java index e4838897..55904d2b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java @@ -176,4 +176,12 @@ public interface RedditAPI { @FormUrlEncoded @POST("/api/unsave") Call<String> unsave(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params); + + @FormUrlEncoded + @POST("/api/hide") + Call<String> hide(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params); + + @FormUrlEncoded + @POST("/api/unhide") + Call<String> unhide(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java index 06487bcb..42a63247 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java @@ -304,6 +304,7 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo } else { if(mMenu != null) { MenuItem saveItem = mMenu.findItem(R.id.action_save_view_post_detail_activity); + MenuItem hideItem = mMenu.findItem(R.id.action_hide_view_post_detail_activity); if(mAccessToken != null) { if(mPost.isSaved()) { saveItem.setVisible(true); @@ -312,8 +313,17 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo saveItem.setVisible(true); saveItem.setIcon(R.drawable.ic_baseline_bookmark_border_24px); } + + if(mPost.isHidden()) { + hideItem.setVisible(true); + hideItem.setTitle(R.string.action_unhide_post); + } else { + hideItem.setVisible(true); + hideItem.setTitle(R.string.action_hide_post); + } } else { saveItem.setVisible(false); + hideItem.setVisible(false); } if(mPost.getAuthor().equals(mAccountName)) { @@ -420,6 +430,7 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo if(mMenu != null) { MenuItem saveItem = mMenu.findItem(R.id.action_save_view_post_detail_activity); + MenuItem hideItem = mMenu.findItem(R.id.action_hide_view_post_detail_activity); if(mAccessToken != null) { if(post.isSaved()) { saveItem.setVisible(true); @@ -428,8 +439,17 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo saveItem.setVisible(true); saveItem.setIcon(R.drawable.ic_baseline_bookmark_border_24px); } + + if(post.isHidden()) { + hideItem.setVisible(true); + hideItem.setTitle(R.string.action_unhide_post); + } else { + hideItem.setVisible(true); + hideItem.setTitle(R.string.action_hide_post); + } } else { saveItem.setVisible(false); + hideItem.setVisible(false); } if(mPost.getAuthor().equals(mAccountName)) { @@ -630,6 +650,7 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo isRefreshing = false; if(mMenu != null) { MenuItem saveItem = mMenu.findItem(R.id.action_save_view_post_detail_activity); + MenuItem hideItem = mMenu.findItem(R.id.action_hide_view_post_detail_activity); if(mAccessToken != null) { if(post.isSaved()) { saveItem.setVisible(true); @@ -638,8 +659,17 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo saveItem.setVisible(true); saveItem.setIcon(R.drawable.ic_baseline_bookmark_border_24px); } + + if(post.isHidden()) { + hideItem.setVisible(true); + hideItem.setTitle(R.string.action_unhide_post); + } else { + hideItem.setVisible(true); + hideItem.setTitle(R.string.action_hide_post); + } } else { saveItem.setVisible(false); + hideItem.setVisible(false); } mMenu.findItem(R.id.action_view_crosspost_parent_view_post_detail_activity).setVisible(mPost.getCrosspostParentId() != null); @@ -668,7 +698,7 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo if(showToast) { Toast.makeText(ViewPostDetailActivity.this, resId, Toast.LENGTH_SHORT).show(); } else { - Snackbar.make(mCoordinatorLayout, resId, Snackbar.LENGTH_SHORT); + Snackbar.make(mCoordinatorLayout, resId, Snackbar.LENGTH_SHORT).show(); } } @@ -872,6 +902,7 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo mMenu = menu; if(mPost != null) { MenuItem saveItem = mMenu.findItem(R.id.action_save_view_post_detail_activity); + MenuItem hideItem = mMenu.findItem(R.id.action_hide_view_post_detail_activity); if(mAccessToken != null) { if(mPost.isSaved()) { saveItem.setVisible(true); @@ -880,8 +911,17 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo saveItem.setVisible(true); saveItem.setIcon(R.drawable.ic_baseline_bookmark_border_24px); } + + if(mPost.isHidden()) { + hideItem.setVisible(true); + hideItem.setTitle(R.string.action_unhide_post); + } else { + hideItem.setVisible(true); + hideItem.setTitle(R.string.action_hide_post); + } } else { saveItem.setVisible(false); + hideItem.setVisible(false); } if(mPost.getAuthor().equals(mAccountName)) { @@ -993,6 +1033,51 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo crosspostIntent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, mPost.getCrosspostParentId()); startActivity(crosspostIntent); return true; + case R.id.action_hide_view_post_detail_activity: + if(mPost != null && mAccessToken != null) { + if(mPost.isHidden()) { + item.setTitle(R.string.action_hide_post); + + HidePost.unhidePost(mOauthRetrofit, mAccessToken, mPost.getFullName(), new HidePost.HidePostListener() { + @Override + public void success() { + mPost.setHidden(false); + item.setTitle(R.string.action_hide_post); + showMessage(R.string.post_unhide_success); + EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)); + } + + @Override + public void failed() { + mPost.setHidden(true); + item.setTitle(R.string.action_unhide_post); + showMessage(R.string.post_unhide_failed); + EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)); + } + }); + } else { + item.setTitle(R.string.action_unhide_post); + + HidePost.hidePost(mOauthRetrofit, mAccessToken, mPost.getFullName(), new HidePost.HidePostListener() { + @Override + public void success() { + mPost.setHidden(true); + item.setTitle(R.string.action_unhide_post); + showMessage(R.string.post_hide_success); + EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)); + } + + @Override + public void failed() { + mPost.setHidden(false); + item.setTitle(R.string.action_hide_post); + showMessage(R.string.post_hide_failed); + EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)); + } + }); + } + } + return true; case R.id.action_edit_view_post_detail_activity: Intent editPostItent = new Intent(this, EditPostActivity.class); editPostItent.putExtra(EditPostActivity.EXTRA_ACCESS_TOKEN, mAccessToken); |