Commit 2f44845a authored by iman Fauzi's avatar iman Fauzi

make payment list selected

parent 5110f6c3
...@@ -40,7 +40,7 @@ public class PaymentActivity extends AppCompatActivity { ...@@ -40,7 +40,7 @@ public class PaymentActivity extends AppCompatActivity {
RecyclerView rvPayment = findViewById(R.id.rvPayment); RecyclerView rvPayment = findViewById(R.id.rvPayment);
LinearLayoutManager llm = new LinearLayoutManager(this); LinearLayoutManager llm = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
rvPayment.setLayoutManager(llm); rvPayment.setLayoutManager(llm);
paymentResponses.add(new PaymentResponse("https://i.ibb.co/RjJQT9K/BNI-logo.png", "cash")); paymentResponses.add(new PaymentResponse("https://i.ibb.co/RjJQT9K/BNI-logo.png", "cash"));
......
...@@ -6,6 +6,7 @@ import android.util.Log; ...@@ -6,6 +6,7 @@ import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.RadioButton;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
...@@ -58,7 +59,8 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold ...@@ -58,7 +59,8 @@ 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(paymentResponses.get(position)); holder.binData(paymentResponses.get(position));
// holder.radioButton.setChecked(position == getPosition);
holder.radioButton.setChecked(position == getPosition);
// final PaymentModel paymentModel = paymentModels.get(position); // final PaymentModel paymentModel = paymentModels.get(position);
// //
// ImageView imageView = holder.logoComp; // ImageView imageView = holder.logoComp;
...@@ -76,15 +78,12 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold ...@@ -76,15 +78,12 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold
} }
public class ViewHolder extends RecyclerView.ViewHolder { public class ViewHolder extends RecyclerView.ViewHolder {
MaterialCardView cardView;
PaymentListBinding binding; PaymentListBinding binding;
public int position; RadioButton radioButton;
public ViewHolder(@NonNull PaymentListBinding view) { public ViewHolder(@NonNull PaymentListBinding view) {
super(view.getRoot()); super(view.getRoot());
this.binding = view; this.binding = view;
getPosition = getAdapterPosition(); radioButton = view.rbPayment;
Log.d("ViewHolder: ", String.valueOf(cardView));
} }
@SuppressLint("ResourceAsColor") @SuppressLint("ResourceAsColor")
...@@ -92,13 +91,12 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold ...@@ -92,13 +91,12 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold
binding.setPayment(paymentResponse); binding.setPayment(paymentResponse);
binding.setLogo(paymentResponse.getUrl()); binding.setLogo(paymentResponse.getUrl());
Log.d("Position ", ""+getAdapterPosition());
binding.cvPayment.setOnClickListener(new View.OnClickListener() { binding.cvPayment.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Log.d("Click VC", paymentResponse.getBank()); getPosition = getAdapterPosition();
binding.cvPayment.toggle(); notifyDataSetChanged();
} }
}); });
} }
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
android:id="@+id/rvPayment" android:id="@+id/rvPayment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/appbar"/> app:layout_constraintTop_toBottomOf="@id/appbar"
/>
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/btnPay" android:id="@+id/btnPay"
......
...@@ -67,6 +67,14 @@ ...@@ -67,6 +67,14 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
/> />
<RadioButton
android:id="@+id/rbPayment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
......
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