Add pull to refresh to comments
This commit is contained in:
parent
696228517d
commit
07168c1c1f
|
@ -136,7 +136,7 @@ class LoginActivity : BaseThemedWithoutBarActivity() {
|
|||
val credentialsDeferred: Deferred<Application?> = async {
|
||||
try {
|
||||
pixelfedAPI.registerApplication(
|
||||
appName, "$oauthScheme://$PACKAGE_ID", SCOPE
|
||||
appName, "$oauthScheme://$PACKAGE_ID", SCOPE, "https://pixeldroid.org"
|
||||
)
|
||||
} catch (exception: IOException) {
|
||||
return@async null
|
||||
|
|
|
@ -39,7 +39,7 @@ class PostActivity : BaseThemedWithBarActivity() {
|
|||
|
||||
private lateinit var binding: ActivityPostBinding
|
||||
private lateinit var profileAdapter: PagingDataAdapter<Status, RecyclerView.ViewHolder>
|
||||
private lateinit var viewModel: FeedViewModel<Status>
|
||||
private lateinit var commentViewModel: FeedViewModel<Status>
|
||||
private var job: Job? = null
|
||||
|
||||
|
||||
|
@ -105,7 +105,7 @@ class PostActivity : BaseThemedWithBarActivity() {
|
|||
private fun retrieveComments() {
|
||||
// get the view model
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
viewModel = ViewModelProvider(this@PostActivity, ProfileViewModelFactory(
|
||||
commentViewModel = ViewModelProvider(this@PostActivity, ProfileViewModelFactory(
|
||||
CommentContentRepository(
|
||||
apiHolder.setToCurrentUser(),
|
||||
status.id
|
||||
|
@ -118,7 +118,7 @@ class PostActivity : BaseThemedWithBarActivity() {
|
|||
binding.commentRecyclerView, binding.motionLayout, binding.errorLayout,
|
||||
profileAdapter)
|
||||
|
||||
job = launch(job, lifecycleScope, viewModel, profileAdapter)
|
||||
job = launch(job, lifecycleScope, commentViewModel, profileAdapter)
|
||||
}
|
||||
|
||||
private suspend fun postComment(
|
||||
|
|
|
@ -55,6 +55,10 @@ internal fun <T: Any> initAdapter(
|
|||
footer = ReposLoadStateAdapter { adapter.retry() }
|
||||
)
|
||||
|
||||
swipeRefreshLayout.setOnRefreshListener {
|
||||
adapter.refresh()
|
||||
}
|
||||
|
||||
adapter.addLoadStateListener { loadState ->
|
||||
|
||||
if(!progressBar.isVisible && swipeRefreshLayout.isRefreshing) {
|
||||
|
|
|
@ -75,10 +75,6 @@ open class CachedFeedFragment<T: FeedContentDatabase> : BaseFragment() {
|
|||
initAdapter(binding.progressBar, binding.swipeRefreshLayout,
|
||||
binding.list, binding.motionLayout, binding.errorLayout, adapter)
|
||||
|
||||
binding.swipeRefreshLayout.setOnRefreshListener {
|
||||
adapter.refresh()
|
||||
}
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
|
|
@ -64,10 +64,6 @@ open class UncachedFeedFragment<T: FeedContent> : BaseFragment() {
|
|||
initAdapter(binding.progressBar, binding.swipeRefreshLayout, binding.list,
|
||||
binding.motionLayout, binding.errorLayout, adapter)
|
||||
|
||||
binding.swipeRefreshLayout.setOnRefreshListener {
|
||||
adapter.refresh()
|
||||
}
|
||||
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,6 @@
|
|||
android:layout_height="match_parent"
|
||||
tools:context=".posts.PostActivity">
|
||||
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/postRefreshLayout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp" />
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -89,14 +83,21 @@
|
|||
layout="@layout/error_layout"
|
||||
tools:layout_editor_absoluteX="50dp" />
|
||||
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/postRefreshLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/errorLayout">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/commentRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="visible"
|
||||
app:layoutManager="LinearLayoutManager"
|
||||
app:layout_constraintTop_toBottomOf="@id/errorLayout"
|
||||
tools:listitem="@layout/comment" />
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/postCommentsProgressBar"
|
||||
|
|
Loading…
Reference in New Issue