| @ -0,0 +1,117 @@ | |||
| package com.nivesh.production.bajajfd.adapter | |||
| import android.view.LayoutInflater | |||
| import android.view.View | |||
| import android.view.ViewGroup | |||
| import android.widget.ImageView | |||
| import android.widget.TextView | |||
| import androidx.recyclerview.widget.RecyclerView | |||
| import com.nivesh.production.bajajfd.R | |||
| import com.nivesh.production.bajajfd.model.BankList | |||
| class BankListAdapter( private val bankList: List<BankList>, | |||
| private var checkedPosition: Int = -2, | |||
| private val selectedAccount: String? = null | |||
| ) | |||
| :RecyclerView.Adapter<BankListAdapter.BankListViewHolder>() | |||
| { | |||
| inner class BankListViewHolder (itemView:View):RecyclerView.ViewHolder(itemView) | |||
| { | |||
| val bankSelector: ImageView = itemView.findViewById(R.id.bankSelector) | |||
| val bankName: TextView = itemView.findViewById(R.id.bankName) | |||
| val bankAcNoTV: TextView = itemView.findViewById(R.id.bankAcNoTV) | |||
| val bankIfscTV: TextView = itemView.findViewById(R.id.bankIfscTV) | |||
| val bankTypeTV: TextView = itemView.findViewById(R.id.bankTypeTV) | |||
| } | |||
| override fun onCreateViewHolder( | |||
| parent: ViewGroup, | |||
| viewType: Int | |||
| ): BankListViewHolder { | |||
| return BankListViewHolder(LayoutInflater.from(parent.context).inflate( | |||
| R.layout.item_banklist_preview, | |||
| parent, | |||
| false | |||
| )) | |||
| } | |||
| override fun onBindViewHolder(holder: BankListViewHolder, position: Int) { | |||
| val bankList =bankList[position] | |||
| holder.itemView.apply { | |||
| holder.bankName.text = bankList.BankName | |||
| holder.bankIfscTV.text = bankList.IFSCCode | |||
| holder.bankAcNoTV.text = bankList.AccountNumber | |||
| holder.bankTypeTV.text = bankList.AccountType | |||
| if (selectedAccount == bankList.AccountNumber && checkedPosition == -2 | |||
| ) { | |||
| holder.bankSelector.setBackgroundResource(R.drawable.ic_select_green) | |||
| checkedPosition = holder.adapterPosition | |||
| } else if (checkedPosition == -1) { | |||
| holder.bankSelector.setBackgroundResource(R.drawable.ic_select_outline) | |||
| } else if (checkedPosition == holder.adapterPosition) | |||
| { | |||
| holder.bankSelector.setBackgroundResource(R.drawable.ic_select_green) | |||
| } else { | |||
| holder.bankSelector.setBackgroundResource(R.drawable.ic_select_outline) | |||
| } | |||
| setOnClickListener{ onItemClickListener?.let { | |||
| it(bankList) | |||
| holder.bankSelector.setBackgroundResource(R.drawable.ic_select_green) | |||
| if (checkedPosition != holder.adapterPosition) { | |||
| notifyItemChanged(checkedPosition) | |||
| checkedPosition = holder.adapterPosition | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| override fun getItemCount(): Int { | |||
| return bankList.size | |||
| } | |||
| private var onItemClickListener:((BankList) ->Unit)?=null | |||
| fun setOnItemClickListener(listener:(BankList) -> Unit) | |||
| { | |||
| onItemClickListener= listener | |||
| } | |||
| fun getSelected(): BankList? { | |||
| return if (checkedPosition != -1) { | |||
| bankList[checkedPosition] | |||
| } else null | |||
| } | |||
| } | |||
| @ -0,0 +1,15 @@ | |||
| package com.nivesh.production.bajajfd.model | |||
| import java.io.Serializable | |||
| data class BankList( | |||
| val BankName: String?, | |||
| val IFSCCode: String?, | |||
| val AccountNumber: String?, | |||
| val BranchName: String?, | |||
| val DefaultBankFlag: String?, | |||
| val IsValBank: String?, | |||
| val AccountType: String? | |||
| ): Serializable | |||
| @ -0,0 +1,5 @@ | |||
| <vector android:height="24dp" android:tint="#6D6B6B" | |||
| android:viewportHeight="24" android:viewportWidth="24" | |||
| android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | |||
| <path android:fillColor="@android:color/white" android:pathData="M13,7h-2v4L7,11v2h4v4h2v-4h4v-2h-4L13,7zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/> | |||
| </vector> | |||
| @ -0,0 +1,5 @@ | |||
| <vector android:height="24dp" android:tint="#69F324" | |||
| android:viewportHeight="24" android:viewportWidth="24" | |||
| android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | |||
| <path android:fillColor="@android:color/white" android:pathData="M12,6c3.31,0 6,2.69 6,6s-2.69,6 -6,6 -6,-2.69 -6,-6 2.69,-6 6,-6m0,-2c-4.42,0 -8,3.58 -8,8s3.58,8 8,8 8,-3.58 8,-8 -3.58,-8 -8,-8z"/> | |||
| </vector> | |||
| @ -0,0 +1,5 @@ | |||
| <vector android:height="24dp" android:tint="#403D3D" | |||
| android:viewportHeight="24" android:viewportWidth="24" | |||
| android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | |||
| <path android:fillColor="@android:color/white" android:pathData="M12,6c3.31,0 6,2.69 6,6s-2.69,6 -6,6 -6,-2.69 -6,-6 2.69,-6 6,-6m0,-2c-4.42,0 -8,3.58 -8,8s3.58,8 8,8 8,-3.58 8,-8 -3.58,-8 -8,-8z"/> | |||
| </vector> | |||
| @ -0,0 +1,167 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <androidx.cardview.widget.CardView | |||
| xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:app="http://schemas.android.com/apk/res-auto" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_margin="4dp" | |||
| app:cardBackgroundColor="@color/white" | |||
| app:cardCornerRadius="8dp" | |||
| app:cardElevation="8dp" | |||
| app:cardMaxElevation="10dp" | |||
| app:cardPreventCornerOverlap="true" | |||
| app:cardUseCompatPadding="true"> | |||
| <!-- In the above cardview widget cardelevation property will give elevation to your card view | |||
| card corner radius will provide radius to your card view card background color will give | |||
| background color to your card view card max elevation will give the cardview maximum | |||
| elevation card prevent corner overlap will add padding to CardView on v20 and before to | |||
| prevent intersections between the Card content and rounded corners. Card use compact padding | |||
| will add padding in API v21+ as well to have the same measurements with previous versions --> | |||
| <RelativeLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content"> | |||
| <!-- ImageVIew to display our Course Image --> | |||
| <ImageView | |||
| android:id="@+id/bankSelector" | |||
| android:layout_width="50dp" | |||
| android:layout_height="50dp" | |||
| android:layout_marginStart="10dp" | |||
| android:layout_marginEnd="10dp" | |||
| android:layout_marginBottom="10dp" | |||
| android:layout_centerVertical="true" | |||
| android:padding="5dp" | |||
| /> | |||
| <LinearLayout | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:orientation="vertical" | |||
| android:layout_toEndOf="@id/bankSelector" | |||
| > | |||
| <!-- Text View to display Course Name --> | |||
| <androidx.appcompat.widget.AppCompatTextView | |||
| android:id="@+id/bankName" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginTop="8dp" | |||
| android:text="" | |||
| android:textColor="@color/black" | |||
| android:textSize="18sp" | |||
| android:textStyle="bold" /> | |||
| <!-- Text VIew to display Course Rating --> | |||
| <!-- Image used in present in drawable folder --> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:orientation="horizontal" | |||
| android:layout_marginTop="8dp" | |||
| android:layout_marginBottom="8dp" | |||
| > | |||
| <androidx.appcompat.widget.AppCompatTextView | |||
| android:id="@+id/bankAcNo" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:drawablePadding="2dp" | |||
| android:text="A/c No: " | |||
| /> | |||
| <androidx.appcompat.widget.AppCompatTextView | |||
| android:id="@+id/bankAcNoTV" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:drawablePadding="2dp" | |||
| android:text="" | |||
| /> | |||
| </LinearLayout> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:orientation="horizontal" | |||
| android:layout_marginTop="8dp" | |||
| android:layout_marginBottom="8dp" | |||
| > | |||
| <androidx.appcompat.widget.AppCompatTextView | |||
| android:id="@+id/bankIfsc" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:drawablePadding="2dp" | |||
| android:text="A/c IFSC : " | |||
| /> | |||
| <androidx.appcompat.widget.AppCompatTextView | |||
| android:id="@+id/bankIfscTV" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:drawablePadding="2dp" | |||
| android:text="" | |||
| /> | |||
| </LinearLayout> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:orientation="horizontal" | |||
| android:layout_marginTop="8dp" | |||
| android:layout_marginBottom="8dp" | |||
| > | |||
| <androidx.appcompat.widget.AppCompatTextView | |||
| android:id="@+id/bankType" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:drawablePadding="2dp" | |||
| android:text="A/c Type : " | |||
| /> | |||
| <androidx.appcompat.widget.AppCompatTextView | |||
| android:id="@+id/bankTypeTV" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:drawablePadding="2dp" | |||
| android:text="" | |||
| /> | |||
| </LinearLayout> | |||
| </LinearLayout> | |||
| </RelativeLayout> | |||
| </androidx.cardview.widget.CardView> | |||
| @ -0,0 +1,4 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <resources> | |||
| <string name="add_new_account">Add New Account</string> | |||
| </resources> | |||
Powered by TurnKey Linux.