forked from organicmaps/organicmaps
Merge pull request #774 from trashkalmar/mm-2106-save-slots-state-master
[android] fix: Restore slots state after device rotated.
This commit is contained in:
commit
7f9f7d63a2
3 changed files with 33 additions and 2 deletions
|
@ -576,6 +576,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
outState.putParcelable(STATE_MAP_OBJECT, mPlacePage.getMapObject());
|
||||
}
|
||||
|
||||
if (!mIsFragmentContainer && RoutingController.get().isPlanning())
|
||||
mRoutingPlanInplaceController.onSaveState(outState);
|
||||
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
|
@ -589,6 +592,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
mPlacePage.setMapObject((MapObject) savedInstanceState.getParcelable(STATE_MAP_OBJECT));
|
||||
mPlacePage.setState(State.PREVIEW);
|
||||
}
|
||||
|
||||
if (!mIsFragmentContainer && RoutingController.get().isPlanning())
|
||||
mRoutingPlanInplaceController.restoreState(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
|
@ -246,4 +247,9 @@ public class RoutingPlanController extends ToolbarController
|
|||
UiUtils.hide(mToggle);
|
||||
showSlots(true, false);
|
||||
}
|
||||
|
||||
public boolean isOpen()
|
||||
{
|
||||
return mOpen;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.mapswithme.maps.routing;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
|
@ -12,6 +13,10 @@ import com.mapswithme.util.statistics.Statistics;
|
|||
|
||||
public class RoutingPlanInplaceController extends RoutingPlanController
|
||||
{
|
||||
private static final String STATE_OPEN = "slots panel open";
|
||||
|
||||
private Boolean mSlotsRestoredState;
|
||||
|
||||
public RoutingPlanInplaceController(MwmActivity activity)
|
||||
{
|
||||
super(activity.findViewById(R.id.routing_plan_frame), activity);
|
||||
|
@ -24,8 +29,11 @@ public class RoutingPlanInplaceController extends RoutingPlanController
|
|||
|
||||
if (show)
|
||||
{
|
||||
showSlots(!(RoutingController.get().getStartPoint() instanceof MapObject.MyPosition) || (RoutingController.get().getEndPoint() == null),
|
||||
false);
|
||||
boolean open = (mSlotsRestoredState == null ? !(RoutingController.get().getStartPoint() instanceof MapObject.MyPosition) ||
|
||||
(RoutingController.get().getEndPoint() == null)
|
||||
: mSlotsRestoredState);
|
||||
showSlots(open, false);
|
||||
mSlotsRestoredState = null;
|
||||
}
|
||||
|
||||
UiUtils.showIf(show, mFrame);
|
||||
|
@ -55,4 +63,15 @@ public class RoutingPlanInplaceController extends RoutingPlanController
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onSaveState(Bundle outState)
|
||||
{
|
||||
outState.putBoolean(STATE_OPEN, isOpen());
|
||||
}
|
||||
|
||||
public void restoreState(Bundle state)
|
||||
{
|
||||
if (state.containsKey(STATE_OPEN))
|
||||
mSlotsRestoredState = state.getBoolean(STATE_OPEN);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue