Profile fixes
This commit is contained in:
parent
c2dd66c54f
commit
4096af2872
|
@ -13,7 +13,6 @@ import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.paging.ExperimentalPagingApi
|
import androidx.paging.ExperimentalPagingApi
|
||||||
import androidx.paging.LoadState
|
|
||||||
import androidx.paging.PagingDataAdapter
|
import androidx.paging.PagingDataAdapter
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
@ -35,10 +34,7 @@ import com.h.pixeldroid.utils.api.objects.Status
|
||||||
import com.h.pixeldroid.utils.db.entities.UserDatabaseEntity
|
import com.h.pixeldroid.utils.db.entities.UserDatabaseEntity
|
||||||
import com.h.pixeldroid.utils.openUrl
|
import com.h.pixeldroid.utils.openUrl
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.flow.collect
|
|
||||||
import kotlinx.coroutines.flow.collectLatest
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
import kotlinx.coroutines.flow.distinctUntilChangedBy
|
|
||||||
import kotlinx.coroutines.flow.filter
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
@ -98,7 +94,6 @@ class ProfileActivity : BaseActivity() {
|
||||||
|
|
||||||
setContent(account)
|
setContent(account)
|
||||||
profileLaunch()
|
profileLaunch()
|
||||||
profileInitSearch()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun profileLaunch() {
|
private fun profileLaunch() {
|
||||||
|
@ -111,18 +106,6 @@ class ProfileActivity : BaseActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun profileInitSearch() {
|
|
||||||
// Scroll to top when the list is refreshed from network.
|
|
||||||
lifecycleScope.launch {
|
|
||||||
profileAdapter.loadStateFlow
|
|
||||||
// Only emit when REFRESH LoadState for RemoteMediator changes.
|
|
||||||
.distinctUntilChangedBy { it.refresh }
|
|
||||||
// Only react to cases where Remote REFRESH completes i.e., NotLoading.
|
|
||||||
.filter { it.refresh is LoadState.NotLoading }
|
|
||||||
.collect { binding.profilePostsRecyclerView.scrollToPosition(0) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows or hides the error in the different FeedFragments
|
* Shows or hides the error in the different FeedFragments
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="20dp"
|
android:layout_marginStart="20dp"
|
||||||
android:layout_marginTop="6dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/default_nposts"
|
android:text="@string/default_nposts"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
@ -46,6 +46,7 @@
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/default_nfollowers"
|
android:text="@string/default_nfollowers"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/nbPostsTextView"
|
app:layout_constraintBottom_toBottomOf="@+id/nbPostsTextView"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/nbFollowingTextView"
|
app:layout_constraintEnd_toStartOf="@+id/nbFollowingTextView"
|
||||||
app:layout_constraintStart_toEndOf="@+id/nbPostsTextView"
|
app:layout_constraintStart_toEndOf="@+id/nbPostsTextView"
|
||||||
|
@ -59,6 +60,7 @@
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/default_nfollowing"
|
android:text="@string/default_nfollowing"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/nbFollowersTextView"
|
app:layout_constraintBottom_toBottomOf="@+id/nbFollowersTextView"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@+id/nbFollowersTextView" />
|
app:layout_constraintTop_toTopOf="@+id/nbFollowersTextView" />
|
||||||
|
@ -134,7 +136,7 @@
|
||||||
android:id="@+id/motionLayout"
|
android:id="@+id/motionLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="6dp"
|
android:layout_marginTop="18dp"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
app:layoutDescription="@xml/error_layout_xml_error_scene"
|
app:layoutDescription="@xml/error_layout_xml_error_scene"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|
|
@ -127,22 +127,16 @@ For more info about Pixelfed, you can check here: https://pixelfed.org"</string>
|
||||||
<string name="post_is_album">This post is an album</string>
|
<string name="post_is_album">This post is an album</string>
|
||||||
<!-- Profile page -->
|
<!-- Profile page -->
|
||||||
<plurals name="nb_posts">
|
<plurals name="nb_posts">
|
||||||
<item quantity="one">"%d
|
<item quantity="one">"%d\nPost"</item>
|
||||||
Post"</item>
|
<item quantity="other">"%d\nPosts"</item>
|
||||||
<item quantity="other">"%d
|
|
||||||
Posts"</item>
|
|
||||||
</plurals>
|
</plurals>
|
||||||
<plurals name="nb_followers">
|
<plurals name="nb_followers">
|
||||||
<item quantity="one">"%d
|
<item quantity="one">"%d\nFollower"</item>
|
||||||
Follower"</item>
|
<item quantity="other">"%d\nFollowers"</item>
|
||||||
<item quantity="other">"%d
|
|
||||||
Followers"</item>
|
|
||||||
</plurals>
|
</plurals>
|
||||||
<plurals name="nb_following">
|
<plurals name="nb_following">
|
||||||
<item quantity="one">"%d
|
<item quantity="one">"%d\nFollowing"</item>
|
||||||
Following"</item>
|
<item quantity="other">"%d\nFollowing"</item>
|
||||||
<item quantity="other">"%d
|
|
||||||
Following"</item>
|
|
||||||
</plurals>
|
</plurals>
|
||||||
<string name="follow_status_failed">Could not get follow status</string>
|
<string name="follow_status_failed">Could not get follow status</string>
|
||||||
<string name="follow_button_failed">Could not display follow button</string>
|
<string name="follow_button_failed">Could not display follow button</string>
|
||||||
|
|
Loading…
Reference in New Issue