diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-02-03 15:01:03 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-02-03 15:01:03 +0000 |
commit | 6e211a582135c1d12cd2e7ff036ad6e40c8e82f2 (patch) | |
tree | d4da94f4008bd8c68a8c4b15d674c21060978dda /app/src/main | |
parent | 73980544db791bf27b08b26d3f64f9ef2e3e822e (diff) | |
download | infinity-for-reddit-6e211a582135c1d12cd2e7ff036ad6e40c8e82f2.tar infinity-for-reddit-6e211a582135c1d12cd2e7ff036ad6e40c8e82f2.tar.gz infinity-for-reddit-6e211a582135c1d12cd2e7ff036ad6e40c8e82f2.tar.bz2 infinity-for-reddit-6e211a582135c1d12cd2e7ff036ad6e40c8e82f2.tar.lz infinity-for-reddit-6e211a582135c1d12cd2e7ff036ad6e40c8e82f2.tar.xz infinity-for-reddit-6e211a582135c1d12cd2e7ff036ad6e40c8e82f2.tar.zst infinity-for-reddit-6e211a582135c1d12cd2e7ff036ad6e40c8e82f2.zip |
Fix crashes on scrolling posts using volume keys.
Diffstat (limited to '')
8 files changed, 43 insertions, 10 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java index ede80722..e855177d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java @@ -161,7 +161,11 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - return ((FragmentCommunicator) mFragment).handleKeyDown(keyCode) || super.onKeyDown(keyCode, event); + if (mFragment != null) { + return ((FragmentCommunicator) mFragment).handleKeyDown(keyCode) || super.onKeyDown(keyCode, event); + } + + return super.onKeyDown(keyCode, event); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java index 1e1e7447..7f3f0341 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java @@ -154,7 +154,11 @@ public class AccountSavedThingActivity extends BaseActivity { @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - return sectionsPagerAdapter.handleKeyDown(keyCode) || super.onKeyDown(keyCode, event); + if (sectionsPagerAdapter != null) { + return sectionsPagerAdapter.handleKeyDown(keyCode) || super.onKeyDown(keyCode, event); + } + + return super.onKeyDown(keyCode, event); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java index 71123450..bb2e40f6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java @@ -180,7 +180,11 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - return ((FragmentCommunicator) mFragment).handleKeyDown(keyCode) || super.onKeyDown(keyCode, event); + if (mFragment != null) { + return ((FragmentCommunicator) mFragment).handleKeyDown(keyCode) || super.onKeyDown(keyCode, event); + } + + return super.onKeyDown(keyCode, event); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java index 865525d2..862ab95d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -942,7 +942,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - return sectionsPagerAdapter.handleKeyDown(keyCode) || super.onKeyDown(keyCode, event); + if (sectionsPagerAdapter != null) { + return sectionsPagerAdapter.handleKeyDown(keyCode) || super.onKeyDown(keyCode, event); + } + + return super.onKeyDown(keyCode, event); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java index f077ee54..96685fec 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java @@ -173,7 +173,10 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - return sectionsPagerAdapter.handleKeyDown(keyCode) || super.onKeyDown(keyCode, event); + if (sectionsPagerAdapter != null) { + return sectionsPagerAdapter.handleKeyDown(keyCode) || super.onKeyDown(keyCode, event); + } + return super.onKeyDown(keyCode, event); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java index e516cdfc..63ebd1ce 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -1564,10 +1564,14 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS } public void lockSwipeRightToGoBack() { - mSlidrInterface.lock(); + if (mSlidrInterface != null) { + mSlidrInterface.lock(); + } } public void unlockSwipeRightToGoBack() { - mSlidrInterface.unlock(); + if (mSlidrInterface != null) { + mSlidrInterface.unlock(); + } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java index 77cbe4b9..cbec2aba 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java @@ -336,7 +336,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - return ((FragmentCommunicator)(mFragment)).handleKeyDown(keyCode) || super.onKeyDown(keyCode, event); + if (mFragment != null) { + return ((FragmentCommunicator)(mFragment)).handleKeyDown(keyCode) || super.onKeyDown(keyCode, event); + } + + return super.onKeyDown(keyCode, event); } @Override @@ -645,7 +649,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST, sortType.getTime().name()).apply(); } - ((PostFragment) mFragment).changeSortType(sortType); + if (mFragment != null) { + ((PostFragment) mFragment).changeSortType(sortType); + } } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java index 90695fde..53eb9720 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java @@ -399,7 +399,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - return sectionsPagerAdapter.handleKeyDown(keyCode) || super.onKeyDown(keyCode, event); + if (sectionsPagerAdapter != null) { + return sectionsPagerAdapter.handleKeyDown(keyCode) || super.onKeyDown(keyCode, event); + } + + return super.onKeyDown(keyCode, event); } @Override |