Merge branch 'r3.9'

This commit is contained in:
Victor Shcherb 2021-03-01 15:06:10 +01:00
commit 907354957d
5 changed files with 25 additions and 7 deletions

View file

@ -417,8 +417,12 @@ public class OsmandAidlApi {
} }
private void registerReceiver(BroadcastReceiver rec, MapActivity ma, String filter) { private void registerReceiver(BroadcastReceiver rec, MapActivity ma, String filter) {
receivers.put(filter, rec); try {
ma.registerReceiver(rec, new IntentFilter(filter)); receivers.put(filter, rec);
ma.registerReceiver(rec, new IntentFilter(filter));
} catch (IllegalStateException e) {
LOG.error(e);
}
} }
private void registerRemoveMapWidgetReceiver(MapActivity mapActivity) { private void registerRemoveMapWidgetReceiver(MapActivity mapActivity) {

View file

@ -468,7 +468,7 @@ public abstract class OsmandPlugin {
FragmentManager fm = mapActivity.getSupportFragmentManager(); FragmentManager fm = mapActivity.getSupportFragmentManager();
Fragment fragment = fm.findFragmentByTag(fragmentData.tag); Fragment fragment = fm.findFragmentByTag(fragmentData.tag);
if (fragment != null) { if (fragment != null) {
fm.beginTransaction().remove(fragment).commit(); fm.beginTransaction().remove(fragment).commitAllowingStateLoss();
} }
} }
} }

View file

@ -1004,7 +1004,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
new TransactionBuilder(mapActivity.getSupportFragmentManager(), settings, mapActivity); new TransactionBuilder(mapActivity.getSupportFragmentManager(), settings, mapActivity);
builder.addFragmentsData(fragmentsData) builder.addFragmentsData(fragmentsData)
.addFragmentsData(OsmandPlugin.getPluginsCardsList()) .addFragmentsData(OsmandPlugin.getPluginsCardsList())
.getFragmentTransaction().commit(); .getFragmentTransaction().commitAllowingStateLoss();
} }
private void removeFragment(String tag) { private void removeFragment(String tag) {

View file

@ -6,6 +6,7 @@ import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.AsyncTask.Status;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.OpenableColumns; import android.provider.OpenableColumns;
@ -25,6 +26,8 @@ import net.osmand.PlatformUtil;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.FavouritePoint.BackgroundType; import net.osmand.data.FavouritePoint.BackgroundType;
import net.osmand.plus.AppInitializer; import net.osmand.plus.AppInitializer;
import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.AppInitializer.InitEvents;
import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GPXDatabase.GpxDataItem;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -707,14 +710,16 @@ public class ImportHelper {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private <P> void executeImportTask(final AsyncTask<P, ?, ?> importTask, final P... requests) { private <P> void executeImportTask(final AsyncTask<P, ?, ?> importTask, final P... requests) {
if (app.isApplicationInitializing()) { if (app.isApplicationInitializing()) {
app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() { app.getAppInitializer().addListener(new AppInitializeListener() {
@Override @Override
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) { public void onProgress(AppInitializer init, InitEvents event) {
} }
@Override @Override
public void onFinish(AppInitializer init) { public void onFinish(AppInitializer init) {
importTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, requests); if (importTask.getStatus() == Status.PENDING) {
importTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, requests);
}
} }
}); });
} else { } else {

View file

@ -75,6 +75,9 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
FavouritesDbHelper helper = getHelper(); FavouritesDbHelper helper = getHelper();
if (editor != null && helper != null) { if (editor != null && helper != null) {
FavouritePoint favorite = editor.getFavorite(); FavouritePoint favorite = editor.getFavorite();
if (favorite == null && savedInstanceState != null) {
favorite = (FavouritePoint) savedInstanceState.getSerializable(FavoriteDialogs.KEY_FAVORITE);
}
this.favorite = favorite; this.favorite = favorite;
this.group = helper.getGroup(favorite); this.group = helper.getGroup(favorite);
this.color = favorite.getColor(); this.color = favorite.getColor();
@ -109,6 +112,12 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
return view; return view;
} }
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putSerializable(FavoriteDialogs.KEY_FAVORITE, getFavorite());
}
private void replacePressed() { private void replacePressed() {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putSerializable(FavoriteDialogs.KEY_FAVORITE, getFavorite()); args.putSerializable(FavoriteDialogs.KEY_FAVORITE, getFavorite());