Merge pull request #4177 from osmandapp/crash_live_updates
Fix crash in LiveUpdates
This commit is contained in:
commit
88ee0c8293
1 changed files with 41 additions and 39 deletions
|
@ -162,47 +162,49 @@ 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) {
|
||||
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));
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue