[android] Added loadCatalog in BookmarksDownloadFragmentDelegate.

This commit is contained in:
velichkomarija 2020-12-10 13:26:09 +03:00 committed by Alexey
parent 00d53383c3
commit 5748f41067
2 changed files with 23 additions and 4 deletions

View file

@ -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);
}

View file

@ -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