mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-12 17:08:59 -04:00
NullPointerException checks in MainActivity
This commit is contained in:
parent
04b6d07b2b
commit
c34934c8b9
@ -532,17 +532,22 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateBottomToolbarArrowsAlpha() {
|
private void updateBottomToolbarArrowsAlpha() {
|
||||||
|
if (checkNull(bottomToolbarArrowBack)) {
|
||||||
if (getCurrentWebView().canGoForward()) {
|
if (getCurrentWebView().canGoForward()) {
|
||||||
bottomToolbarArrowForward.setAlpha(1f);
|
bottomToolbarArrowForward.setAlpha(1f);
|
||||||
} else {
|
} else {
|
||||||
bottomToolbarArrowForward.setAlpha(0.6f);
|
bottomToolbarArrowForward.setAlpha(0.6f);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkNull(bottomToolbarArrowForward)) {
|
||||||
if (getCurrentWebView().canGoBack()) {
|
if (getCurrentWebView().canGoBack()) {
|
||||||
bottomToolbarArrowBack.setAlpha(1f);
|
bottomToolbarArrowBack.setAlpha(1f);
|
||||||
} else {
|
} else {
|
||||||
bottomToolbarArrowBack.setAlpha(0.6f);
|
bottomToolbarArrowBack.setAlpha(0.6f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@OnClick(R.id.bottom_toolbar_toc)
|
@OnClick(R.id.bottom_toolbar_toc)
|
||||||
void openToc() {
|
void openToc() {
|
||||||
@ -1284,6 +1289,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateBottomToolbarVisibility() {
|
private void updateBottomToolbarVisibility() {
|
||||||
|
if (checkNull(bottomToolbar)) {
|
||||||
if (sharedPreferenceUtil.getPrefBottomToolbar() && !HOME_URL.equals(
|
if (sharedPreferenceUtil.getPrefBottomToolbar() && !HOME_URL.equals(
|
||||||
getCurrentWebView().getUrl())
|
getCurrentWebView().getUrl())
|
||||||
&& tabSwitcherRoot.getVisibility() != View.VISIBLE) {
|
&& tabSwitcherRoot.getVisibility() != View.VISIBLE) {
|
||||||
@ -1300,6 +1306,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
contentFrame.setPadding(0, 0, 0, 0);
|
contentFrame.setPadding(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
@ -1574,6 +1581,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void refreshBookmarkSymbol() {
|
private void refreshBookmarkSymbol() {
|
||||||
|
if (checkNull(bottomToolbarBookmark)) {
|
||||||
if (getCurrentWebView().getUrl() != null &&
|
if (getCurrentWebView().getUrl() != null &&
|
||||||
ZimContentProvider.getId() != null &&
|
ZimContentProvider.getId() != null &&
|
||||||
!getCurrentWebView().getUrl().equals(HOME_URL)) {
|
!getCurrentWebView().getUrl().equals(HOME_URL)) {
|
||||||
@ -1584,6 +1592,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
bottomToolbarBookmark.setImageResource(R.drawable.ic_bookmark_border_24dp);
|
bottomToolbarBookmark.setImageResource(R.drawable.ic_bookmark_border_24dp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void loadPrefs() {
|
private void loadPrefs() {
|
||||||
nightMode = sharedPreferenceUtil.nightMode();
|
nightMode = sharedPreferenceUtil.nightMode();
|
||||||
@ -1832,6 +1841,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void webViewProgressChanged(int progress) {
|
public void webViewProgressChanged(int progress) {
|
||||||
|
if (checkNull(progressBar)) {
|
||||||
progressBar.setProgress(progress);
|
progressBar.setProgress(progress);
|
||||||
if (progress == 100) {
|
if (progress == 100) {
|
||||||
if (requestClearHistoryAfterLoad) {
|
if (requestClearHistoryAfterLoad) {
|
||||||
@ -1844,6 +1854,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
Log.d(TAG_KIWIX, "Loaded URL: " + getCurrentWebView().getUrl());
|
Log.d(TAG_KIWIX, "Loaded URL: " + getCurrentWebView().getUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void webViewTitleUpdated(String title) {
|
public void webViewTitleUpdated(String title) {
|
||||||
@ -1941,4 +1952,8 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
fileSearch.scan(sharedPreferenceUtil.getPrefStorage());
|
fileSearch.scan(sharedPreferenceUtil.getPrefStorage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkNull(View view) {
|
||||||
|
return view != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user