diff --git a/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java index 0eaaeb8bfe..a409f3a833 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java @@ -23,6 +23,7 @@ import android.widget.ListView; import android.widget.TextView; import androidx.annotation.ColorRes; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.content.res.AppCompatResources; @@ -97,7 +98,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download public void onAttach(Activity activity) { super.onAttach(activity); invalidateListView(activity); - startLoadLiveMapsAsyncTask(); + startLoadLiveMapsAsyncTask(getMyApplication()); } @Override @@ -109,7 +110,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download public void downloadHasFinished() { invalidateListView(getMyActivity()); updateUpdateAllButton(); - startLoadLiveMapsAsyncTask(); + startLoadLiveMapsAsyncTask(getMyApplication()); } @Override @@ -222,8 +223,8 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download stopLoadLiveMapsAsyncTask(); } - private void startLoadLiveMapsAsyncTask() { - loadLiveMapsTask = new LoadLiveMapsTask(listAdapter, this); + private void startLoadLiveMapsAsyncTask(OsmandApplication app) { + loadLiveMapsTask = new LoadLiveMapsTask(listAdapter, app); loadLiveMapsTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } @@ -256,6 +257,11 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download return (DownloadActivity) getActivity(); } + @Nullable + public OsmandApplication getMyApplication() { + return getMyActivity().getMyApplication(); + } + @SuppressWarnings("deprecation") @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { @@ -272,10 +278,6 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download } } - public OsmandApplication getMyApplication() { - return getMyActivity().getMyApplication(); - } - @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == RELOAD_ID) { @@ -287,8 +289,8 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download } @Override - public void onUpdateStates() { - startLoadLiveMapsAsyncTask(); + public void onUpdateStates(OsmandApplication app) { + startLoadLiveMapsAsyncTask(app); } private class UpdateIndexAdapter extends ArrayAdapter { @@ -428,10 +430,9 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download private final UpdateIndexAdapter adapter; private final LocalIndexHelper helper; - public LoadLiveMapsTask(UpdateIndexAdapter adapter, - UpdatesIndexFragment fragment) { + public LoadLiveMapsTask(UpdateIndexAdapter adapter, OsmandApplication app) { this.adapter = adapter; - helper = new LocalIndexHelper(fragment.getMyApplication()); + helper = new LocalIndexHelper(app); } @Override diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesClearDialogFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesClearDialogFragment.java index de68d90b9c..2d46883aeb 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesClearDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesClearDialogFragment.java @@ -96,7 +96,7 @@ public class LiveUpdatesClearDialogFragment extends MenuBottomSheetDialogFragmen } public interface OnRefreshLiveUpdates { - void onUpdateStates(); + void onUpdateStates(OsmandApplication app); } @Override @@ -105,7 +105,7 @@ public class LiveUpdatesClearDialogFragment extends MenuBottomSheetDialogFragmen Fragment fragment = getTargetFragment(); if (fragment instanceof OnRefreshLiveUpdates) { - ((OnRefreshLiveUpdates) fragment).onUpdateStates(); + ((OnRefreshLiveUpdates) fragment).onUpdateStates(app); } dismiss(); diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java index c6d7b63c0f..b34c6986ba 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java @@ -222,7 +222,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements super.onDismiss(dialog); Fragment target = getTargetFragment(); if (target instanceof OnRefreshLiveUpdates) { - ((OnRefreshLiveUpdates) target).onUpdateStates(); + ((OnRefreshLiveUpdates) target).onUpdateStates(app); } } diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragmentNew.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragmentNew.java index 6d1d403e91..13dfb63bb0 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragmentNew.java @@ -475,7 +475,7 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF } @Override - public void onUpdateStates() { + public void onUpdateStates(OsmandApplication app) { final OnLiveUpdatesForLocalChange confirmationInterface = (OnLiveUpdatesForLocalChange) getTargetFragment(); if (confirmationInterface != null) { confirmationInterface.updateList();