Skip to content

Commit

Permalink
Add checks to avoid NPEs
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhinterlong committed Jul 20, 2017
1 parent 7f47030 commit 27ee4aa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
6 changes: 4 additions & 2 deletions app/src/main/java/com/jtmcn/archwiki/viewer/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_share:
WikiPage wikiPage = wikiViewer.getCurrentWebPage();
Intent intent = AndroidUtils.shareText(wikiPage.getPageTitle(), wikiPage.getPageUrl(), this);
shareActionProvider.setShareIntent(intent);
if (wikiPage != null) {
Intent intent = AndroidUtils.shareText(wikiPage.getPageTitle(), wikiPage.getPageUrl(), this);
shareActionProvider.setShareIntent(intent);
}
break;
case R.id.refresh:
wikiViewer.onRefresh();
Expand Down
28 changes: 15 additions & 13 deletions app/src/main/java/com/jtmcn/archwiki/viewer/WikiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,20 @@ public void onFinish(WikiPage results) {
public void refreshPage() {
lastLoadedUrl = null; // set to null if page should restore position, otherwise start at top of page
WikiPage currentWebPage = getCurrentWebPage();
final int scrollPosition = currentWebPage.getScrollPosition();

String url = currentWebPage.getPageUrl();
showProgress();
Fetch.page(new FetchUrl.OnFinish<WikiPage>() {
@Override
public void onFinish(WikiPage wikiPage) {
webpageStack.pop();
webpageStack.push(wikiPage);
wikiPage.setScrollPosition(scrollPosition);
loadWikiHtml(wikiPage);
}
}, url, false);
if (currentWebPage != null) {
final int scrollPosition = currentWebPage.getScrollPosition();

String url = currentWebPage.getPageUrl();
showProgress();
Fetch.page(new FetchUrl.OnFinish<WikiPage>() {
@Override
public void onFinish(WikiPage wikiPage) {
webpageStack.pop();
webpageStack.push(wikiPage);
wikiPage.setScrollPosition(scrollPosition);
loadWikiHtml(wikiPage);
}
}, url, false);
}
}
}

0 comments on commit 27ee4aa

Please sign in to comment.