fix refresh last date check after clear downloaded data;

fix refresh list after update all enabled
This commit is contained in:
Skalii 2021-03-07 12:50:26 +02:00
parent 2c6204810c
commit 1797e24f43
2 changed files with 11 additions and 11 deletions

View file

@ -217,6 +217,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
stopUpdateDateAsyncTask(); stopUpdateDateAsyncTask();
stopLoadLiveMapsAsyncTask(); stopLoadLiveMapsAsyncTask();
} }
@Override @Override
public void onDismiss(@NonNull DialogInterface dialog) { public void onDismiss(@NonNull DialogInterface dialog) {
super.onDismiss(dialog); super.onDismiss(dialog);
@ -262,7 +263,6 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
@Override @Override
public void onClick(View view) { public void onClick(View view) {
boolean visible = !isChecked; boolean visible = !isChecked;
if (visible) { if (visible) {
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) { if (InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
switchOnLiveUpdates(); switchOnLiveUpdates();
@ -291,7 +291,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
} }
private void showUpdateDialog() { private void showUpdateDialog() {
final AsyncResponse runListSort = new AsyncResponse() { final AsyncResponse refreshAfterUpdate = new AsyncResponse() {
@Override @Override
public void processFinish() { public void processFinish() {
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
@ -300,7 +300,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
if (!Algorithms.isEmpty(adapter.mapsList)) { if (!Algorithms.isEmpty(adapter.mapsList)) {
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, runListSort); runLiveUpdate(getActivity(), li.getFileName(), false, refreshAfterUpdate);
} 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);
@ -311,14 +311,10 @@ 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()) {
if (adapter.mapsList.indexOf(li) == adapter.mapsList.size() - 1) { runLiveUpdate(getActivity(), li.getFileName(), false, refreshAfterUpdate);
runLiveUpdate(getActivity(), li.getFileName(), false, runListSort);
} else {
runLiveUpdate(getActivity(), li.getFileName(), false);
}
} }
startUpdateDateAsyncTask();
} }
startUpdateDateAsyncTask();
} }
}); });
bld.setNegativeButton(R.string.shared_string_no, null); bld.setNegativeButton(R.string.shared_string_no, null);

View file

@ -518,6 +518,10 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
if (confirmationInterface != null) { if (confirmationInterface != null) {
confirmationInterface.updateList(); confirmationInterface.updateList();
} }
if (indexLastCheckItem != -1) {
((BottomSheetItemWithDescription) items.get(indexLastCheckItem))
.setDescription(getLastCheckString());
}
if (indexClearItem != -1) { if (indexClearItem != -1) {
((BottomSheetItemWithDescription) items.get(indexClearItem)) ((BottomSheetItemWithDescription) items.get(indexClearItem))
.setDescription(getUpdatesSizeStr()); .setDescription(getUpdatesSizeStr());
@ -535,8 +539,8 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
void updateList(); void updateList();
} }
public String getStateText(boolean state) { public String getStateText(boolean isEnabled) {
return app.getResources().getString(state ? R.string.shared_string_enabled : R.string.shared_string_disabled); return app.getResources().getString(isEnabled ? R.string.shared_string_enabled : R.string.shared_string_disabled);
} }
@ColorRes @ColorRes