Added null check for weakreference
This commit is contained in:
parent
e237a90389
commit
4384f4ddd5
1 changed files with 5 additions and 3 deletions
|
@ -157,6 +157,9 @@ public class WikivoyageWebViewClient extends WebViewClient implements RegionCall
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void warnAboutExternalLoad(final String url, final Context context, final boolean nightMode) {
|
private static void warnAboutExternalLoad(final String url, final Context context, final boolean nightMode) {
|
||||||
|
if (context == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
new AlertDialog.Builder(context)
|
new AlertDialog.Builder(context)
|
||||||
.setTitle(url)
|
.setTitle(url)
|
||||||
.setMessage(R.string.online_webpage_warning)
|
.setMessage(R.string.online_webpage_warning)
|
||||||
|
@ -302,13 +305,12 @@ public class WikivoyageWebViewClient extends WebViewClient implements RegionCall
|
||||||
protected void onCancelled(){
|
protected void onCancelled(){
|
||||||
dialog = null;
|
dialog = null;
|
||||||
indexes.clear();
|
indexes.clear();
|
||||||
weakContext.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(List<Amenity> found) {
|
protected void onPostExecute(List<Amenity> found) {
|
||||||
MapActivity activity = weakContext.get();
|
MapActivity activity = weakContext.get();
|
||||||
if (!activity.isActivityDestroyed() && dialog != null) {
|
if (activity != null && !activity.isActivityDestroyed() && dialog != null) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
if (!found.isEmpty()) {
|
if (!found.isEmpty()) {
|
||||||
WikipediaDialogFragment.showInstance(activity, found.get(0));
|
WikipediaDialogFragment.showInstance(activity, found.get(0));
|
||||||
|
@ -320,7 +322,7 @@ public class WikivoyageWebViewClient extends WebViewClient implements RegionCall
|
||||||
|
|
||||||
private ProgressDialog createProgressDialog() {
|
private ProgressDialog createProgressDialog() {
|
||||||
MapActivity activity = weakContext.get();
|
MapActivity activity = weakContext.get();
|
||||||
if (!activity.isActivityDestroyed()) {
|
if (activity != null && !activity.isActivityDestroyed()) {
|
||||||
ProgressDialog dialog = new ProgressDialog(activity);
|
ProgressDialog dialog = new ProgressDialog(activity);
|
||||||
dialog.setCancelable(false);
|
dialog.setCancelable(false);
|
||||||
dialog.setMessage(activity.getString(R.string.wiki_article_search_text));
|
dialog.setMessage(activity.getString(R.string.wiki_article_search_text));
|
||||||
|
|
Loading…
Reference in a new issue