Add helper fab for quick scroll to bottom
This commit is contained in:
parent
2d6ff0bc30
commit
37944e8b40
|
@ -81,6 +81,8 @@ class ThreadActivity : SimpleActivity() {
|
||||||
private val TYPE_SEND = 15
|
private val TYPE_SEND = 15
|
||||||
private val TYPE_DELETE = 16
|
private val TYPE_DELETE = 16
|
||||||
|
|
||||||
|
private val SCROLL_TO_BOTTOM_FAB_LIMIT = 20
|
||||||
|
|
||||||
private var threadId = 0L
|
private var threadId = 0L
|
||||||
private var currentSIMCardIndex = 0
|
private var currentSIMCardIndex = 0
|
||||||
private var isActivityVisible = false
|
private var isActivityVisible = false
|
||||||
|
@ -144,6 +146,7 @@ class ThreadActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
setupThread()
|
setupThread()
|
||||||
|
setupScrollFab()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
finish()
|
finish()
|
||||||
|
@ -442,6 +445,22 @@ class ThreadActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupScrollFab() {
|
||||||
|
thread_messages_list.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||||
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
|
super.onScrolled(recyclerView, dx, dy)
|
||||||
|
val layoutManager = thread_messages_list.layoutManager as LinearLayoutManager
|
||||||
|
val lastVisibleItemPosition = layoutManager.findLastCompletelyVisibleItemPosition()
|
||||||
|
val isCloseToBottom = lastVisibleItemPosition >= getOrCreateThreadAdapter().itemCount - SCROLL_TO_BOTTOM_FAB_LIMIT
|
||||||
|
if (isCloseToBottom) {
|
||||||
|
scroll_to_bottom_fab.hide()
|
||||||
|
} else {
|
||||||
|
scroll_to_bottom_fab.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
private fun handleItemClick(any: Any) {
|
private fun handleItemClick(any: Any) {
|
||||||
when {
|
when {
|
||||||
any is Message && any.isScheduled -> showScheduledMessageInfo(any)
|
any is Message && any.isScheduled -> showScheduledMessageInfo(any)
|
||||||
|
@ -534,6 +553,7 @@ class ThreadActivity : SimpleActivity() {
|
||||||
private fun setupButtons() {
|
private fun setupButtons() {
|
||||||
updateTextColors(thread_holder)
|
updateTextColors(thread_holder)
|
||||||
val textColor = getProperTextColor()
|
val textColor = getProperTextColor()
|
||||||
|
val backgroundColor = getProperBackgroundColor()
|
||||||
thread_send_message.apply {
|
thread_send_message.apply {
|
||||||
setTextColor(textColor)
|
setTextColor(textColor)
|
||||||
compoundDrawables.forEach {
|
compoundDrawables.forEach {
|
||||||
|
@ -637,6 +657,11 @@ class ThreadActivity : SimpleActivity() {
|
||||||
addAttachment(it)
|
addAttachment(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scroll_to_bottom_fab.setOnClickListener {
|
||||||
|
scrollToBottom()
|
||||||
|
}
|
||||||
|
scroll_to_bottom_fab.hide()
|
||||||
|
scroll_to_bottom_fab.setColors(textColor, backgroundColor, backgroundColor)
|
||||||
|
|
||||||
setupScheduleSendUi()
|
setupScheduleSendUi()
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,17 @@
|
||||||
|
|
||||||
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
|
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyFloatingActionButton
|
||||||
|
android:id="@+id/scroll_to_bottom_fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/activity_margin"
|
||||||
|
android:src="@drawable/ic_arrow_down_vector"
|
||||||
|
app:fabSize="mini"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/thread_messages_fastscroller"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/thread_messages_fastscroller"
|
||||||
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/layout_invalid_short_code_info"
|
layout="@layout/layout_invalid_short_code_info"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in New Issue