adding some animations

This commit is contained in:
tibbi 2021-03-15 23:43:42 +01:00
parent 0e07117b3a
commit ab50b0b74a
5 changed files with 42 additions and 21 deletions

View File

@ -247,6 +247,7 @@ class MainActivity : SimpleActivity() {
conversations_list.adapter = this conversations_list.adapter = this
} }
conversations_list.scheduleLayoutAnimation()
conversations_fastscroller.setViews(conversations_list) { conversations_fastscroller.setViews(conversations_list) {
val listItem = (conversations_list.adapter as? ConversationsAdapter)?.conversations?.getOrNull(it) val listItem = (conversations_list.adapter as? ConversationsAdapter)?.conversations?.getOrNull(it)
conversations_fastscroller.updateBubbleText(listItem?.title ?: "") conversations_fastscroller.updateBubbleText(listItem?.title ?: "")

View File

@ -138,6 +138,8 @@ class NewConversationActivity : SimpleActivity() {
no_contacts_placeholder.text = getString(placeholderText) no_contacts_placeholder.text = getString(placeholderText)
} }
val currAdapter = contacts_list.adapter
if (currAdapter == null) {
ContactsAdapter(this, contacts, contacts_list, null) { ContactsAdapter(this, contacts, contacts_list, null) {
hideKeyboard() hideKeyboard()
val contact = it as SimpleContact val contact = it as SimpleContact
@ -158,6 +160,11 @@ class NewConversationActivity : SimpleActivity() {
contacts_list.adapter = this contacts_list.adapter = this
} }
contacts_list.scheduleLayoutAnimation()
} else {
(currAdapter as ContactsAdapter).updateContacts(contacts)
}
setupLetterFastscroller(contacts) setupLetterFastscroller(contacts)
} }

View File

@ -17,8 +17,10 @@ import com.simplemobiletools.smsmessenger.R
import com.simplemobiletools.smsmessenger.activities.SimpleActivity import com.simplemobiletools.smsmessenger.activities.SimpleActivity
import java.util.* import java.util.*
class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleContact>, recyclerView: MyRecyclerView, fastScroller: FastScroller?, class ContactsAdapter(
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) { activity: SimpleActivity, var contacts: ArrayList<SimpleContact>, recyclerView: MyRecyclerView, fastScroller: FastScroller?,
itemClick: (Any) -> Unit
) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
private var fontSize = activity.getTextSize() private var fontSize = activity.getTextSize()
override fun getActionMenuId() = 0 override fun getActionMenuId() = 0
@ -51,10 +53,12 @@ class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleCo
override fun getItemCount() = contacts.size override fun getItemCount() = contacts.size
override fun onViewRecycled(holder: ViewHolder) { fun updateContacts(newContacts: ArrayList<SimpleContact>) {
super.onViewRecycled(holder) val oldHashCode = contacts.hashCode()
if (!activity.isDestroyed && !activity.isFinishing) { val newHashCode = newContacts.hashCode()
Glide.with(activity).clear(holder.itemView.findViewById<ImageView>(R.id.item_contact_image)) if (newHashCode != oldHashCode) {
contacts = newContacts
notifyDataSetChanged()
} }
} }
@ -75,4 +79,11 @@ class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleCo
SimpleContactsHelper(context).loadContactImage(contact.photoUri, findViewById(R.id.item_contact_image), contact.name) SimpleContactsHelper(context).loadContactImage(contact.photoUri, findViewById(R.id.item_contact_image), contact.name)
} }
} }
override fun onViewRecycled(holder: ViewHolder) {
super.onViewRecycled(holder)
if (!activity.isDestroyed && !activity.isFinishing) {
Glide.with(activity).clear(holder.itemView.findViewById<ImageView>(R.id.item_contact_image))
}
}
} }

View File

@ -43,6 +43,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:clipToPadding="false" android:clipToPadding="false"
android:layoutAnimation="@anim/layout_animation"
android:overScrollMode="ifContentScrolls" android:overScrollMode="ifContentScrolls"
android:scrollbars="none" android:scrollbars="none"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" /> app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />

View File

@ -101,6 +101,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_below="@+id/suggestions_scrollview" android:layout_below="@+id/suggestions_scrollview"
android:clipToPadding="false" android:clipToPadding="false"
android:layoutAnimation="@anim/layout_animation"
android:overScrollMode="ifContentScrolls" android:overScrollMode="ifContentScrolls"
android:scrollbars="none" android:scrollbars="none"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" /> app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />