AA-4 | Reyaz & Shashidhara | Change layout so that completed loans can also be viewed in same layout
This commit is contained in:
@@ -27,15 +27,28 @@ class MyLoansAdapter(private val context: Context) :
|
||||
|
||||
override fun onBindViewHolder(holder: MyLoansViewHolder, position: Int) {
|
||||
val loan = loans[position]
|
||||
holder.binding.emiDueText.text =
|
||||
context.getString(R.string.rupees_format, loan.emiDue)
|
||||
holder.binding.loanAmountText.text =
|
||||
context.getString(R.string.rupees_format, loan.amount)
|
||||
holder.binding.dueDateText.text = loan.dueDate.toString()
|
||||
holder.binding.loanTypeText.text = loan.type?.value
|
||||
holder.binding.startDateText.text = loan.startDate.toString()
|
||||
holder.binding.interestRateText.text =
|
||||
context.getString(R.string.percentage_format, loan.interestRate)
|
||||
holder.binding.apply {
|
||||
loanAmountText.text =
|
||||
context.getString(R.string.rupees_format, loan.amount)
|
||||
loanTypeText.text = loan.type?.value
|
||||
startDateText.text = loan.startDate
|
||||
interestRateText.text =
|
||||
context.getString(R.string.percentage_format, loan.interestRate)
|
||||
if (loan.status == LoanStatus.ACTIVE) {
|
||||
emiDueOrCompletionDateText.text =
|
||||
context.getString(R.string.rupees_format, loan.emiDue)
|
||||
emiDueOrCompletionDateLabelText.text =
|
||||
context.getString(R.string.emi_due)
|
||||
dueDateOrStatusLabelText.text = context.getString(R.string.due_date)
|
||||
dueDateOrStatusText.text = loan.dueDate
|
||||
} else {
|
||||
emiDueOrCompletionDateText.text = loan.completionDate
|
||||
emiDueOrCompletionDateLabelText.text =
|
||||
context.getString(R.string.completion_date)
|
||||
dueDateOrStatusLabelText.text = context.getString(R.string.status)
|
||||
dueDateOrStatusText.text = loan.status?.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MyLoansViewHolder(val binding: LoanCardBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
@@ -6,34 +6,36 @@
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
app:cardElevation="8dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/emi_due_label_text"
|
||||
android:id="@+id/emi_due_or_completion_date_label_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/emi_due"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@string/emi_due" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/emi_due_text"
|
||||
android:id="@+id/emi_due_or_completion_date_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:text="@string/rupees_format"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/emi_due_label_text"
|
||||
app:layout_constraintStart_toEndOf="@+id/emi_due_label_text"
|
||||
app:layout_constraintTop_toTopOf="@+id/emi_due_label_text" />
|
||||
app:layout_constraintBottom_toBottomOf="@+id/emi_due_or_completion_date_label_text"
|
||||
app:layout_constraintStart_toEndOf="@+id/emi_due_or_completion_date_label_text"
|
||||
app:layout_constraintTop_toTopOf="@+id/emi_due_or_completion_date_label_text"
|
||||
tools:text="Rs 25000" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loan_amount_label_text"
|
||||
@@ -42,8 +44,8 @@
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/loan_amount"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintStart_toStartOf="@+id/emi_due_label_text"
|
||||
app:layout_constraintTop_toBottomOf="@+id/emi_due_label_text" />
|
||||
app:layout_constraintStart_toStartOf="@+id/emi_due_or_completion_date_label_text"
|
||||
app:layout_constraintTop_toBottomOf="@+id/emi_due_or_completion_date_label_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loan_amount_text"
|
||||
@@ -58,22 +60,22 @@
|
||||
app:layout_constraintTop_toTopOf="@+id/loan_amount_label_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/due_date_label_text"
|
||||
android:id="@+id/due_date_or_status_label_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/due_date"
|
||||
app:layout_constraintStart_toStartOf="@+id/due_date_text"
|
||||
app:layout_constraintTop_toTopOf="@+id/emi_due_text" />
|
||||
app:layout_constraintStart_toStartOf="@+id/due_date_or_status_text"
|
||||
app:layout_constraintTop_toTopOf="@+id/emi_due_or_completion_date_text"
|
||||
tools:text="@string/due_date" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/due_date_text"
|
||||
android:id="@+id/due_date_or_status_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/due_date_label_text"
|
||||
app:layout_constraintTop_toBottomOf="@+id/due_date_or_status_label_text"
|
||||
tools:text="24th August" />
|
||||
|
||||
<View
|
||||
|
||||
@@ -16,5 +16,7 @@
|
||||
<string name="loan_type">Loan Type</string>
|
||||
<string name="start_date">Start Date</string>
|
||||
<string name="interest_rate">Interest Rate</string>
|
||||
<string name="percentage_format">%d %%</string>
|
||||
<string name="percentage_format">%.1f %%</string>
|
||||
<string name="completion_date">Completion Date</string>
|
||||
<string name="status">Status</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user