Commit 8cecb337 authored by iman Fauzi's avatar iman Fauzi

fix

parents 5d2672c6 3af68606
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">
......
...@@ -6,11 +6,14 @@ import androidx.recyclerview.widget.RecyclerView; ...@@ -6,11 +6,14 @@ import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle; import android.os.Bundle;
import com.yono.messeripos.adapter.PaymentAdapter;
import com.yono.messeripos.response.PaymentResponse;
import java.util.ArrayList; import java.util.ArrayList;
public class PaymentActivity extends AppCompatActivity { public class PaymentActivity extends AppCompatActivity {
private ArrayList<PaymentModel> paymentModels = new ArrayList<>(); private ArrayList<PaymentResponse> paymentResponses = new ArrayList<>();
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -22,11 +25,11 @@ public class PaymentActivity extends AppCompatActivity { ...@@ -22,11 +25,11 @@ public class PaymentActivity extends AppCompatActivity {
LinearLayoutManager llm = new LinearLayoutManager(this); LinearLayoutManager llm = new LinearLayoutManager(this);
rvPayment.setLayoutManager(llm); rvPayment.setLayoutManager(llm);
paymentModels.add(new PaymentModel("https://i.ibb.co/XCsdmmT/Bank-Mandiri-logo.png", "mandiri")); paymentResponses.add(new PaymentResponse("https://i.ibb.co/XCsdmmT/Bank-Mandiri-logo.png", "mandiri"));
paymentModels.add(new PaymentModel("https://i.ibb.co/2n65nCT/bca-bank-central-asia.png", "bca")); paymentResponses.add(new PaymentResponse("https://i.ibb.co/2n65nCT/bca-bank-central-asia.png", "bca"));
paymentModels.add(new PaymentModel("https://i.ibb.co/RjJQT9K/BNI-logo.png", "bni")); paymentResponses.add(new PaymentResponse("https://i.ibb.co/RjJQT9K/BNI-logo.png", "bni"));
PaymentAdapter adapter = new PaymentAdapter(paymentModels, this); PaymentAdapter adapter = new PaymentAdapter(paymentResponses, this);
rvPayment.setAdapter(adapter); rvPayment.setAdapter(adapter);
} }
......
package com.yono.messeripos; package com.yono.messeripos.adapter;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.button.MaterialButton; import com.google.android.material.button.MaterialButton;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;
import com.yono.messeripos.PaymentActivity;
import com.yono.messeripos.response.PaymentResponse;
import com.yono.messeripos.R;
import com.yono.messeripos.databinding.PaymentListBinding;
import java.util.ArrayList; import java.util.ArrayList;
public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHolder> { public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHolder> {
private ArrayList<PaymentModel> paymentModels; private ArrayList<PaymentResponse> paymentResponses;
Context context; Context context;
int getPosition = -1; int getPosition = -1;
public PaymentAdapter(ArrayList<PaymentModel> paymentModels, PaymentActivity mainActivity) { public PaymentAdapter(ArrayList<PaymentResponse> paymentResponses, PaymentActivity mainActivity) {
this.paymentModels = paymentModels; this.paymentResponses = paymentResponses;
this.context = mainActivity; this.context = mainActivity;
} }
...@@ -50,7 +51,7 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold ...@@ -50,7 +51,7 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold
@Override @Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) { public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.binData(paymentModels.get(position)); holder.binData(paymentResponses.get(position));
// holder.cardView.setTag(position); // holder.cardView.setTag(position);
// holder.radioButton.setChecked(position == getPosition); // holder.radioButton.setChecked(position == getPosition);
// final PaymentModel paymentModel = paymentModels.get(position); // final PaymentModel paymentModel = paymentModels.get(position);
...@@ -65,7 +66,7 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold ...@@ -65,7 +66,7 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold
@Override @Override
public int getItemCount() { public int getItemCount() {
return paymentModels.size(); return paymentResponses.size();
} }
public class ViewHolder extends RecyclerView.ViewHolder { public class ViewHolder extends RecyclerView.ViewHolder {
...@@ -75,8 +76,9 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold ...@@ -75,8 +76,9 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold
this.binding = view; this.binding = view;
} }
public void binData(PaymentModel paymentModel){ public void binData(PaymentResponse paymentResponse){
binding.setPayment(paymentModel); binding.setPayment(paymentResponse);
binding.setLogo(paymentResponse.getUrl());
} }
} }
} }
package com.yono.messeripos; package com.yono.messeripos.response;
public class PaymentModel { import android.widget.ImageView;
import androidx.databinding.BindingAdapter;
import com.bumptech.glide.Glide;
public class PaymentResponse {
private String url; private String url;
private String bank; private String bank;
public PaymentModel(String url, String bank) { public PaymentResponse(String url, String bank) {
this.url = url; this.url = url;
this.bank = bank; this.bank = bank;
} }
...@@ -25,4 +31,11 @@ public class PaymentModel { ...@@ -25,4 +31,11 @@ public class PaymentModel {
public void setBank(String bank) { public void setBank(String bank) {
this.bank = bank; this.bank = bank;
} }
@BindingAdapter("logo_bank")
public static void loadImage(ImageView view, String url) {
Glide.with(view.getContext())
.load(url)
.into(view);
}
} }
\ No newline at end of file
...@@ -7,8 +7,13 @@ ...@@ -7,8 +7,13 @@
<data> <data>
<variable <variable
name="payment" name="payment"
type="com.yono.messeripos.PaymentModel" /> type="com.yono.messeripos.response.PaymentResponse" />
<variable
name="logo"
type="String" />
</data> </data>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -44,6 +49,7 @@ ...@@ -44,6 +49,7 @@
android:layout_width="131dp" android:layout_width="131dp"
android:layout_height="39dp" android:layout_height="39dp"
android:src="@drawable/ic_bni_logo" android:src="@drawable/ic_bni_logo"
app:logo_bank="@{logo}"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment