Fix activity queue (without parents yet)

This commit is contained in:
Alexey Kulish 2016-02-02 22:37:17 +03:00
parent 6294a667b5
commit 829a43d8ae
4 changed files with 24 additions and 7 deletions

View file

@ -1,5 +1,6 @@
package net.osmand.plus.activities;
import android.app.Activity;
import android.app.Dialog;
import android.app.Notification;
import android.app.NotificationManager;
@ -405,6 +406,8 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
setIntent(intent);
}
private static Intent prevActivityIntent = null;
@Override
public void onBackPressed() {
if (dashboardOnMap.onBackPressed()) {
@ -414,7 +417,14 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
closeDrawer();
return;
}
super.onBackPressed();
if (prevActivityIntent != null && getSupportFragmentManager().getBackStackEntryCount() == 0) {
prevActivityIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
this.startActivity(prevActivityIntent);
prevActivityIntent = null;
} else {
super.onBackPressed();
}
}
@Override
@ -1008,13 +1018,17 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
}
((MapActivity) activity).readLocationToShow();
} else {
prevActivityIntent = new Intent(((Activity) activity).getIntent());
Intent newIntent = new Intent(activity, ((OsmandApplication) activity.getApplicationContext())
.getAppCustomization().getMapActivity());
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_CLEAR_TOP);
activity.startActivity(newIntent);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
OsmandPlugin.onMapActivityResult(requestCode, resultCode, data);

View file

@ -600,7 +600,9 @@ public class MapActivityActions implements DialogProvider {
if (mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation()) {
newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true);
}
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
return true;
}
@ -612,7 +614,7 @@ public class MapActivityActions implements DialogProvider {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getFavoritesActivity());
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
return true;
}

View file

@ -530,11 +530,11 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
super.onPause();
if (searchNearBy) {
app.getLocationProvider().pauseAllUpdates();
if (!app.accessibilityEnabled()) {
app.getLocationProvider().removeCompassListener(this);
}
app.getLocationProvider().removeLocationListener(this);
}
if (!app.accessibilityEnabled()) {
app.getLocationProvider().removeCompassListener(this);
}
}
@Override

View file

@ -243,6 +243,7 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc
private void showFilterActivity(String filterId) {
final Intent newIntent = new Intent(getActivity(), SearchPOIActivity.class);
newIntent.putExtra(SearchPOIActivity.AMENITY_FILTER, filterId);
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
updateIntentToLaunch(newIntent);
startActivityForResult(newIntent, 0);
}