[android] Added placeholder to local expert item

This commit is contained in:
Александр Зацепин 2017-12-07 14:34:25 +03:00 committed by Ilya Grechuhin
parent 3389f81c10
commit 6bc840f3b3
11 changed files with 39 additions and 38 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -20,6 +20,7 @@ import com.mapswithme.maps.ugc.Impress;
import com.mapswithme.maps.ugc.UGC;
import com.mapswithme.maps.widget.RatingView;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
import java.util.List;
@ -160,7 +161,7 @@ public class Holders
private final TextView mButton;
public LocalExpertViewHolder(@NonNull View itemView, @NonNull List<Items.LocalExpertItem> items,
@NonNull GalleryAdapter<?, Items.LocalExpertItem> adapter)
@NonNull GalleryAdapter<?, Items.LocalExpertItem> adapter)
{
super(itemView, items, adapter);
mTitle = (TextView) itemView.findViewById(R.id.name);
@ -174,34 +175,36 @@ public class Holders
{
super.bind(item);
if (!TextUtils.isEmpty(item.getPhotoUrl()))
{
Glide.with(mAvatar.getContext())
.load(item.getPhotoUrl())
.asBitmap()
.centerCrop()
.into(new BitmapImageViewTarget(mAvatar)
Glide.with(mAvatar.getContext())
.load(item.getPhotoUrl())
.asBitmap()
.centerCrop()
.placeholder(R.drawable.ic_local_expert_default)
.into(new BitmapImageViewTarget(mAvatar)
{
@Override
protected void setResource(Bitmap resource)
{
@Override
protected void setResource(Bitmap resource)
{
RoundedBitmapDrawable circularBitmapDrawable =
RoundedBitmapDrawableFactory.create(mAvatar.getContext().getResources(),
resource);
circularBitmapDrawable.setCircular(true);
mAvatar.setImageDrawable(circularBitmapDrawable);
}
});
}
RoundedBitmapDrawable circularBitmapDrawable =
RoundedBitmapDrawableFactory.create(mAvatar.getContext().getResources(),
resource);
circularBitmapDrawable.setCircular(true);
mAvatar.setImageDrawable(circularBitmapDrawable);
}
});
Context context = mButton.getContext();
String priceLabel;
if (item.getPrice() == 0 || TextUtils.isEmpty(item.getCurrency()))
if (item.getPrice() == 0 && TextUtils.isEmpty(item.getCurrency()))
{
priceLabel = context.getString(R.string.free);
}
else
priceLabel = context.getString(R.string.price_per_hour,
item.getCurrency()
+ String.valueOf(item.getPrice()));
{
String formattedPrice = Utils.formatCurrencyString(String.valueOf(item.getPrice()),
item.getCurrency());
priceLabel = context.getString(R.string.price_per_hour, formattedPrice);
}
UiUtils.setTextAndHideIfEmpty(mButton, priceLabel);
float rating = (float) item.getRating();
Impress impress = Impress.values()[UGC.nativeToImpress(rating)];
@ -221,8 +224,9 @@ public class Holders
public static class LocalExpertMoreItemViewHolder extends BaseViewHolder<Items.LocalExpertItem>
{
public LocalExpertMoreItemViewHolder(@NonNull View itemView, @NonNull List<Items.LocalExpertItem>
items, @NonNull GalleryAdapter<?, Items.LocalExpertItem> adapter)
public LocalExpertMoreItemViewHolder(@NonNull View itemView,
@NonNull List<Items.LocalExpertItem> items,
@NonNull GalleryAdapter<?, Items.LocalExpertItem> adapter)
{
super(itemView, items, adapter);
}

View file

@ -6,8 +6,8 @@ import android.view.View;
import com.mapswithme.maps.R;
public abstract class OfflineAdapterStrategy extends SingleItemAdapterStrategy<Holders
.OfflineViewHolder>
public abstract class OfflineAdapterStrategy
extends SingleItemAdapterStrategy<Holders.OfflineViewHolder>
{
protected OfflineAdapterStrategy(@Nullable String url)
{
@ -15,8 +15,8 @@ public abstract class OfflineAdapterStrategy extends SingleItemAdapterStrategy<H
}
@Override
protected Holders.OfflineViewHolder createViewHolder(@NonNull View itemView, @NonNull
GalleryAdapter<?, Items.Item> adapter)
protected Holders.OfflineViewHolder createViewHolder(@NonNull View itemView,
@NonNull GalleryAdapter<?, Items.Item> adapter)
{
return new Holders.OfflineViewHolder(itemView, mItems, adapter);
}

View file

@ -48,8 +48,8 @@ abstract class SingleItemAdapterStrategy<T extends Holders.BaseViewHolder<Items.
return createViewHolder(itemView, adapter);
}
protected abstract T createViewHolder(@NonNull View itemView, @NonNull GalleryAdapter<?, Items
.Item> adapter);
protected abstract T createViewHolder(@NonNull View itemView,
@NonNull GalleryAdapter<?, Items.Item> adapter);
@StringRes
protected abstract int getLabelForDetailsView();

View file

@ -28,8 +28,7 @@ public class LocalExpertsAdapterStrategy extends RegularAdapterStrategy<Items.Lo
@NonNull
@Override
protected Holders.BaseViewHolder<Items.LocalExpertItem> createProductViewHodler
(@NonNull ViewGroup parent, int viewType, @NonNull GalleryAdapter<?, Items.LocalExpertItem>
adapter)
(@NonNull ViewGroup parent, int viewType, @NonNull GalleryAdapter<?, Items.LocalExpertItem> adapter)
{
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_discovery_expert, parent,
@ -40,8 +39,7 @@ public class LocalExpertsAdapterStrategy extends RegularAdapterStrategy<Items.Lo
@NonNull
@Override
protected Holders.BaseViewHolder<Items.LocalExpertItem> createMoreProductsViewHolder
(@NonNull ViewGroup parent, int viewType, @NonNull GalleryAdapter<?, Items.LocalExpertItem>
adapter)
(@NonNull ViewGroup parent, int viewType, @NonNull GalleryAdapter<?, Items.LocalExpertItem> adapter)
{
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_viator_more, parent,
false);

View file

@ -29,8 +29,7 @@ public class SimpleErrorAdapterStrategy
@Override
protected Holders.SimpleViewHolder createViewHolder(@NonNull View itemView,
@NonNull GalleryAdapter<?, Items.Item>
adapter)
@NonNull GalleryAdapter<?, Items.Item> adapter)
{
return new Holders.SimpleViewHolder(itemView, mItems, adapter);
}

View file

@ -16,7 +16,7 @@ import com.mapswithme.maps.viator.ViatorProduct;
import java.util.ArrayList;
import java.util.List;
public class ViatorAdapterStrategy
public class ViatorAdapterStrategy
extends RegularAdapterStrategy<Items.ViatorItem>
{
ViatorAdapterStrategy(@NonNull ViatorProduct[] products, @Nullable String moreUrl)