preyearegmi
6 years ago
12 changed files with 404 additions and 38 deletions
-
6app/src/main/AndroidManifest.xml
-
31app/src/main/java/com/gmeremit/online/gmeremittance_native/customwidgets/CustomPaddingRv.java
-
56app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/adapter/PaymentModeRvAdapter.java
-
25app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/PaymentModeMapper.java
-
64app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/CountryPaymentService.java
-
34app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/PaymentMode.java
-
33app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java
-
93app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/SelectedRedBorderDecoration.java
-
3app/src/main/java/com/gmeremit/online/gmeremittance_native/home/view/HomeFragment.java
-
5app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/Utils.java
-
90app/src/main/res/layout/activity_exchange_method_v2.xml
-
2app/src/main/res/layout/paymentmode_rv_viewholder.xml
@ -0,0 +1,31 @@ |
|||||
|
package com.gmeremit.online.gmeremittance_native.customwidgets; |
||||
|
|
||||
|
import android.graphics.Rect; |
||||
|
import android.support.v7.widget.RecyclerView; |
||||
|
import android.view.View; |
||||
|
|
||||
|
public class CustomPaddingRv extends RecyclerView.ItemDecoration { |
||||
|
|
||||
|
private final int paddingX; |
||||
|
|
||||
|
public CustomPaddingRv(int paddingX) { |
||||
|
this.paddingX = paddingX; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, |
||||
|
RecyclerView.State state) { |
||||
|
if(parent.getChildAdapterPosition(view)==0) |
||||
|
{ |
||||
|
outRect.right=paddingX ; |
||||
|
} |
||||
|
else if(parent.getChildAdapterPosition(view)!=parent.getChildCount()) |
||||
|
{ |
||||
|
outRect.right=paddingX; |
||||
|
} |
||||
|
else { |
||||
|
outRect.left = paddingX; |
||||
|
outRect.right = paddingX; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -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; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
@ -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<String> currency = null; |
||||
|
@SerializedName("serviceAvailable") |
||||
|
@Expose |
||||
|
private List<PaymentMode> 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<String> getCurrency() { |
||||
|
return currency; |
||||
|
} |
||||
|
|
||||
|
public void setCurrency(List<String> currency) { |
||||
|
this.currency = currency; |
||||
|
} |
||||
|
|
||||
|
public List<PaymentMode> getServiceAvailable() { |
||||
|
return serviceAvailable; |
||||
|
} |
||||
|
|
||||
|
public void setServiceAvailable(List<PaymentMode> serviceAvailable) { |
||||
|
this.serviceAvailable = serviceAvailable; |
||||
|
} |
||||
|
} |
@ -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; |
||||
|
} |
||||
|
} |
@ -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(); |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue