[android] Added cross promo integration

This commit is contained in:
Dmitry Donskoy 2019-06-13 14:07:00 +03:00 committed by Aleksandr Zatsepin
parent 5c9c012602
commit 4fd2c90bbb
13 changed files with 412 additions and 96 deletions

View file

@ -26,13 +26,16 @@ import com.mapswithme.maps.bookmarks.data.MapObject;
import com.mapswithme.maps.gallery.GalleryAdapter;
import com.mapswithme.maps.gallery.ItemSelectedListener;
import com.mapswithme.maps.gallery.Items;
import com.mapswithme.maps.gallery.RegularAdapterStrategy;
import com.mapswithme.maps.gallery.impl.Factory;
import com.mapswithme.maps.gallery.impl.LoggableItemSelectedListener;
import com.mapswithme.maps.metrics.UserActionsLogger;
import com.mapswithme.maps.promo.PromoCityGallery;
import com.mapswithme.maps.promo.PromoEntity;
import com.mapswithme.maps.search.SearchResult;
import com.mapswithme.maps.widget.PlaceholderView;
import com.mapswithme.maps.widget.ToolbarController;
import com.mapswithme.maps.widget.placepage.LoadingCatalogPromoListener;
import com.mapswithme.maps.widget.placepage.RegularCatalogPromoListener;
import com.mapswithme.maps.widget.recycler.ItemDecoratorFactory;
import com.mapswithme.util.ConnectionState;
import com.mapswithme.util.Language;
@ -42,6 +45,8 @@ import com.mapswithme.util.Utils;
import com.mapswithme.util.statistics.GalleryType;
import com.mapswithme.util.statistics.Statistics;
import java.util.List;
import static com.mapswithme.util.statistics.Destination.EXTERNAL;
import static com.mapswithme.util.statistics.Destination.PLACEPAGE;
import static com.mapswithme.util.statistics.Destination.ROUTING;
@ -77,6 +82,14 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove
}
};
@SuppressWarnings("NullableProblems")
@NonNull
private View mTitleView;
@SuppressWarnings("NullableProblems")
@NonNull
private RecyclerView mCatalogPromoRecycler;
@Override
public void onAttach(Context context)
{
@ -206,7 +219,8 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove
RecyclerView localGuides = getGallery(R.id.localGuides);
localGuides.setAdapter(Factory.createLocalExpertsLoadingAdapter());
RecyclerView promoRecycler = getGallery(R.id.catalog_promo_recycler);
promoRecycler.setAdapter(Factory.createCatalogPromoLoadingAdapter());
LoadingCatalogPromoListener<Items.Item> listener = new LoadingCatalogPromoListener<>(requireActivity());
promoRecycler.setAdapter(Factory.createCatalogPromoLoadingAdapter(listener));
return;
}
@ -219,11 +233,11 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove
private void initCatalogPromoGallery(@NonNull View root)
{
RecyclerView catalogPromoRecycler = root.findViewById(R.id.catalog_promo_recycler);
setLayoutManagerAndItemDecoration(requireContext(), catalogPromoRecycler);
View titleView = root.findViewById(R.id.catalog_promo_title);
titleView.setVisibility(View.VISIBLE);
catalogPromoRecycler.setVisibility(View.VISIBLE);
mCatalogPromoRecycler = root.findViewById(R.id.catalog_promo_recycler);
setLayoutManagerAndItemDecoration(requireContext(), mCatalogPromoRecycler);
mTitleView = root.findViewById(R.id.catalog_promo_title);
mTitleView.setVisibility(View.VISIBLE);
mCatalogPromoRecycler.setVisibility(View.VISIBLE);
}
private void requestDiscoveryInfo()
@ -298,13 +312,14 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove
gallery.setAdapter(adapter);
}
public void onCatalogPromoReceived(@NonNull RegularAdapterStrategy.Item[] experts)
public void onCatalogPromoReceived(@NonNull PromoCityGallery experts)
{
updateViewsVisibility(experts, R.id.catalog_promo_title, R.id.catalog_promo_recycler);
String url = "";
UiUtils.hideIf(experts.getItems().isEmpty(), mCatalogPromoRecycler, mTitleView);
String url = experts.getMoreUrl();
ItemSelectedListener<RegularAdapterStrategy.Item> listener = new CatalogPromoSelectedListener();
GalleryAdapter adapter = Factory.createCatalogPromoAdapter(experts, url, listener, DISCOVERY);
ItemSelectedListener<PromoEntity> listener = new RegularCatalogPromoListener(requireActivity());
List<PromoEntity> data = PromoCityGallery.toEntities(experts);
GalleryAdapter adapter = Factory.createCatalogPromoAdapter(requireContext(), data, url, listener, DISCOVERY);
RecyclerView recycler = getGallery(R.id.catalog_promo_recycler);
recycler.setAdapter(adapter);
}
@ -515,25 +530,4 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove
void onShowFilter();
void onShowSimilarObjects(@NonNull Items.SearchItem item, @NonNull ItemType type);
}
private static class CatalogPromoSelectedListener implements ItemSelectedListener<RegularAdapterStrategy.Item>
{
@Override
public void onItemSelected(@NonNull RegularAdapterStrategy.Item item, int position)
{
}
@Override
public void onMoreItemSelected(@NonNull RegularAdapterStrategy.Item item)
{
}
@Override
public void onActionButtonSelected(@NonNull RegularAdapterStrategy.Item item, int position)
{
}
}
}

