From f0d97e18edaac60c7a45ea5dd7e999d28de1b738 Mon Sep 17 00:00:00 2001 From: OrenZak Date: Wed, 3 Jul 2019 11:18:50 +0300 Subject: [PATCH] add space to amount if spend type --- .../com/kin/ecosystem/base/BaseViewHolder.java | 8 ++++++++ .../marketplace/view/OfferRecyclerAdapter.java | 14 ++++++++++++++ .../layout/kinecosystem_offer_recycler_item.xml | 1 - sdk/src/main/res/values/dimens.xml | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sdk/src/main/java/com/kin/ecosystem/base/BaseViewHolder.java b/sdk/src/main/java/com/kin/ecosystem/base/BaseViewHolder.java index 38d541f1..502319c4 100644 --- a/sdk/src/main/java/com/kin/ecosystem/base/BaseViewHolder.java +++ b/sdk/src/main/java/com/kin/ecosystem/base/BaseViewHolder.java @@ -83,6 +83,14 @@ protected void setViewTopMargin(@IdRes int viewId, int topMargin) { } } + protected void setViewLeftMargin(@IdRes int viewId, int leftMargin) { + View view = getView(viewId); + if (view != null) { + ViewGroup.MarginLayoutParams params = (MarginLayoutParams)view.getLayoutParams(); + params.leftMargin = leftMargin; + } + } + /** * @param viewId The view id. * @param value The text to put in the text view. diff --git a/sdk/src/main/java/com/kin/ecosystem/marketplace/view/OfferRecyclerAdapter.java b/sdk/src/main/java/com/kin/ecosystem/marketplace/view/OfferRecyclerAdapter.java index 0a31984d..383c7ec0 100644 --- a/sdk/src/main/java/com/kin/ecosystem/marketplace/view/OfferRecyclerAdapter.java +++ b/sdk/src/main/java/com/kin/ecosystem/marketplace/view/OfferRecyclerAdapter.java @@ -20,6 +20,8 @@ class OfferRecyclerAdapter extends BaseRecyclerAdapter { private static final float WIDTH_RATIO = 0.205f; + private static final int AMOUNT_SPACE_EARN = 0; + private static int AMOUNT_SPACE_SPEND = -1; OfferRecyclerAdapter() { super(R.layout.kinecosystem_offer_recycler_item); @@ -62,6 +64,9 @@ protected void init(Context context) { imageSize = (int) (DeviceUtils.getScreenWidth() * WIDTH_RATIO); earnColor = ContextCompat.getColor(context, R.color.kinecosystem_purple); spendColor = ContextCompat.getColor(context, R.color.kinecosystem_green); + if(AMOUNT_SPACE_SPEND == -1) { + AMOUNT_SPACE_SPEND = context.getResources().getDimensionPixelSize(R.dimen.kinecosystem_offer_title_char_space); + } } @Override @@ -70,12 +75,21 @@ protected void bindObject(final Offer item) { setTitle(item); setAmountText(item); setText(R.id.sub_title, item.getDescription()); + setSpaceAmount(item.getOfferType()); if (item.getOfferType() == OfferType.EARN && item.getContentType() == ContentTypeEnum.POLL) { setOnItemClickListener(getOnItemClickListener()); } } + private void setSpaceAmount(OfferType offerType) { + if (offerType == OfferType.EARN) { + setViewLeftMargin(R.id.kin_logo, AMOUNT_SPACE_EARN); + } else { + setViewLeftMargin(R.id.kin_logo, AMOUNT_SPACE_SPEND); + } + } + private void setTitle(final Offer item) { if(item.getOfferType() == OfferType.EARN) { setText(R.id.title, item.getTitle() + " +"); diff --git a/sdk/src/main/res/layout/kinecosystem_offer_recycler_item.xml b/sdk/src/main/res/layout/kinecosystem_offer_recycler_item.xml index eb98ed51..137005d3 100644 --- a/sdk/src/main/res/layout/kinecosystem_offer_recycler_item.xml +++ b/sdk/src/main/res/layout/kinecosystem_offer_recycler_item.xml @@ -44,7 +44,6 @@ android:id="@+id/kin_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/kinecosystem_tiny_margin" app:layout_constraintBottom_toBottomOf="@id/title" app:layout_constraintHorizontal_bias="0" app:layout_constraintStart_toEndOf="@id/title" diff --git a/sdk/src/main/res/values/dimens.xml b/sdk/src/main/res/values/dimens.xml index c3805818..79b00778 100644 --- a/sdk/src/main/res/values/dimens.xml +++ b/sdk/src/main/res/values/dimens.xml @@ -12,4 +12,6 @@ 18sp 16sp + 3dp + \ No newline at end of file