From 7ec0c9f3a63236531a23e7851cb69439c583871d Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 5 Jan 2015 13:29:55 +0200 Subject: [PATCH] Fixed NPE in DashDownloadMapFragment --- OsmAnd/src/net/osmand/plus/dashboard/DashBaseFragment.java | 3 +++ .../net/osmand/plus/dashboard/DashDownloadMapsFragment.java | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashBaseFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashBaseFragment.java index f6411de761..9a4fe6a4b2 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashBaseFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashBaseFragment.java @@ -9,6 +9,9 @@ import net.osmand.plus.OsmandApplication; public class DashBaseFragment extends SherlockFragment { public OsmandApplication getMyApplication(){ + if (getActivity() == null){ + return null; + } return (OsmandApplication) getActivity().getApplication(); } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashDownloadMapsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashDownloadMapsFragment.java index a34bce2a2e..0f67c08a45 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashDownloadMapsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashDownloadMapsFragment.java @@ -84,7 +84,8 @@ public class DashDownloadMapsFragment extends DashBaseFragment { } protected void updateCount(String s) { - if (!DashDownloadMapsFragment.this.isAdded()){ + if (!DashDownloadMapsFragment.this.isAdded() || + getMyApplication() == null){ return; } File ms = getMyApplication().getAppPath(s); @@ -104,7 +105,8 @@ public class DashDownloadMapsFragment extends DashBaseFragment { @Override protected void onPostExecute(Void result) { super.onPostExecute(result); - if (!DashDownloadMapsFragment.this.isAdded()){ + if (!DashDownloadMapsFragment.this.isAdded() + || getMyApplication() == null){ return; } if(countMaps > 0) {