diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 30d425fa..2e1e42d1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -17,7 +17,6 @@ android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true" /> - + implements View.OnClickListener { +import java.util.ArrayList; +import java.util.List; + +public class PaymentModeRvAdapter extends RecyclerView.Adapter implements SelectedRedBorderDecoration.RedItemSelectionListener { private final OnPaymentModeSelectionListener listener; + private int selectedItemPosition; + private List data; public PaymentModeRvAdapter(OnPaymentModeSelectionListener listener) { this.listener = listener; + this.data=new ArrayList<>(); + this.selectedItemPosition=-1; } @Override @@ -23,24 +33,52 @@ public class PaymentModeRvAdapter extends RecyclerView.Adapter0) + { + this.selectedItemPosition=position; + if(listener!=null) + { + notifyItemChanged(selectedItemPosition); + listener.onPaymentModeSelected(data.get(selectedItemPosition)); + } + } + } + + + public void setData(List data) + { + if(data!=null&&data.size()>0) + { + this.data=data; + notifyDataSetChanged(); + } } @Override - public void onClick(View v) { - if (listener != null) - listener.onPaymentModeSelected(); + public int getSelectedRedItemPosition() { + return this.selectedItemPosition; } public interface OnPaymentModeSelectionListener { - void onPaymentModeSelected(); + void onPaymentModeSelected(PaymentMode selectedData); } } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/PaymentModeMapper.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/PaymentModeMapper.java new file mode 100644 index 00000000..2d6bbaac --- /dev/null +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/PaymentModeMapper.java @@ -0,0 +1,25 @@ +package com.gmeremit.online.gmeremittance_native.exchange_rate.model; + +import com.gmeremit.online.gmeremittance_native.R; + +public class PaymentModeMapper { + + public static int getPaymentModeImageFromId(String id) + { + switch(id) + { + case "1": + return R.drawable.ic_cash_image; + + case "2": + return R.drawable.ic_bank_image; + + case "3": + return R.drawable.ic_home_delivery; + + default: + return -1; + + } + } +} diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/CountryPaymentService.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/CountryPaymentService.java new file mode 100644 index 00000000..876a4f84 --- /dev/null +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/CountryPaymentService.java @@ -0,0 +1,64 @@ +package com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +public class CountryPaymentService { + @SerializedName("country") + @Expose + private String country; + @SerializedName("countryCode") + @Expose + private String countryCode; + @SerializedName("countryId") + @Expose + private String countryId; + @SerializedName("currency") + @Expose + private List currency = null; + @SerializedName("serviceAvailable") + @Expose + private List serviceAvailable = null; + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getCountryCode() { + return countryCode; + } + + public void setCountryCode(String countryCode) { + this.countryCode = countryCode; + } + + public String getCountryId() { + return countryId; + } + + public void setCountryId(String countryId) { + this.countryId = countryId; + } + + public List getCurrency() { + return currency; + } + + public void setCurrency(List currency) { + this.currency = currency; + } + + public List getServiceAvailable() { + return serviceAvailable; + } + + public void setServiceAvailable(List serviceAvailable) { + this.serviceAvailable = serviceAvailable; + } +} diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/PaymentMode.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/PaymentMode.java new file mode 100644 index 00000000..0d5657cf --- /dev/null +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/PaymentMode.java @@ -0,0 +1,34 @@ +package com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class PaymentMode { + @SerializedName("id") + @Expose + private String id; + @SerializedName("text") + @Expose + private String text; + + public PaymentMode(String id, String text) { + this.id = id; + this.text = text; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } +} diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java index 74969d78..b5f3c4dc 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java @@ -2,11 +2,18 @@ package com.gmeremit.online.gmeremittance_native.exchange_rate.view; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.RecyclerView; import android.widget.EditText; import com.gmeremit.online.gmeremittance_native.R; +import com.gmeremit.online.gmeremittance_native.customwidgets.CustomPaddingRv; +import com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView; import com.gmeremit.online.gmeremittance_native.exchange_rate.adapter.PaymentModeRvAdapter; +import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentMode; + +import java.util.ArrayList; +import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; @@ -15,13 +22,16 @@ public class ExchangeMethodV2Activity extends AppCompatActivity implements Payme @BindView(R.id.sendAmountEdTxt) EditText sendMoneyEditText; -// -// @BindView(R.id.receiveAmountEdTxt) -// EditText recieveMoneyEditText; + + @BindView(R.id.receiveAmountEdTxt) + EditText recieveMoneyEditText; @BindView(R.id.paymentModeRV) RecyclerView paymentModeRv; + @BindView(R.id.toolbar_title) + GmeTextView toolbarTitle; + private PaymentModeRvAdapter paymentModeRvAdapter; @Override @@ -39,18 +49,33 @@ public class ExchangeMethodV2Activity extends AppCompatActivity implements Payme } private void performDefaultAction(Bundle savedInstanceState) { + toolbarTitle.setText("Today's Rate"); + mockData(); + + } + + private void mockData() { + List paymentModeList=new ArrayList<>(); + paymentModeList.add(new PaymentMode("1","Cash Delivery")); + paymentModeList.add(new PaymentMode("2","Bank Deposit")); + paymentModeList.add(new PaymentMode("3","Home Delivery")); + paymentModeRvAdapter.setData(paymentModeList); + paymentModeRvAdapter.setSelectedItem(1); } private void setupRv() { paymentModeRvAdapter = new PaymentModeRvAdapter(this); paymentModeRv.setAdapter(paymentModeRvAdapter); + paymentModeRv.addItemDecoration(new SelectedRedBorderDecoration(this)); + paymentModeRv.addItemDecoration(new CustomPaddingRv(8)); + paymentModeRv.setItemAnimator(new DefaultItemAnimator()); } @Override - public void onPaymentModeSelected() { + public void onPaymentModeSelected(PaymentMode selectedData) { } } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/SelectedRedBorderDecoration.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/SelectedRedBorderDecoration.java new file mode 100644 index 00000000..c61eda9e --- /dev/null +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/SelectedRedBorderDecoration.java @@ -0,0 +1,93 @@ +package com.gmeremit.online.gmeremittance_native.exchange_rate.view; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.RectF; +import android.os.Build; +import android.support.v7.widget.RecyclerView; + +import com.gmeremit.online.gmeremittance_native.R; +import com.gmeremit.online.gmeremittance_native.utils.Utils; + +public class SelectedRedBorderDecoration extends RecyclerView.ItemDecoration{ + + private float mRectWidth; + private float mCornerRadius; + private Paint mTickStampPaint; + private Paint mBorderPaint; + private float multi; + private Paint mTickColorPaint; + private RectF rectF; + + + public SelectedRedBorderDecoration(Context context) { + init(context); + } + + private void init(Context context) { + multi = context.getResources().getDisplayMetrics().density; + mRectWidth = multi * 1; + mCornerRadius = multi * 12; + mBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mBorderPaint.setStyle(Paint.Style.STROKE); + mBorderPaint.setStrokeWidth(mRectWidth); + mBorderPaint.setStrokeCap(Paint.Cap.ROUND); + + mTickStampPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mTickStampPaint.setStyle(Paint.Style.FILL); + + mTickColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mTickColorPaint.setStyle(Paint.Style.STROKE); + mTickColorPaint.setStrokeWidth(mRectWidth); + mTickColorPaint.setStrokeCap(Paint.Cap.ROUND); + rectF = new RectF(); + if (Utils.getCurrentAPILevel() < Build.VERSION_CODES.M) { + mBorderPaint.setColor(context.getResources().getColor(R.color.colorPrimary)); + mTickStampPaint.setColor(context.getResources().getColor(R.color.colorPrimary)); + mTickColorPaint.setColor(context.getResources().getColor(R.color.white)); + } else { + mBorderPaint.setColor(context.getResources().getColor(R.color.colorPrimary, null)); + mTickStampPaint.setColor(context.getResources().getColor(R.color.colorPrimary, null)); + mTickColorPaint.setColor(context.getResources().getColor(R.color.white, null)); + } + } + + @Override + public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { + int selectedPosition = ((RedItemSelectionListener) parent.getAdapter()).getSelectedRedItemPosition(); + for (int i = 0; i < parent.getChildCount(); i++) { + int childViewAdapterPosition = parent.getChildAdapterPosition(parent.getChildAt(i)); + // System.out.println("Selected Item Position =" + selectedPosition + ", indivisual item adapter position: " + childViewAdapterPosition); + if (childViewAdapterPosition == selectedPosition) { +// rectF.left = parent.getChildAt(i).getLeft() + (5 * multi); +// rectF.top = parent.getChildAt(i).getTop() + (1 * multi); +// rectF.right = parent.getChildAt(i).getRight() - (9 * multi); +// rectF.bottom = parent.getChildAt(i).getBottom() - (9 * multi); +// + rectF.left = parent.getChildAt(i).getLeft()+(1*multi); + rectF.top = parent.getChildAt(i).getTop()+(1*multi) ; + rectF.right = parent.getChildAt(i).getRight()-(1*multi) ; + rectF.bottom = parent.getChildAt(i).getBottom()-(1*multi) ; + + c.drawRoundRect(rectF, mCornerRadius, mCornerRadius, mBorderPaint); + + +// drawTickStamp(c, parent.getChildAt(i).getRight() - (9 * multi), parent.getChildAt(i).getTop() + (1 * multi)); + } + } + + } + + + private void drawTickStamp(Canvas c, float x, float y) { + c.drawCircle(x, y, 13 * multi, mTickStampPaint); + c.drawLine(x - (4 * multi), y, x, y + (3 * multi), mTickColorPaint); + c.drawLine(x, y + (3 * multi), x + (6.5f * multi), y - (4 * multi), mTickColorPaint); + } + + + public interface RedItemSelectionListener { + int getSelectedRedItemPosition(); + } +} diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/home/view/HomeFragment.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/home/view/HomeFragment.java index 78f6ece3..b35c321b 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/home/view/HomeFragment.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/home/view/HomeFragment.java @@ -42,6 +42,7 @@ import com.facebook.share.widget.ShareDialog; import com.gmeremit.online.gmeremittance_native.R; import com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView; import com.gmeremit.online.gmeremittance_native.exchange_rate.view.ExchangeMethodActivity; +import com.gmeremit.online.gmeremittance_native.exchange_rate.view.ExchangeMethodV2Activity; import com.gmeremit.online.gmeremittance_native.gme_branches.view.GmeBranchesActivity; import com.gmeremit.online.gmeremittance_native.home.HomeContract; import com.gmeremit.online.gmeremittance_native.home.adapters.MenuAdapter; @@ -524,7 +525,7 @@ public class HomeFragment extends Fragment implements HomeContract.MenuItemClick if (isVerified()) startActivity(new Intent(getContext(), MobileRechargeActivity.class)); } else if (id == 3) { - startActivity(new Intent(getContext(), ExchangeMethodActivity.class)); + startActivity(new Intent(getContext(), ExchangeMethodV2Activity.class)); } else if (id == 4) { startActivity(new Intent(getContext(), TrackYourTransferActivity.class)); } else if (id == 5) { diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/Utils.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/Utils.java index b08b0f78..768f2001 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/Utils.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/Utils.java @@ -9,6 +9,7 @@ import android.graphics.Color; import android.graphics.drawable.Drawable; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.os.Build; import android.os.Environment; import android.provider.Settings; import android.support.design.internal.BottomNavigationItemView; @@ -470,4 +471,8 @@ public class Utils { } return countries; } + + public static int getCurrentAPILevel() { + return Build.VERSION.SDK_INT; + } } diff --git a/app/src/main/res/layout/activity_exchange_method_v2.xml b/app/src/main/res/layout/activity_exchange_method_v2.xml index 75b706b4..b4d76ba0 100644 --- a/app/src/main/res/layout/activity_exchange_method_v2.xml +++ b/app/src/main/res/layout/activity_exchange_method_v2.xml @@ -3,23 +3,26 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_height="match_parent" + tools:context="com.gmeremit.online.gmeremittance_native.exchange_rate.view.ExchangeMethodV2Activity" android:layout_width="match_parent"> - + android:orientation="vertical"> + android:orientation="horizontal" + > + android:textSize="14sp" + android:paddingLeft="3dp" /> @@ -93,19 +104,40 @@ android:paddingEnd="3dp" android:layout_height="match_parent" /> - + android:orientation="vertical"> + + + + @@ -131,16 +167,20 @@ android:layout_width="wrap_content" android:paddingStart="3dp" android:paddingEnd="3dp" - android:layout_height="40dp" /> + android:layout_height="50dp" /> + + android:textSize="14sp" + android:paddingLeft="3dp" /> diff --git a/app/src/main/res/layout/paymentmode_rv_viewholder.xml b/app/src/main/res/layout/paymentmode_rv_viewholder.xml index 96823f76..6cb705ae 100644 --- a/app/src/main/res/layout/paymentmode_rv_viewholder.xml +++ b/app/src/main/res/layout/paymentmode_rv_viewholder.xml @@ -3,7 +3,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/homeDeliveryLayout" android:layout_width="100dp" - android:layout_height="110dp" + android:layout_height="100dp" android:background="@drawable/ic_rounded_white">