Skip to content

Commit 289d7a8

Browse files
fix rare NPE
Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent 1a45f98 commit 289d7a8

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

app/src/main/java/com/fox2code/mmm/MainActivity.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464

6565
public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRefreshListener, SearchView.OnQueryTextListener, SearchView.OnCloseListener, OverScrollManager.OverScrollHelper {
6666
private static final int PRECISION = 10000;
67-
private static MainActivity INSTANCE;
6867
public static boolean doSetupNowRunning = true;
6968
public static boolean doSetupRestarting = false;
7069
public static List<LocalModuleInfo> localModuleInfoList = new ArrayList<>();
@@ -491,8 +490,12 @@ private void updateBlurState() {
491490
if (MainApplication.isBlurEnabled()) {
492491
// set bottom navigation bar color to transparent blur
493492
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
494-
bottomNavigationView.setBackgroundColor(Color.TRANSPARENT);
495-
bottomNavigationView.setAlpha(0.8F);
493+
if (bottomNavigationView != null) {
494+
bottomNavigationView.setBackgroundColor(Color.TRANSPARENT);
495+
bottomNavigationView.setAlpha(0.8F);
496+
} else {
497+
Timber.w("Bottom navigation view not found");
498+
}
496499
// set dialogs to have transparent blur
497500
getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
498501
}

app/src/main/java/com/fox2code/mmm/markdown/MarkdownActivity.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.io.IOException;
3333
import java.nio.charset.StandardCharsets;
3434
import java.util.HashMap;
35+
import java.util.Objects;
3536

3637
import timber.log.Timber;
3738

@@ -77,7 +78,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
7778
this.forceBackPressed();
7879
return;
7980
}
80-
String url = intent.getExtras().getString(Constants.EXTRA_MARKDOWN_URL);
81+
String url = Objects.requireNonNull(intent.getExtras()).getString(Constants.EXTRA_MARKDOWN_URL);
8182
String title = intent.getExtras().getString(Constants.EXTRA_MARKDOWN_TITLE);
8283
String config = intent.getExtras().getString(Constants.EXTRA_MARKDOWN_CONFIG);
8384
boolean change_boot = intent.getExtras().getBoolean(Constants.EXTRA_MARKDOWN_CHANGE_BOOT);
@@ -152,8 +153,12 @@ private void updateBlurState() {
152153
if (MainApplication.isBlurEnabled()) {
153154
// set bottom navigation bar color to transparent blur
154155
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
155-
bottomNavigationView.setBackgroundColor(Color.TRANSPARENT);
156-
bottomNavigationView.setAlpha(0.8F);
156+
if (bottomNavigationView != null) {
157+
bottomNavigationView.setBackgroundColor(Color.TRANSPARENT);
158+
bottomNavigationView.setAlpha(0.8F);
159+
} else {
160+
Timber.w("Bottom navigation view not found");
161+
}
157162
// set dialogs to have transparent blur
158163
getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
159164
}

0 commit comments

Comments
 (0)