View file

@ -21,6 +21,7 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import com.mapswithme.HotelUtils;
import com.mapswithme.maps.R;
import com.mapswithme.maps.promo.PromoEntity;
import com.mapswithme.maps.search.Popularity;
import com.mapswithme.maps.ugc.Impress;
import com.mapswithme.maps.ugc.UGC;
@ -334,11 +335,11 @@ public class Holders
implements View.OnClickListener
{
@NonNull
ProgressBar mProgressBar;
final ProgressBar mProgressBar;
@NonNull
TextView mSubtitle;
final TextView mSubtitle;
@NonNull
TextView mMore;
final TextView mMore;
LoadingViewHolder(@NonNull View itemView, @NonNull List<Items.Item> items,
@Nullable ItemSelectedListener<Items.Item> listener)
@ -436,21 +437,21 @@ public class Holders
}
}
public static class CatalogPromoHolder extends BaseViewHolder<RegularAdapterStrategy.Item>
public static class CatalogPromoHolder extends BaseViewHolder<PromoEntity>
{
@NonNull
private final ImageView mImage;
public CatalogPromoHolder(@NonNull View itemView,
@NonNull List<RegularAdapterStrategy.Item> items,
@Nullable ItemSelectedListener<RegularAdapterStrategy.Item> listener)
@NonNull List<PromoEntity> items,
@Nullable ItemSelectedListener<PromoEntity> listener)
{
super(itemView, items, listener);
mImage = itemView.findViewById(R.id.image);
}
@Override
public void bind(@NonNull RegularAdapterStrategy.Item item)
public void bind(@NonNull PromoEntity item)
{
super.bind(item);
Glide.with(itemView.getContext())

View file

@ -10,20 +10,21 @@ import com.mapswithme.maps.R;
import com.mapswithme.maps.gallery.Holders;
import com.mapswithme.maps.gallery.ItemSelectedListener;
import com.mapswithme.maps.gallery.RegularAdapterStrategy;
import com.mapswithme.maps.promo.PromoEntity;
import java.util.List;
class CatalogPromoAdapterStrategy extends RegularAdapterStrategy<RegularAdapterStrategy.Item>
class CatalogPromoAdapterStrategy extends RegularAdapterStrategy<PromoEntity>
{
CatalogPromoAdapterStrategy(@NonNull List<Item> items, @Nullable Item moreItem,
@Nullable ItemSelectedListener<Item> listener)
CatalogPromoAdapterStrategy(@NonNull List<PromoEntity> items, @Nullable PromoEntity moreItem,
@Nullable ItemSelectedListener<PromoEntity> listener)
{
super(items, moreItem, listener);
}
@NonNull
@Override
protected Holders.BaseViewHolder<Item> createProductViewHolder(@NonNull ViewGroup parent,
protected Holders.BaseViewHolder<PromoEntity> createProductViewHolder(@NonNull ViewGroup parent,
int viewType)
{
View view = LayoutInflater.from(parent.getContext())
@ -35,7 +36,7 @@ class CatalogPromoAdapterStrategy extends RegularAdapterStrategy<RegularAdapterS
@NonNull
@Override
protected Holders.BaseViewHolder<Item> createMoreProductsViewHolder(@NonNull ViewGroup parent,
protected Holders.BaseViewHolder<PromoEntity> createMoreProductsViewHolder(@NonNull ViewGroup parent,
int viewType)
{
LayoutInflater inflater = LayoutInflater.from(parent.getContext());

View file

@ -1,20 +1,23 @@
package com.mapswithme.maps.gallery.impl;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.mapswithme.maps.R;
import com.mapswithme.maps.discovery.LocalExpert;
import com.mapswithme.maps.gallery.Constants;
import com.mapswithme.maps.gallery.GalleryAdapter;
import com.mapswithme.maps.gallery.ItemSelectedListener;
import com.mapswithme.maps.gallery.Items;
import com.mapswithme.maps.gallery.RegularAdapterStrategy;
import com.mapswithme.maps.promo.PromoEntity;
import com.mapswithme.maps.search.SearchResult;
import com.mapswithme.util.statistics.GalleryPlacement;
import com.mapswithme.util.statistics.GalleryState;
import com.mapswithme.util.statistics.GalleryType;
import com.mapswithme.util.statistics.Statistics;
import java.util.Arrays;
import java.util.List;
import static com.mapswithme.util.statistics.GalleryState.OFFLINE;
import static com.mapswithme.util.statistics.GalleryState.ONLINE;
@ -81,28 +84,31 @@ public class Factory
}
@NonNull
public static GalleryAdapter createCatalogPromoAdapter(@NonNull RegularAdapterStrategy.Item[] items,
public static GalleryAdapter createCatalogPromoAdapter(@NonNull Context context,
@NonNull List<PromoEntity> items,
@Nullable String url,
@Nullable ItemSelectedListener<RegularAdapterStrategy.Item> listener,
@Nullable ItemSelectedListener<PromoEntity> listener,
@NonNull GalleryPlacement placement)
{
Items.LocalExpertMoreItem item = new Items.LocalExpertMoreItem(url);
CatalogPromoAdapterStrategy strategy = new CatalogPromoAdapterStrategy(Arrays.asList(items),
PromoEntity item = new PromoEntity(Constants.TYPE_MORE,
context.getString(R.string.placepage_more_button),
null, url, null);
CatalogPromoAdapterStrategy strategy = new CatalogPromoAdapterStrategy(items,
item,
listener);
return new GalleryAdapter<>(strategy);
}
@NonNull
public static GalleryAdapter createCatalogPromoLoadingAdapter()
public static GalleryAdapter createCatalogPromoLoadingAdapter(@NonNull ItemSelectedListener<Items.Item> listener)
{
return new GalleryAdapter<>(new CatalogPromoLoadingAdapterStrategy(null));
return new GalleryAdapter<>(new CatalogPromoLoadingAdapterStrategy(listener));
}
@NonNull
public static GalleryAdapter createCatalogPromoErrorAdapter()
public static GalleryAdapter createCatalogPromoErrorAdapter(@NonNull ItemSelectedListener<Items.Item> listener)
{
return new GalleryAdapter<>(new CatalogPromoErrorAdapterStrategy(null));
return new GalleryAdapter<>(new CatalogPromoErrorAdapterStrategy(listener));
}
private static <Product> void trackProductGalleryShownOrError(@NonNull Product[] products,

View file

@ -4,29 +4,70 @@ import android.graphics.Color;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import com.mapswithme.maps.gallery.Constants;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public final class PromoCityGallery
{
@NonNull
private Item[] mItems;
private final List<Item> mItems;
@NonNull
private String mMoreUrl;
private final String mMoreUrl;
PromoCityGallery(@NonNull Item[] items, @NonNull String moreUrl)
{
mItems = Collections.unmodifiableList(Arrays.asList(items));
mMoreUrl = moreUrl;
}
@NonNull
public static List<PromoEntity> toEntities(@NonNull PromoCityGallery gallery)
{
List<PromoEntity> items = new ArrayList<>();
for (PromoCityGallery.Item each : gallery.getItems())
{
PromoEntity item = new PromoEntity(Constants.TYPE_PRODUCT,
each.getName(),
each.getAuthor().getName(),
each.getUrl(),
each.getLuxCategory());
items.add(item);
}
return items;
}
@NonNull
public List<Item> getItems()
{
return mItems;
}
@NonNull
public String getMoreUrl()
{
return mMoreUrl;
}
public static final class Item
{
@NonNull
private String mName;
private final String mName;
@NonNull
private String mUrl;
private final String mUrl;
@NonNull
private String mImageUrl;
private final String mImageUrl;
@NonNull
private String mAccess;
private final String mAccess;
@NonNull
private String mTier;
private final String mTier;
@NonNull
private Author mAuthor;
private final Author mAuthor;
@NonNull
private LuxCategory mLuxCategory;
private final LuxCategory mLuxCategory;
public Item(@NonNull String name, @NonNull String url, @NonNull String imageUrl,
@NonNull String access, @NonNull String tier, @NonNull Author author,
@ -40,12 +81,55 @@ public final class PromoCityGallery
mAuthor = author;
mLuxCategory = luxCategory;
}
@NonNull
public String getName()
{
return mName;
}
@NonNull
public String getUrl()
{
return mUrl;
}
@NonNull
public String getImageUrl()
{
return mImageUrl;
}
@NonNull
public String getAccess()
{
return mAccess;
}
@NonNull
public String getTier()
{
return mTier;
}
@NonNull
public Author getAuthor()
{
return mAuthor;
}
@NonNull
public LuxCategory getLuxCategory()
{
return mLuxCategory;
}
}
public static final class Author
{
@NonNull
private String mId;
@NonNull
private String mName;
@ -54,32 +138,58 @@ public final class PromoCityGallery
mId = id;
mName = name;
}
@NonNull
public String getId()
{
return mId;
}
@NonNull
public String getName()
{
return mName;
}
}
public static final class LuxCategory
{
@NonNull
private String mName;
private final String mName;
@ColorInt
private int mColor;
private final int mColor;
LuxCategory(@NonNull String name, @NonNull String color)
{
mName = name;
try
{
mColor = Color.parseColor("#" + color);
mColor = makeColorSafely(color);
}
@NonNull
public String getName()
{
return mName;
}
public int getColor()
{
return mColor;
}
private static int makeColorSafely(@NonNull String color)
{
try {
return makeColor(color);
}
catch (IllegalArgumentException exception)
{
mColor = 0;
catch (IllegalArgumentException exception) {
return 0;
}
}
}
private static int makeColor(@NonNull String color)
{
return Color.parseColor("#" + color);
}
PromoCityGallery(@NonNull Item[] items, @NonNull String moreUrl)
{
mItems = items;
mMoreUrl = moreUrl;
}
}

View file

@ -0,0 +1,25 @@
package com.mapswithme.maps.promo;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.mapswithme.maps.gallery.RegularAdapterStrategy;
public class PromoEntity extends RegularAdapterStrategy.Item
{
@NonNull
private final PromoCityGallery.LuxCategory mCategory;
public PromoEntity(int type, @NonNull String title, @Nullable String subtitle,
@Nullable String url, @NonNull PromoCityGallery.LuxCategory category)
{
super(type, title, subtitle, url);
mCategory = category;
}
@NonNull
public PromoCityGallery.LuxCategory getCategory()
{
return mCategory;
}
}

View file

@ -0,0 +1,37 @@
package com.mapswithme.maps.widget.placepage;
import android.app.Activity;
import android.support.annotation.NonNull;
import com.mapswithme.maps.gallery.ItemSelectedListener;
import com.mapswithme.maps.gallery.Items;
public abstract class AbstractActionButtonCatalogPromoListener<T extends Items.Item> implements ItemSelectedListener<T>
{
@NonNull
private final Activity mActivity;
public AbstractActionButtonCatalogPromoListener(@NonNull Activity activity)
{
mActivity = activity;
}
@Override
public void onItemSelected(@NonNull T item, int position)
{
}
@Override
public void onMoreItemSelected(@NonNull T item)
{
}
@NonNull
protected Activity getActivity()
{
return mActivity;
}
}

View file

@ -30,6 +30,8 @@ import com.mapswithme.maps.bookmarks.data.MapObject;
import com.mapswithme.maps.bookmarks.data.RoadWarningMarkType;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.location.LocationListener;
import com.mapswithme.maps.promo.Promo;
import com.mapswithme.maps.promo.PromoCityGallery;
import com.mapswithme.maps.purchase.AdsRemovalPurchaseControllerProvider;
import com.mapswithme.util.Graphics;
import com.mapswithme.util.NetworkPolicy;
@ -553,7 +555,7 @@ public class BottomSheetPlacePageController implements PlacePageController, Loca
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState)
{
// No op.
Promo.INSTANCE.setListener(new LoadingCatalogPromoListener(mPlacePage));
}
@Override
@ -589,7 +591,7 @@ public class BottomSheetPlacePageController implements PlacePageController, Loca
@Override
public void onActivityDestroyed(Activity activity)
{
// No op.
Promo.INSTANCE.setListener(null);
}
private static boolean isSettlingState(@AnchorBottomSheetBehavior.State int state)
@ -669,6 +671,29 @@ public class BottomSheetPlacePageController implements PlacePageController, Loca
close();
}
private static class LoadingCatalogPromoListener implements Promo.Listener
{
@NonNull
private final PlacePageView mPlacePage;
LoadingCatalogPromoListener(@NonNull PlacePageView placePage)
{
mPlacePage = placePage;
}
@Override
public void onCityGalleryReceived(@NonNull PromoCityGallery gallery)
{
mPlacePage.setCatalogPromoGallery(gallery);
}
@Override
public void onErrorReceived()
{
mPlacePage.setCatalogPromoGalleryError();
}
}
private class PlacePageGestureListener extends GestureDetector.SimpleOnGestureListener
{
@Override

View file

@ -0,0 +1,22 @@
package com.mapswithme.maps.widget.placepage;
import android.app.Activity;
import android.support.annotation.NonNull;
import com.mapswithme.maps.gallery.Items;
import com.mapswithme.util.Utils;
public class ErrorCatalogPromoListener<T extends Items.Item> extends AbstractActionButtonCatalogPromoListener<T>
{
public ErrorCatalogPromoListener(@NonNull Activity activity)
{
super(activity);
}
@Override
public void onActionButtonSelected(@NonNull Items.Item item, int position)
{
Utils.showSystemSettings(getActivity());
}
}

View file

@ -0,0 +1,22 @@
package com.mapswithme.maps.widget.placepage;
import android.app.Activity;
import android.support.annotation.NonNull;
import com.mapswithme.maps.gallery.ItemSelectedListener;
import com.mapswithme.maps.gallery.Items;
import com.mapswithme.util.Utils;
public class LoadingCatalogPromoListener<T extends Items.Item> extends AbstractActionButtonCatalogPromoListener<T>
{
public LoadingCatalogPromoListener(@NonNull Activity activity)
{
super(activity);
}
@Override
public void onActionButtonSelected(@NonNull T item, int position)
{
Utils.openUrl(getActivity(), item.getUrl());
}
}

View file

@ -43,7 +43,6 @@ import com.mapswithme.maps.Framework;
import com.mapswithme.maps.MwmActivity;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.maps.adapter.OnItemClickListener;
import com.mapswithme.maps.ads.LocalAdInfo;
import com.mapswithme.maps.api.ParsedMwmRequest;
import com.mapswithme.maps.bookmarks.PlaceDescriptionActivity;
@ -63,8 +62,12 @@ import com.mapswithme.maps.editor.data.TimeFormatUtils;
import com.mapswithme.maps.editor.data.Timetable;
import com.mapswithme.maps.gallery.FullScreenGalleryActivity;
import com.mapswithme.maps.gallery.GalleryActivity;
import com.mapswithme.maps.gallery.Items;
import com.mapswithme.maps.gallery.impl.Factory;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.promo.Promo;
import com.mapswithme.maps.promo.PromoCityGallery;
import com.mapswithme.maps.promo.PromoEntity;
import com.mapswithme.maps.review.Review;
import com.mapswithme.maps.routing.RoutingController;
import com.mapswithme.maps.search.FilterUtils;
@ -92,6 +95,7 @@ import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
import com.mapswithme.util.sharing.ShareOption;
import com.mapswithme.util.statistics.AlohaHelper;
import com.mapswithme.util.statistics.GalleryPlacement;
import com.mapswithme.util.statistics.Statistics;
import java.util.ArrayList;
@ -322,6 +326,10 @@ public class PlacePageView extends NestedScrollView
@NonNull
private RecyclerView mCatalogPromoRecycler;
@SuppressWarnings("NullableProblems")
@NonNull
private View mCatalogPromoTitleView;
void setScrollable(boolean scrollable)
{
mScrollable = scrollable;
@ -737,7 +745,7 @@ public class PlacePageView extends NestedScrollView
mRoutingModeListener.toggleRouteSettings(roadType);
Statistics.INSTANCE.trackEvent(Statistics.EventName.PP_DRIVING_OPTIONS_ACTION,
Statistics.params().add(Statistics.EventParam.TYPE,
roadType.name()));
roadType.name()));
}
private void initPlaceDescriptionView()
@ -818,17 +826,21 @@ public class PlacePageView extends NestedScrollView
private void initCatalogPromoView()
{
mCatalogPromoRecycler = findViewById(R.id.catalog_promo_recycler);
mCatalogPromoRecycler.setVisibility(GONE);
View titleView = findViewById(R.id.catalog_promo_title);
titleView.setVisibility(GONE);
com.mapswithme.maps.gallery.GalleryAdapter adapter = Factory.createCatalogPromoLoadingAdapter();
mCatalogPromoRecycler.setVisibility(VISIBLE);
mCatalogPromoTitleView = findViewById(R.id.catalog_promo_title);
mCatalogPromoTitleView.setVisibility(VISIBLE);
LoadingCatalogPromoListener<Items.Item> listener =
new LoadingCatalogPromoListener<>(getActivity());
com.mapswithme.maps.gallery.GalleryAdapter adapter =
Factory.createCatalogPromoLoadingAdapter(listener);
mCatalogPromoRecycler.setNestedScrollingEnabled(false);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(),
LinearLayoutManager.HORIZONTAL,
false);
mCatalogPromoRecycler.setLayoutManager(layoutManager);
RecyclerView.ItemDecoration decor =
ItemDecoratorFactory.createSponsoredGalleryDecorator(getContext(), LinearLayoutManager.HORIZONTAL);
ItemDecoratorFactory.createSponsoredGalleryDecorator(getContext(),
LinearLayoutManager.HORIZONTAL);
mCatalogPromoRecycler.addItemDecoration(decor);
mCatalogPromoRecycler.setAdapter(adapter);
}
@ -1054,11 +1066,13 @@ public class PlacePageView extends NestedScrollView
break;
case Sponsored.TYPE_OPENTABLE:
if (mMapObject != null)
Statistics.INSTANCE.trackRestaurantEvent(PP_SPONSORED_OPENTABLE, info, mMapObject);
Statistics.INSTANCE.trackRestaurantEvent(PP_SPONSORED_OPENTABLE, info,
mMapObject);
break;
case Sponsored.TYPE_PARTNER:
if (mMapObject != null && !info.getPartnerName().isEmpty())
Statistics.INSTANCE.trackSponsoredObjectEvent(PP_SPONSORED_ACTION, info, mMapObject);
Statistics.INSTANCE.trackSponsoredObjectEvent(PP_SPONSORED_ACTION, info,
mMapObject);
break;
case Sponsored.TYPE_NONE:
break;
@ -1079,7 +1093,7 @@ public class PlacePageView extends NestedScrollView
Utils.openUrl(getContext(), info.getUrl());
else
Utils.openUrl(getContext(), isDetails ? info.getDescriptionUrl()
: info.getMoreUrl());
: info.getMoreUrl());
}
}
catch (ActivityNotFoundException e)
@ -1180,6 +1194,9 @@ public class PlacePageView extends NestedScrollView
attachCountry(country);
}
// Promo.INSTANCE.nativeRequestCityGallery(policy, "");
boolean hasPromoGallery = mSponsored != null && mSponsored.getType() == Sponsored.TYPE_PROMO_CATALOG;
toggleCatalogPromoGallery(hasPromoGallery);
refreshViews(policy);
}
@ -1298,7 +1315,8 @@ public class PlacePageView extends NestedScrollView
refreshSponsoredViews(mapObject, priceInfo);
}
private void refreshSponsoredViews(@NonNull MapObject mapObject, @Nullable HotelPriceInfo priceInfo)
private void refreshSponsoredViews(@NonNull MapObject mapObject,
@Nullable HotelPriceInfo priceInfo)
{
boolean isPriceEmpty = TextUtils.isEmpty(mSponsoredPrice);
@SuppressWarnings("ConstantConditions")
@ -2068,13 +2086,30 @@ public class PlacePageView extends NestedScrollView
return mPreview.getHeight();
}
private static class MoreClickListener implements OnItemClickListener<String>
public void toggleCatalogPromoGallery(boolean enabled)
{
@Override
public void onItemClick(@NonNull View v, @NonNull String item)
{
mCatalogPromoRecycler.setVisibility(enabled ? VISIBLE : GONE);
mCatalogPromoTitleView.setVisibility(enabled ? VISIBLE : GONE);
}
}
public void setCatalogPromoGallery(@NonNull PromoCityGallery gallery)
{
String url = gallery.getMoreUrl();
List<PromoEntity> items = PromoCityGallery.toEntities(gallery);
RegularCatalogPromoListener promoListener = new RegularCatalogPromoListener(getActivity());
com.mapswithme.maps.gallery.GalleryAdapter adapter = Factory.createCatalogPromoAdapter(getContext(),
items,
url,
promoListener,
GalleryPlacement.PLACEPAGE);
mCatalogPromoRecycler.setAdapter(adapter);
}
public void setCatalogPromoGalleryError()
{
ErrorCatalogPromoListener<Items.Item> listener = new ErrorCatalogPromoListener<>(getActivity());
com.mapswithme.maps.gallery.GalleryAdapter adapter = Factory.createCatalogPromoErrorAdapter(listener);
mCatalogPromoRecycler.setAdapter(adapter);
}
private class EditBookmarkClickListener implements OnClickListener

View file

@ -0,0 +1,37 @@
package com.mapswithme.maps.widget.placepage;
import android.app.Activity;
import android.support.annotation.NonNull;
import com.mapswithme.maps.bookmarks.BookmarksCatalogActivity;
import com.mapswithme.maps.gallery.ItemSelectedListener;
import com.mapswithme.maps.promo.PromoEntity;
public class RegularCatalogPromoListener implements ItemSelectedListener<PromoEntity>
{
@NonNull
private final Activity mActivity;
public RegularCatalogPromoListener(@NonNull Activity activity)
{
mActivity = activity;
}
@Override
public void onItemSelected(@NonNull PromoEntity item, int position)
{
BookmarksCatalogActivity.startByGuidesPageDeeplink(mActivity, item.getUrl());
}
@Override
public void onMoreItemSelected(@NonNull PromoEntity item)
{
BookmarksCatalogActivity.startByGuidesPageDeeplink(mActivity, item.getUrl());
}
@Override
public void onActionButtonSelected(@NonNull PromoEntity item, int position)
{
BookmarksCatalogActivity.startByGuidesPageDeeplink(mActivity, item.getUrl());
}
}

View file

@ -28,9 +28,10 @@ public final class Sponsored
public static final int TYPE_OPENTABLE = 2;
public static final int TYPE_PARTNER = 3;
public static final int TYPE_HOLIDAY = 4;
public static final int TYPE_PROMO_CATALOG = 5;
@Retention(RetentionPolicy.SOURCE)
@IntDef({ TYPE_NONE, TYPE_BOOKING, TYPE_OPENTABLE, TYPE_PARTNER, TYPE_HOLIDAY })
@IntDef({ TYPE_NONE, TYPE_BOOKING, TYPE_OPENTABLE, TYPE_PARTNER, TYPE_PROMO_CATALOG })
public @interface SponsoredType {}
static class FacilityType