small fixes
This commit is contained in:
parent
bccfe95597
commit
e2b108aefc
3 changed files with 17 additions and 17 deletions
|
@ -52,7 +52,7 @@ import net.osmand.plus.liveupdates.LiveUpdatesHelper.TimeOfDay;
|
||||||
import net.osmand.plus.liveupdates.LiveUpdatesHelper.UpdateFrequency;
|
import net.osmand.plus.liveupdates.LiveUpdatesHelper.UpdateFrequency;
|
||||||
import net.osmand.plus.liveupdates.LiveUpdatesSettingsDialogFragmentNew.OnLiveUpdatesForLocalChange;
|
import net.osmand.plus.liveupdates.LiveUpdatesSettingsDialogFragmentNew.OnLiveUpdatesForLocalChange;
|
||||||
import net.osmand.plus.liveupdates.LoadLiveMapsTask.LocalIndexInfoAdapter;
|
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.CommonPreference;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
|
@ -309,7 +309,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
|
||||||
private void showUpdateDialog() {
|
private void showUpdateDialog() {
|
||||||
startUpdateDateAsyncTask();
|
startUpdateDateAsyncTask();
|
||||||
if (!Algorithms.isEmpty(adapter.mapsList)) {
|
if (!Algorithms.isEmpty(adapter.mapsList)) {
|
||||||
final AsyncResponse refreshAfterUpdate = new AsyncResponse() {
|
final LiveUpdateListener listener = new LiveUpdateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void processFinish() {
|
public void processFinish() {
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
@ -317,7 +317,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
|
||||||
};
|
};
|
||||||
if (adapter.countEnabled == 1) {
|
if (adapter.countEnabled == 1) {
|
||||||
LocalIndexInfo li = adapter.mapsList.get(0);
|
LocalIndexInfo li = adapter.mapsList.get(0);
|
||||||
runLiveUpdate(getActivity(), li.getFileName(), false, refreshAfterUpdate);
|
runLiveUpdate(getActivity(), li.getFileName(), false, listener);
|
||||||
} else if (adapter.countEnabled > 1) {
|
} else if (adapter.countEnabled > 1) {
|
||||||
AlertDialog.Builder bld = new AlertDialog.Builder(getMyActivity());
|
AlertDialog.Builder bld = new AlertDialog.Builder(getMyActivity());
|
||||||
bld.setMessage(R.string.update_all_maps_now);
|
bld.setMessage(R.string.update_all_maps_now);
|
||||||
|
@ -328,7 +328,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
|
||||||
for (LocalIndexInfo li : adapter.mapsList) {
|
for (LocalIndexInfo li : adapter.mapsList) {
|
||||||
CommonPreference<Boolean> localUpdateOn = preferenceForLocalIndex(li.getFileName(), settings);
|
CommonPreference<Boolean> localUpdateOn = preferenceForLocalIndex(li.getFileName(), settings);
|
||||||
if (localUpdateOn.get()) {
|
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<Boolean> liveUpdatePreference = preferenceForLocalIndex(fileName, settings);
|
final CommonPreference<Boolean> liveUpdatePreference = preferenceForLocalIndex(fileName, settings);
|
||||||
liveUpdatePreference.set(newValue);
|
liveUpdatePreference.set(newValue);
|
||||||
if (settings.IS_LIVE_UPDATES_ON.get() && liveUpdatePreference.get()) {
|
if (settings.IS_LIVE_UPDATES_ON.get() && liveUpdatePreference.get()) {
|
||||||
runLiveUpdate(getActivity(), fileName, true, new AsyncResponse() {
|
runLiveUpdate(getActivity(), fileName, true, new LiveUpdateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void processFinish() {
|
public void processFinish() {
|
||||||
runSort();
|
runSort();
|
||||||
|
@ -673,7 +673,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
|
||||||
@Override
|
@Override
|
||||||
public void forceUpdateLocal(String fileName, boolean userRequested, final Runnable callback) {
|
public void forceUpdateLocal(String fileName, boolean userRequested, final Runnable callback) {
|
||||||
if (settings.IS_LIVE_UPDATES_ON.get()) {
|
if (settings.IS_LIVE_UPDATES_ON.get()) {
|
||||||
runLiveUpdate(getActivity(), fileName, userRequested, new AsyncResponse() {
|
runLiveUpdate(getActivity(), fileName, userRequested, new LiveUpdateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void processFinish() {
|
public void processFinish() {
|
||||||
updateList();
|
updateList();
|
||||||
|
|
|
@ -11,7 +11,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
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.CommonPreference;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
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));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,20 +46,20 @@ public class PerformLiveUpdateAsyncTask
|
||||||
@NonNull
|
@NonNull
|
||||||
private final String localIndexFileName;
|
private final String localIndexFileName;
|
||||||
private final boolean userRequested;
|
private final boolean userRequested;
|
||||||
private final AsyncResponse runOnPost;
|
private final LiveUpdateListener listener;
|
||||||
|
|
||||||
public interface AsyncResponse {
|
public interface LiveUpdateListener {
|
||||||
void processFinish();
|
void processFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PerformLiveUpdateAsyncTask(@NonNull Context context,
|
public PerformLiveUpdateAsyncTask(@NonNull Context context,
|
||||||
@NonNull String localIndexFileName,
|
@NonNull String localIndexFileName,
|
||||||
boolean userRequested,
|
boolean userRequested,
|
||||||
@Nullable AsyncResponse runOnPost) {
|
@Nullable LiveUpdateListener listener) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.localIndexFileName = localIndexFileName;
|
this.localIndexFileName = localIndexFileName;
|
||||||
this.userRequested = userRequested;
|
this.userRequested = userRequested;
|
||||||
this.runOnPost = runOnPost;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -149,8 +149,8 @@ public class PerformLiveUpdateAsyncTask
|
||||||
((DownloadIndexesThread.DownloadEvents) context).downloadInProgress();
|
((DownloadIndexesThread.DownloadEvents) context).downloadInProgress();
|
||||||
}
|
}
|
||||||
updateLatestAvailability(application, localIndexFileName);
|
updateLatestAvailability(application, localIndexFileName);
|
||||||
if (runOnPost != null) {
|
if (listener != null) {
|
||||||
runOnPost.processFinish();
|
listener.processFinish();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("onPostExecute: Not enough space for updates");
|
LOG.debug("onPostExecute: Not enough space for updates");
|
||||||
|
@ -163,8 +163,8 @@ public class PerformLiveUpdateAsyncTask
|
||||||
((DownloadIndexesThread.DownloadEvents) context).downloadInProgress();
|
((DownloadIndexesThread.DownloadEvents) context).downloadInProgress();
|
||||||
if (userRequested && context instanceof DownloadActivity) {
|
if (userRequested && context instanceof DownloadActivity) {
|
||||||
updateLatestAvailability(application, localIndexFileName);
|
updateLatestAvailability(application, localIndexFileName);
|
||||||
if (runOnPost != null) {
|
if (listener != null) {
|
||||||
runOnPost.processFinish();
|
listener.processFinish();
|
||||||
}
|
}
|
||||||
application.showShortToastMessage(R.string.no_updates_available);
|
application.showShortToastMessage(R.string.no_updates_available);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue