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,24 +138,31 @@ class NewConversationActivity : SimpleActivity() {
no_contacts_placeholder.text = getString(placeholderText) no_contacts_placeholder.text = getString(placeholderText)
} }
ContactsAdapter(this, contacts, contacts_list, null) { val currAdapter = contacts_list.adapter
hideKeyboard() if (currAdapter == null) {
val contact = it as SimpleContact ContactsAdapter(this, contacts, contacts_list, null) {
val phoneNumbers = contact.phoneNumbers hideKeyboard()
if (phoneNumbers.size > 1) { val contact = it as SimpleContact
val items = ArrayList<RadioItem>() val phoneNumbers = contact.phoneNumbers
phoneNumbers.forEachIndexed { index, phoneNumber -> if (phoneNumbers.size > 1) {
items.add(RadioItem(index, phoneNumber, phoneNumber)) val items = ArrayList<RadioItem>()
} phoneNumbers.forEachIndexed { index, phoneNumber ->
items.add(RadioItem(index, phoneNumber, phoneNumber))
}
RadioGroupDialog(this, items) { RadioGroupDialog(this, items) {
launchThreadActivity(it as String, contact.name) launchThreadActivity(it as String, contact.name)
}
} else {
launchThreadActivity(phoneNumbers.first(), contact.name)
} }
} else { }.apply {
launchThreadActivity(phoneNumbers.first(), contact.name) contacts_list.adapter = this
} }
}.apply {
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" />