From e2b108aefc01bc387c91901f663af5e12a71e206 Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 11 Mar 2021 16:14:40 +0200 Subject: [PATCH] small fixes --- .../plus/liveupdates/LiveUpdatesFragmentNew.java | 12 ++++++------ .../plus/liveupdates/LiveUpdatesHelper.java | 6 +++--- .../liveupdates/PerformLiveUpdateAsyncTask.java | 16 ++++++++-------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java index 2ab25f1696..45ccf2b3fa 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java @@ -52,7 +52,7 @@ import net.osmand.plus.liveupdates.LiveUpdatesHelper.TimeOfDay; import net.osmand.plus.liveupdates.LiveUpdatesHelper.UpdateFrequency; import net.osmand.plus.liveupdates.LiveUpdatesSettingsDialogFragmentNew.OnLiveUpdatesForLocalChange; import net.osmand.plus.liveupdates.LoadLiveMapsTask.LocalIndexInfoAdapter; -import net.osmand.plus.liveupdates.PerformLiveUpdateAsyncTask.AsyncResponse; +import net.osmand.plus.liveupdates.PerformLiveUpdateAsyncTask.LiveUpdateListener; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.widgets.TextViewEx; @@ -309,7 +309,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements private void showUpdateDialog() { startUpdateDateAsyncTask(); if (!Algorithms.isEmpty(adapter.mapsList)) { - final AsyncResponse refreshAfterUpdate = new AsyncResponse() { + final LiveUpdateListener listener = new LiveUpdateListener() { @Override public void processFinish() { adapter.notifyDataSetChanged(); @@ -317,7 +317,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements }; if (adapter.countEnabled == 1) { LocalIndexInfo li = adapter.mapsList.get(0); - runLiveUpdate(getActivity(), li.getFileName(), false, refreshAfterUpdate); + runLiveUpdate(getActivity(), li.getFileName(), false, listener); } else if (adapter.countEnabled > 1) { AlertDialog.Builder bld = new AlertDialog.Builder(getMyActivity()); bld.setMessage(R.string.update_all_maps_now); @@ -328,7 +328,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements for (LocalIndexInfo li : adapter.mapsList) { CommonPreference localUpdateOn = preferenceForLocalIndex(li.getFileName(), settings); if (localUpdateOn.get()) { - runLiveUpdate(getActivity(), li.getFileName(), false, refreshAfterUpdate); + runLiveUpdate(getActivity(), li.getFileName(), false, listener); } } } @@ -650,7 +650,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements final CommonPreference liveUpdatePreference = preferenceForLocalIndex(fileName, settings); liveUpdatePreference.set(newValue); if (settings.IS_LIVE_UPDATES_ON.get() && liveUpdatePreference.get()) { - runLiveUpdate(getActivity(), fileName, true, new AsyncResponse() { + runLiveUpdate(getActivity(), fileName, true, new LiveUpdateListener() { @Override public void processFinish() { runSort(); @@ -673,7 +673,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements @Override public void forceUpdateLocal(String fileName, boolean userRequested, final Runnable callback) { if (settings.IS_LIVE_UPDATES_ON.get()) { - runLiveUpdate(getActivity(), fileName, userRequested, new AsyncResponse() { + runLiveUpdate(getActivity(), fileName, userRequested, new LiveUpdateListener() { @Override public void processFinish() { updateList(); diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java index 4ff0afee0a..afcb313217 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java @@ -11,7 +11,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.liveupdates.PerformLiveUpdateAsyncTask.AsyncResponse; +import net.osmand.plus.liveupdates.PerformLiveUpdateAsyncTask.LiveUpdateListener; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; @@ -254,8 +254,8 @@ public class LiveUpdatesHelper { } } - public static void runLiveUpdate(Context context, final String fileName, boolean userRequested, @Nullable final AsyncResponse runOnPost) { + public static void runLiveUpdate(Context context, final String fileName, boolean userRequested, @Nullable final LiveUpdateListener listener) { final String fnExt = Algorithms.getFileNameWithoutExtension(new File(fileName)); - new PerformLiveUpdateAsyncTask(context, fileName, userRequested, runOnPost).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, fnExt); + new PerformLiveUpdateAsyncTask(context, fileName, userRequested, listener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, fnExt); } } diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java b/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java index 920127cfa5..d148e8c697 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java @@ -46,20 +46,20 @@ public class PerformLiveUpdateAsyncTask @NonNull private final String localIndexFileName; private final boolean userRequested; - private final AsyncResponse runOnPost; + private final LiveUpdateListener listener; - public interface AsyncResponse { + public interface LiveUpdateListener { void processFinish(); } public PerformLiveUpdateAsyncTask(@NonNull Context context, @NonNull String localIndexFileName, boolean userRequested, - @Nullable AsyncResponse runOnPost) { + @Nullable LiveUpdateListener listener) { this.context = context; this.localIndexFileName = localIndexFileName; this.userRequested = userRequested; - this.runOnPost = runOnPost; + this.listener = listener; } @Override @@ -149,8 +149,8 @@ public class PerformLiveUpdateAsyncTask ((DownloadIndexesThread.DownloadEvents) context).downloadInProgress(); } updateLatestAvailability(application, localIndexFileName); - if (runOnPost != null) { - runOnPost.processFinish(); + if (listener != null) { + listener.processFinish(); } } else { LOG.debug("onPostExecute: Not enough space for updates"); @@ -163,8 +163,8 @@ public class PerformLiveUpdateAsyncTask ((DownloadIndexesThread.DownloadEvents) context).downloadInProgress(); if (userRequested && context instanceof DownloadActivity) { updateLatestAvailability(application, localIndexFileName); - if (runOnPost != null) { - runOnPost.processFinish(); + if (listener != null) { + listener.processFinish(); } application.showShortToastMessage(R.string.no_updates_available); }