From 5748f41067f82949f0ef4740ba3f3e80d9a661c0 Mon Sep 17 00:00:00 2001 From: velichkomarija Date: Thu, 10 Dec 2020 13:26:09 +0300 Subject: [PATCH] [android] Added loadCatalog in BookmarksDownloadFragmentDelegate. --- .../maps/bookmarks/BookmarksCatalogFragment.java | 11 ++++++++++- .../BookmarksDownloadFragmentDelegate.java | 16 +++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java b/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java index 7850ea254a..9a3a62cd74 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java @@ -30,6 +30,7 @@ import com.android.billingclient.api.SkuDetails; import com.mapswithme.maps.Framework; import com.mapswithme.maps.PrivateVariables; import com.mapswithme.maps.R; +import com.mapswithme.maps.auth.AuthorizationListener; import com.mapswithme.maps.auth.BaseWebViewMwmFragment; import com.mapswithme.maps.auth.TargetFragmentCallback; import com.mapswithme.maps.bookmarks.data.BookmarkCategory; @@ -106,13 +107,21 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment @Nullable private String mProductDetailsBundle; + @NonNull + private final AuthorizationListener mAuthorizationListener = success -> { + if (!success) + return; + + loadCatalog(mProductDetailsBundle); + }; + @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle extra = requireActivity().getIntent() .getBundleExtra(BookmarksCatalogActivity.EXTRA_ARGS); - mDelegate = new BookmarksDownloadFragmentDelegate(this, extra); + mDelegate = new BookmarksDownloadFragmentDelegate(this, extra, mAuthorizationListener); mDelegate.onCreate(savedInstanceState); mInvalidSubsDialogCallback = new InvalidSubscriptionAlertDialogCallback(this); } diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarksDownloadFragmentDelegate.java b/android/src/com/mapswithme/maps/bookmarks/BookmarksDownloadFragmentDelegate.java index 6f811868c4..dbc734a090 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarksDownloadFragmentDelegate.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarksDownloadFragmentDelegate.java @@ -13,6 +13,7 @@ import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import com.mapswithme.maps.R; +import com.mapswithme.maps.auth.AuthorizationListener; import com.mapswithme.maps.auth.Authorizer; import com.mapswithme.maps.auth.TargetFragmentCallback; import com.mapswithme.maps.base.Detachable; @@ -46,6 +47,8 @@ class BookmarksDownloadFragmentDelegate implements Authorizer.Callback, Bookmark @Nullable private Runnable mAuthCompletionRunnable; + @Nullable + private final AuthorizationListener mAuthorizationListener; @NonNull private final ExpiredCategoriesListener mExpiredCategoriesListener; @NonNull @@ -53,14 +56,17 @@ class BookmarksDownloadFragmentDelegate implements Authorizer.Callback, Bookmark BookmarksDownloadFragmentDelegate(@NonNull Fragment fragment) { - this(fragment, AuthBundleFactory.guideCatalogue()); + this(fragment, AuthBundleFactory.guideCatalogue(), null); } - BookmarksDownloadFragmentDelegate(@NonNull Fragment fragment, @NonNull Bundle bundle) + BookmarksDownloadFragmentDelegate(@NonNull Fragment fragment, + @NonNull Bundle bundle, + @Nullable AuthorizationListener authorizationListener) { mFragment = fragment; mExpiredCategoriesListener = new ExpiredCategoriesListener(fragment); mBundle = bundle; + mAuthorizationListener = authorizationListener; } void onCreate(@Nullable Bundle savedInstanceState) @@ -185,7 +191,11 @@ class BookmarksDownloadFragmentDelegate implements Authorizer.Callback, Bookmark @Override public void onAuthorizationRequired() { - authorize(this::retryBookmarkDownload); + authorize(() -> { + if (mAuthorizationListener != null) + mAuthorizationListener.onAuthorized(true); + retryBookmarkDownload(); + }); } @Override