Try to fix some npe or IllegalStateException
This commit is contained in:
parent
9f0bda924d
commit
2bc49ea8f8
3 changed files with 23 additions and 5 deletions
|
@ -417,8 +417,12 @@ public class OsmandAidlApi {
|
|||
}
|
||||
|
||||
private void registerReceiver(BroadcastReceiver rec, MapActivity ma, String filter) {
|
||||
receivers.put(filter, rec);
|
||||
ma.registerReceiver(rec, new IntentFilter(filter));
|
||||
try {
|
||||
receivers.put(filter, rec);
|
||||
ma.registerReceiver(rec, new IntentFilter(filter));
|
||||
} catch (IllegalStateException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerRemoveMapWidgetReceiver(MapActivity mapActivity) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
|||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.AsyncTask.Status;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.OpenableColumns;
|
||||
|
@ -25,6 +26,8 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.FavouritePoint.BackgroundType;
|
||||
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.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -704,14 +707,16 @@ public class ImportHelper {
|
|||
@SuppressWarnings("unchecked")
|
||||
private <P> void executeImportTask(final AsyncTask<P, ?, ?> importTask, final P... requests) {
|
||||
if (app.isApplicationInitializing()) {
|
||||
app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() {
|
||||
app.getAppInitializer().addListener(new AppInitializeListener() {
|
||||
@Override
|
||||
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
|
||||
public void onProgress(AppInitializer init, InitEvents event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
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 {
|
||||
|
|
|
@ -75,6 +75,9 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
FavouritesDbHelper helper = getHelper();
|
||||
if (editor != null && helper != null) {
|
||||
FavouritePoint favorite = editor.getFavorite();
|
||||
if (favorite == null && savedInstanceState != null) {
|
||||
favorite = (FavouritePoint) savedInstanceState.getSerializable(FavoriteDialogs.KEY_FAVORITE);
|
||||
}
|
||||
this.favorite = favorite;
|
||||
this.group = helper.getGroup(favorite);
|
||||
this.color = favorite.getColor();
|
||||
|
@ -109,6 +112,12 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putSerializable(FavoriteDialogs.KEY_FAVORITE, getFavorite());
|
||||
}
|
||||
|
||||
private void replacePressed() {
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(FavoriteDialogs.KEY_FAVORITE, getFavorite());
|
||||
|
|
Loading…
Reference in a new issue