Commit b2224723 authored by iman Fauzi's avatar iman Fauzi

fix button payment when bank name is selected

parent 2f44845a
......@@ -6,8 +6,11 @@ import androidx.recyclerview.widget.RecyclerView;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.Toast;
import android.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
......@@ -19,6 +22,9 @@ import java.util.ArrayList;
public class PaymentActivity extends AppCompatActivity {
private ArrayList<PaymentResponse> paymentResponses = new ArrayList<>();
Button btnPay;
public static String methodPay="";
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -51,5 +57,18 @@ public class PaymentActivity extends AppCompatActivity {
PaymentAdapter adapter = new PaymentAdapter(paymentResponses, this);
rvPayment.setAdapter(adapter);
btnPay = findViewById(R.id.btnPay);
adapter.setListener(paymentResponse -> {
methodPay = paymentResponse.getBank();
btnPay.setEnabled(true);
});
btnPay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), methodPay, Toast.LENGTH_LONG).show();
}
});
}
}
\ No newline at end of file
package com.yono.messeripos.adapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
......@@ -87,6 +88,7 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.MyViewHolder>
this.binding = binding;
}
@SuppressLint("SetTextI18n")
public void bindData(ProductCartModels cartModels) {
binding.setCarts(cartModels);
binding.setPrice(utils.convertPrice("Rp. ", cartModels.getPrice_orders()));
......
......@@ -18,6 +18,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.card.MaterialCardView;
import com.yono.messeripos.PaymentActivity;
import com.yono.messeripos.models.ProductCartModels;
import com.yono.messeripos.response.PaymentResponse;
import com.yono.messeripos.R;
import com.yono.messeripos.databinding.PaymentListBinding;
......@@ -30,6 +31,16 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold
Context context;
int getPosition = -1;
public interface PaymentListener {
void onSelectPayment(PaymentResponse paymentResponse);
}
private PaymentListener listener;
public void setListener(PaymentListener listener) {
this.listener = listener;
}
public PaymentAdapter(ArrayList<PaymentResponse> paymentResponses, PaymentActivity mainActivity) {
this.paymentResponses = paymentResponses;
this.context = mainActivity;
......@@ -80,10 +91,11 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold
public class ViewHolder extends RecyclerView.ViewHolder {
PaymentListBinding binding;
RadioButton radioButton;
public ViewHolder(@NonNull PaymentListBinding view) {
super(view.getRoot());
this.binding = view;
radioButton = view.rbPayment;
this.radioButton = view.rbPayment;
}
@SuppressLint("ResourceAsColor")
......@@ -91,14 +103,10 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold
binding.setPayment(paymentResponse);
binding.setLogo(paymentResponse.getUrl());
binding.cvPayment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
binding.cvPayment.setOnClickListener(view ->{
getPosition = getAdapterPosition();
notifyDataSetChanged();
}
});
listener.onSelectPayment(paymentResponse);});
}
}
}
......@@ -29,6 +29,7 @@
android:text="pay"
android:padding="15dp"
android:textSize="16sp"
android:enabled="false"
android:layout_margin="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
......
......@@ -71,6 +71,8 @@
android:id="@+id/rbPayment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:buttonTint="@color/colorPrimary"
android:enabled="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="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