forked from organicmaps/organicmaps
[android] Added opening catalog by pressing on activate item in guides gallery
This commit is contained in:
parent
b12b82d52b
commit
ee4ba01276
5 changed files with 47 additions and 11 deletions
|
@ -62,6 +62,7 @@ import com.mapswithme.maps.editor.EditorHostFragment;
|
|||
import com.mapswithme.maps.editor.FeatureCategoryActivity;
|
||||
import com.mapswithme.maps.editor.ReportFragment;
|
||||
import com.mapswithme.maps.gallery.Items;
|
||||
import com.mapswithme.maps.guides.GuidesGalleryListener;
|
||||
import com.mapswithme.maps.intent.Factory;
|
||||
import com.mapswithme.maps.intent.MapTask;
|
||||
import com.mapswithme.maps.location.CompassData;
|
||||
|
@ -184,7 +185,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
MaterialTapTargetPrompt.PromptStateChangeListener,
|
||||
WelcomeDialogFragment.OnboardingStepPassedListener,
|
||||
OnIsolinesLayerToggleListener,
|
||||
OnGuidesLayerToggleListener
|
||||
OnGuidesLayerToggleListener,
|
||||
GuidesGalleryListener
|
||||
{
|
||||
private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
|
||||
private static final String TAG = MwmActivity.class.getSimpleName();
|
||||
|
@ -534,7 +536,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
|
||||
setContentView(R.layout.activity_map);
|
||||
|
||||
mPlacePageController = PlacePageFactory.createCompositePlacePageController(this, this, this);
|
||||
mPlacePageController = PlacePageFactory.createCompositePlacePageController(
|
||||
this, this, this, this);
|
||||
mPlacePageController.initialize(this);
|
||||
mPlacePageController.onActivityCreated(this, savedInstanceState);
|
||||
|
||||
|
@ -2604,6 +2607,13 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
// Do nothing by default.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGalleryGuideSelected(@NonNull String url)
|
||||
{
|
||||
BookmarksCatalogActivity.startForResult(
|
||||
this, BookmarkCategoriesActivity.REQ_CODE_DOWNLOAD_BOOKMARK_CATEGORY, url);
|
||||
}
|
||||
|
||||
private class CurrentPositionClickListener implements OnClickListener
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package com.mapswithme.maps.guides;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public interface GuidesGalleryListener
|
||||
{
|
||||
void onGalleryGuideSelected(@NonNull String url);
|
||||
}
|
|
@ -2,8 +2,8 @@ package com.mapswithme.maps.widget.placepage;
|
|||
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -19,6 +19,7 @@ import com.mapswithme.maps.gallery.ItemSelectedListener;
|
|||
import com.mapswithme.maps.gallery.impl.Factory;
|
||||
import com.mapswithme.maps.guides.GuidesGallery;
|
||||
import com.mapswithme.maps.guides.GuidesGallery.Item;
|
||||
import com.mapswithme.maps.guides.GuidesGalleryListener;
|
||||
import com.mapswithme.maps.maplayer.guides.GuidesManager;
|
||||
import com.mapswithme.maps.maplayer.guides.OnGuidesGalleryChangedListener;
|
||||
import com.mapswithme.maps.widget.recycler.ItemDecoratorFactory;
|
||||
|
@ -54,8 +55,9 @@ public class GuidesGalleryViewRenderer implements PlacePageViewRenderer<PlacePag
|
|||
{
|
||||
if (item == mActiveItem)
|
||||
{
|
||||
Toast.makeText(mRecyclerView.getContext(), "Open catalog coming soon",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
String url = mActiveItem.getUrl();
|
||||
if (!TextUtils.isEmpty(url) && mGalleryListener != null)
|
||||
mGalleryListener.onGalleryGuideSelected(url);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -82,6 +84,8 @@ public class GuidesGalleryViewRenderer implements PlacePageViewRenderer<PlacePag
|
|||
};
|
||||
@Nullable
|
||||
private GalleryAdapter mAdapter;
|
||||
@Nullable
|
||||
private final GuidesGalleryListener mGalleryListener;
|
||||
|
||||
@NonNull
|
||||
private final OnScrollListener mOnScrollListener = new OnScrollListener()
|
||||
|
@ -122,6 +126,11 @@ public class GuidesGalleryViewRenderer implements PlacePageViewRenderer<PlacePag
|
|||
private int mActivePosition = RecyclerView.NO_POSITION;
|
||||
private int mTargetPosition = RecyclerView.NO_POSITION;
|
||||
|
||||
GuidesGalleryViewRenderer(@Nullable GuidesGalleryListener galleryListener)
|
||||
{
|
||||
mGalleryListener = galleryListener;
|
||||
}
|
||||
|
||||
private void smoothScrollToPosition(int position)
|
||||
{
|
||||
mSmoothScroller.setTargetPosition(position);
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.os.Bundle;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.mapswithme.maps.guides.GuidesGalleryListener;
|
||||
import com.mapswithme.maps.purchase.AdsRemovalPurchaseControllerProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -18,6 +19,8 @@ class PlacePageControllerComposite implements PlacePageController
|
|||
private final PlacePageController.SlideListener mSlideListener;
|
||||
@Nullable
|
||||
private final RoutingModeListener mRoutingModeListener;
|
||||
@Nullable
|
||||
private final GuidesGalleryListener mGuidesGalleryListener;
|
||||
@NonNull
|
||||
private final List<PlacePageController> mControllers = new ArrayList<>();
|
||||
@SuppressWarnings("NullableProblems")
|
||||
|
@ -26,11 +29,13 @@ class PlacePageControllerComposite implements PlacePageController
|
|||
|
||||
PlacePageControllerComposite(@NonNull AdsRemovalPurchaseControllerProvider adsProvider,
|
||||
@NonNull SlideListener slideListener,
|
||||
@Nullable RoutingModeListener routingModeListener)
|
||||
@Nullable RoutingModeListener routingModeListener,
|
||||
@Nullable GuidesGalleryListener galleryListener)
|
||||
{
|
||||
mAdsProvider = adsProvider;
|
||||
mSlideListener = slideListener;
|
||||
mRoutingModeListener = routingModeListener;
|
||||
mGuidesGalleryListener = galleryListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,7 +129,7 @@ class PlacePageControllerComposite implements PlacePageController
|
|||
mControllers.add(elevationProfileController);
|
||||
|
||||
PlacePageController guidesGalleryController =
|
||||
PlacePageFactory.createGuidesGalleryController(mSlideListener);
|
||||
PlacePageFactory.createGuidesGalleryController(mSlideListener, mGuidesGalleryListener);
|
||||
guidesGalleryController.initialize(activity);
|
||||
mControllers.add(guidesGalleryController);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.mapswithme.maps.widget.placepage;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.guides.GuidesGalleryListener;
|
||||
import com.mapswithme.maps.purchase.AdsRemovalPurchaseControllerProvider;
|
||||
|
||||
public class PlacePageFactory
|
||||
|
@ -11,9 +12,11 @@ public class PlacePageFactory
|
|||
public static PlacePageController createCompositePlacePageController(
|
||||
@NonNull AdsRemovalPurchaseControllerProvider provider,
|
||||
@NonNull PlacePageController.SlideListener slideListener,
|
||||
@NonNull RoutingModeListener routingModeListener)
|
||||
@NonNull RoutingModeListener routingModeListener,
|
||||
@Nullable GuidesGalleryListener galleryListener)
|
||||
{
|
||||
return new PlacePageControllerComposite(provider, slideListener, routingModeListener);
|
||||
return new PlacePageControllerComposite(provider, slideListener, routingModeListener,
|
||||
galleryListener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -35,9 +38,10 @@ public class PlacePageFactory
|
|||
|
||||
@NonNull
|
||||
static PlacePageController createGuidesGalleryController(
|
||||
@NonNull PlacePageController.SlideListener listener)
|
||||
@NonNull PlacePageController.SlideListener listener,
|
||||
@Nullable GuidesGalleryListener galleryListener)
|
||||
{
|
||||
GuidesGalleryViewRenderer renderer = new GuidesGalleryViewRenderer();
|
||||
GuidesGalleryViewRenderer renderer = new GuidesGalleryViewRenderer(galleryListener);
|
||||
return new SimplePlacePageController(R.id.guides_gallery_bottom_sheet, renderer, renderer,
|
||||
listener);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue