Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #324 from kinecosystem/ECO-1268/double_space
Browse files Browse the repository at this point in the history
Fix space to offers amount on marketplace
  • Loading branch information
OrenZak authored Jul 7, 2019
2 parents c20827b + 6901ec7 commit 371db2f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions sdk/src/main/java/com/kin/ecosystem/base/BaseViewHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
class OfferRecyclerAdapter extends BaseRecyclerAdapter<Offer, ViewHolder> {

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);
Expand Down Expand Up @@ -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
Expand All @@ -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() + " +");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions sdk/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
<dimen name="kinecosystem_transfer_header_size">18sp</dimen>
<dimen name="kinecosystem_transfer_title_size">16sp</dimen>

<dimen name="kinecosystem_offer_title_char_space">3dp</dimen>

</resources>

0 comments on commit 371db2f

Please sign in to comment.