forked from organicmaps/organicmaps
[android] Fix routing plan error saved state. Added error view to the routing plan fragment layout.
This commit is contained in:
parent
abee9b23d5
commit
dface83167
3 changed files with 44 additions and 0 deletions
|
@ -23,6 +23,19 @@
|
|||
layout="@layout/routing_action_panel"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/error"
|
||||
android:paddingLeft="@dimen/margin_base"
|
||||
android:paddingStart="@dimen/margin_base"
|
||||
android:paddingRight="@dimen/margin_base"
|
||||
android:paddingEnd="@dimen/margin_base"
|
||||
android:paddingTop="@dimen/margin_half_plus"
|
||||
android:paddingBottom="@dimen/margin_half_plus"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
|
|
@ -188,6 +188,10 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
@Nullable
|
||||
private Dialog mLocationErrorDialog;
|
||||
|
||||
private boolean mRestoreRoutingPlanFragmentNeeded;
|
||||
@Nullable
|
||||
private Bundle mSaveState;
|
||||
|
||||
@NonNull
|
||||
private final OnClickListener mOnMyPositionClickListener = new OnClickListener()
|
||||
{
|
||||
|
@ -968,7 +972,14 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
{
|
||||
RoutingPlanFragment fragment = (RoutingPlanFragment) getFragment(RoutingPlanFragment.class);
|
||||
if (fragment != null)
|
||||
{
|
||||
fragment.restoreRoutingPanelState(savedInstanceState);
|
||||
}
|
||||
else if (RoutingController.get().isPlanning())
|
||||
{
|
||||
mRestoreRoutingPlanFragmentNeeded = true;
|
||||
mSaveState = savedInstanceState;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mIsFragmentContainer && RoutingController.get().isPlanning())
|
||||
|
@ -1765,6 +1776,12 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (mIsFragmentContainer)
|
||||
{
|
||||
replaceFragment(RoutingPlanFragment.class, null, completionListener);
|
||||
if (mRestoreRoutingPlanFragmentNeeded && mSaveState != null)
|
||||
{
|
||||
RoutingPlanFragment fragment = (RoutingPlanFragment) getFragment(RoutingPlanFragment.class);
|
||||
if (fragment != null)
|
||||
fragment.restoreRoutingPanelState(mSaveState);
|
||||
}
|
||||
showAddStartOrFinishFrame(RoutingController.get(), false);
|
||||
int width = UiUtils.dimen(R.dimen.panel_width);
|
||||
adjustTraffic(width, UiUtils.getStatusBarHeight(getApplicationContext()));
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.support.annotation.StringRes;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.text.TextUtils;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -42,6 +43,7 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
{
|
||||
private static final String STATE_ALTITUDE_CHART_SHOWN = "altitude_chart_shown";
|
||||
private static final String STATE_TAXI_INFO = "taxi_info";
|
||||
private static final String STATE_ERROR = "error";
|
||||
|
||||
@NonNull
|
||||
private final Activity mContext;
|
||||
|
@ -73,6 +75,9 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
@Nullable
|
||||
private TaxiInfo.Product mTaxiProduct;
|
||||
|
||||
@StringRes
|
||||
private int mErrorMessage;
|
||||
|
||||
@NonNull
|
||||
static RoutingBottomMenuController newInstance(@NonNull Activity activity, @NonNull View frame)
|
||||
{
|
||||
|
@ -137,6 +142,7 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
void showAltitudeChartAndRoutingDetails()
|
||||
{
|
||||
UiUtils.hide(mError, mTaxiFrame, mActionFrame);
|
||||
mErrorMessage = 0;
|
||||
|
||||
showRouteAltitudeChart();
|
||||
showRoutingDetails();
|
||||
|
@ -154,6 +160,7 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
void showTaxiInfo(@NonNull TaxiInfo info)
|
||||
{
|
||||
UiUtils.hide(mError, mAltitudeChartFrame, mActionFrame);
|
||||
mErrorMessage = 0;
|
||||
UiUtils.showTaxiIcon((ImageView) mTaxiFrame.findViewById(R.id.iv__logo), info.getType());
|
||||
final List<TaxiInfo.Product> products = info.getProducts();
|
||||
mTaxiInfo = info;
|
||||
|
@ -263,6 +270,7 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
|
||||
void showError(@StringRes int message)
|
||||
{
|
||||
mErrorMessage = message;
|
||||
UiUtils.hide(mTaxiFrame, mAltitudeChartFrame);
|
||||
mError.setText(message);
|
||||
mError.setVisibility(View.VISIBLE);
|
||||
|
@ -278,6 +286,8 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
{
|
||||
outState.putBoolean(STATE_ALTITUDE_CHART_SHOWN, UiUtils.isVisible(mAltitudeChartFrame));
|
||||
outState.putParcelable(STATE_TAXI_INFO, mTaxiInfo);
|
||||
if (mErrorMessage > 0)
|
||||
outState.putInt(STATE_ERROR, mErrorMessage);
|
||||
}
|
||||
|
||||
void restoreRoutingPanelState(@NonNull Bundle state)
|
||||
|
@ -288,6 +298,10 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
TaxiInfo info = state.getParcelable(STATE_TAXI_INFO);
|
||||
if (info != null)
|
||||
showTaxiInfo(info);
|
||||
|
||||
int error = state.getInt(STATE_ERROR);
|
||||
if (error > 0)
|
||||
showError(error);
|
||||
}
|
||||
|
||||
private void showRouteAltitudeChart()
|
||||
|
|
Loading…
Add table
Reference in a new issue