I have two recyclerViews, which represent my grocery list.
When I click on an item it gets "transferred" to the other list.
The problem is that the images are loaded with Glide and Firebase Storage and they don't show the correct images even if the listitem does not have a path.
I have tried every notifyDataSetChanged(), recyclerView.notifyItemChanged() and recyclerView.invalidate() and others. Maybe you could help me.
This is my Adapter:
class RecyclerViewAdapterEinkaufslisteDetail(
val context: Context,
val lebensmittelList: ArrayList<Inventarstueck>
) :
RecyclerView.Adapter<RecyclerViewAdapterEinkaufslisteDetail.ViewHolder>() {
override fun onBindViewHolder(holder: RecyclerViewAdapterEinkaufslisteDetail.ViewHolder, position: Int) {
// TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
//Es wird der Name, die Anzahl, die Einheit (gramm, kg, etc) das Bild und ein Warnzeichen angezeigt, falls ein Produkt abläufty
holder.mName.text = lebensmittelList[position].name_de.toString()
val array = holder.itemView.getContext().getResources().getStringArray(R.array.einheit_kurz)
val placeholder =
lebensmittelList[position].restlichemenge.toString() + " " + array[lebensmittelList[position].einheit!!]
holder.mAnzahl.text = placeholder
// holder.txtTitle.text = userList[position]
holder.mZeichen.visibility = View.INVISIBLE
//KLEINEs Anzeigebild der Produkte runterladen
if (!(lebensmittelList[position].fotoURL.isNullOrEmpty() || lebensmittelList[position].fotoURL.isNullOrBlank())) {
//Überprüfen, ob im Feld die Endung gespeichert ist, wenn nicht, immer png!!
val url:String
if(lebensmittelList[position].fotoURL!!.endsWith(".png")){
url = lebensmittelList[position].fotoURL!!
}else{
url = lebensmittelList[position].fotoURL + ".png"
}
val storage = FirebaseStorage.getInstance()
val storageRef = storage.reference
// Points to "images"
val imagesRef = storageRef.child(Constants.FIREBASE_STORAGE_PRODUKTFOTO_KLEIN_PFAD)
val fotoRef = imagesRef.child(url)
GlideApp.with(this.context).load(fotoRef).into(holder.mProduktfoto)
}
}
override fun getItemCount(): Int {
return lebensmittelList.size
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerViewAdapterEinkaufslisteDetail.ViewHolder {
val v = LayoutInflater.from(parent.context).inflate(R.layout.recyclerview_item_inventar, parent, false)
return ViewHolder(v)
}
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnClickListener, View.OnLongClickListener{
init {
itemView.setOnClickListener(this)
itemView.setOnLongClickListener(this)
}
override fun onClick(v: View) {
clickListener!!.onItemClick(adapterPosition, v);
}
override fun onLongClick(v: View): Boolean {
clickListener!!.onItemLongClick(adapterPosition, v)
return true
}
val mName = itemView.findViewById<TextView>(R.id.rvInventar_tv_Produktname)
val mAnzahl = itemView.findViewById<TextView>(R.id.rvInventar_tv_Anzahl)
val mProduktfoto = itemView.findViewById<ImageView>(R.id.rvInventarProduktFoto)
val mZeichen = itemView.findViewById<ImageView>(R.id.rvInventar_Icon)
// val txtTitle = itemView.findViewById<TextView>(R.id.txtTitle)
val mCard = itemView.findViewById<MaterialCardView>(R.id.rvCardInventar)
}
fun setOnItemClickListener(clickListener: ClickListener) {
RecyclerViewAdapterEinkaufslisteDetail.clickListener = clickListener
}
interface ClickListener {
fun onItemClick(position: Int, v: View)
fun onItemLongClick(position: Int, v: View)
}
companion object {
private var clickListener: RecyclerViewAdapterEinkaufslisteDetail.ClickListener? = null
}
}
This is where I change the data:
rvKaufen = findViewById(R.id.rvEinkaufslisteDetailKaufen)
val layoutmanager = GridLayoutManager(this, 3)
rvKaufen.layoutManager = layoutmanager
rvGekauft = findViewById(R.id.rvEinkaufslisteDetailGekauft)
val layoutmanager2 = GridLayoutManager(this, 3)
rvGekauft.layoutManager = layoutmanager2
rvadapter = RecyclerViewAdapterEinkaufslisteDetail(this, itemsInEinkaufsliste)
// val rvadapter = RecyclerViewAdapterInventar(this.context!!, lebensmittelliste)
rvadapterGekauft = RecyclerViewAdapterEinkaufslisteDetail(this, itemsGekauft)
//nur einmal itemclicklistener zuweisen, sonst megafehler! intern abrufen aus welchem Recyclerview der Click gekommen ist
/**/ rvadapter.setOnItemClickListener(object : RecyclerViewAdapterEinkaufslisteDetail.ClickListener {
override fun onItemClick(position: Int, v: View) {
Log.d("Click", "onItemClick position: $position")
val parentId = (v.parent as View).id
if (parentId == rvKaufen.id) {
Toast.makeText(this#EinkaufslisteDetail, "GeKAUFt", Toast.LENGTH_SHORT).show()
/* val inventarstueck = rvadapter.lebensmittelList[position].copy()
//Hier auch aus den Listen löschen??
//TODO
rvadapterGekauft.lebensmittelList.add(inventarstueck)
rvadapterGekauft.notifyDataSetChanged()
rvadapter.lebensmittelList.removeAt(position)
// itemsInEinkaufsliste.removeAt(position)
rvadapter.notifyItemRemoved(position)
// rvadapter.lebensmittelList.removeAt(position)
*/
//rvadapter.notifyDataSetChanged()
val inventarstueck = itemsInEinkaufsliste[position].copy()
//itemsGekauft.add(inventarstueck)
itemsGekauft.add(inventarstueck)
rvadapterGekauft.notifyItemInserted(itemsGekauft.size-1)
// rvadapterGekauft.notifyItemRangeChanged(0,itemsGekauft.size)
itemsInEinkaufsliste.removeAt(position)
rvadapter.notifyItemRemoved(position)
rvadapter.notifyItemRangeChanged(position,itemsInEinkaufsliste.size)
/* rvKaufen.adapter = null
rvKaufen.layoutManager = null
rvKaufen.adapter = rvadapter
val layoutmanager3 = GridLayoutManager(this#EinkaufslisteDetail, 3)
rvKaufen.layoutManager = layoutmanager3
rvadapter.notifyDataSetChanged()
//rvKaufen.removeViewAt(position)
// rvGekauft.add
rvGekauft.adapter = null
rvGekauft.layoutManager = null
rvGekauft.adapter = rvadapterGekauft
val layoutmanager4 = GridLayoutManager(this#EinkaufslisteDetail, 3)
rvKaufen.layoutManager = layoutmanager4
rvadapterGekauft.notifyDataSetChanged()*/
} else if (parentId == rvGekauft.id) {
Toast.makeText(this#EinkaufslisteDetail, "Zurück geschoben", Toast.LENGTH_SHORT).show()
/* val inventarstueck = rvadapterGekauft.lebensmittelList[position].copy()
rvadapter.lebensmittelList.add(inventarstueck)
rvadapter.notifyDataSetChanged()
rvadapterGekauft.lebensmittelList.removeAt(position)
rvadapterGekauft.notifyItemRemoved(position)*/
val inventarstueck = itemsGekauft[position].copy()
//itemsGekauft.add(inventarstueck)
itemsInEinkaufsliste.add(inventarstueck)
rvadapter.notifyItemInserted(itemsInEinkaufsliste.size-1)
// rvadapter.notifyItemRangeChanged(0,itemsInEinkaufsliste.size)
itemsGekauft.removeAt(position)
rvadapterGekauft.notifyItemRemoved(position)
rvadapterGekauft.notifyItemRangeChanged(position,itemsGekauft.size)
/* rvKaufen.adapter = null
rvKaufen.layoutManager = null
rvKaufen.adapter = rvadapter
val layoutmanager3 = GridLayoutManager(this#EinkaufslisteDetail, 3)
rvKaufen.layoutManager = layoutmanager3
rvadapter.notifyDataSetChanged()
rvGekauft.adapter = null
rvGekauft.layoutManager = null
rvGekauft.adapter = rvadapterGekauft
val layoutmanager4 = GridLayoutManager(this#EinkaufslisteDetail, 3)
rvKaufen.layoutManager = layoutmanager4
rvadapterGekauft.notifyDataSetChanged()*/
}
}
override fun onItemLongClick(position: Int, v: View) {
Log.d("Click", "onItemLongClick pos = $position")
Log.d("Click", "onItemClick position: $position")
val parentId = (v.parent as View).id
if (parentId == rvKaufen.id) {
Toast.makeText(this#EinkaufslisteDetail, "Verändern", Toast.LENGTH_SHORT).show()
val inventarstueck = rvadapter.lebensmittelList[position].copy()
val intent = Intent(this#EinkaufslisteDetail, EinkaufslisteProduktBearbeiten::class.java)
intent.putExtra("swissID",inventarstueck.swiss_id)
intent.putExtra("scandatum",inventarstueck.scandatum)
intent.putExtra("einkaufslistenID",einkaufslistenID)
startActivityForResult(intent,_resultCODE)
}else if (parentId == rvGekauft.id) {
Toast.makeText(this#EinkaufslisteDetail, "Keine Aktion möglich", Toast.LENGTH_SHORT).show()
}
}
})
When I call the SetItemClickListener on the second recyclerView as well, then the whole process doesn't work.
It is very rare that there are two recyclerViews used so I haven't found anything either.
EDIT
I found the solution for my Problem:
I set the ImageView to a default picture, in case there is no URL.,
if (!(lebensmittelList[position].fotoURL.isNullOrEmpty() || lebensmittelList[position].fotoURL.isNullOrBlank())) {
.
.
. GlideApp.with(this.context).load(fotoRef).into(holder.mProduktfoto)
}else{
holder.mProduktfoto.setImageResource(R.drawable.logo_384_384)
}
Related
Here RecyclerView loads only one item however the loops works prefect but with RecyclerView loads only one item and not load all items
.........................................................................................................................................................................................................................................
GetJson.kt
class GetJson : AppCompatActivity() {
lateinit var recyclerView: RecyclerView
var arrayList = ArrayList<JsonModel>()
private var requestQueue : RequestQueue? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_get_json)
recyclerView = findViewById(R.id.recyclerView2)
recyclerView.layoutManager = LinearLayoutManager(this)
val getButton : Button = findViewById(R.id.ShowButtonJson)
requestQueue = Volley.newRequestQueue(this)
getButton.setOnClickListener {
getFromServer()
}
}
fun getFromServer(){
val url = "http://..../testapp/getjson.php"
val request = JsonObjectRequest(Request.Method.GET,url,null, {
response -> try {
val jsonArray = response.getJSONArray("names")
for (i in 0 until jsonArray.length()){
val name = jsonArray.getJSONObject(i)
val firstname = name.getString("firstname")
val middlename = name.getString("middlename")
val lastname = name.getString("lastname")
arrayList.add(JsonModel(firstname,middlename,lastname))
}
val namesAdapter = jsonAdapter(arrayList)
recyclerView.adapter = namesAdapter
namesAdapter.notifyDataSetChanged()
} catch (e: JSONException){
e.printStackTrace()
}
}, { response -> response.printStackTrace()
})
requestQueue?.add(request)
}
}
jsonAdapter.kt
class jsonAdapter(val data : List<JsonModel>) : RecyclerView.Adapter<jsonAdapter.ViewHolder>() {
class ViewHolder(view : View) : RecyclerView.ViewHolder(view) {
val firstnameText : TextView = view.findViewById(R.id.firstnameView)
val middlenameText : TextView = view.findViewById(R.id.middleNameView)
val lastnameText : TextView = view.findViewById(R.id.lastNameView)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): jsonAdapter.ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.jsonlist,parent,false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: jsonAdapter.ViewHolder, position: Int) {
val namesModel = data[position]
holder.firstnameText.text = namesModel.firstname
holder.middlenameText.text = namesModel.middlename
holder.lastnameText.text = namesModel.lastname
}
override fun getItemCount(): Int {
return data.size
}
}
When I just added it, everything is fine, but when I restart the application, only textViews is displayed. There is an empty space instead of an imageView.
My recycler adapter:
class PersonAdapter(options: FirebaseRecyclerOptions<Outfit?>) :
FirebaseRecyclerAdapter<Outfit, personsViewHolder>(options) {
override fun onBindViewHolder(holder: personsViewHolder, position: Int, model: Outfit) {
holder.name.text = model.name
holder.brand.text = model.brand
holder.size.text = model.size
holder.comment.text = model.comment
holder.price.text = model.price
Picasso.get().load(model.imageUrl).into(holder.imageView) //Glide analog
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): personsViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.recycler_item, parent, false)
return personsViewHolder(view)
}
class personsViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var name: TextView = itemView.findViewById(R.id.tv_name_value)
var brand: TextView = itemView.findViewById(R.id.tv_brand_value)
var size: TextView = itemView.findViewById(R.id.tv_size_value)
var comment: TextView = itemView.findViewById(R.id.tv_comment_value)
var price: TextView = itemView.findViewById(R.id.tv_price_value)
var imageView: ImageView = itemView.findViewById(R.id.imageView)
}
}
Class what add to database:
private var dataBase: DatabaseReference? = null
private lateinit var outfitImage: ImageView
private var imageUri: Uri? = null
private var id: Int = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_add_outfit)
nameView = findViewById(R.id.et_outfitName)
brandView = findViewById(R.id.et_outfitBrand)
sizeView = findViewById(R.id.et_outfitSize)
commentView = findViewById(R.id.et_outfitComment)
priceView = findViewById(R.id.et_outfitPrice)
btnAdd = findViewById(R.id.btn_addOutfit)
btnLoad = findViewById(R.id.btn_load)
btnAdd?.setOnClickListener {
onClickSave()
Toast.makeText(this, "Added to database", Toast.LENGTH_SHORT).show()
startActivity(Intent(this, MainActivity::class.java))
}
btnLoad?.setOnClickListener {
onClickRead()
}
outfitImage = findViewById(R.id.iv_upload_image)
outfitImage.setOnClickListener {
chooseImage()
}
}
//SAVE BUTTON
private fun onClickSave() {
dataBase = FirebaseDatabase.getInstance().getReference(UUID.randomUUID().toString())
dataBase?.setValue(
Outfit(
nameView?.text.toString(),
brandView?.text.toString(),
sizeView?.text.toString(),
commentView?.text.toString(),
priceView?.text.toString(),
imageUri.toString()
)
)
uploadImageToFirebase(imageUri!!)
}
//----------------UPLOAD IMAGE-----------------------
private fun chooseImage() {
val intent = Intent()
intent.type = "image/*"
intent.action = Intent.ACTION_GET_CONTENT
startActivityForResult(
Intent.createChooser(intent, "Please select..."), 1
)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == 1 && resultCode == Activity.RESULT_OK && data != null && data.data != null) {
// Get the Uri of data
imageUri = data.data
outfitImage.setImageURI(imageUri)
}
}
private fun uploadImageToFirebase(imageUri: Uri) {
val pd: ProgressDialog = ProgressDialog(this)
pd.setTitle("Uploading image...")
pd.show()
val fileName = UUID.randomUUID().toString()
val refStorage = FirebaseStorage.getInstance().reference.child("images/$fileName")
refStorage.putFile(imageUri)
.addOnSuccessListener { taskSnapshot ->
taskSnapshot.storage.downloadUrl.addOnSuccessListener {
pd.dismiss()
Snackbar.make(
findViewById(android.R.id.content),
"Image uploaded.",
Snackbar.LENGTH_LONG
)
val imageUrl = it.toString()
}
}
.addOnFailureListener { e ->
print(e.message)
pd.dismiss()
}
//progressbar
.addOnProgressListener {
var progressPercents: Double = (100.00 * it.bytesTransferred / it.totalByteCount)
pd.setMessage("Percentage: $progressPercents%")
}
}
}
Logic at MainActivity:
mbase = FirebaseDatabase.getInstance().reference
recyclerView = findViewById(R.id.recycler1)
recyclerView.layoutManager = LinearLayoutManager(this)
val options = FirebaseRecyclerOptions.Builder<Outfit>()
.setQuery(mbase!!, Outfit::class.java)
.build()
// Connecting object of required Adapter class to the Adapter class itself
adapter = PersonAdapter(options)
// Connecting Adapter class with the Recycler view*/
recyclerView.adapter = adapter
swipeRefreshLayout.setOnRefreshListener(this)
Here are screenshots of how everything looks in the backend:
my backend
images storage
private fun uploadToFirebase() {
val pd: ProgressDialog = ProgressDialog(this)
pd.setTitle("Uploading image...")
pd.show()
val fileName = UUID.randomUUID().toString()
val refStorage = FirebaseStorage.getInstance().getReference("/images/$fileName")
refStorage.putFile(selectedPhotoUri!!)
.addOnSuccessListener {
pd.dismiss() //close loading
refStorage.downloadUrl.addOnSuccessListener {
saveDataToDatabase(it.toString()) //get downloading url
}
}
.addOnFailureListener { e ->
print(e.message)
pd.dismiss()
}
//progressbar
.addOnProgressListener {
var progressPercents: Double = (100.00 * it.bytesTransferred / it.totalByteCount)
pd.setMessage("Percentage: $progressPercents%")
}
}
private fun saveDataToDatabase(imageUrl:String) {
dataBase = FirebaseDatabase.getInstance().getReference(UUID.randomUUID().toString())
dataBase?.setValue(
Outfit(
nameView?.text.toString(),
brandView?.text.toString(),
sizeView?.text.toString(),
commentView?.text.toString(),
priceView?.text.toString(),
imageUrl
)
)
}
Here is my solution. Bad url was a ploblem.
I have implemented a onClicklistener in my recycleview which works but the onLongClickListener is not responding? I have added the code in the Adapter, which is being called from a fragment. The onClickListener works well. Whn I click onLongClick -> it needs to display an AlertDialog, but in this case on running the app, there are no errors and no longclick too. This is in Kotlin, what am I doing wrong - any thoughts please?
class UserMsgAdapter(
mContext: Context,
userMsgList: List<MessageList>,
mUsers: List<Users>,
isChatCheck: Boolean
): RecyclerView.Adapter<UserMsgAdapter.ViewHolder?>()
{
private val mContext: Context
private val userMsgList: List<MessageList>
private val mUsers:List<Users>
private var isChatCheck: Boolean
init{
this.mUsers = mUsers
this.userMsgList = userMsgList
this.mContext = mContext
this.isChatCheck = isChatCheck
}
var lastMsg: String = ""
var timeMsg: Long = 0
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder {
val view: View = LayoutInflater.from(mContext).inflate(
R.layout.user_search_item_layout,
viewGroup,
false
)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val message: MessageList? = userMsgList[position]
//Accessing the receiverId from the ChatList
val receiverId = message!!.getId()
val ref = FirebaseDatabase.getInstance().reference.child("Users").child(receiverId!!)
ref.addListenerForSingleValueEvent(object : ValueEventListener {
override fun onDataChange(p0: DataSnapshot) {
val user = p0.getValue(Users::class.java)
holder.userNameText.text = user!!.getUserName()
Picasso.get().load(user.getProfile())
.placeholder(R.drawable.ic_baseline_whatshot_24).fit().centerCrop().into(
holder.profileImageView
)
//Showcasing Last Message
if (isChatCheck) {
retrieveLastMessage(
user.getUID(),
holder.lastMessagetxt,
holder.timestamptxt,
holder.new_message_count
)
} else {
holder.lastMessagetxt.visibility = View.GONE
}
//Calling the Message Activity
holder.itemView.setOnClickListener {
val intent = Intent(mContext, MessageActivity::class.java)
intent.putExtra("visit_id", user.getUID())
mContext.startActivity(intent)
}
//Menu on Search Fragment
holder.itemView.setOnLongClickListener {
val options = arrayOf<CharSequence>(
"Delete Chat",
"Visit Profile"
)
val builder: AlertDialog.Builder = AlertDialog.Builder(mContext)
builder.setTitle("What would you like to do?")
builder.setItems(options, DialogInterface.OnClickListener { _, which ->
if (which == 0) {
val intent = Intent(mContext, MessageActivity::class.java)
intent.putExtra("visit_id", user.getUID())
mContext.startActivity(intent)
}
if (which == 1) {
val intent = Intent(mContext, VisitUserProfile::class.java)
intent.putExtra("visit_id", user.getUID())
mContext.startActivity(intent)
}
})
builder.show()
true
}
}
override fun onCancelled(error: DatabaseError) {
}
})
}
override fun getItemCount(): Int {
return userMsgList.size
}
class ViewHolder(itemView: View): RecyclerView.ViewHolder(itemView)
{
var userNameText: TextView = itemView.findViewById(R.id.username)
var profileImageView: ShapeableImageView = itemView.findViewById(R.id.profile_image)
var lastMessagetxt: TextView = itemView.findViewById(R.id.last_message)
var timestamptxt: TextView = itemView.findViewById(R.id.time_stamp)
var new_message_count: TextView = itemView.findViewById(R.id.new_message_count)
}
//print last message and timestamp
private fun retrieveLastMessage(
messageUserId: String?, lastMessagetxt: TextView,
timestamptxt: TextView, new_message_count: TextView,
)
{
lastMsg = "defaultMsg"
timeMsg = 0
var countUnreadMessages = 0
val firebaseUser = FirebaseAuth.getInstance().currentUser
val reference = FirebaseDatabase.getInstance().reference.child("Chats")
reference.addValueEventListener(object : ValueEventListener {
override fun onDataChange(p0: DataSnapshot) {
for (dataSnapshot in p0.children) {
val message: Message? = dataSnapshot.getValue(Message::class.java)
if (firebaseUser != null && message != null) {
if (message.getReceiver() == firebaseUser.uid && message.getSender() == messageUserId ||
message.getReceiver() == messageUserId && message.getSender() == firebaseUser.uid
) {
lastMsg = message.getMessage()!!
timeMsg = message.getTimestamp()!!
}
if (message.getReceiver() == firebaseUser.uid && message.getSender() == messageUserId && !message.isIsSeen()) {
countUnreadMessages += 1
}
}
}
when (lastMsg) {
"defaultMsg" -> lastMessagetxt.text = ""
"Shared an image with you." -> lastMessagetxt.text = "Shared an image"
else -> lastMessagetxt.text = lastMsg
}
//Display count of unread messages
if (countUnreadMessages != 0) {
new_message_count.text = countUnreadMessages.toString()
new_message_count.setBackgroundResource(R.drawable.new_chat_bg)
} else {
new_message_count.setBackgroundResource(0)
new_message_count.text = ""
}
countUnreadMessages = 0
//Display formatted date and time
val time = dateFormatter(timeMsg)
when (time) {
"01-01-1970" -> timestamptxt.text = ""
else -> timestamptxt.text = time
}
}
override fun onCancelled(error: DatabaseError) {
}
})
}
}
I am trying to rewrite an existing app in Kotlin for the purpose of learning and getting used to the language. The app allows the user to enter and modify entries and each entry is hosted in a RecyclerView list with a custom list item. Although entries are successfully added to the database (confirming that with Toast messages), there isn't a list item present for the said entry.
This is my adapter:
class EntryAdapter : androidx.recyclerview.widget.ListAdapter<Entry, EntryAdapter.ViewHolder>(DIFF_CALLBACK){
private var listener: OnItemLongClickListener? = null
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.recyclerview_item, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int){
val currentEntry = getItem(position)
holder.hint.text = currentEntry.hint
holder.username.text = currentEntry.username
holder.password.text = currentEntry.password
}
fun getEntryAt(position: Int): Entry{return getItem(position)}
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){
val username: TextView = itemView.findViewById(R.id.username_display)
val password: TextView = itemView.findViewById(R.id.password_display)
val hint: TextView = itemView.findViewById(R.id.hint_display)
init {
itemView.setOnLongClickListener{
val position = adapterPosition
if (listener != null && position != RecyclerView.NO_POSITION){listener!!.onItemLongClick(getItem(position))}
true
}
}
}
interface OnItemLongClickListener{fun onItemLongClick(entry: Entry)}
fun setOnItemLongClickListener(listener: OnItemLongClickListener){this.listener = listener}
companion object{
private val DIFF_CALLBACK = object : DiffUtil.ItemCallback<Entry>(){
override fun areItemsTheSame(oldItem: Entry, newItem: Entry): Boolean{return oldItem.id == newItem.id}
override fun areContentsTheSame(oldItem: Entry, newItem: Entry): Boolean{return oldItem.username == newItem.username && oldItem.hint == newItem.hint && oldItem.password == newItem.password}
}
}
}
This is my AddEditEntry.kt activity. The way it works is that when the user wishes to make an entry, he/she clicks on the FAB button which invokes this activity. This activity is where the user enters the entry and adds it to the database (and by extension, the RecyclerView) by clicking the saveEntry button:
class AddEditEntryActivity : AppCompatActivity() {
private var usernameEditText: EditText? = null
private var passwordEditText: EditText? = null
private var hintEditText: EditText? = null
private var passwordABCD: CheckBox? = null
private var passwordabcd: CheckBox? = null
private var password0123: CheckBox? = null
private var passwordSymbols: CheckBox? = null
private var radio4: RadioButton? = null
private var radio8: RadioButton? = null
private var radio12: RadioButton? = null
private var radio16: RadioButton? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_addedit_entry)
usernameEditText = findViewById(R.id.username_field)
passwordEditText = findViewById(R.id.password_field)
hintEditText = findViewById(R.id.hint_field)
passwordABCD = findViewById(R.id.upp_checkbox)
passwordabcd = findViewById(R.id.low_checkbox)
password0123 = findViewById(R.id.num_checkbox)
passwordSymbols = findViewById(R.id.sym_checkbox)
radio4 = findViewById(R.id.four)
radio8 = findViewById(R.id.eight)
radio12 = findViewById(R.id.twelve)
radio16 = findViewById(R.id.sixteen)
val generatePassword = findViewById<Button>(R.id.btn_password_generate)
val saveEntry = findViewById<Button>(R.id.btn_save)
val intent = intent
if (intent.hasExtra(EXTRA_ID)) {
title = getString(R.string.edit_entry)
saveEntry.setText(R.string.update_entry)
usernameEditText!!.setText(getIntent().getStringExtra(EXTRA_USERNAME))
passwordEditText!!.setText(getIntent().getStringExtra(EXTRA_PASSWORD))
hintEditText!!.setText(getIntent().getStringExtra(EXTRA_HINT))
}
else {title = "Add Entry"}
Objects.requireNonNull<ActionBar>(supportActionBar).setHomeAsUpIndicator(R.drawable.ic_close_white_24dp)
generatePassword.setOnClickListener { passwordEditText!!.setText(generatedPassword()) }
saveEntry.setOnClickListener {
val data = Intent()
data.putExtra(EXTRA_USERNAME, usernameEditText!!.text.toString())
data.putExtra(EXTRA_HINT, hintEditText!!.text.toString())
data.putExtra(EXTRA_PASSWORD, passwordEditText!!.text.toString())
val id = getIntent().getIntExtra(EXTRA_ID, -1)
if (id != -1) {data.putExtra(EXTRA_ID, id)}
setResult(Activity.RESULT_OK, data)
finish()
Toast.makeText(this, "data.putExtra() from AddEditEntryActivity", Toast.LENGTH_SHORT).show()
Toast.makeText(this, usernameEditText!!.text.toString(), Toast.LENGTH_SHORT).show()
Toast.makeText(this, hintEditText!!.text.toString(), Toast.LENGTH_SHORT).show()
Toast.makeText(this, passwordEditText!!.text.toString(), Toast.LENGTH_SHORT).show()
}
}
private fun generatedPassword(): String? {
var length = 0
val generatedString = StringBuilder()
val rand = Random()
val capitalLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
val lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"
val numbers = "0123456789"
val characters = "!##$%^&*()"
if (radio4!!.isChecked) {length = 4}
else if (radio8!!.isChecked) {length = 8}
else if (radio12!!.isChecked) {length = 12}
else if (radio16!!.isChecked) {length = 16}
var totalCharacters = ""
if (passwordABCD!!.isChecked) {totalCharacters += capitalLetters}
if (passwordabcd!!.isChecked) {totalCharacters += lowercaseLetters}
if (password0123!!.isChecked) {totalCharacters += numbers}
if (passwordSymbols!!.isChecked) {totalCharacters += characters}
if (!totalCharacters.trim { it <= ' ' }.isEmpty() && length > 0) {
for (i in 0 until length) {generatedString.append(totalCharacters[rand.nextInt(totalCharacters.length)])}
return generatedString.toString()
}
else {Toast.makeText(this, "Not a valid password!", Toast.LENGTH_SHORT).show()}
return null
}
companion object {
val EXTRA_USERNAME = "com.ozbek.cryptpass.EXTRA_USERNAME"
val EXTRA_HINT = "com.ozbek.cryptpass.EXTRA_HINT"
val EXTRA_PASSWORD = "com.ozbek.cryptpass.EXTRA_PASSWORD"
val EXTRA_ID = "com.ozbek.cryptpass.EXTRA_ID"
}
}
And this is the MainActivity.kt file where the user enters new entries. The first if block in onActivityResult() is the code that retrieves the entries from AddEditEntry.kt file and adds it to the entity class:
class MainActivity : AppCompatActivity(), LifecycleOwner {
private lateinit var recyclerView: RecyclerView
internal lateinit var adapter: EntryAdapter
private lateinit var floatingActionButton: FloatingActionButton
private lateinit var layoutManager: RecyclerView.LayoutManager
private lateinit var addEditEntryActivity: AddEditEntryActivity
internal lateinit var entry: Entry
private lateinit var viewModel: EntryViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val ctx = this.applicationContext
val sentryDsn = "https://93f06d5090d646ac9443a3fc531fc5de#sentry.io/1454826:port/1?options"
Sentry.init(sentryDsn, AndroidSentryClientFactory(ctx))
Sentry.init(AndroidSentryClientFactory(ctx))
viewModel = ViewModelProviders.of(this).get(EntryViewModel::class.java)
viewModel.allEntries.observe(this, Observer { entries -> adapter.submitList(entries) })
adapter = EntryAdapter()
layoutManager = LinearLayoutManager(this)
recyclerView = findViewById<RecyclerView>(R.id.userpass_recyclerview).apply{
layoutManager = layoutManager
adapter = adapter
}
addEditEntryActivity = AddEditEntryActivity()
entry = Entry()
floatingActionButton = findViewById<FloatingActionButton>(R.id.generate_fab)
floatingActionButton.setOnClickListener {
val intent = Intent(this#MainActivity, AddEditEntryActivity::class.java)
Toast.makeText(this, "AddEditActivity started", Toast.LENGTH_SHORT).show()
startActivityForResult(intent, ADD_ENTRY_REQUEST)
}
ItemTouchHelper(object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT) {
override fun onMove(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean {return false}
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {viewModel.delete(adapter.getEntryAt(viewHolder.adapterPosition))}
}).attachToRecyclerView(recyclerView)
adapter.setOnItemLongClickListener (object: EntryAdapter.OnItemLongClickListener {
override fun onItemLongClick(entry: Entry){
val intent = Intent(this#MainActivity, AddEditEntryActivity::class.java)
intent.putExtra(AddEditEntryActivity.EXTRA_ID, entry.id)
intent.putExtra(AddEditEntryActivity.EXTRA_USERNAME, entry.username)
intent.putExtra(AddEditEntryActivity.EXTRA_HINT, entry.hint)
intent.putExtra(AddEditEntryActivity.EXTRA_PASSWORD, entry.password)
startActivityForResult(intent, EDIT_ENTRY_REQUEST)
}
})
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu, menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
val itemId = item.itemId
if (itemId == R.id.delete_all) {viewModel.deleteAll()}
return super.onOptionsItemSelected(item)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == ADD_ENTRY_REQUEST && resultCode == Activity.RESULT_OK) {
Toast.makeText(this, data?.getStringExtra(AddEditEntryActivity.EXTRA_USERNAME), Toast.LENGTH_SHORT).show()
Toast.makeText(this, data?.getStringExtra(AddEditEntryActivity.EXTRA_PASSWORD), Toast.LENGTH_SHORT).show()
Toast.makeText(this, data?.getStringExtra(AddEditEntryActivity.EXTRA_HINT), Toast.LENGTH_SHORT).show()
val username = Objects.requireNonNull<Intent>(data).getStringExtra(AddEditEntryActivity.EXTRA_USERNAME)
val password = Objects.requireNonNull<Intent>(data).getStringExtra(AddEditEntryActivity.EXTRA_PASSWORD)
val hint = Objects.requireNonNull<Intent>(data).getStringExtra(AddEditEntryActivity.EXTRA_HINT)
val entry = Entry(username, hint, password)
viewModel.insert(entry)
Toast.makeText(this, "Entry added!", Toast.LENGTH_SHORT).show()
} else if (requestCode == EDIT_ENTRY_REQUEST && resultCode == Activity.RESULT_OK) {
Toast.makeText(this, data!!.getIntExtra(AddEditEntryActivity.EXTRA_ID, -1), Toast.LENGTH_SHORT).show()
Toast.makeText(this, data.getStringExtra(AddEditEntryActivity.EXTRA_USERNAME), Toast.LENGTH_SHORT).show()
Toast.makeText(this, data.getStringExtra(AddEditEntryActivity.EXTRA_PASSWORD), Toast.LENGTH_SHORT).show()
Toast.makeText(this, data.getStringExtra(AddEditEntryActivity.EXTRA_HINT), Toast.LENGTH_SHORT).show()
val id = Objects.requireNonNull<Intent>(data).getIntExtra(AddEditEntryActivity.EXTRA_ID, -1)
if (id == -1) {
Toast.makeText(this, "Something went wrong", Toast.LENGTH_SHORT).show()
return
}
val username = Objects.requireNonNull<Intent>(data).getStringExtra(AddEditEntryActivity.EXTRA_USERNAME)
val password = Objects.requireNonNull<Intent>(data).getStringExtra(AddEditEntryActivity.EXTRA_PASSWORD)
val hint = Objects.requireNonNull<Intent>(data).getStringExtra(AddEditEntryActivity.EXTRA_HINT)
val entry = Entry(username, hint, password, id)
entry.id = id
viewModel.update(entry)
Toast.makeText(this, "Entry updated", Toast.LENGTH_SHORT).show()
} else {Toast.makeText(this, "Entry not added!", Toast.LENGTH_SHORT).show()}
}
companion object {
const val ADD_ENTRY_REQUEST = 1
const val EDIT_ENTRY_REQUEST = 2
}
}
I can add more code per request. This is the full Github repo.
Here is the problem:
recyclerView = findViewById<RecyclerView>(R.id.userpass_recyclerview).apply{
layoutManager = layoutManager
adapter = adapter
}
Idk what's going on but it seems like you're initializing them to themselves. Don't do that. Its good practice to keep your variable names distinct. Refactor the objects like this:
internal lateinit var entryAdapter: EntryAdapter
private lateinit var linearLayoutManager: RecyclerView.LayoutManager
And make the following changes in your onCreate():
recyclerView = findViewById<RecyclerView>(R.id.userpass_recyclerview).apply{
adapter = entryAdapter
layoutManager = linearLayoutManager
}
I'm new to android development. I'm developing an app which needs vertical RecyclerView inside another vertical RecyclerView . I created it but the problem is that I want to group the inner RecyclerView elements according to the outer RecyclerView elements.
I have attached the code for reference!
private fun ResponsibilityExpListFun() {
CommonFunctions.hideSoftKeyboard(this#DailyTasksPage)
builder = AlertDialog.Builder(this#DailyTasksPage)
inflater = layoutInflater
dialogView = inflater!!.inflate(R.layout.expandable_list_dialog, null)
dialog = builder!!.create()
expandableListView = dialogView!!.findViewById(R.id.expandablelistview) as ExpandableListView
dialog!!.setView(dialogView)
expandableListView?.setAdapter(TaskResponsibiltyExpandableAdapter(this, expandableListView!!, header, body))
dialog!!.show()
dialog!!.setCancelable(true)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_daily_tasks)
setSupportActionBar(daily_task_toolbar)
daily_task_toolbar.navigationIcon = resources.getDrawable(R.drawable.back_icon)
daily_task_toolbar.setNavigationOnClickListener { finish() }
/* daily_Task_Refresh.setOnRefreshListener {
try {
onStart()
} catch (e: Exception) {
e.printStackTrace()
}
}*/
daily_Task_Refresh.isEnabled = false
val sharedPreferences = getSharedPreferences("App_Details", Context.MODE_PRIVATE)
strMobileIdentifier = sharedPreferences.getString("IMEI_NUMBER", null)
strTokenSecret = sharedPreferences.getString("TOKEN_SECRET", null)
var linearLayoutManager = LinearLayoutManager(this)
Daily_Tasks_recyclerview?.layoutManager = linearLayoutManager
ahowalltaskadapter = AllTaskAdapter(slotIDarrayList)
Daily_Tasks_recyclerview.adapter = ahowalltaskadapter
cayyoverslotadapter = CarryOverSlotAdapter(previousSlotarrayList)
//ahowalltaskadapter = ahowalltaskadapter(slotIDarrayList)
/* preplan_Image_Toggle.setOnClickListener {
preplan_Image_ToggleUp.visibility = View.VISIBLE
preplan_Image_Toggle.visibility = View.GONE
PrePlanTaskRecyclerView.visibility = View.VISIBLE
}
preplan_Image_ToggleUp.setOnClickListener {
preplan_Image_Toggle.visibility = View.VISIBLE
preplan_Image_ToggleUp.visibility = View.GONE
PrePlanTaskRecyclerView.visibility = View.GONE
}*/
fab_btn_DailyTask.setOnClickListener { it ->
builder = AlertDialog.Builder(this)
inflater = layoutInflater
dialogView = inflater!!.inflate(R.layout.edit_curremt_slot, null)
dialog = builder!!.create()
layout = dialogView!!.findViewById(R.id.edit_current_slot_cardview) as CardView
taskName = dialogView!!.findViewById(R.id.edit_content) as TextInputEditText
taskResp = dialogView!!.findViewById(R.id.edit_resp_content) as TextView
taskPackage = dialogView!!.findViewById(R.id.edit_prod_content) as TextView
taskPriority = dialogView!!.findViewById(R.id.edit_priority_content) as TextView
SaveBtn = dialogView!!.findViewById(R.id.SaveEditSlot) as Button
CancelBtn = dialogView!!.findViewById(R.id.cancelEditSlot) as Button
layout!!.setOnClickListener {
CommonFunctions.hideSoftKeyboard(activity = this#DailyTasksPage)
}
CancelBtn!!.setOnClickListener {
dialog!!.dismiss()
}
// expandableListView = dialogView!!.findViewById(R.id.expandablelistview) as ExpandableListView
dialog!!.show()
taskResp!!.setOnClickListener {
count = 1
ResponsibilityExpListFun()
}
taskPackage!!.setOnClickListener {
count = 2
PackageExpListFun()
}
taskPriority!!.setOnClickListener {
PriorityFun()
}
SaveBtn!!.setOnClickListener {
strTaskName = taskName!!.text.toString()
if (strTaskName.isNullOrEmpty()) {
Snackbar.make(dialogView!!, "Task Name field is empty", Snackbar.LENGTH_LONG).show()
return#setOnClickListener
}
if (taskResp!!.text.isNullOrEmpty()) {
Snackbar.make(dialogView!!, "Task Responsibility field is empty", Snackbar.LENGTH_LONG).show()
return#setOnClickListener
}
if (taskPriority!!.text.isNullOrEmpty()) {
Snackbar.make(dialogView!!, "Task Priority field is empty", Snackbar.LENGTH_LONG).show()
return#setOnClickListener
}
AddTaskFunction()
dialog!!.dismiss()
}
// expandableListView?.setAdapter(TaskResponsibiltyExpandableAdapter(this, expandableListView!!, header, body))
dialog!!.setView(dialogView)
dialog!!.show()
// dialog!!.setCancelable(false)
}
}
inner class AllTaskAdapter(val alltaskList: ArrayList<SlotIDClass>) : RecyclerView.Adapter<AllTaskAdapter.ViewHolderAdapter>() {
var slotName: String? = null
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AllTaskAdapter.ViewHolderAdapter {
val View = LayoutInflater.from(parent.context).inflate(R.layout.previous_slot_format, parent, false)
val sharedPreferences = View.context.getSharedPreferences("App_Details", Context.MODE_PRIVATE)
slotName = sharedPreferences.getString("SlotName", null)
return ViewHolderAdapter(View)
}
override fun getItemCount(): Int {
return alltaskList.size
}
override fun onBindViewHolder(holder: AllTaskAdapter.ViewHolderAdapter, position: Int) {
val layoutManager = CustomLinearLayoutManager(holder.itemView.context)
taskinnerAdapter = RunningTaskAdapter(currTaskarrayList)
holder.DailyTasks_Recyclerview!!.setLayoutManager(layoutManager)
holder.DailyTasks_Recyclerview!!.addItemDecoration(DividerItemDecoration(holder.DailyTasks_Recyclerview!!.context, DividerItemDecoration.VERTICAL))
holder.DailyTasks_Recyclerview!!.adapter = taskinnerAdapter
println("Running tASK aDaPtEr------------------------------" + ahowalltaskadapter.toString())
holder.SlotName!!.text = alltaskList.get(position).SlotName
if (holder.SlotName!!.text.equals(slotName)) {
holder.title_prev_slot!!.setBackgroundColor(holder.itemView.resources.getColor(R.color.dark_orange))
holder.strShowime!!.visibility = View.VISIBLE
var SlotTime = (ToMilliseconds!! - CurrentMilliseconds!!).toLong()
object : CountDownTimer(SlotTime.toLong(), 1000) {
override fun onTick(millisUntilFinished: Long) {
strShowime = String.format(Locale.getDefault(), "Time Remaining %02d hour %02d min %02d sec",
TimeUnit.MILLISECONDS.toHours(millisUntilFinished),
TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished) % 60,
TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) % 60)
holder.strShowime!!.setText(strShowime)
}
override fun onFinish() {
onStart()
GetCurrentSlot()
}
}.start()
Toast.makeText(holder.itemView.context.applicationContext, strShowime, Toast.LENGTH_LONG).show()
}
}
inner class ViewHolderAdapter(view: View) : RecyclerView.ViewHolder(view), View.OnClickListener {
override fun onClick(v: View?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
var DailyTasks_Recyclerview: RecyclerView? = null
var SlotName: TextView? = null
var title_prev_slot: RelativeLayout? = null
var strShowime: TextView? = null
init {
this.DailyTasks_Recyclerview = view.findViewById(R.id.Daily_Tasks_recyclerview) as RecyclerView
this.SlotName = view.findViewById(R.id.prev_SlotName) as TextView
this.title_prev_slot = view.findViewById(R.id.title_prev_slot) as RelativeLayout
this.strShowime = view.findViewById(R.id.strShowime) as TextView
}
}
}
inner class RunningTaskAdapter(val runningtaskList: ArrayList<TaskDetailsDataClass>) : RecyclerView.Adapter<RunningTaskAdapter.RunningTaskViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RunningTaskAdapter.RunningTaskViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.runningtasks_format, parent, false)
return RunningTaskViewHolder(view)
}
override fun getItemCount(): Int {
return runningtaskList.size
}
override fun onBindViewHolder(holder: RunningTaskAdapter.RunningTaskViewHolder, position: Int) {
holder.tasknameText?.text = runningtaskList.get(position).strTaskName
holder.respnameText?.text = runningtaskList.get(position).strRespName
holder.priorityIDText?.text = runningtaskList.get(position).intPriorityID.toString()
holder.TaskStatusText?.text = runningtaskList.get(position).intTaskStatusID.toString()
holder.PackageText?.text = runningtaskList.get(position).PackageName
holder.intTaskID?.text = runningtaskList.get(position).intTaskID.toString()
holder.intTimeElapsed?.text = runningtaskList.get(position).intTimeElapsed.toString()
holder.intinitial_time_elapsed?.text = runningtaskList.get(position).intinitial_time_elapsed.toString()
holder.strRemarks?.text = runningtaskList.get(position).strRemarks
// holder.ResumeTime?.text = runningtaskList.get(position).ResumeTime
if (holder.TaskStatusText!!.text.equals("1")) {
holder.running_task_Image!!.visibility = View.VISIBLE
} else {
holder.running_task_Image!!.visibility = View.INVISIBLE
}
holder.RunningTaskCardView!!.setOnClickListener {
holder.itemView.context.startActivity(Intent(holder.itemView.context, CurrentTaskDetails::class.java)
.putExtra("Task_Name", holder.tasknameText?.text.toString())
.putExtra("Responsibility_Name", holder.respnameText?.text.toString())
.putExtra("Package_Name", holder.PackageText?.text.toString())
.putExtra("TaskStatusID", holder.TaskStatusText?.text.toString())
.putExtra("Task_ID", holder.intTaskID?.text.toString())
.putExtra("Time_Elapsed", holder.intTimeElapsed?.text.toString())
.putExtra("Initial_Time_Elapsed", holder.intinitial_time_elapsed?.text.toString())
.putExtra("PriorityID", holder.priorityIDText?.text.toString())
.putExtra("Remarks", holder.strRemarks?.text.toString()))
// val activity = holder.itemView.getContext() as AppCompatActivity
// val fragment = CurrentTaskDetails()
// val arguments = Bundle()
// arguments.putString("Task_Name", holder.tasknameText?.text.toString())
// arguments.putString("Responsibility_Name", holder.respnameText?.text.toString())
// fragment.setArguments(arguments)
// activity.supportFragmentManager.beginTransaction().replace(R.id.daily_task_layout, fragment).addToBackStack(null).commit()
}
}
inner class RunningTaskViewHolder(v: View) : RecyclerView.ViewHolder(v), View.OnClickListener {
override fun onClick(v: View?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
var running_task_Image: ImageView? = null
var tasknameText: TextView? = null
var respnameText: TextView? = null
var priorityIDText: TextView? = null
var TaskStatusText: TextView? = null
var RunningTaskCardView: CardView? = null
var PackageText: TextView? = null
var intTaskID: TextView? = null
var intTimeElapsed: TextView? = null
var intinitial_time_elapsed: TextView? = null
var strRemarks: TextView? = null
init {
this.tasknameText = v.findViewById(R.id.task_name_rt_format) as TextView
this.respnameText = v.findViewById(R.id.task_responsibilty_rt_format) as TextView
this.running_task_Image = v.findViewById(R.id.running_task_Image) as ImageView
this.priorityIDText = v.findViewById(R.id.priority_id_rt_format) as TextView
this.TaskStatusText = v.findViewById(R.id.task_status_rt) as TextView
this.PackageText = v.findViewById(R.id.task_package_rt_format) as TextView
this.RunningTaskCardView = v.findViewById(R.id.running_task_cardview) as CardView
this.intTaskID = v.findViewById(R.id.intTaskID) as TextView
this.intTimeElapsed = v.findViewById(R.id.intTimeElapsed) as TextView
this.intinitial_time_elapsed = v.findViewById(R.id.intinitial_time_elapsed) as TextView
this.strRemarks = v.findViewById(R.id.strRemarks) as TextView
}
}
}