forked from organicmaps/organicmaps
[android] Fixed review notes
https://github.com/mapsme/omim/pull/10934#discussion_r288519503 https://github.com/mapsme/omim/pull/10934#discussion_r288514258 https://github.com/mapsme/omim/pull/10934#discussion_r288513022 https://github.com/mapsme/omim/pull/10934#discussion_r288523019
This commit is contained in:
parent
f70b9a0b7c
commit
c429517595
21 changed files with 278 additions and 160 deletions
|
@ -181,20 +181,10 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove
|
|||
initFoodGallery();
|
||||
initLocalExpertsGallery();
|
||||
initSearchBasedAdapters();
|
||||
initCrossTrafficGallery(view);
|
||||
initCatalogPromoGallery(view);
|
||||
requestDiscoveryInfoAndInitAdapters();
|
||||
}
|
||||
|
||||
private void initCrossTrafficGallery(@NonNull View root)
|
||||
{
|
||||
mCatalogPromoRecycler = root.findViewById(R.id.catalog_promo_recycler);
|
||||
setLayoutManagerAndItemDecoration(requireContext(), mCatalogPromoRecycler);
|
||||
View titleView = root.findViewById(R.id.catalog_promo_title);
|
||||
titleView.setVisibility(View.VISIBLE);
|
||||
mCatalogPromoRecycler.setVisibility(View.VISIBLE);
|
||||
mCatalogPromoRecycler.setAdapter(Factory.createCatalogPromoLoadingAdapter());
|
||||
}
|
||||
|
||||
private void requestDiscoveryInfoAndInitAdapters()
|
||||
{
|
||||
NetworkPolicy.checkNetworkPolicy(getFragmentManager(), policy ->
|
||||
|
@ -219,6 +209,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());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -228,6 +220,16 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove
|
|||
R.id.localGuides);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private void requestDiscoveryInfo()
|
||||
{
|
||||
DiscoveryParams params;
|
||||
|
@ -300,14 +302,15 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove
|
|||
gallery.setAdapter(adapter);
|
||||
}
|
||||
|
||||
public void initCatalogPromoRecycler(@NonNull RegularAdapterStrategy.Item[] experts)
|
||||
public void onCatalogPromoReceived(@NonNull RegularAdapterStrategy.Item[] experts)
|
||||
{
|
||||
updateViewsVisibility(experts, R.id.catalog_promo_title, R.id.catalog_promo_recycler);
|
||||
String url = "";
|
||||
|
||||
ItemSelectedListener<RegularAdapterStrategy.Item> listener = new CatalogPromoSelectedListener();
|
||||
GalleryAdapter adapter = Factory.createCatalogPromoAdapter(experts, url, listener, DISCOVERY);
|
||||
mCatalogPromoRecycler.setAdapter(adapter);
|
||||
RecyclerView recycler = getGallery(R.id.catalog_promo_recycler);
|
||||
recycler.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.mapswithme.maps.gallery;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -8,9 +9,17 @@ import java.util.List;
|
|||
|
||||
public abstract class AdapterStrategy<VH extends Holders.BaseViewHolder<I>, I extends Items.Item>
|
||||
{
|
||||
@Nullable
|
||||
private final ItemSelectedListener<I> mListener;
|
||||
|
||||
@NonNull
|
||||
protected final List<I> mItems = new ArrayList<>();
|
||||
|
||||
AdapterStrategy(@Nullable ItemSelectedListener<I> listener)
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
abstract VH createViewHolder(@NonNull ViewGroup parent, int viewType,
|
||||
@NonNull GalleryAdapter<?, I> adapter);
|
||||
|
@ -23,4 +32,10 @@ public abstract class AdapterStrategy<VH extends Holders.BaseViewHolder<I>, I ex
|
|||
{
|
||||
return mItems.size();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ItemSelectedListener<I> getListener()
|
||||
{
|
||||
return mListener;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.mapswithme.maps.gallery;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
|
||||
public abstract class ErrorAdapterStrategy extends SingleItemAdapterStrategy<Holders.ErrorViewHolder>
|
||||
{
|
||||
protected ErrorAdapterStrategy(@Nullable String url,
|
||||
@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(url, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Holders.ErrorViewHolder createViewHolder(@NonNull View itemView)
|
||||
{
|
||||
return new Holders.ErrorViewHolder(itemView, mItems, getListener());
|
||||
}
|
||||
}
|
|
@ -10,20 +10,10 @@ public class GalleryAdapter<VH extends Holders.BaseViewHolder<I>, I extends Item
|
|||
{
|
||||
@NonNull
|
||||
private final AdapterStrategy<VH, I> mStrategy;
|
||||
@Nullable
|
||||
private final ItemSelectedListener<I> mListener;
|
||||
|
||||
public GalleryAdapter(@NonNull AdapterStrategy<VH, I> strategy,
|
||||
@Nullable ItemSelectedListener<I> listener)
|
||||
public GalleryAdapter(@NonNull AdapterStrategy<VH, I> strategy)
|
||||
{
|
||||
mStrategy = strategy;
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemSelectedListener<I> getListener()
|
||||
{
|
||||
return mListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.mapswithme.maps.gallery;
|
|||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.CallSuper;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
@ -35,10 +36,10 @@ public class Holders
|
|||
extends BaseViewHolder<T>
|
||||
{
|
||||
|
||||
public GenericMoreHolder(@NonNull View itemView, @NonNull List<T> items, @NonNull GalleryAdapter<?, T>
|
||||
adapter)
|
||||
public GenericMoreHolder(@NonNull View itemView, @NonNull List<T> items,
|
||||
@Nullable ItemSelectedListener<T> listener)
|
||||
{
|
||||
super(itemView, items, adapter.getListener());
|
||||
super(itemView, items, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,9 +57,9 @@ public class Holders
|
|||
{
|
||||
|
||||
public SearchMoreHolder(@NonNull View itemView, @NonNull List<Items.SearchItem> items,
|
||||
@NonNull GalleryAdapter<?, Items.SearchItem> adapter)
|
||||
@Nullable ItemSelectedListener<Items.SearchItem> listener)
|
||||
{
|
||||
super(itemView, items, adapter);
|
||||
super(itemView, items, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,9 +81,9 @@ public class Holders
|
|||
private final TextView mButton;
|
||||
|
||||
public LocalExpertViewHolder(@NonNull View itemView, @NonNull List<Items.LocalExpertItem> items,
|
||||
@NonNull GalleryAdapter<?, Items.LocalExpertItem> adapter)
|
||||
@Nullable ItemSelectedListener<Items.LocalExpertItem> listener)
|
||||
{
|
||||
super(itemView, items, adapter.getListener());
|
||||
super(itemView, items, listener);
|
||||
mAvatar = (ImageView) itemView.findViewById(R.id.avatar);
|
||||
mRating = (RatingView) itemView.findViewById(R.id.ratingView);
|
||||
mButton = (TextView) itemView.findViewById(R.id.button);
|
||||
|
@ -136,9 +137,10 @@ public class Holders
|
|||
@NonNull
|
||||
private final TextView mButton;
|
||||
|
||||
ActionButtonViewHolder(@NonNull View itemView, @NonNull List<T> items, @NonNull GalleryAdapter<?, T> adapter)
|
||||
ActionButtonViewHolder(@NonNull View itemView, @NonNull List<T> items,
|
||||
@Nullable ItemSelectedListener<T> listener)
|
||||
{
|
||||
super(itemView, items, adapter.getListener());
|
||||
super(itemView, items, listener);
|
||||
mButton = itemView.findViewById(R.id.button);
|
||||
mButton.setOnClickListener(this);
|
||||
itemView.findViewById(R.id.infoLayout).setOnClickListener(this);
|
||||
|
@ -181,7 +183,7 @@ public class Holders
|
|||
private final RatingView mPopularTagRating;
|
||||
|
||||
public SearchViewHolder(@NonNull View itemView, @NonNull List<Items.SearchItem> items,
|
||||
@NonNull GalleryAdapter<?, Items.SearchItem> adapter)
|
||||
@Nullable ItemSelectedListener<Items.SearchItem> adapter)
|
||||
{
|
||||
super(itemView, items, adapter);
|
||||
mSubtitle = itemView.findViewById(R.id.subtitle);
|
||||
|
@ -221,10 +223,10 @@ public class Holders
|
|||
@NonNull
|
||||
private final TextView mDistance;
|
||||
|
||||
public HotelViewHolder(@NonNull View itemView, @NonNull List<Items.SearchItem> items, @NonNull
|
||||
GalleryAdapter<?, Items.SearchItem> adapter)
|
||||
public HotelViewHolder(@NonNull View itemView, @NonNull List<Items.SearchItem> items, @Nullable
|
||||
ItemSelectedListener<Items.SearchItem> listener)
|
||||
{
|
||||
super(itemView, items, adapter);
|
||||
super(itemView, items, listener);
|
||||
mTitle = itemView.findViewById(R.id.title);
|
||||
mSubtitle = itemView.findViewById(R.id.subtitle);
|
||||
mRatingView = itemView.findViewById(R.id.ratingView);
|
||||
|
@ -339,9 +341,9 @@ public class Holders
|
|||
TextView mMore;
|
||||
|
||||
LoadingViewHolder(@NonNull View itemView, @NonNull List<Items.Item> items,
|
||||
@NonNull GalleryAdapter<?, Items.Item> adapter)
|
||||
@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(itemView, items, adapter.getListener());
|
||||
super(itemView, items, listener);
|
||||
mProgressBar = (ProgressBar) itemView.findViewById(R.id.pb__progress);
|
||||
mSubtitle = (TextView) itemView.findViewById(R.id.tv__subtitle);
|
||||
mMore = (TextView) itemView.findViewById(R.id.button);
|
||||
|
@ -378,9 +380,9 @@ public class Holders
|
|||
public static class SimpleViewHolder extends BaseViewHolder<Items.Item>
|
||||
{
|
||||
public SimpleViewHolder(@NonNull View itemView, @NonNull List<Items.Item> items,
|
||||
@NonNull GalleryAdapter<?, Items.Item> adapter)
|
||||
@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(itemView, items, adapter.getListener());
|
||||
super(itemView, items, listener);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,9 +390,9 @@ public class Holders
|
|||
{
|
||||
|
||||
ErrorViewHolder(@NonNull View itemView, @NonNull List<Items.Item> items,
|
||||
@NonNull GalleryAdapter<?, Items.Item> adapter)
|
||||
@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(itemView, items, adapter);
|
||||
super(itemView, items, listener);
|
||||
UiUtils.hide(mProgressBar);
|
||||
}
|
||||
}
|
||||
|
@ -398,9 +400,9 @@ public class Holders
|
|||
public static class OfflineViewHolder extends LoadingViewHolder
|
||||
{
|
||||
OfflineViewHolder(@NonNull View itemView, @NonNull List<Items.Item> items,
|
||||
@NonNull GalleryAdapter<?, Items.Item> adapter)
|
||||
@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(itemView, items, adapter);
|
||||
super(itemView, items, listener);
|
||||
UiUtils.hide(mProgressBar);
|
||||
}
|
||||
|
||||
|
@ -422,4 +424,39 @@ public class Holders
|
|||
listener.onActionButtonSelected(item, position);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CrossPromoLoadingHolder extends SimpleViewHolder
|
||||
{
|
||||
public CrossPromoLoadingHolder(@NonNull View itemView, @NonNull List<Items.Item> items,
|
||||
@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(itemView, items, listener);
|
||||
TextView subtitle = itemView.findViewById(R.id.subtitle);
|
||||
subtitle.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
public static class CatalogPromoHolder extends BaseViewHolder<RegularAdapterStrategy.Item>
|
||||
{
|
||||
@NonNull
|
||||
private final ImageView mImage;
|
||||
|
||||
public CatalogPromoHolder(@NonNull View itemView,
|
||||
@NonNull List<RegularAdapterStrategy.Item> items,
|
||||
@Nullable ItemSelectedListener<RegularAdapterStrategy.Item> listener)
|
||||
{
|
||||
super(itemView, items, listener);
|
||||
mImage = itemView.findViewById(R.id.image);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(@NonNull RegularAdapterStrategy.Item item)
|
||||
{
|
||||
super.bind(item);
|
||||
Glide.with(itemView.getContext())
|
||||
.load(Uri.parse(item.getUrl()))
|
||||
.placeholder(R.drawable.img_guides_gallery_placeholder)
|
||||
.into(mImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.mapswithme.maps.gallery;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
|
||||
public abstract class LoadingAdapterStrategy
|
||||
extends SingleItemAdapterStrategy<Holders.LoadingViewHolder>
|
||||
{
|
||||
|
||||
protected LoadingAdapterStrategy(@Nullable String url, @Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(url, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Holders.LoadingViewHolder createViewHolder(@NonNull View itemView)
|
||||
{
|
||||
return new Holders.LoadingViewHolder(itemView, mItems, getListener());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.mapswithme.maps.gallery;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
public abstract class OfflineAdapterStrategy
|
||||
extends SingleItemAdapterStrategy<Holders.OfflineViewHolder>
|
||||
{
|
||||
protected OfflineAdapterStrategy(@Nullable String url,
|
||||
@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(url, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Holders.OfflineViewHolder createViewHolder(@NonNull View itemView)
|
||||
{
|
||||
return new Holders.OfflineViewHolder(itemView, mItems, getListener());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLabelForDetailsView()
|
||||
{
|
||||
return R.string.details;
|
||||
}
|
||||
}
|
|
@ -14,8 +14,10 @@ public abstract class RegularAdapterStrategy<T extends RegularAdapterStrategy.It
|
|||
{
|
||||
private static final int MAX_ITEMS = 5;
|
||||
|
||||
public RegularAdapterStrategy(@NonNull List<T> items, @Nullable T moreItem)
|
||||
public RegularAdapterStrategy(@NonNull List<T> items, @Nullable T moreItem,
|
||||
@Nullable ItemSelectedListener<T> listener)
|
||||
{
|
||||
super(listener);
|
||||
boolean showMoreItem = moreItem != null && items.size() >= MAX_ITEMS;
|
||||
int size = showMoreItem ? MAX_ITEMS : items.size();
|
||||
for (int i = 0; i < size; i++)
|
||||
|
@ -35,9 +37,9 @@ public abstract class RegularAdapterStrategy<T extends RegularAdapterStrategy.It
|
|||
switch (viewType)
|
||||
{
|
||||
case TYPE_PRODUCT:
|
||||
return createProductViewHolder(parent, viewType, adapter);
|
||||
return createProductViewHolder(parent, viewType);
|
||||
case TYPE_MORE:
|
||||
return createMoreProductsViewHolder(parent, viewType, adapter);
|
||||
return createMoreProductsViewHolder(parent, viewType);
|
||||
default:
|
||||
throw new UnsupportedOperationException("This strategy doesn't support specified view type: "
|
||||
+ viewType);
|
||||
|
@ -58,12 +60,10 @@ public abstract class RegularAdapterStrategy<T extends RegularAdapterStrategy.It
|
|||
|
||||
@NonNull
|
||||
protected abstract Holders.BaseViewHolder<T> createProductViewHolder(@NonNull ViewGroup parent,
|
||||
int viewType,
|
||||
@NonNull GalleryAdapter<?, T> adapter);
|
||||
int viewType);
|
||||
@NonNull
|
||||
protected abstract Holders.BaseViewHolder<T> createMoreProductsViewHolder(@NonNull ViewGroup parent,
|
||||
int viewType,
|
||||
@NonNull GalleryAdapter<?, T> adapter);
|
||||
int viewType);
|
||||
|
||||
public static class Item extends Items.Item
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ import com.mapswithme.maps.MwmApplication;
|
|||
public abstract class SimpleSingleItemAdapterStrategy<T extends Holders.BaseViewHolder<Items.Item>>
|
||||
extends SingleItemAdapterStrategy<T>
|
||||
{
|
||||
protected SimpleSingleItemAdapterStrategy()
|
||||
protected SimpleSingleItemAdapterStrategy(@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(null);
|
||||
super(null, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,7 +30,7 @@ public abstract class SimpleSingleItemAdapterStrategy<T extends Holders.BaseView
|
|||
@NonNull GalleryAdapter<?, Items.Item> adapter)
|
||||
{
|
||||
View itemView = inflateView(LayoutInflater.from(parent.getContext()), parent);
|
||||
return createViewHolder(itemView, adapter);
|
||||
return createViewHolder(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,8 +15,10 @@ import com.mapswithme.maps.R;
|
|||
abstract class SingleItemAdapterStrategy<T extends Holders.BaseViewHolder<Items.Item>>
|
||||
extends AdapterStrategy<T, Items.Item>
|
||||
{
|
||||
SingleItemAdapterStrategy(@Nullable String url)
|
||||
SingleItemAdapterStrategy(@Nullable String url,
|
||||
@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(listener);
|
||||
buildItem(url);
|
||||
}
|
||||
|
||||
|
@ -45,11 +47,10 @@ abstract class SingleItemAdapterStrategy<T extends Holders.BaseViewHolder<Items.
|
|||
View itemView = inflateView(LayoutInflater.from(parent.getContext()), parent);
|
||||
TextView button = (TextView) itemView.findViewById(R.id.button);
|
||||
button.setText(getLabelForDetailsView());
|
||||
return createViewHolder(itemView, adapter);
|
||||
return createViewHolder(itemView);
|
||||
}
|
||||
|
||||
protected abstract T createViewHolder(@NonNull View itemView,
|
||||
@NonNull GalleryAdapter<?, Items.Item> adapter);
|
||||
protected abstract T createViewHolder(@NonNull View itemView);
|
||||
|
||||
@StringRes
|
||||
protected abstract int getLabelForDetailsView();
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
package com.mapswithme.maps.gallery.impl;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.gallery.GalleryAdapter;
|
||||
import com.mapswithme.maps.gallery.Holders;
|
||||
import com.mapswithme.maps.gallery.ItemSelectedListener;
|
||||
import com.mapswithme.maps.gallery.RegularAdapterStrategy;
|
||||
|
@ -19,55 +15,31 @@ import java.util.List;
|
|||
|
||||
class CatalogPromoAdapterStrategy extends RegularAdapterStrategy<RegularAdapterStrategy.Item>
|
||||
{
|
||||
CatalogPromoAdapterStrategy(@NonNull List<Item> items, @Nullable Item moreItem)
|
||||
CatalogPromoAdapterStrategy(@NonNull List<Item> items, @Nullable Item moreItem,
|
||||
@Nullable ItemSelectedListener<Item> listener)
|
||||
{
|
||||
super(items, moreItem);
|
||||
super(items, moreItem, listener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Holders.BaseViewHolder<Item> createProductViewHolder(@NonNull ViewGroup parent,
|
||||
int viewType,
|
||||
@NonNull GalleryAdapter<?, Item> adapter)
|
||||
int viewType)
|
||||
{
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.catalog_promo_item_card, parent,
|
||||
false);
|
||||
|
||||
return new CatalogPromoHolder(view, mItems, adapter.getListener());
|
||||
return new Holders.CatalogPromoHolder(view, mItems, getListener());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Holders.BaseViewHolder<Item> createMoreProductsViewHolder(@NonNull ViewGroup parent, int viewType,
|
||||
@NonNull GalleryAdapter<?, Item> adapter)
|
||||
protected Holders.BaseViewHolder<Item> createMoreProductsViewHolder(@NonNull ViewGroup parent,
|
||||
int viewType)
|
||||
{
|
||||
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<Item>
|
||||
{
|
||||
@NonNull
|
||||
private final ImageView mImage;
|
||||
|
||||
CatalogPromoHolder(@NonNull View itemView,
|
||||
@NonNull List<Item> items,
|
||||
@Nullable ItemSelectedListener<Item> 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);
|
||||
}
|
||||
View view = inflater.inflate(R.layout.item_search_more, parent, false);
|
||||
return new Holders.GenericMoreHolder<>(view, mItems, getListener());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
package com.mapswithme.maps.gallery.impl;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.gallery.ItemSelectedListener;
|
||||
import com.mapswithme.maps.gallery.Items;
|
||||
|
||||
class CatalogPromoErrorAdapterStrategy extends SimpleErrorAdapterStrategy
|
||||
{
|
||||
CatalogPromoErrorAdapterStrategy(@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(listener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent)
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
package com.mapswithme.maps.gallery.impl;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
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.ItemSelectedListener;
|
||||
import com.mapswithme.maps.gallery.Items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class CatalogPromoLoadingAdapterStrategy extends SimpleLoadingAdapterStrategy
|
||||
{
|
||||
CatalogPromoLoadingAdapterStrategy(@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(listener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent)
|
||||
|
@ -23,19 +26,8 @@ class CatalogPromoLoadingAdapterStrategy extends SimpleLoadingAdapterStrategy
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Holders.SimpleViewHolder createViewHolder(@NonNull View itemView, @NonNull GalleryAdapter<?, Items.Item> adapter)
|
||||
protected Holders.SimpleViewHolder createViewHolder(@NonNull View itemView)
|
||||
{
|
||||
return new CrossPromoLoadingHolder(itemView, mItems, adapter);
|
||||
}
|
||||
|
||||
private class CrossPromoLoadingHolder extends Holders.SimpleViewHolder
|
||||
{
|
||||
CrossPromoLoadingHolder(@NonNull View itemView, @NonNull List<Items.Item> items,
|
||||
@NonNull GalleryAdapter<?, Items.Item> adapter)
|
||||
{
|
||||
super(itemView, items, adapter);
|
||||
TextView subtitle = itemView.findViewById(R.id.subtitle);
|
||||
subtitle.setText("");
|
||||
}
|
||||
return new Holders.CrossPromoLoadingHolder(itemView, mItems, getListener());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,19 +31,19 @@ public class Factory
|
|||
@Nullable Items.MoreSearchItem item)
|
||||
{
|
||||
trackProductGalleryShownOrError(results, type, OFFLINE, placement);
|
||||
return new GalleryAdapter<>(new SearchBasedAdapterStrategy(results, item), listener);
|
||||
return new GalleryAdapter<>(new SearchBasedAdapterStrategy(results, item, listener));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static GalleryAdapter createSearchBasedLoadingAdapter()
|
||||
{
|
||||
return new GalleryAdapter<>(new SimpleLoadingAdapterStrategy(), null);
|
||||
return new GalleryAdapter<>(new SimpleLoadingAdapterStrategy(null));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static GalleryAdapter createSearchBasedErrorAdapter()
|
||||
{
|
||||
return new GalleryAdapter<>(new SimpleErrorAdapterStrategy(), null);
|
||||
return new GalleryAdapter<>(new SimpleErrorAdapterStrategy(null));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -54,7 +54,7 @@ public class Factory
|
|||
@NonNull GalleryPlacement placement)
|
||||
{
|
||||
trackProductGalleryShownOrError(results, type, OFFLINE, placement);
|
||||
return new GalleryAdapter<>(new HotelAdapterStrategy(results), listener);
|
||||
return new GalleryAdapter<>(new HotelAdapterStrategy(results, listener));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -65,19 +65,19 @@ public class Factory
|
|||
@NonNull GalleryPlacement placement)
|
||||
{
|
||||
trackProductGalleryShownOrError(experts, LOCAL_EXPERTS, ONLINE, placement);
|
||||
return new GalleryAdapter<>(new LocalExpertsAdapterStrategy(experts, expertsUrl), listener);
|
||||
return new GalleryAdapter<>(new LocalExpertsAdapterStrategy(experts, expertsUrl, listener));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static GalleryAdapter createLocalExpertsLoadingAdapter()
|
||||
{
|
||||
return new GalleryAdapter<>(new LocalExpertsLoadingAdapterStrategy(), null);
|
||||
return new GalleryAdapter<>(new LocalExpertsLoadingAdapterStrategy(null));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static GalleryAdapter createLocalExpertsErrorAdapter()
|
||||
{
|
||||
return new GalleryAdapter<>(new LocalExpertsErrorAdapterStrategy(), null);
|
||||
return new GalleryAdapter<>(new LocalExpertsErrorAdapterStrategy(null));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -88,20 +88,21 @@ public class Factory
|
|||
{
|
||||
Items.LocalExpertMoreItem item = new Items.LocalExpertMoreItem(url);
|
||||
CatalogPromoAdapterStrategy strategy = new CatalogPromoAdapterStrategy(Arrays.asList(items),
|
||||
item);
|
||||
return new GalleryAdapter<>(strategy, listener);
|
||||
item,
|
||||
listener);
|
||||
return new GalleryAdapter<>(strategy);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static GalleryAdapter createCatalogPromoLoadingAdapter()
|
||||
{
|
||||
return new GalleryAdapter<>(new CatalogPromoLoadingAdapterStrategy(), null);
|
||||
return new GalleryAdapter<>(new CatalogPromoLoadingAdapterStrategy(null));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static GalleryAdapter createCatalogPromoErrorAdapter()
|
||||
{
|
||||
return new GalleryAdapter<>(new CatalogPromoErrorAdapterStrategy(), null);
|
||||
return new GalleryAdapter<>(new CatalogPromoErrorAdapterStrategy(null));
|
||||
}
|
||||
|
||||
private static <Product> void trackProductGalleryShownOrError(@NonNull Product[] products,
|
||||
|
|
|
@ -7,8 +7,8 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.gallery.GalleryAdapter;
|
||||
import com.mapswithme.maps.gallery.Holders;
|
||||
import com.mapswithme.maps.gallery.ItemSelectedListener;
|
||||
import com.mapswithme.maps.gallery.Items;
|
||||
import com.mapswithme.maps.gallery.RegularAdapterStrategy;
|
||||
import com.mapswithme.maps.search.SearchResult;
|
||||
|
@ -17,36 +17,36 @@ import java.util.List;
|
|||
|
||||
public class HotelAdapterStrategy extends RegularAdapterStrategy<Items.SearchItem>
|
||||
{
|
||||
HotelAdapterStrategy(@NonNull SearchResult[] results)
|
||||
HotelAdapterStrategy(@NonNull SearchResult[] results,
|
||||
@Nullable ItemSelectedListener<Items.SearchItem> listener)
|
||||
{
|
||||
this(SearchBasedAdapterStrategy.convertItems(results), new Items.MoreSearchItem());
|
||||
this(SearchBasedAdapterStrategy.convertItems(results), new Items.MoreSearchItem(), listener);
|
||||
}
|
||||
|
||||
private HotelAdapterStrategy(@NonNull List<Items.SearchItem> items, @Nullable Items.SearchItem
|
||||
moreItem)
|
||||
private HotelAdapterStrategy(@NonNull List<Items.SearchItem> items,
|
||||
@Nullable Items.SearchItem moreItem,
|
||||
@Nullable ItemSelectedListener<Items.SearchItem> listener)
|
||||
{
|
||||
super(items, moreItem);
|
||||
super(items, moreItem, listener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Holders.BaseViewHolder<Items.SearchItem> createProductViewHolder
|
||||
(@NonNull ViewGroup parent, int viewType,
|
||||
@NonNull GalleryAdapter<?, Items.SearchItem> adapter)
|
||||
(@NonNull ViewGroup parent, int viewType)
|
||||
{
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_discovery_hotel_product, parent, false);
|
||||
return new Holders.HotelViewHolder(view, mItems, adapter);
|
||||
return new Holders.HotelViewHolder(view, mItems, getListener());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Holders.BaseViewHolder<Items.SearchItem> createMoreProductsViewHolder
|
||||
(@NonNull ViewGroup parent, int viewType,
|
||||
@NonNull GalleryAdapter<?, Items.SearchItem> adapter)
|
||||
(@NonNull ViewGroup parent, int viewType)
|
||||
{
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_search_more, parent,
|
||||
false);
|
||||
return new Holders.SearchMoreHolder(view, mItems, adapter);
|
||||
return new Holders.SearchMoreHolder(view, mItems, getListener());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ import android.view.ViewGroup;
|
|||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.discovery.LocalExpert;
|
||||
import com.mapswithme.maps.gallery.GalleryAdapter;
|
||||
import com.mapswithme.maps.gallery.Holders;
|
||||
import com.mapswithme.maps.gallery.ItemSelectedListener;
|
||||
import com.mapswithme.maps.gallery.Items;
|
||||
import com.mapswithme.maps.gallery.RegularAdapterStrategy;
|
||||
|
||||
|
@ -20,30 +20,31 @@ import static com.mapswithme.maps.gallery.Constants.TYPE_PRODUCT;
|
|||
|
||||
public class LocalExpertsAdapterStrategy extends RegularAdapterStrategy<Items.LocalExpertItem>
|
||||
{
|
||||
LocalExpertsAdapterStrategy(@NonNull LocalExpert[] experts, @Nullable String moreUrl)
|
||||
LocalExpertsAdapterStrategy(@NonNull LocalExpert[] experts, @Nullable String moreUrl,
|
||||
@Nullable ItemSelectedListener<Items.LocalExpertItem> listener)
|
||||
{
|
||||
super(convertItems(experts), new Items.LocalExpertMoreItem(moreUrl));
|
||||
super(convertItems(experts), new Items.LocalExpertMoreItem(moreUrl), listener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Holders.BaseViewHolder<Items.LocalExpertItem> createProductViewHolder
|
||||
(@NonNull ViewGroup parent, int viewType, @NonNull GalleryAdapter<?, Items.LocalExpertItem> adapter)
|
||||
(@NonNull ViewGroup parent, int viewType)
|
||||
{
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_discovery_expert, parent,
|
||||
false);
|
||||
return new Holders.LocalExpertViewHolder(view, mItems, adapter);
|
||||
return new Holders.LocalExpertViewHolder(view, mItems, getListener());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Holders.BaseViewHolder<Items.LocalExpertItem> createMoreProductsViewHolder
|
||||
(@NonNull ViewGroup parent, int viewType, @NonNull GalleryAdapter<?, Items.LocalExpertItem> adapter)
|
||||
(@NonNull ViewGroup parent, int viewType)
|
||||
{
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_viator_more, parent,
|
||||
false);
|
||||
return new Holders.GenericMoreHolder<>(view, mItems, adapter);
|
||||
return new Holders.GenericMoreHolder<>(view, mItems, getListener());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
package com.mapswithme.maps.gallery.impl;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.gallery.ItemSelectedListener;
|
||||
import com.mapswithme.maps.gallery.Items;
|
||||
|
||||
public class LocalExpertsErrorAdapterStrategy extends SimpleErrorAdapterStrategy
|
||||
{
|
||||
LocalExpertsErrorAdapterStrategy(@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(listener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent)
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
package com.mapswithme.maps.gallery.impl;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.gallery.ItemSelectedListener;
|
||||
import com.mapswithme.maps.gallery.Items;
|
||||
|
||||
public class LocalExpertsLoadingAdapterStrategy extends SimpleLoadingAdapterStrategy
|
||||
{
|
||||
LocalExpertsLoadingAdapterStrategy(@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(listener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent)
|
||||
|
|
|
@ -7,8 +7,8 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.gallery.GalleryAdapter;
|
||||
import com.mapswithme.maps.gallery.Holders;
|
||||
import com.mapswithme.maps.gallery.ItemSelectedListener;
|
||||
import com.mapswithme.maps.gallery.Items;
|
||||
import com.mapswithme.maps.gallery.RegularAdapterStrategy;
|
||||
import com.mapswithme.maps.search.SearchResult;
|
||||
|
@ -18,35 +18,37 @@ import java.util.List;
|
|||
|
||||
class SearchBasedAdapterStrategy extends RegularAdapterStrategy<Items.SearchItem>
|
||||
{
|
||||
SearchBasedAdapterStrategy(@NonNull SearchResult[] results, @Nullable Items.SearchItem moreItem)
|
||||
SearchBasedAdapterStrategy(@NonNull SearchResult[] results, @Nullable Items.SearchItem moreItem,
|
||||
@Nullable ItemSelectedListener<Items.SearchItem> listener)
|
||||
{
|
||||
this(convertItems(results), moreItem);
|
||||
this(convertItems(results), moreItem, listener);
|
||||
}
|
||||
|
||||
private SearchBasedAdapterStrategy(@NonNull List<Items.SearchItem> items,
|
||||
@Nullable Items.SearchItem moreItem)
|
||||
@Nullable Items.SearchItem moreItem,
|
||||
@Nullable ItemSelectedListener<Items.SearchItem> listener)
|
||||
{
|
||||
super(items, moreItem);
|
||||
super(items, moreItem, listener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Holders.BaseViewHolder<Items.SearchItem> createProductViewHolder
|
||||
(@NonNull ViewGroup parent, int viewType, @NonNull GalleryAdapter<?, Items.SearchItem> adapter)
|
||||
(@NonNull ViewGroup parent, int viewType)
|
||||
{
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_discovery_search, parent, false);
|
||||
return new Holders.SearchViewHolder(view, mItems, adapter);
|
||||
return new Holders.SearchViewHolder(view, mItems, getListener());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Holders.BaseViewHolder<Items.SearchItem> createMoreProductsViewHolder(
|
||||
@NonNull ViewGroup parent, int viewType, @NonNull GalleryAdapter<?, Items.SearchItem> adapter)
|
||||
@NonNull ViewGroup parent, int viewType)
|
||||
{
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_search_more, parent,
|
||||
false);
|
||||
return new Holders.SearchMoreHolder(view, mItems, adapter);
|
||||
return new Holders.SearchMoreHolder(view, mItems, getListener());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -1,19 +1,25 @@
|
|||
package com.mapswithme.maps.gallery.impl;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.gallery.GalleryAdapter;
|
||||
import com.mapswithme.maps.gallery.Holders;
|
||||
import com.mapswithme.maps.gallery.ItemSelectedListener;
|
||||
import com.mapswithme.maps.gallery.Items;
|
||||
import com.mapswithme.maps.gallery.SimpleSingleItemAdapterStrategy;
|
||||
|
||||
public class SimpleErrorAdapterStrategy
|
||||
extends SimpleSingleItemAdapterStrategy<Holders.SimpleViewHolder>
|
||||
{
|
||||
SimpleErrorAdapterStrategy(@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getTitle()
|
||||
{
|
||||
|
@ -28,9 +34,8 @@ public class SimpleErrorAdapterStrategy
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Holders.SimpleViewHolder createViewHolder(@NonNull View itemView,
|
||||
@NonNull GalleryAdapter<?, Items.Item> adapter)
|
||||
protected Holders.SimpleViewHolder createViewHolder(@NonNull View itemView)
|
||||
{
|
||||
return new Holders.SimpleViewHolder(itemView, mItems, adapter);
|
||||
return new Holders.SimpleViewHolder(itemView, mItems, getListener());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,25 @@
|
|||
package com.mapswithme.maps.gallery.impl;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.gallery.GalleryAdapter;
|
||||
import com.mapswithme.maps.gallery.Holders;
|
||||
import com.mapswithme.maps.gallery.ItemSelectedListener;
|
||||
import com.mapswithme.maps.gallery.Items;
|
||||
import com.mapswithme.maps.gallery.SimpleSingleItemAdapterStrategy;
|
||||
|
||||
public class SimpleLoadingAdapterStrategy
|
||||
extends SimpleSingleItemAdapterStrategy<Holders.SimpleViewHolder>
|
||||
{
|
||||
SimpleLoadingAdapterStrategy(@Nullable ItemSelectedListener<Items.Item> listener)
|
||||
{
|
||||
super(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getTitle()
|
||||
{
|
||||
|
@ -28,9 +34,8 @@ public class SimpleLoadingAdapterStrategy
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Holders.SimpleViewHolder createViewHolder(@NonNull View itemView,
|
||||
@NonNull GalleryAdapter<?, Items.Item> adapter)
|
||||
protected Holders.SimpleViewHolder createViewHolder(@NonNull View itemView)
|
||||
{
|
||||
return new Holders.SimpleViewHolder(itemView, mItems, adapter);
|
||||
return new Holders.SimpleViewHolder(itemView, mItems, getListener());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue