I have a list of contacts that is shown in recyclerview. After clicking on an item its view changes in the way I want to and if I click on another item the previous selected one returns back to its original state so, so far everything is good. However when I click on the item that is already clicked before and expanded nothing happens. Here is my code in onBindViewHolder
if(selectedPosition==position){
if(holder.itemView.contactsListOptionsMenu.isVisible){
holder.itemView.contactsListOptionsMenu.visibility = View.GONE
holder.itemView.contactsListCallBtn.visibility = View.GONE
holder.itemView.contactsListDetailsBtn.visibility = View.GONE
holder.itemView.contactFullName.setCompoundDrawablesRelativeWithIntrinsicBounds(0,0,R.drawable.ic_arrow_down_24,0)
} else{
holder.itemView.contactsListOptionsMenu.visibility = View.VISIBLE
holder.itemView.contactsListCallBtn.visibility = View.VISIBLE
holder.itemView.contactsListDetailsBtn.visibility = View.VISIBLE
holder.itemView.contactFullName.setCompoundDrawablesRelativeWithIntrinsicBounds(0,0,R.drawable.ic_arrow_up_24,0)
}
} else { if(holder.itemView.contactsListOptionsMenu.isVisible){
holder.itemView.contactsListOptionsMenu.visibility = View.GONE
holder.itemView.contactsListCallBtn.visibility = View.GONE
holder.itemView.contactsListDetailsBtn.visibility = View.GONE
holder.itemView.contactFullName.setCompoundDrawablesRelativeWithIntrinsicBounds(0,0,R.drawable.ic_arrow_down_24,0)
}
}
what do I have to do in order to collapse the item that is already expanded when I click on it again and vice versa?