-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: added coin data class * feat: added a comment * feat: added a comment * added splash screen * feat: added converter page ui * feat: added rv adapter Co-authored-by: Rohith Menon <[email protected]> Co-authored-by: rudrankbasant <[email protected]> Co-authored-by: Rudrank Basant <[email protected]>
- Loading branch information
1 parent
ca655fc
commit d431f65
Showing
2 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.example.coint.adapters | ||
|
||
import android.content.Context | ||
import android.provider.ContactsContract | ||
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.example.coint.R | ||
import com.example.coint.models.CoinData | ||
|
||
class RVAdapter( | ||
val context: Context | ||
): RecyclerView.Adapter<RVAdapter.ViewHolder>(){ | ||
|
||
private val allEntries = ArrayList<CoinData>() | ||
inner class ViewHolder(itemView: View): RecyclerView.ViewHolder(itemView){ | ||
val titleTV =itemView.findViewById<TextView>(R.id.tvCoinTitle) | ||
val descTV= itemView.findViewById<TextView>(R.id.tvCoinDescription) | ||
val valueTV =itemView.findViewById<TextView>(R.id.tvCoinValue) | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
val itemView = LayoutInflater.from(parent.context).inflate(R.layout.item_coin,parent,false) | ||
return ViewHolder(itemView) | ||
|
||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
holder.titleTV.setText(allEntries.get(position).abbrev) | ||
holder.descTV.setText(allEntries.get(position).full) | ||
holder.valueTV.setText(allEntries.get(position).value.toString()) | ||
|
||
} | ||
|
||
override fun getItemCount(): Int { | ||
return allEntries.size | ||
} | ||
|
||
fun updateList(newList: List<CoinData>){ | ||
allEntries.clear() | ||
allEntries.addAll(newList) | ||
notifyDataSetChanged() | ||
} | ||
} |