Browse Source

Layout for exchange rate done

master
preyearegmi 6 years ago
parent
commit
2354c82b74
  1. 6
      app/src/main/AndroidManifest.xml
  2. 31
      app/src/main/java/com/gmeremit/online/gmeremittance_native/customwidgets/CustomPaddingRv.java
  3. 56
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/adapter/PaymentModeRvAdapter.java
  4. 25
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/PaymentModeMapper.java
  5. 64
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/CountryPaymentService.java
  6. 34
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/PaymentMode.java
  7. 33
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java
  8. 93
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/SelectedRedBorderDecoration.java
  9. 3
      app/src/main/java/com/gmeremit/online/gmeremittance_native/home/view/HomeFragment.java
  10. 5
      app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/Utils.java
  11. 90
      app/src/main/res/layout/activity_exchange_method_v2.xml
  12. 2
      app/src/main/res/layout/paymentmode_rv_viewholder.xml

6
app/src/main/AndroidManifest.xml

@ -17,7 +17,6 @@
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-sdk tools:overrideLibrary="app.frantic.mylibrary" />
<uses-feature
@ -323,6 +322,11 @@
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name=".exchange_rate.view.ExchangeMethodV2Activity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name=".gme_branches.view.GmeBranchesActivity"
android:screenOrientation="portrait"

31
app/src/main/java/com/gmeremit/online/gmeremittance_native/customwidgets/CustomPaddingRv.java

@ -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;
}
}
}

56
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/adapter/PaymentModeRvAdapter.java

@ -6,14 +6,24 @@ import android.view.View;
import android.view.ViewGroup;
import com.gmeremit.online.gmeremittance_native.R;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.PaymentModeMapper;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentMode;
import com.gmeremit.online.gmeremittance_native.exchange_rate.view.PaymentModeViewHolder;
import com.gmeremit.online.gmeremittance_native.exchange_rate.view.SelectedRedBorderDecoration;
public class PaymentModeRvAdapter extends RecyclerView.Adapter<PaymentModeViewHolder> implements View.OnClickListener {
import java.util.ArrayList;
import java.util.List;
public class PaymentModeRvAdapter extends RecyclerView.Adapter<PaymentModeViewHolder> implements SelectedRedBorderDecoration.RedItemSelectionListener {
private final OnPaymentModeSelectionListener listener;
private int selectedItemPosition;
private List<PaymentMode> 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.Adapter<PaymentModeViewHo
}
@Override
public void onBindViewHolder(PaymentModeViewHolder holder, int position) {
holder.itemView.setOnClickListener(this);
public void onBindViewHolder(final PaymentModeViewHolder holder, int position) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setSelectedItem(holder.getAdapterPosition());
}
});
holder.setImage(PaymentModeMapper.getPaymentModeImageFromId(data.get(position).getId()));
holder.setTitle(data.get(position).getText());
}
@Override
public int getItemCount() {
return 0;
return data.size();
}
public void setSelectedItem(int position)
{
if(position!=-1&&data!=null&&data.size()>0)
{
this.selectedItemPosition=position;
if(listener!=null)
{
notifyItemChanged(selectedItemPosition);
listener.onPaymentModeSelected(data.get(selectedItemPosition));
}
}
}
public void setData(List<PaymentMode> 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);
}
}

25
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;
}
}
}

64
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<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;
}
}

34
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;
}
}

33
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<PaymentMode> 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) {
}
}

93
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();
}
}

3
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) {

5
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;
}
}

90
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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp"
android:orientation="vertical"
tools:context="com.gmeremit.online.gmeremittance_native.exchange_rate.view.ExchangeMethodV2Activity">
android:orientation="vertical">
<include layout="@layout/layout_sendmoney_toolbar"/>
<LinearLayout
android:padding="1.5dp"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:background="@drawable/curve_rectangle_grey_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
>
<LinearLayout
android:paddingLeft="5dp"
android:paddingRight="5dp"
@ -28,17 +31,21 @@
android:layout_weight="1"
android:layout_height="wrap_content">
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView
android:paddingTop="3dp"
android:paddingStart="3dp"
android:id="@+id/bank_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="You Send"
android:textColor="@color/darkgray"
android:textSize="14sp"/>
android:textSize="14sp"
android:paddingLeft="3dp" />
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeEditText
android:id="@+id/sendAmountEdTxt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="10,30,30,30"
android:text="100000"
android:inputType="numberDecimal"
android:gravity="center_vertical"
android:backgroundTint="@android:color/transparent"
android:textColor="@color/colorPrimary"
@ -81,6 +88,10 @@
</FrameLayout>
</LinearLayout>
<LinearLayout
android:paddingStart="10dp"
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:paddingEnd="10dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -93,19 +104,40 @@
android:paddingEnd="3dp"
android:layout_height="match_parent" />
</FrameLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/paymentModeRV"
<LinearLayout
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="25dp"
android:layout_marginBottom="25dp"
android:orientation="horizontal"
app:layoutManager="android.support.v7.widget.LinearLayoutManager" />
android:orientation="vertical">
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Select Payment Mode"
android:paddingTop="6dp"
android:paddingBottom="12dp"
android:textColor="@color/darkgray"
android:gravity="start|left"
android:textSize="14sp"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/paymentModeRV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:orientation="horizontal"
android:layout_gravity="center"
app:layoutManager="android.support.v7.widget.LinearLayoutManager" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:paddingStart="10dp"
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:paddingEnd="10dp"
android:layout_marginTop="-1dp"
android:orientation="horizontal"
android:layout_width="match_parent"
@ -118,12 +150,16 @@
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="You Send"
android:text="- 5000 KWR (Transfer Fee Included)"
android:textColor="@color/darkgray"
android:gravity="center_vertical"
android:textSize="14sp"/>
</LinearLayout>
<LinearLayout
android:paddingStart="10dp"
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:paddingEnd="10dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -131,16 +167,20 @@
android:layout_width="wrap_content"
android:paddingStart="3dp"
android:paddingEnd="3dp"
android:layout_height="40dp" />
android:layout_height="50dp" />
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="You Send"
android:text=" 0.978 (Current Exchange Rate)"
android:textColor="@color/darkgray"
android:gravity="center_vertical"
android:textSize="14sp"/>
</LinearLayout>
<LinearLayout
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:padding="1.5dp"
android:background="@drawable/curve_rectangle_grey_bg"
android:layout_width="match_parent"
@ -153,17 +193,22 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="3dp"
android:paddingStart="3dp"
android:text="Recepient Gets"
android:textColor="@color/darkgray"
android:textSize="14sp"/>
android:textSize="14sp"
android:paddingLeft="3dp" />
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeEditText
android:id="@+id/receiveAmountEdTxt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="10,30,30,30"
android:inputType="numberDecimal"
android:text="1100000"
android:gravity="center_vertical"
android:backgroundTint="@android:color/transparent"
android:textColor="@color/colorPrimary"
@ -211,12 +256,13 @@
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeButton
android:layout_marginTop="20dp"
android:id="@+id/btn_invite"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="@drawable/ic_rounded_background_coloured"
android:text="Proceed"
android:text="Calculate"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="18sp" />

2
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">
<LinearLayout
android:orientation="vertical"

Loading…
Cancel
Save