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.scheduleLayoutAnimation()
conversations_fastscroller.setViews(conversations_list) {
val listItem = (conversations_list.adapter as? ConversationsAdapter)?.conversations?.getOrNull(it)
conversations_fastscroller.updateBubbleText(listItem?.title ?: "")

View File

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

View File

@ -17,8 +17,10 @@ import com.simplemobiletools.smsmessenger.R
import com.simplemobiletools.smsmessenger.activities.SimpleActivity
import java.util.*
class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleContact>, recyclerView: MyRecyclerView, fastScroller: FastScroller?,
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
class ContactsAdapter(
activity: SimpleActivity, var contacts: ArrayList<SimpleContact>, recyclerView: MyRecyclerView, fastScroller: FastScroller?,
itemClick: (Any) -> Unit
) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
private var fontSize = activity.getTextSize()
override fun getActionMenuId() = 0
@ -51,10 +53,12 @@ class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleCo
override fun getItemCount() = contacts.size
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))
fun updateContacts(newContacts: ArrayList<SimpleContact>) {
val oldHashCode = contacts.hashCode()
val newHashCode = newContacts.hashCode()
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)
}
}
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_height="match_parent"
android:clipToPadding="false"
android:layoutAnimation="@anim/layout_animation"
android:overScrollMode="ifContentScrolls"
android:scrollbars="none"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />

View File

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