From 4aa118fe459ac87c53071ec2a9766720b8b85341 Mon Sep 17 00:00:00 2001 From: PavelRatushnyi Date: Sat, 22 Jul 2017 19:58:03 +0300 Subject: [PATCH] Fix crash --- .../plus/liveupdates/LiveUpdatesFragment.java | 76 ++++++++++--------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java index aa07f041d7..911e55f938 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java @@ -164,45 +164,47 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList public void updateSubscriptionHeader() { View subscriptionBanner = subscriptionHeader.findViewById(R.id.subscription_banner); View subscriptionInfo = subscriptionHeader.findViewById(R.id.subscription_info); - if (getSettings().LIVE_UPDATES_PURCHASED.get()) { - ImageView statusIcon = (ImageView) subscriptionHeader.findViewById(R.id.statusIcon); - TextView statusTextView = (TextView) subscriptionHeader.findViewById(R.id.statusTextView); - TextView regionNameTextView = (TextView) subscriptionHeader.findViewById(R.id.regionTextView); - statusTextView.setText(getString(R.string.osm_live_active)); - statusIcon.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_done)); + if (getActivity() instanceof OsmLiveActivity) { + if (getSettings().LIVE_UPDATES_PURCHASED.get()) { + ImageView statusIcon = (ImageView) subscriptionHeader.findViewById(R.id.statusIcon); + TextView statusTextView = (TextView) subscriptionHeader.findViewById(R.id.statusTextView); + TextView regionNameTextView = (TextView) subscriptionHeader.findViewById(R.id.regionTextView); + statusTextView.setText(getString(R.string.osm_live_active)); + statusIcon.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_done)); - String countryName = getSettings().BILLING_USER_COUNTRY.get(); - if (Algorithms.isEmpty(countryName)) { - WorldRegion world = getMyApplication().getRegions().getWorldRegion(); - countryName = world.getLocaleName(); + String countryName = getSettings().BILLING_USER_COUNTRY.get(); + if (Algorithms.isEmpty(countryName)) { + WorldRegion world = getMyApplication().getRegions().getWorldRegion(); + countryName = world.getLocaleName(); + } + regionNameTextView.setText(countryName); + + subscriptionBanner.setVisibility(View.GONE); + subscriptionInfo.setVisibility(View.VISIBLE); + } else { + Button readMoreBtn = (Button) subscriptionHeader.findViewById(R.id.read_more_button); + readMoreBtn.setEnabled(!processing); + readMoreBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Uri uri = Uri.parse("https://osmand.net/osm_live.php"); + Intent goToOsmLive = new Intent(Intent.ACTION_VIEW, uri); + startActivity(goToOsmLive); + } + }); + Button subscriptionButton = (Button) subscriptionHeader.findViewById(R.id.subscription_button); + subscriptionButton.setEnabled(!processing); + subscriptionButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + SubscriptionFragment subscriptionFragment = new SubscriptionFragment(); + subscriptionFragment.show(getChildFragmentManager(), SubscriptionFragment.TAG); + } + }); + + subscriptionBanner.setVisibility(View.VISIBLE); + subscriptionInfo.setVisibility(View.GONE); } - regionNameTextView.setText(countryName); - - subscriptionBanner.setVisibility(View.GONE); - subscriptionInfo.setVisibility(View.VISIBLE); - } else { - Button readMoreBtn = (Button) subscriptionHeader.findViewById(R.id.read_more_button); - readMoreBtn.setEnabled(!processing); - readMoreBtn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Uri uri = Uri.parse("https://osmand.net/osm_live.php"); - Intent goToOsmLive = new Intent(Intent.ACTION_VIEW, uri); - startActivity(goToOsmLive); - } - }); - Button subscriptionButton = (Button) subscriptionHeader.findViewById(R.id.subscription_button); - subscriptionButton.setEnabled(!processing); - subscriptionButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - SubscriptionFragment subscriptionFragment = new SubscriptionFragment(); - subscriptionFragment.show(getChildFragmentManager(), SubscriptionFragment.TAG); - } - }); - - subscriptionBanner.setVisibility(View.VISIBLE); - subscriptionInfo.setVisibility(View.GONE); } }