From 3592dc29dabe1fbc41f4af5536e395987963c810 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 17 Sep 2019 08:44:48 +0800 Subject: Fixed android.view.DisplayListCanvas.throwIfCannotDraw in ViewPostDetailActivity. Fixed app crashes when pressing the comment button in ViewPostDetailActivity while the post is not loaded. Re-enable spalsh screen. --- .../CommentAndPostRecyclerViewAdapter.java | 1 - .../infinityforreddit/MainActivity.java | 2 + .../infinityforreddit/ViewPostDetailActivity.java | 50 ++++++++++++++-------- 3 files changed, 34 insertions(+), 19 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java index 1cbc1466..28249f40 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java @@ -741,7 +741,6 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java index 389dc1d5..f07c0f39 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java @@ -163,6 +163,8 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe @Override protected void onCreate(Bundle savedInstanceState) { + setTheme(R.style.AppTheme_NoActionBarWithTransparentStatusBar); + super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java index 27b31083..04e013fe 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java @@ -305,6 +305,9 @@ 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); + + mMenu.findItem(R.id.action_comment_view_post_detail_activity).setVisible(true); + if(mAccessToken != null) { if(mPost.isSaved()) { saveItem.setVisible(true); @@ -431,6 +434,9 @@ 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); + + mMenu.findItem(R.id.action_comment_view_post_detail_activity).setVisible(true); + if(mAccessToken != null) { if(post.isSaved()) { saveItem.setVisible(true); @@ -654,6 +660,9 @@ 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); + + mMenu.findItem(R.id.action_comment_view_post_detail_activity).setVisible(true); + if(mAccessToken != null) { if(post.isSaved()) { saveItem.setVisible(true); @@ -906,6 +915,9 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo 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); + + mMenu.findItem(R.id.action_comment_view_post_detail_activity).setVisible(true); + if(mAccessToken != null) { if(mPost.isSaved()) { saveItem.setVisible(true); @@ -964,27 +976,29 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo refresh(true, true); return true; case R.id.action_comment_view_post_detail_activity: - if(mPost.isArchived()) { - showMessage(R.string.archived_post_reply_unavailable); - return true; - } + if(mPost != null) { + if(mPost.isArchived()) { + showMessage(R.string.archived_post_reply_unavailable); + return true; + } - if(mPost.isLocked()) { - showMessage(R.string.locked_post_comment_unavailable); - return true; - } + if(mPost.isLocked()) { + showMessage(R.string.locked_post_comment_unavailable); + return true; + } - if(mAccessToken == null) { - showMessage(R.string.login_first); - return true; - } + if(mAccessToken == null) { + showMessage(R.string.login_first); + return true; + } - Intent intent = new Intent(this, CommentActivity.class); - intent.putExtra(CommentActivity.EXTRA_COMMENT_PARENT_TEXT_KEY, mPost.getTitle()); - intent.putExtra(CommentActivity.EXTRA_PARENT_FULLNAME_KEY, mPost.getFullName()); - intent.putExtra(CommentActivity.EXTRA_PARENT_DEPTH_KEY, 0); - intent.putExtra(CommentActivity.EXTRA_IS_REPLYING_KEY, false); - startActivityForResult(intent, WRITE_COMMENT_REQUEST_CODE); + Intent intent = new Intent(this, CommentActivity.class); + intent.putExtra(CommentActivity.EXTRA_COMMENT_PARENT_TEXT_KEY, mPost.getTitle()); + intent.putExtra(CommentActivity.EXTRA_PARENT_FULLNAME_KEY, mPost.getFullName()); + intent.putExtra(CommentActivity.EXTRA_PARENT_DEPTH_KEY, 0); + intent.putExtra(CommentActivity.EXTRA_IS_REPLYING_KEY, false); + startActivityForResult(intent, WRITE_COMMENT_REQUEST_CODE); + } return true; case R.id.action_save_view_post_detail_activity: if(mPost != null && mAccessToken != null) { -- cgit v1.2.3