Fix open live updates subscription from banner

This commit is contained in:
Alexey Kulish 2016-08-19 17:19:15 +03:00
parent 3a303fa949
commit 7e062f5759
4 changed files with 18 additions and 0 deletions

View file

@ -437,6 +437,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
public void onClick(View v) {
Intent intent = new Intent(ctx, OsmLiveActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.putExtra(OsmLiveActivity.OPEN_SUBSCRIPTION_INTENT_PARAM, true);
ctx.startActivity(intent);
}
});

View file

@ -168,6 +168,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
if (listAdapter.isShowOsmLiveBanner() && position == 0) {
Intent intent = new Intent(getMyActivity(), OsmLiveActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.putExtra(OsmLiveActivity.OPEN_SUBSCRIPTION_INTENT_PARAM, true);
getMyActivity().startActivity(intent);
} else {
final IndexItem e = (IndexItem) getListAdapter().getItem(position);

View file

@ -210,6 +210,11 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList
helper.addListener(this);
helper.start(false);
}
if (((OsmLiveActivity) getActivity()).shouldOpenSubscription()) {
SubscriptionFragment subscriptionFragment = new SubscriptionFragment();
subscriptionFragment.show(getChildFragmentManager(), SubscriptionFragment.TAG);
}
}
@Override

View file

@ -22,8 +22,10 @@ import org.apache.commons.logging.Log;
public class OsmLiveActivity extends AbstractDownloadActivity
implements DownloadIndexesThread.DownloadEvents{
private final static Log LOG = PlatformUtil.getLog(OsmLiveActivity.class);
public final static String OPEN_SUBSCRIPTION_INTENT_PARAM = "open_subscription_intent_param";
private LiveUpdatesFragmentPagerAdapter pagerAdapter;
private InAppHelper inAppHelper;
private boolean openSubscription;
public InAppHelper getInAppHelper() {
return inAppHelper;
@ -40,6 +42,11 @@ public class OsmLiveActivity extends AbstractDownloadActivity
inAppHelper = null;
}
Intent intent = getIntent();
if (intent != null && intent.getExtras() != null) {
openSubscription = intent.getExtras().getBoolean(OPEN_SUBSCRIPTION_INTENT_PARAM, false);
}
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
pagerAdapter = new LiveUpdatesFragmentPagerAdapter(getSupportFragmentManager(), getResources());
viewPager.setAdapter(pagerAdapter);
@ -94,6 +101,10 @@ public class OsmLiveActivity extends AbstractDownloadActivity
((LiveUpdatesFragment) pagerAdapter.fragments[0]).notifyLiveUpdatesChanged();
}
public boolean shouldOpenSubscription() {
return openSubscription;
}
public static class LiveUpdatesFragmentPagerAdapter extends FragmentPagerAdapter {
private final Fragment[] fragments = new Fragment[]{new LiveUpdatesFragment(),
new ReportsFragment()};