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. --- app/src/main/AndroidManifest.xml | 2 +- .../CommentAndPostRecyclerViewAdapter.java | 1 - .../infinityforreddit/MainActivity.java | 2 + .../infinityforreddit/ViewPostDetailActivity.java | 50 ++++++++++++++-------- .../main/res/menu/view_post_detail_activity.xml | 3 +- 5 files changed, 37 insertions(+), 21 deletions(-) (limited to 'app') diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index da61fa45..81a9c8f3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -193,7 +193,7 @@ + android:theme="@style/AppTheme.Launcher"> 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) { diff --git a/app/src/main/res/menu/view_post_detail_activity.xml b/app/src/main/res/menu/view_post_detail_activity.xml index d971b154..63c2106f 100644 --- a/app/src/main/res/menu/view_post_detail_activity.xml +++ b/app/src/main/res/menu/view_post_detail_activity.xml @@ -6,7 +6,8 @@ android:orderInCategory="1" android:title="@string/action_add_comment" android:icon="@drawable/ic_insert_comment_white_24dp" - app:showAsAction="ifRoom" /> + app:showAsAction="ifRoom" + android:visible="false" />