switching to the new fastscroller

This commit is contained in:
tibbi 2021-11-15 15:41:25 +01:00
parent 081c979535
commit 86a9cab458
4 changed files with 24 additions and 33 deletions

View File

@ -56,7 +56,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:5e4cf928a7' implementation 'com.github.SimpleMobileTools:Simple-Commons:7123443731'
implementation 'org.greenrobot:eventbus:3.2.0' implementation 'org.greenrobot:eventbus:3.2.0'
implementation 'com.klinkerapps:android-smsmms:5.2.6' implementation 'com.klinkerapps:android-smsmms:5.2.6'
implementation 'com.github.tibbi:IndicatorFastScroll:c3de1d040a' implementation 'com.github.tibbi:IndicatorFastScroll:c3de1d040a'

View File

@ -94,10 +94,11 @@ class MainActivity : SimpleActivity() {
(conversations_list.adapter as? ConversationsAdapter)?.updateDrafts() (conversations_list.adapter as? ConversationsAdapter)?.updateDrafts()
updateTextColors(main_coordinator) updateTextColors(main_coordinator)
no_conversations_placeholder_2.setTextColor(getAdjustedPrimaryColor())
val adjustedPrimaryColor = getAdjustedPrimaryColor()
no_conversations_placeholder_2.setTextColor(adjustedPrimaryColor)
no_conversations_placeholder_2.underlineText() no_conversations_placeholder_2.underlineText()
conversations_fastscroller.updatePrimaryColor() conversations_fastscroller.updateColors(adjustedPrimaryColor, adjustedPrimaryColor.getContrastColor())
conversations_fastscroller.updateBubbleColors()
checkShortcut() checkShortcut()
} }
@ -261,7 +262,7 @@ class MainActivity : SimpleActivity() {
val currAdapter = conversations_list.adapter val currAdapter = conversations_list.adapter
if (currAdapter == null) { if (currAdapter == null) {
ConversationsAdapter(this, sortedConversations, conversations_list, conversations_fastscroller) { ConversationsAdapter(this, sortedConversations, conversations_list) {
Intent(this, ThreadActivity::class.java).apply { Intent(this, ThreadActivity::class.java).apply {
putExtra(THREAD_ID, (it as Conversation).threadId) putExtra(THREAD_ID, (it as Conversation).threadId)
putExtra(THREAD_TITLE, it.title) putExtra(THREAD_TITLE, it.title)
@ -274,11 +275,6 @@ class MainActivity : SimpleActivity() {
if (areSystemAnimationsEnabled) { if (areSystemAnimationsEnabled) {
conversations_list.scheduleLayoutAnimation() conversations_list.scheduleLayoutAnimation()
} }
conversations_fastscroller.setViews(conversations_list) {
val listItem = (conversations_list.adapter as? ConversationsAdapter)?.conversations?.getOrNull(it)
conversations_fastscroller.updateBubbleText(listItem?.title ?: "")
}
} else { } else {
try { try {
(currAdapter as ConversationsAdapter).updateConversations(sortedConversations) (currAdapter as ConversationsAdapter).updateConversations(sortedConversations)

View File

@ -9,6 +9,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
@ -16,7 +17,6 @@ import com.simplemobiletools.commons.helpers.KEY_PHONE
import com.simplemobiletools.commons.helpers.SimpleContactsHelper import com.simplemobiletools.commons.helpers.SimpleContactsHelper
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isNougatPlus import com.simplemobiletools.commons.helpers.isNougatPlus
import com.simplemobiletools.commons.views.FastScroller
import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.commons.views.MyRecyclerView
import com.simplemobiletools.smsmessenger.R import com.simplemobiletools.smsmessenger.R
import com.simplemobiletools.smsmessenger.activities.SimpleActivity import com.simplemobiletools.smsmessenger.activities.SimpleActivity
@ -26,9 +26,8 @@ import com.simplemobiletools.smsmessenger.models.Conversation
import kotlinx.android.synthetic.main.item_conversation.view.* import kotlinx.android.synthetic.main.item_conversation.view.*
class ConversationsAdapter( class ConversationsAdapter(
activity: SimpleActivity, var conversations: ArrayList<Conversation>, recyclerView: MyRecyclerView, fastScroller: FastScroller, activity: SimpleActivity, var conversations: ArrayList<Conversation>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit
itemClick: (Any) -> Unit ) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
private var fontSize = activity.getTextSize() private var fontSize = activity.getTextSize()
private var drafts = HashMap<Long, String?>() private var drafts = HashMap<Long, String?>()
@ -344,4 +343,6 @@ class ConversationsAdapter(
SimpleContactsHelper(context).loadContactImage(conversation.photoUri, conversation_image, conversation.title, placeholder) SimpleContactsHelper(context).loadContactImage(conversation.photoUri, conversation_image, conversation.title, placeholder)
} }
} }
override fun onChange(position: Int) = conversations.getOrNull(position)?.title ?: ""
} }

View File

@ -38,6 +38,11 @@
android:textSize="@dimen/bigger_text_size" android:textSize="@dimen/bigger_text_size"
android:visibility="gone" /> android:visibility="gone" />
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
android:id="@+id/conversations_fastscroller"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.simplemobiletools.commons.views.MyRecyclerView <com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/conversations_list" android:id="@+id/conversations_list"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -48,18 +53,7 @@
android:scrollbars="none" android:scrollbars="none"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" /> app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
<com.simplemobiletools.commons.views.FastScroller </com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
android:id="@+id/conversations_fastscroller"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignTop="@+id/conversations_list"
android:layout_alignBottom="@+id/conversations_list"
android:layout_alignParentEnd="true"
android:paddingStart="@dimen/normal_margin">
<include layout="@layout/fastscroller_handle_vertical" />
</com.simplemobiletools.commons.views.FastScroller>
</RelativeLayout> </RelativeLayout>
<com.simplemobiletools.commons.views.MyFloatingActionButton <com.simplemobiletools.commons.views.MyFloatingActionButton