Dismiss osmlive activity on choose plan dismiss

This commit is contained in:
Alexey Kulish 2018-04-30 10:53:15 +03:00
parent 83663e351d
commit 1fdb663204
2 changed files with 8 additions and 12 deletions

View file

@ -3,6 +3,7 @@ package net.osmand.plus.chooseplan;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -56,7 +57,7 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment
private View planTypeCardButton; private View planTypeCardButton;
public interface ChoosePlanDialogListener { public interface ChoosePlanDialogListener {
void onChoosePlanDialogDismissed(); void onChoosePlanDialogDismiss();
} }
public enum OsmAndFeature { public enum OsmAndFeature {
@ -198,11 +199,11 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment
} }
@Override @Override
public void dismiss() { public void onDismiss(DialogInterface dialog) {
super.dismiss(); super.onDismiss(dialog);
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null && activity instanceof ChoosePlanDialogListener) { if (activity != null && activity instanceof ChoosePlanDialogListener) {
((ChoosePlanDialogListener) activity).onChoosePlanDialogDismissed(); ((ChoosePlanDialogListener) activity).onChoosePlanDialogDismiss();
} }
} }

View file

@ -35,12 +35,10 @@ public class OsmLiveActivity extends AbstractDownloadActivity implements Downloa
private final static Log LOG = PlatformUtil.getLog(OsmLiveActivity.class); private final static Log LOG = PlatformUtil.getLog(OsmLiveActivity.class);
public final static String OPEN_SUBSCRIPTION_INTENT_PARAM = "open_subscription_intent_param"; public final static String OPEN_SUBSCRIPTION_INTENT_PARAM = "open_subscription_intent_param";
public final static String SHOW_SETTINGS_ONLY_INTENT_PARAM = "show_settings_only_intent_param"; public final static String SHOW_SETTINGS_ONLY_INTENT_PARAM = "show_settings_only_intent_param";
public final static String CHOOSE_PLAN_DIALOG_DISMISSED_KEY = "choose_plan_dialog_dismissed_key";
private LiveUpdatesFragmentPagerAdapter pagerAdapter; private LiveUpdatesFragmentPagerAdapter pagerAdapter;
private boolean openSubscription; private boolean openSubscription;
private boolean showSettingOnly; private boolean showSettingOnly;
private boolean choosePlanDialogDismissed;
private GetLastUpdateDateTask getLastUpdateDateTask; private GetLastUpdateDateTask getLastUpdateDateTask;
private static final String URL = "https://osmand.net/api/osmlive_status"; private static final String URL = "https://osmand.net/api/osmlive_status";
@ -57,7 +55,6 @@ public class OsmLiveActivity extends AbstractDownloadActivity implements Downloa
} else if (savedInstanceState != null) { } else if (savedInstanceState != null) {
openSubscription = savedInstanceState.getBoolean(OPEN_SUBSCRIPTION_INTENT_PARAM, false); openSubscription = savedInstanceState.getBoolean(OPEN_SUBSCRIPTION_INTENT_PARAM, false);
showSettingOnly = savedInstanceState.getBoolean(SHOW_SETTINGS_ONLY_INTENT_PARAM, false); showSettingOnly = savedInstanceState.getBoolean(SHOW_SETTINGS_ONLY_INTENT_PARAM, false);
choosePlanDialogDismissed = savedInstanceState.getBoolean(CHOOSE_PLAN_DIALOG_DISMISSED_KEY, false);
} }
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
@ -89,8 +86,7 @@ public class OsmLiveActivity extends AbstractDownloadActivity implements Downloa
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
if (!getMyApplication().getSettings().LIVE_UPDATES_PURCHASED.get() && showSettingOnly if (!getMyApplication().getSettings().LIVE_UPDATES_PURCHASED.get() && showSettingOnly) {
&& !choosePlanDialogDismissed) {
ChoosePlanDialogFragment.showOsmLiveInstance(getSupportFragmentManager()); ChoosePlanDialogFragment.showOsmLiveInstance(getSupportFragmentManager());
} }
} }
@ -114,12 +110,11 @@ public class OsmLiveActivity extends AbstractDownloadActivity implements Downloa
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
outState.putBoolean(OPEN_SUBSCRIPTION_INTENT_PARAM, openSubscription); outState.putBoolean(OPEN_SUBSCRIPTION_INTENT_PARAM, openSubscription);
outState.putBoolean(SHOW_SETTINGS_ONLY_INTENT_PARAM, showSettingOnly); outState.putBoolean(SHOW_SETTINGS_ONLY_INTENT_PARAM, showSettingOnly);
outState.putBoolean(CHOOSE_PLAN_DIALOG_DISMISSED_KEY, choosePlanDialogDismissed);
} }
@Override @Override
public void onChoosePlanDialogDismissed() { public void onChoosePlanDialogDismiss() {
choosePlanDialogDismissed = true; finish();
} }
public boolean isShowSettingOnly() { public boolean isShowSettingOnly() {