mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
Hide progress bar after loading from telephony
This commit is contained in:
@ -111,8 +111,8 @@ class MainActivity : SimpleActivity() {
|
|||||||
search_holder.setBackgroundColor(getProperBackgroundColor())
|
search_holder.setBackgroundColor(getProperBackgroundColor())
|
||||||
|
|
||||||
val properPrimaryColor = getProperPrimaryColor()
|
val properPrimaryColor = getProperPrimaryColor()
|
||||||
no_conversations_placeholder_2.setTextColor(properPrimaryColor)
|
start_conversation_placeholder.setTextColor(properPrimaryColor)
|
||||||
no_conversations_placeholder_2.underlineText()
|
start_conversation_placeholder.underlineText()
|
||||||
conversations_fastscroller.updateColors(properPrimaryColor)
|
conversations_fastscroller.updateColors(properPrimaryColor)
|
||||||
conversations_progress_bar.setIndicatorColor(properPrimaryColor)
|
conversations_progress_bar.setIndicatorColor(properPrimaryColor)
|
||||||
conversations_progress_bar.trackColor = properPrimaryColor.adjustAlpha(LOWER_ALPHA)
|
conversations_progress_bar.trackColor = properPrimaryColor.adjustAlpha(LOWER_ALPHA)
|
||||||
@ -239,7 +239,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
getCachedConversations()
|
getCachedConversations()
|
||||||
|
|
||||||
no_conversations_placeholder_2.setOnClickListener {
|
start_conversation_placeholder.setOnClickListener {
|
||||||
launchNewConversation()
|
launchNewConversation()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
|
|
||||||
updateUnreadCountBadge(conversations)
|
updateUnreadCountBadge(conversations)
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
setupConversations(conversations)
|
setupConversations(conversations, cached = true)
|
||||||
getNewConversations(conversations)
|
getNewConversations(conversations)
|
||||||
}
|
}
|
||||||
conversations.forEach {
|
conversations.forEach {
|
||||||
@ -349,33 +349,25 @@ class MainActivity : SimpleActivity() {
|
|||||||
return currAdapter as ConversationsAdapter
|
return currAdapter as ConversationsAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupConversations(conversations: ArrayList<Conversation>) {
|
private fun setupConversations(conversations: ArrayList<Conversation>, cached: Boolean = false) {
|
||||||
val hasConversations = conversations.isNotEmpty()
|
|
||||||
val sortedConversations = conversations.sortedWith(
|
val sortedConversations = conversations.sortedWith(
|
||||||
compareByDescending<Conversation> { config.pinnedConversations.contains(it.threadId.toString()) }
|
compareByDescending<Conversation> { config.pinnedConversations.contains(it.threadId.toString()) }
|
||||||
.thenByDescending { it.date }
|
.thenByDescending { it.date }
|
||||||
).toMutableList() as ArrayList<Conversation>
|
).toMutableList() as ArrayList<Conversation>
|
||||||
|
|
||||||
conversations_fastscroller.beVisibleIf(hasConversations)
|
if (cached && config.appRunCount == 1) {
|
||||||
no_conversations_placeholder.beGoneIf(hasConversations)
|
// there are no cached conversations on the first run so we show the loading placeholder and progress until we are done loading from telephony
|
||||||
no_conversations_placeholder_2.beGoneIf(hasConversations)
|
showOrHideProgress(show = conversations.isEmpty())
|
||||||
|
|
||||||
if (!hasConversations && config.appRunCount == 1) {
|
|
||||||
no_conversations_placeholder.text = getString(R.string.loading_messages)
|
|
||||||
no_conversations_placeholder_2.beGone()
|
|
||||||
conversations_progress_bar.beVisible()
|
|
||||||
} else {
|
} else {
|
||||||
conversations_progress_bar.beGone()
|
showOrHideProgress(show = false)
|
||||||
|
showOrHidePlaceholder(show = conversations.isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getOrCreateConversationsAdapter().apply {
|
getOrCreateConversationsAdapter().apply {
|
||||||
updateConversations(sortedConversations) {
|
updateConversations(sortedConversations) {
|
||||||
if (currentList.isEmpty()) {
|
if (!cached) {
|
||||||
conversations_fastscroller.beGone()
|
showOrHidePlaceholder(show = currentList.isEmpty())
|
||||||
no_conversations_placeholder.text = getString(R.string.no_conversations_found)
|
|
||||||
no_conversations_placeholder.beVisible()
|
|
||||||
no_conversations_placeholder_2.beVisible()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,6 +375,24 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showOrHideProgress(show: Boolean) {
|
||||||
|
if (show) {
|
||||||
|
conversations_progress_bar.show()
|
||||||
|
conversations_placeholder.beVisible()
|
||||||
|
conversations_placeholder.text = getString(R.string.loading_messages)
|
||||||
|
} else {
|
||||||
|
conversations_progress_bar.hide()
|
||||||
|
conversations_placeholder.beGone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showOrHidePlaceholder(show: Boolean) {
|
||||||
|
conversations_fastscroller.beGoneIf(show)
|
||||||
|
conversations_placeholder.beVisibleIf(show)
|
||||||
|
conversations_placeholder.text = getString(R.string.no_conversations_found)
|
||||||
|
start_conversation_placeholder.beVisibleIf(show)
|
||||||
|
}
|
||||||
|
|
||||||
private fun fadeOutSearch() {
|
private fun fadeOutSearch() {
|
||||||
search_holder.animate().alpha(0f).setDuration(SHORT_ANIMATION_DURATION).withEndAction {
|
search_holder.animate().alpha(0f).setDuration(SHORT_ANIMATION_DURATION).withEndAction {
|
||||||
search_holder.beGone()
|
search_holder.beGone()
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
android:id="@+id/no_conversations_placeholder"
|
android:id="@+id/conversations_placeholder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
@ -57,10 +57,10 @@
|
|||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
android:id="@+id/no_conversations_placeholder_2"
|
android:id="@+id/start_conversation_placeholder"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/no_conversations_placeholder"
|
android:layout_below="@+id/conversations_placeholder"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:background="@drawable/ripple_all_corners"
|
android:background="@drawable/ripple_all_corners"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
Reference in New Issue
Block a user