[android] Added ignoring of purchase server ping if product details not loaded

This commit is contained in:
Александр Зацепин 2019-12-25 12:09:11 +03:00 committed by Arsentiy Milchakov
parent 596f866c41
commit 3254f9d6a6
2 changed files with 22 additions and 5 deletions

View file

@ -26,6 +26,7 @@ import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
import com.mapswithme.util.statistics.Statistics;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@ -165,6 +166,13 @@ abstract class AbstractBookmarkSubscriptionFragment extends BaseAuthFragment
return mProductDetails[period.ordinal()];
}
@Nullable
List<ProductDetails> getProductDetails()
{
return mProductDetails == null ? null
: Collections.synchronizedList(Arrays.asList(mProductDetails));
}
@Override
public void onAuthorizationFinish(boolean success)
{
@ -277,7 +285,6 @@ abstract class AbstractBookmarkSubscriptionFragment extends BaseAuthFragment
mDelegate.onPriceSelection();
}
@Override
@CallSuper
public void onProductDetailsLoading()

View file

@ -8,6 +8,8 @@ import com.mapswithme.maps.R;
import com.mapswithme.maps.widget.SubscriptionButton;
import com.mapswithme.util.Utils;
import java.util.List;
class TwoButtonsSubscriptionFragmentDelegate extends SubscriptionFragmentDelegate
{
@SuppressWarnings("NullableProblems")
@ -31,16 +33,24 @@ class TwoButtonsSubscriptionFragmentDelegate extends SubscriptionFragmentDelegat
super.onCreateView(root);
mYearlyButton = root.findViewById(R.id.annual_button);
mYearlyButton.setOnClickListener(v -> {
mSelectedPeriod = PurchaseUtils.Period.P1Y;
getFragment().pingBookmarkCatalog();
onSubscriptionButtonClicked(PurchaseUtils.Period.P1Y);
});
mMonthlyButton = root.findViewById(R.id.monthly_button);
mMonthlyButton.setOnClickListener(v -> {
mSelectedPeriod = PurchaseUtils.Period.P1M;
getFragment().pingBookmarkCatalog();
onSubscriptionButtonClicked(PurchaseUtils.Period.P1M);
});
}
private void onSubscriptionButtonClicked(@NonNull PurchaseUtils.Period period)
{
List<ProductDetails> productDetails = getFragment().getProductDetails();
if (productDetails == null || productDetails.isEmpty())
return;
mSelectedPeriod = period;
getFragment().pingBookmarkCatalog();
}
@NonNull
@Override
PurchaseUtils.Period getSelectedPeriod()