Merge branch 'fix/endless-loading-circle-inbox-fix'

This commit is contained in:
Hafiz 2025-07-18 12:57:26 -05:00
commit e5c13d8dc2
2 changed files with 16 additions and 0 deletions

View file

@ -72,6 +72,8 @@
android:layout_height="42dp"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:layout_marginStart="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_medium"
android:layout_marginBottom="8dp"
android:lineSpacingMultiplier="1.0"
android:text="Start chatting below! Remember to be friendly and follow the Community Guidelines."

View file

@ -17,6 +17,7 @@ import androidx.fragment.app.viewModels
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.paging.LoadState
import androidx.paging.PagingData
import androidx.recyclerview.widget.RecyclerView
import com.habitrpg.android.habitica.R
@ -37,6 +38,7 @@ import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar.Companion.showSnackbar
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
import com.habitrpg.common.habitica.helpers.ExceptionHandler
import com.habitrpg.common.habitica.helpers.RecyclerViewState
import com.habitrpg.common.habitica.helpers.launchCatching
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.delay
@ -124,6 +126,18 @@ class InboxMessageListFragment : BaseMainFragment<FragmentInboxMessageListBindin
}
}
chatAdapter?.addLoadStateListener { loadStates ->
val isEmpty = loadStates.refresh is LoadState.NotLoading &&
loadStates.append.endOfPaginationReached &&
chatAdapter?.itemCount == 0
if (isEmpty) {
binding?.recyclerView?.state = RecyclerViewState.EMPTY
} else {
binding?.recyclerView?.state = RecyclerViewState.DISPLAYING_DATA
}
}
binding?.chatBarView?.sendAction = { sendMessage(it) }
binding?.chatBarView?.maxChatLength = configManager.maxChatLength()