Wikipedia Poi (Fixes 2)
This commit is contained in:
parent
3d3da9ee8e
commit
0d3f0711fd
2 changed files with 31 additions and 9 deletions
|
@ -27,6 +27,7 @@ import androidx.appcompat.widget.SwitchCompat;
|
|||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.core.android.MapRendererContext;
|
||||
|
@ -245,7 +246,16 @@ public class ConfigureMapMenu {
|
|||
showGpxSelectionDialog(adapter, adapter.getItem(pos));
|
||||
}
|
||||
} else if (itemId == R.string.shared_string_wikipedia) {
|
||||
WikipediaPoiMenu.toggleWikipediaPoi(ma, isChecked, true);
|
||||
WikipediaPoiMenu.toggleWikipediaPoi(ma, isChecked, true,
|
||||
new CallbackWithObject<Boolean>() {
|
||||
@Override
|
||||
public boolean processResult(Boolean result) {
|
||||
item.setSelected(result);
|
||||
item.setColorRes(result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||
adapter.notifyDataSetChanged();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} else if (itemId == R.string.map_markers) {
|
||||
settings.SHOW_MAP_MARKERS.set(isChecked);
|
||||
} else if (itemId == R.string.layer_map) {
|
||||
|
|
|
@ -59,6 +59,14 @@ public class WikipediaPoiMenu {
|
|||
adapter.setProfileDependent(true);
|
||||
adapter.setNightMode(nightMode);
|
||||
|
||||
final CallbackWithObject<Boolean> callback = new CallbackWithObject<Boolean>() {
|
||||
@Override
|
||||
public boolean processResult(Boolean result) {
|
||||
mapActivity.getDashboard().refreshContent(true);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter,
|
||||
|
@ -67,11 +75,11 @@ public class WikipediaPoiMenu {
|
|||
app.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
toggleWikipediaPoi(mapActivity, !enabled, true);
|
||||
toggleWikipediaPoi(mapActivity, !enabled, true, callback);
|
||||
}
|
||||
});
|
||||
} else if (itemId == languageActionStringId) {
|
||||
showLanguagesDialog(mapActivity, appMode, true, true);
|
||||
showLanguagesDialog(mapActivity, appMode, true, true, callback);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -225,7 +233,8 @@ public class WikipediaPoiMenu {
|
|||
private static void showLanguagesDialog(@NonNull final MapActivity mapActivity,
|
||||
@NonNull final ApplicationMode appMode,
|
||||
final boolean usedOnMap,
|
||||
final boolean refresh) {
|
||||
final boolean refresh,
|
||||
final CallbackWithObject<Boolean> callback) {
|
||||
final OsmandApplication app = mapActivity.getMyApplication();
|
||||
SelectWikiLanguagesBottomSheet.showInstance(mapActivity, appMode, usedOnMap,
|
||||
new CallbackWithObject<Boolean>() {
|
||||
|
@ -239,10 +248,10 @@ public class WikipediaPoiMenu {
|
|||
if (refresh) {
|
||||
refreshWikiPoi(mapActivity, globalWikiEnabled);
|
||||
} else {
|
||||
toggleWikipediaPoi(mapActivity, true, usedOnMap);
|
||||
toggleWikipediaPoi(mapActivity, true, usedOnMap, callback);
|
||||
}
|
||||
} else {
|
||||
toggleWikipediaPoi(mapActivity, false, usedOnMap);
|
||||
toggleWikipediaPoi(mapActivity, false, usedOnMap, callback);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -293,7 +302,8 @@ public class WikipediaPoiMenu {
|
|||
return bundle;
|
||||
}
|
||||
|
||||
public static void toggleWikipediaPoi(final MapActivity mapActivity, boolean enable, boolean usedOnMap) {
|
||||
public static void toggleWikipediaPoi(final MapActivity mapActivity, boolean enable,
|
||||
boolean usedOnMap, CallbackWithObject<Boolean> callback) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
OsmandSettings settings = app.getSettings();
|
||||
if (enable) {
|
||||
|
@ -304,13 +314,15 @@ public class WikipediaPoiMenu {
|
|||
showWikiOnMap(app, globalWikiEnabled);
|
||||
} else {
|
||||
ApplicationMode appMode = settings.getApplicationMode();
|
||||
showLanguagesDialog(mapActivity, appMode, usedOnMap, false);
|
||||
showLanguagesDialog(mapActivity, appMode, usedOnMap, false, callback);
|
||||
}
|
||||
} else {
|
||||
settings.SHOW_WIKIPEDIA_POI.set(false);
|
||||
hideWikiFromMap(app);
|
||||
}
|
||||
mapActivity.getDashboard().refreshContent(true);
|
||||
if (callback != null) {
|
||||
callback.processResult(settings.SHOW_WIKIPEDIA_POI.get());
|
||||
}
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue