diff --git a/android/res/layout/catalog_promo_container.xml b/android/res/layout/catalog_promo_container.xml index fa026f0756..6ac97de775 100644 --- a/android/res/layout/catalog_promo_container.xml +++ b/android/res/layout/catalog_promo_container.xml @@ -14,7 +14,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone"/> - -{ - @NonNull - private List mCatalogPromoItems = Collections.emptyList(); - - @NonNull - @Override - public CatalogPromoHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) - { - LayoutInflater inflater = LayoutInflater.from(parent.getContext()); - View container = inflater.inflate(R.layout.catalog_promo_item_card, parent, false); - return new CatalogPromoHolder(container); - } - - @Override - public void onBindViewHolder(@NonNull CatalogPromoHolder holder, int position) - { - CatalogPromoItem item = mCatalogPromoItems.get(position); - holder.mSubTitle.setText(item.getDescription()); - holder.mTitle.setText(item.getTitle()); - Glide.with(holder.itemView.getContext()) - .load(Uri.parse(item.getImgUrl())) - .placeholder(R.drawable.img_guides_gallery_placeholder) - .into(holder.mImage); - } - - @Override - public int getItemCount() - { - return mCatalogPromoItems.size(); - } - - public void setData(@NonNull List items) - { - mCatalogPromoItems = items; - } - - static class CatalogPromoHolder extends RecyclerView.ViewHolder - { - @NonNull - private final ImageView mImage; - - @NonNull - private final TextView mTitle; - - @NonNull - private final TextView mSubTitle; - - CatalogPromoHolder(@NonNull View itemView) - { - super(itemView); - mImage = itemView.findViewById(R.id.image); - mTitle = itemView.findViewById(R.id.title); - mSubTitle = itemView.findViewById(R.id.subtitle); - } - } -} diff --git a/android/src/com/mapswithme/maps/discovery/DiscoveryFragment.java b/android/src/com/mapswithme/maps/discovery/DiscoveryFragment.java index 163af3e815..bd5bb7efb8 100644 --- a/android/src/com/mapswithme/maps/discovery/DiscoveryFragment.java +++ b/android/src/com/mapswithme/maps/discovery/DiscoveryFragment.java @@ -20,16 +20,13 @@ import android.view.ViewGroup; import com.mapswithme.maps.R; import com.mapswithme.maps.activity.CustomNavigateUpListener; -import com.mapswithme.maps.adapter.AdapterPositionConverter; -import com.mapswithme.maps.adapter.DefaultPositionConverter; -import com.mapswithme.maps.adapter.OnItemClickListener; -import com.mapswithme.maps.adapter.RecyclerCompositeAdapter; import com.mapswithme.maps.base.BaseMwmToolbarFragment; import com.mapswithme.maps.bookmarks.data.FeatureId; 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; @@ -45,8 +42,6 @@ import com.mapswithme.util.Utils; import com.mapswithme.util.statistics.GalleryType; import com.mapswithme.util.statistics.Statistics; -import java.util.Arrays; - import static com.mapswithme.util.statistics.Destination.EXTERNAL; import static com.mapswithme.util.statistics.Destination.PLACEPAGE; import static com.mapswithme.util.statistics.Destination.ROUTING; @@ -86,18 +81,6 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove @NonNull private RecyclerView mCatalogPromoRecycler; - @SuppressWarnings("NullableProblems") - @NonNull - private View mCatalogPromoPlaceholderCard; - - @SuppressWarnings("NullableProblems") - @NonNull - private CatalogPromoAdapter mCatalogPromoAdapter; - - @SuppressWarnings("NullableProblems") - @NonNull - private View mCatalogPromoProgress; - @Override public void onAttach(Context context) { @@ -205,22 +188,11 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove private void initCrossTrafficGallery(@NonNull View root) { mCatalogPromoRecycler = root.findViewById(R.id.catalog_promo_recycler); - mCatalogPromoPlaceholderCard = root.findViewById(R.id.catalog_promo_placeholder_card); - mCatalogPromoProgress = mCatalogPromoPlaceholderCard.findViewById(R.id.progress); - mCatalogPromoAdapter = new CatalogPromoAdapter(); - - MoreAdapter moreAdapter = new MoreAdapter(new CatalogPromoMoreClickListener()); setLayoutManagerAndItemDecoration(requireContext(), mCatalogPromoRecycler); - - AdapterPositionConverter converter = - new DefaultPositionConverter(Arrays.asList(mCatalogPromoAdapter, moreAdapter)); - RecyclerCompositeAdapter compositeAdapter = new RecyclerCompositeAdapter(converter, - mCatalogPromoAdapter, - moreAdapter); - - AdapterDataObserverWrapper observer = new AdapterDataObserverWrapper(compositeAdapter); - mCatalogPromoAdapter.registerAdapterDataObserver(observer); - mCatalogPromoRecycler.setAdapter(compositeAdapter); + View titleView = root.findViewById(R.id.catalog_promo_title); + titleView.setVisibility(View.VISIBLE); + mCatalogPromoRecycler.setVisibility(View.VISIBLE); + mCatalogPromoRecycler.setAdapter(Factory.createCatalogPromoLoadingAdapter()); } private void requestDiscoveryInfoAndInitAdapters() @@ -284,7 +256,8 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove ItemType.ATTRACTIONS); RecyclerView gallery = getGallery(R.id.attractions); GalleryAdapter adapter = Factory.createSearchBasedAdapter(results, listener, SEARCH_ATTRACTIONS, - DISCOVERY, new Items.MoreSearchItem()); + DISCOVERY, + new Items.MoreSearchItem()); gallery.setAdapter(adapter); } @@ -327,6 +300,16 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove gallery.setAdapter(adapter); } + public void initCatalogPromoRecycler(@NonNull RegularAdapterStrategy.Item[] experts) + { + updateViewsVisibility(experts, R.id.catalog_promo_title, R.id.catalog_promo_recycler); + String url = ""; + + ItemSelectedListener listener = new CatalogPromoSelectedListener(); + GalleryAdapter adapter = Factory.createCatalogPromoAdapter(experts, url, listener, DISCOVERY); + mCatalogPromoRecycler.setAdapter(adapter); + } + @Override public void onError(@NonNull ItemType type) { @@ -444,7 +427,8 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove @Override public void onItemSelectedInternal(@NonNull I item, int position) { - Statistics.INSTANCE.trackGalleryProductItemSelected(galleryType, DISCOVERY, position, EXTERNAL); + Statistics.INSTANCE.trackGalleryProductItemSelected(galleryType, DISCOVERY, position, + EXTERNAL); } @Override @@ -533,10 +517,22 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove void onShowSimilarObjects(@NonNull Items.SearchItem item, @NonNull ItemType type); } - private static class CatalogPromoMoreClickListener implements OnItemClickListener + private static class CatalogPromoSelectedListener implements ItemSelectedListener { @Override - public void onItemClick(@NonNull View v, @NonNull String item) + 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) { } diff --git a/android/src/com/mapswithme/maps/gallery/Holders.java b/android/src/com/mapswithme/maps/gallery/Holders.java index 4e21537c2d..6a8aacffec 100644 --- a/android/src/com/mapswithme/maps/gallery/Holders.java +++ b/android/src/com/mapswithme/maps/gallery/Holders.java @@ -38,13 +38,13 @@ public class Holders public GenericMoreHolder(@NonNull View itemView, @NonNull List items, @NonNull GalleryAdapter adapter) { - super(itemView, items, adapter); + super(itemView, items, adapter.getListener()); } @Override protected void onItemSelected(@NonNull T item, int position) { - ItemSelectedListener listener = mAdapter.getListener(); + ItemSelectedListener listener = getListener(); if (listener == null || TextUtils.isEmpty(item.getUrl())) return; @@ -64,7 +64,7 @@ public class Holders @Override protected void onItemSelected(@NonNull Items.SearchItem item, int position) { - ItemSelectedListener listener = mAdapter.getListener(); + ItemSelectedListener listener = getListener(); if (listener != null) listener.onMoreItemSelected(item); } @@ -82,8 +82,7 @@ public class Holders public LocalExpertViewHolder(@NonNull View itemView, @NonNull List items, @NonNull GalleryAdapter adapter) { - super(itemView, items, adapter); - mTitle = (TextView) itemView.findViewById(R.id.name); + super(itemView, items, adapter.getListener()); mAvatar = (ImageView) itemView.findViewById(R.id.avatar); mRating = (RatingView) itemView.findViewById(R.id.ratingView); mButton = (TextView) itemView.findViewById(R.id.button); @@ -137,10 +136,9 @@ public class Holders @NonNull private final TextView mButton; - ActionButtonViewHolder(@NonNull View itemView, @NonNull List items, @NonNull - GalleryAdapter adapter) + ActionButtonViewHolder(@NonNull View itemView, @NonNull List items, @NonNull GalleryAdapter adapter) { - super(itemView, items, adapter); + super(itemView, items, adapter.getListener()); mButton = itemView.findViewById(R.id.button); mButton.setOnClickListener(this); itemView.findViewById(R.id.infoLayout).setOnClickListener(this); @@ -154,7 +152,7 @@ public class Holders if (position == RecyclerView.NO_POSITION || mItems.isEmpty()) return; - ItemSelectedListener listener = mAdapter.getListener(); + ItemSelectedListener listener = getListener(); if (listener == null) return; @@ -186,7 +184,6 @@ public class Holders @NonNull GalleryAdapter adapter) { super(itemView, items, adapter); - mTitle = itemView.findViewById(R.id.title); mSubtitle = itemView.findViewById(R.id.subtitle); mDistance = itemView.findViewById(R.id.distance); mNumberRating = itemView.findViewById(R.id.counter_rating_view); @@ -202,7 +199,7 @@ public class Holders String localizedType = Utils.getLocalizedFeatureType(mSubtitle.getContext(), featureType); String title = TextUtils.isEmpty(item.getTitle()) ? localizedType : item.getTitle(); - UiUtils.setTextAndHideIfEmpty(mTitle, title); + UiUtils.setTextAndHideIfEmpty(getTitle(), title); UiUtils.setTextAndHideIfEmpty(mSubtitle, localizedType); UiUtils.setTextAndHideIfEmpty(mDistance, item.getDistance()); UiUtils.showIf(item.getPopularity().getType() == Popularity.Type.POPULAR, mPopularTagRating); @@ -278,20 +275,20 @@ public class Holders implements View.OnClickListener { @NonNull - TextView mTitle; + private final TextView mTitle; + @Nullable + private final ItemSelectedListener mListener; @NonNull protected final List mItems; - @NonNull - final GalleryAdapter mAdapter; - BaseViewHolder(@NonNull View itemView, @NonNull List items, - @NonNull GalleryAdapter adapter) + public BaseViewHolder(@NonNull View itemView, @NonNull List items, + @Nullable ItemSelectedListener listener) { super(itemView); - mTitle = itemView.findViewById(R.id.tv__title); + mTitle = itemView.findViewById(R.id.title); + mListener = listener; itemView.setOnClickListener(this); mItems = items; - mAdapter = adapter; } public void bind(@NonNull I item) @@ -309,14 +306,26 @@ public class Holders onItemSelected(mItems.get(position), position); } + @NonNull + protected TextView getTitle() + { + return mTitle; + } + protected void onItemSelected(@NonNull I item, int position) { - ItemSelectedListener listener = mAdapter.getListener(); + ItemSelectedListener listener = getListener(); if (listener == null || TextUtils.isEmpty(item.getUrl())) return; listener.onItemSelected(item, position); } + + @Nullable + protected ItemSelectedListener getListener() + { + return mListener; + } } public static class LoadingViewHolder extends BaseViewHolder @@ -332,7 +341,7 @@ public class Holders LoadingViewHolder(@NonNull View itemView, @NonNull List items, @NonNull GalleryAdapter adapter) { - super(itemView, items, adapter); + super(itemView, items, adapter.getListener()); mProgressBar = (ProgressBar) itemView.findViewById(R.id.pb__progress); mSubtitle = (TextView) itemView.findViewById(R.id.tv__subtitle); mMore = (TextView) itemView.findViewById(R.id.button); @@ -359,10 +368,10 @@ public class Holders @Override protected void onItemSelected(@NonNull Items.Item item, int position) { - if (mAdapter.getListener() == null || TextUtils.isEmpty(item.getUrl())) + if (getListener() == null || TextUtils.isEmpty(item.getUrl())) return; - mAdapter.getListener().onActionButtonSelected(item, position); + getListener().onActionButtonSelected(item, position); } } @@ -371,8 +380,7 @@ public class Holders public SimpleViewHolder(@NonNull View itemView, @NonNull List items, @NonNull GalleryAdapter adapter) { - super(itemView, items, adapter); - mTitle = (TextView) itemView.findViewById(R.id.message); + super(itemView, items, adapter.getListener()); } } @@ -407,10 +415,11 @@ public class Holders @Override protected void onItemSelected(@NonNull Items.Item item, int position) { - if (mAdapter.getListener() == null) + ItemSelectedListener listener = getListener(); + if (listener == null) return; - mAdapter.getListener().onActionButtonSelected(item, position); + listener.onActionButtonSelected(item, position); } } } diff --git a/android/src/com/mapswithme/maps/gallery/Items.java b/android/src/com/mapswithme/maps/gallery/Items.java index 8e702ef1ea..e5b1e9dbb4 100644 --- a/android/src/com/mapswithme/maps/gallery/Items.java +++ b/android/src/com/mapswithme/maps/gallery/Items.java @@ -27,7 +27,7 @@ public class Items @Nullable String url, @Nullable String photoUrl, double price, @NonNull String currency, double rating) { - super(viewType, title, url, null); + super(viewType, title, null, url); mPhotoUrl = photoUrl; mPrice = price; mCurrency = currency; @@ -74,7 +74,7 @@ public class Items public SearchItem(@NonNull SearchResult result) { - super(TYPE_PRODUCT, result.name, null, result.description.featureType); + super(TYPE_PRODUCT, result.name, result.description.featureType, null); mResult = result; } diff --git a/android/src/com/mapswithme/maps/gallery/RegularAdapterStrategy.java b/android/src/com/mapswithme/maps/gallery/RegularAdapterStrategy.java index 905aba8a6b..6f0fab3f6a 100644 --- a/android/src/com/mapswithme/maps/gallery/RegularAdapterStrategy.java +++ b/android/src/com/mapswithme/maps/gallery/RegularAdapterStrategy.java @@ -70,8 +70,8 @@ public abstract class RegularAdapterStrategy +{ + CatalogPromoAdapterStrategy(@NonNull List items, @Nullable Item moreItem) + { + super(items, moreItem); + } + + @NonNull + @Override + protected Holders.BaseViewHolder createProductViewHolder(@NonNull ViewGroup parent, + int viewType, + @NonNull GalleryAdapter adapter) + { + View view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.catalog_promo_item_card, parent, + false); + + return new CatalogPromoHolder(view, mItems, adapter.getListener()); + } + + @NonNull + @Override + protected Holders.BaseViewHolder createMoreProductsViewHolder(@NonNull ViewGroup parent, int viewType, + @NonNull GalleryAdapter adapter) + { + LayoutInflater inflater = LayoutInflater.from(parent.getContext()); + View view = inflater.inflate(R.layout.item_search_more, parent,false); + return new Holders.GenericMoreHolder<>(view, mItems, adapter); + } + + public static class CatalogPromoHolder extends Holders.BaseViewHolder + { + @NonNull + private final ImageView mImage; + + CatalogPromoHolder(@NonNull View itemView, + @NonNull List items, + @Nullable ItemSelectedListener listener) + { + super(itemView, items, listener); + mImage = itemView.findViewById(R.id.image); + } + + @Override + public void bind(@NonNull Item item) + { + super.bind(item); + Glide.with(itemView.getContext()) + .load(Uri.parse(item.getUrl())) + .placeholder(R.drawable.img_guides_gallery_placeholder) + .into(mImage); + } + } +} diff --git a/android/src/com/mapswithme/maps/gallery/impl/CatalogPromoErrorAdapterStrategy.java b/android/src/com/mapswithme/maps/gallery/impl/CatalogPromoErrorAdapterStrategy.java new file mode 100644 index 0000000000..676a52aa6b --- /dev/null +++ b/android/src/com/mapswithme/maps/gallery/impl/CatalogPromoErrorAdapterStrategy.java @@ -0,0 +1,18 @@ +package com.mapswithme.maps.gallery.impl; + +import android.support.annotation.NonNull; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.mapswithme.maps.R; + +class CatalogPromoErrorAdapterStrategy extends SimpleErrorAdapterStrategy +{ + @NonNull + @Override + protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) + { + return inflater.inflate(R.layout.catalog_promo_placeholder_card, parent, false); + } +} diff --git a/android/src/com/mapswithme/maps/gallery/impl/CatalogPromoLoadingAdapterStrategy.java b/android/src/com/mapswithme/maps/gallery/impl/CatalogPromoLoadingAdapterStrategy.java new file mode 100644 index 0000000000..408984404a --- /dev/null +++ b/android/src/com/mapswithme/maps/gallery/impl/CatalogPromoLoadingAdapterStrategy.java @@ -0,0 +1,41 @@ +package com.mapswithme.maps.gallery.impl; + +import android.support.annotation.NonNull; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.mapswithme.maps.R; +import com.mapswithme.maps.gallery.GalleryAdapter; +import com.mapswithme.maps.gallery.Holders; +import com.mapswithme.maps.gallery.Items; + +import java.util.List; + +class CatalogPromoLoadingAdapterStrategy extends SimpleLoadingAdapterStrategy +{ + @NonNull + @Override + protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) + { + return inflater.inflate(R.layout.catalog_promo_placeholder_card, parent, false); + } + + @Override + protected Holders.SimpleViewHolder createViewHolder(@NonNull View itemView, @NonNull GalleryAdapter adapter) + { + return new CrossPromoLoadingHolder(itemView, mItems, adapter); + } + + private class CrossPromoLoadingHolder extends Holders.SimpleViewHolder + { + CrossPromoLoadingHolder(@NonNull View itemView, @NonNull List items, + @NonNull GalleryAdapter adapter) + { + super(itemView, items, adapter); + TextView subtitle = itemView.findViewById(R.id.subtitle); + subtitle.setText(""); + } + } +} diff --git a/android/src/com/mapswithme/maps/gallery/impl/Factory.java b/android/src/com/mapswithme/maps/gallery/impl/Factory.java index e51d1a690b..844694f4f4 100644 --- a/android/src/com/mapswithme/maps/gallery/impl/Factory.java +++ b/android/src/com/mapswithme/maps/gallery/impl/Factory.java @@ -7,12 +7,15 @@ import com.mapswithme.maps.discovery.LocalExpert; 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.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 static com.mapswithme.util.statistics.GalleryState.OFFLINE; import static com.mapswithme.util.statistics.GalleryState.ONLINE; import static com.mapswithme.util.statistics.GalleryType.LOCAL_EXPERTS; @@ -77,6 +80,30 @@ public class Factory return new GalleryAdapter<>(new LocalExpertsErrorAdapterStrategy(), null); } + @NonNull + public static GalleryAdapter createCatalogPromoAdapter(@NonNull RegularAdapterStrategy.Item[] items, + @Nullable String url, + @Nullable ItemSelectedListener listener, + @NonNull GalleryPlacement placement) + { + Items.LocalExpertMoreItem item = new Items.LocalExpertMoreItem(url); + CatalogPromoAdapterStrategy strategy = new CatalogPromoAdapterStrategy(Arrays.asList(items), + item); + return new GalleryAdapter<>(strategy, listener); + } + + @NonNull + public static GalleryAdapter createCatalogPromoLoadingAdapter() + { + return new GalleryAdapter<>(new CatalogPromoLoadingAdapterStrategy(), null); + } + + @NonNull + public static GalleryAdapter createCatalogPromoErrorAdapter() + { + return new GalleryAdapter<>(new CatalogPromoErrorAdapterStrategy(), null); + } + private static void trackProductGalleryShownOrError(@NonNull Product[] products, @NonNull GalleryType type, @NonNull GalleryState state, diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index a85f2f0f39..446718ef1f 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -43,10 +43,7 @@ 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.AdapterPositionConverter; -import com.mapswithme.maps.adapter.DefaultPositionConverter; import com.mapswithme.maps.adapter.OnItemClickListener; -import com.mapswithme.maps.adapter.RecyclerCompositeAdapter; import com.mapswithme.maps.ads.LocalAdInfo; import com.mapswithme.maps.api.ParsedMwmRequest; import com.mapswithme.maps.bookmarks.PlaceDescriptionActivity; @@ -57,10 +54,6 @@ import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut; import com.mapswithme.maps.bookmarks.data.MapObject; import com.mapswithme.maps.bookmarks.data.Metadata; import com.mapswithme.maps.bookmarks.data.RoadWarningMarkType; -import com.mapswithme.maps.discovery.AdapterDataObserverWrapper; -import com.mapswithme.maps.discovery.CatalogPromoAdapter; -import com.mapswithme.maps.discovery.CatalogPromoItem; -import com.mapswithme.maps.discovery.MoreAdapter; import com.mapswithme.maps.downloader.CountryItem; import com.mapswithme.maps.downloader.DownloaderStatusIcon; import com.mapswithme.maps.downloader.MapManager; @@ -70,6 +63,7 @@ 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.impl.Factory; import com.mapswithme.maps.location.LocationHelper; import com.mapswithme.maps.review.Review; import com.mapswithme.maps.routing.RoutingController; @@ -324,22 +318,10 @@ public class PlacePageView extends NestedScrollView @Nullable private RoutingModeListener mRoutingModeListener; - @SuppressWarnings("NullableProblems") - @NonNull - private CatalogPromoAdapter mCatalogPromoAdapter; - @SuppressWarnings("NullableProblems") @NonNull private RecyclerView mCatalogPromoRecycler; - @SuppressWarnings("NullableProblems") - @NonNull - private View mCatalogPromoPlaceholderCard; - - @SuppressWarnings("NullableProblems") - @NonNull - private View mCatalogPromoProgress; - void setScrollable(boolean scrollable) { mScrollable = scrollable; @@ -836,27 +818,19 @@ public class PlacePageView extends NestedScrollView private void initCatalogPromoView() { mCatalogPromoRecycler = findViewById(R.id.catalog_promo_recycler); - mCatalogPromoPlaceholderCard = findViewById(R.id.catalog_promo_placeholder_card); - mCatalogPromoProgress = mCatalogPromoPlaceholderCard.findViewById(R.id.progress); - mCatalogPromoAdapter = new CatalogPromoAdapter(); - - MoreAdapter moreAdapter = new MoreAdapter(new MoreClickListener()); + mCatalogPromoRecycler.setVisibility(VISIBLE); + View titleView = findViewById(R.id.catalog_promo_title); + titleView.setVisibility(VISIBLE); + com.mapswithme.maps.gallery.GalleryAdapter adapter = Factory.createCatalogPromoLoadingAdapter(); mCatalogPromoRecycler.setNestedScrollingEnabled(false); - mCatalogPromoRecycler.setLayoutManager(new LinearLayoutManager(getContext(), - LinearLayoutManager.HORIZONTAL, - false)); - mCatalogPromoRecycler.addItemDecoration( - ItemDecoratorFactory.createSponsoredGalleryDecorator(getContext(), - LinearLayoutManager.HORIZONTAL)); - AdapterPositionConverter converter = - new DefaultPositionConverter(Arrays.asList(mCatalogPromoAdapter, moreAdapter)); - RecyclerCompositeAdapter compositeAdapter = new RecyclerCompositeAdapter(converter, - mCatalogPromoAdapter, - moreAdapter); - - AdapterDataObserverWrapper observer = new AdapterDataObserverWrapper(compositeAdapter); - mCatalogPromoAdapter.registerAdapterDataObserver(observer); - mCatalogPromoRecycler.setAdapter(compositeAdapter); + LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), + LinearLayoutManager.HORIZONTAL, + false); + mCatalogPromoRecycler.setLayoutManager(layoutManager); + RecyclerView.ItemDecoration decor = + ItemDecoratorFactory.createSponsoredGalleryDecorator(getContext(), LinearLayoutManager.HORIZONTAL); + mCatalogPromoRecycler.addItemDecoration(decor); + mCatalogPromoRecycler.setAdapter(adapter); } private void initHotelFacilitiesView()