1
0
mirror of https://gitlab.shinice.net/pixeldroid/PixelDroid synced 2025-02-03 17:07:31 +01:00

add reload and error to profile

This commit is contained in:
Matthieu 2020-11-02 21:58:01 +01:00
parent 0167a63148
commit c65a121e28
8 changed files with 235 additions and 249 deletions

View File

@ -6,14 +6,14 @@ import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.View import android.view.View
import android.widget.Button import android.widget.*
import android.widget.ImageView import androidx.annotation.StringRes
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.h.pixeldroid.adapters.ProfilePostsRecyclerViewAdapter import com.h.pixeldroid.adapters.ProfilePostsRecyclerViewAdapter
import com.h.pixeldroid.api.PixelfedAPI import com.h.pixeldroid.api.PixelfedAPI
import com.h.pixeldroid.db.AppDatabase import com.h.pixeldroid.db.AppDatabase
@ -24,6 +24,7 @@ import com.h.pixeldroid.objects.Relationship
import com.h.pixeldroid.objects.Status import com.h.pixeldroid.objects.Status
import com.h.pixeldroid.utils.HtmlUtils.Companion.parseHTMLText import com.h.pixeldroid.utils.HtmlUtils.Companion.parseHTMLText
import com.h.pixeldroid.utils.ImageConverter import com.h.pixeldroid.utils.ImageConverter
import kotlinx.android.synthetic.main.fragment_search.*
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
@ -33,9 +34,9 @@ class ProfileActivity : AppCompatActivity() {
private lateinit var pixelfedAPI : PixelfedAPI private lateinit var pixelfedAPI : PixelfedAPI
private lateinit var adapter : ProfilePostsRecyclerViewAdapter private lateinit var adapter : ProfilePostsRecyclerViewAdapter
private lateinit var recycler : RecyclerView private lateinit var recycler : RecyclerView
private lateinit var refreshLayout: SwipeRefreshLayout
private lateinit var accessToken : String private lateinit var accessToken : String
private lateinit var domain : String private lateinit var domain : String
private var account: Account? = null
private var user: UserDatabaseEntity? = null private var user: UserDatabaseEntity? = null
@Inject @Inject
@ -64,7 +65,16 @@ class ProfileActivity : AppCompatActivity() {
adapter = ProfilePostsRecyclerViewAdapter() adapter = ProfilePostsRecyclerViewAdapter()
recycler.adapter = adapter recycler.adapter = adapter
setContent() // Set profile according to given account
val account = intent.getSerializableExtra(Account.ACCOUNT_TAG) as Account?
setContent(account)
refreshLayout = findViewById(R.id.profileRefreshLayout)
refreshLayout.setOnRefreshListener {
getAndSetAccount(account?.id ?: user!!.user_id)
}
} }
override fun onSupportNavigateUp(): Boolean { override fun onSupportNavigateUp(): Boolean {
@ -72,96 +82,128 @@ class ProfileActivity : AppCompatActivity() {
return true return true
} }
private fun setContent() { private fun setContent(account: Account?) {
// Set profile according to given account
account = intent.getSerializableExtra(Account.ACCOUNT_TAG) as Account?
if(account != null){ if(account != null){
setViews() setViews(account)
setPosts() setPosts(account)
} else { } else {
pixelfedAPI.verifyCredentials("Bearer $accessToken") pixelfedAPI.verifyCredentials("Bearer $accessToken")
.enqueue(object : Callback<Account> { .enqueue(object : Callback<Account> {
override fun onResponse(call: Call<Account>, response: Response<Account>) { override fun onResponse(call: Call<Account>, response: Response<Account>) {
if (response.code() == 200) { if (response.code() == 200) {
account = response.body()!! val myAccount = response.body()!!
setViews() setViews(myAccount)
// Populate profile page with user's posts // Populate profile page with user's posts
setPosts() setPosts(myAccount)
} else {
showError()
} }
} }
override fun onFailure(call: Call<Account>, t: Throwable) { override fun onFailure(call: Call<Account>, t: Throwable) {
Log.e("ProfileActivity:", t.toString()) Log.e("ProfileActivity:", t.toString())
showError()
} }
}) })
} }
//if we aren't viewing our own account, activate follow button //if we aren't viewing our own account, activate follow button
if(account != null && account!!.id != user?.user_id) activateFollow() if(account != null && account.id != user?.user_id) activateFollow(account)
//if we *are* viewing our own account, activate the edit button //if we *are* viewing our own account, activate the edit button
else activateEditButton() else activateEditButton()
// On click open followers list // On click open followers list
findViewById<TextView>(R.id.nbFollowersTextView).setOnClickListener{ onClickFollowers() } findViewById<TextView>(R.id.nbFollowersTextView).setOnClickListener{ onClickFollowers(account) }
// On click open followers list // On click open followers list
findViewById<TextView>(R.id.nbFollowingTextView).setOnClickListener{ onClickFollowing() } findViewById<TextView>(R.id.nbFollowingTextView).setOnClickListener{ onClickFollowing(account) }
}
private fun getAndSetAccount(id: String){
pixelfedAPI.getAccount("Bearer $accessToken", id)
.enqueue(object : Callback<Account> {
override fun onResponse(call: Call<Account>, response: Response<Account>) {
if (response.code() == 200) {
val account = response.body()!!
setContent(account)
} else {
showError()
}
}
override fun onFailure(call: Call<Account>, t: Throwable) {
Log.e("ProfileActivity:", t.toString())
showError()
}
})
}
private fun showError(@StringRes errorText: Int = R.string.loading_toast, show: Boolean = true){
val motionLayout = findViewById<MotionLayout>(R.id.motionLayout)
if(show){
motionLayout?.transitionToEnd()
} else {
findViewById<ProgressBar>(R.id.profileProgressBar).visibility = View.GONE
motionLayout?.transitionToStart()
}
refreshLayout.isRefreshing = false
} }
/** /**
* Populate myProfile page with user's data * Populate profile page with user's data
*/ */
private fun setViews() { private fun setViews(account: Account) {
val profilePicture = findViewById<ImageView>(R.id.profilePictureImageView) val profilePicture = findViewById<ImageView>(R.id.profilePictureImageView)
ImageConverter.setRoundImageFromURL( ImageConverter.setRoundImageFromURL(
View(applicationContext), View(applicationContext),
account!!.avatar, account.avatar,
profilePicture profilePicture
) )
val description = findViewById<TextView>(R.id.descriptionTextView) val description = findViewById<TextView>(R.id.descriptionTextView)
description.text = parseHTMLText( description.text = parseHTMLText(
account!!.note ?: "", emptyList(), pixelfedAPI, account.note ?: "", emptyList(), pixelfedAPI,
applicationContext, "Bearer $accessToken" applicationContext, "Bearer $accessToken"
) )
val accountName = findViewById<TextView>(R.id.accountNameTextView) val accountName = findViewById<TextView>(R.id.accountNameTextView)
accountName.text = account!!.getDisplayName() accountName.text = account.getDisplayName()
val displayName = account!!.getDisplayName() val displayName = account.getDisplayName()
supportActionBar?.title = displayName supportActionBar?.title = displayName
if(displayName != "@${account!!.acct}"){ if(displayName != "@${account.acct}"){
supportActionBar?.subtitle = "@${account!!.acct}" supportActionBar?.subtitle = "@${account.acct}"
} }
accountName.setTypeface(null, Typeface.BOLD) accountName.setTypeface(null, Typeface.BOLD)
val nbPosts = findViewById<TextView>(R.id.nbPostsTextView) val nbPosts = findViewById<TextView>(R.id.nbPostsTextView)
nbPosts.text = applicationContext.getString(R.string.nb_posts) nbPosts.text = applicationContext.getString(R.string.nb_posts)
.format(account!!.statuses_count.toString()) .format(account.statuses_count.toString())
nbPosts.setTypeface(null, Typeface.BOLD) nbPosts.setTypeface(null, Typeface.BOLD)
val nbFollowers = findViewById<TextView>(R.id.nbFollowersTextView) val nbFollowers = findViewById<TextView>(R.id.nbFollowersTextView)
nbFollowers.text = applicationContext.getString(R.string.nb_followers) nbFollowers.text = applicationContext.getString(R.string.nb_followers)
.format(account!!.followers_count.toString()) .format(account.followers_count.toString())
nbFollowers.setTypeface(null, Typeface.BOLD) nbFollowers.setTypeface(null, Typeface.BOLD)
val nbFollowing = findViewById<TextView>(R.id.nbFollowingTextView) val nbFollowing = findViewById<TextView>(R.id.nbFollowingTextView)
nbFollowing.text = applicationContext.getString(R.string.nb_following) nbFollowing.text = applicationContext.getString(R.string.nb_following)
.format(account!!.following_count.toString()) .format(account.following_count.toString())
nbFollowing.setTypeface(null, Typeface.BOLD) nbFollowing.setTypeface(null, Typeface.BOLD)
} }
/** /**
* Populate profile page with user's posts * Populate profile page with user's posts
*/ */
private fun setPosts() { private fun setPosts(account: Account) {
pixelfedAPI.accountPosts("Bearer $accessToken", account_id = account!!.id) pixelfedAPI.accountPosts("Bearer $accessToken", account_id = account.id)
.enqueue(object : Callback<List<Status>> { .enqueue(object : Callback<List<Status>> {
override fun onFailure(call: Call<List<Status>>, t: Throwable) { override fun onFailure(call: Call<List<Status>>, t: Throwable) {
showError()
Log.e("ProfileActivity.Posts:", t.toString()) Log.e("ProfileActivity.Posts:", t.toString())
} }
@ -172,6 +214,9 @@ class ProfileActivity : AppCompatActivity() {
if (response.code() == 200) { if (response.code() == 200) {
val statuses = response.body()!! val statuses = response.body()!!
adapter.addPosts(statuses) adapter.addPosts(statuses)
showError(show = false)
} else {
showError()
} }
} }
}) })
@ -188,7 +233,7 @@ class ProfileActivity : AppCompatActivity() {
} }
} }
private fun onClickFollowers() { private fun onClickFollowers(account: Account?) {
val intent = Intent(this, FollowsActivity::class.java) val intent = Intent(this, FollowsActivity::class.java)
intent.putExtra(Account.FOLLOWERS_TAG, true) intent.putExtra(Account.FOLLOWERS_TAG, true)
intent.putExtra(Account.ACCOUNT_TAG, account) intent.putExtra(Account.ACCOUNT_TAG, account)
@ -196,7 +241,7 @@ class ProfileActivity : AppCompatActivity() {
ContextCompat.startActivity(this, intent, null) ContextCompat.startActivity(this, intent, null)
} }
private fun onClickFollowing() { private fun onClickFollowing(account: Account?) {
val intent = Intent(this, FollowsActivity::class.java) val intent = Intent(this, FollowsActivity::class.java)
intent.putExtra(Account.FOLLOWERS_TAG, false) intent.putExtra(Account.FOLLOWERS_TAG, false)
intent.putExtra(Account.ACCOUNT_TAG, account) intent.putExtra(Account.ACCOUNT_TAG, account)
@ -214,9 +259,9 @@ class ProfileActivity : AppCompatActivity() {
/** /**
* Set up follow button * Set up follow button
*/ */
private fun activateFollow() { private fun activateFollow(account: Account) {
// Get relationship between the two users (credential and this) and set followButton accordingly // Get relationship between the two users (credential and this) and set followButton accordingly
pixelfedAPI.checkRelationships("Bearer $accessToken", listOf(account!!.id.orEmpty())) pixelfedAPI.checkRelationships("Bearer $accessToken", listOf(account.id.orEmpty()))
.enqueue(object : Callback<List<Relationship>> { .enqueue(object : Callback<List<Relationship>> {
override fun onFailure(call: Call<List<Relationship>>, t: Throwable) { override fun onFailure(call: Call<List<Relationship>>, t: Throwable) {
@ -236,9 +281,9 @@ class ProfileActivity : AppCompatActivity() {
val followButton = findViewById<Button>(R.id.followButton) val followButton = findViewById<Button>(R.id.followButton)
if (response.body()!![0].following) { if (response.body()!![0].following) {
setOnClickUnfollow() setOnClickUnfollow(account)
} else { } else {
setOnClickFollow() setOnClickFollow(account)
} }
followButton.visibility = View.VISIBLE followButton.visibility = View.VISIBLE
} }
@ -252,13 +297,13 @@ class ProfileActivity : AppCompatActivity() {
}) })
} }
private fun setOnClickFollow() { private fun setOnClickFollow(account: Account) {
val followButton = findViewById<Button>(R.id.followButton) val followButton = findViewById<Button>(R.id.followButton)
followButton.setText(R.string.follow) followButton.setText(R.string.follow)
followButton.setOnClickListener { followButton.setOnClickListener {
pixelfedAPI.follow(account!!.id.orEmpty(), "Bearer $accessToken") pixelfedAPI.follow(account.id.orEmpty(), "Bearer $accessToken")
.enqueue(object : Callback<Relationship> { .enqueue(object : Callback<Relationship> {
override fun onFailure(call: Call<Relationship>, t: Throwable) { override fun onFailure(call: Call<Relationship>, t: Throwable) {
@ -274,7 +319,7 @@ class ProfileActivity : AppCompatActivity() {
response: Response<Relationship> response: Response<Relationship>
) { ) {
if (response.code() == 200) { if (response.code() == 200) {
setOnClickUnfollow() setOnClickUnfollow(account)
} else if (response.code() == 403) { } else if (response.code() == 403) {
Toast.makeText( Toast.makeText(
applicationContext, getString(R.string.action_not_allowed), applicationContext, getString(R.string.action_not_allowed),
@ -286,13 +331,13 @@ class ProfileActivity : AppCompatActivity() {
} }
} }
private fun setOnClickUnfollow() { private fun setOnClickUnfollow(account: Account) {
val followButton = findViewById<Button>(R.id.followButton) val followButton = findViewById<Button>(R.id.followButton)
followButton.setText(R.string.unfollow) followButton.setText(R.string.unfollow)
followButton.setOnClickListener { followButton.setOnClickListener {
pixelfedAPI.unfollow(account!!.id.orEmpty(), "Bearer $accessToken") pixelfedAPI.unfollow(account.id.orEmpty(), "Bearer $accessToken")
.enqueue(object : Callback<Relationship> { .enqueue(object : Callback<Relationship> {
override fun onFailure(call: Call<Relationship>, t: Throwable) { override fun onFailure(call: Call<Relationship>, t: Throwable) {
@ -308,7 +353,7 @@ class ProfileActivity : AppCompatActivity() {
response: Response<Relationship> response: Response<Relationship>
) { ) {
if (response.code() == 200) { if (response.code() == 200) {
setOnClickFollow() setOnClickFollow(account)
} else if (response.code() == 401) { } else if (response.code() == 401) {
Toast.makeText( Toast.makeText(
applicationContext, getString(R.string.access_token_invalid), applicationContext, getString(R.string.access_token_invalid),

View File

@ -20,9 +20,9 @@ class ProfilePostsRecyclerViewAdapter: RecyclerView.Adapter<ProfilePostViewHolde
private val posts: ArrayList<Status> = ArrayList() private val posts: ArrayList<Status> = ArrayList()
fun addPosts(newPosts : List<Status>) { fun addPosts(newPosts : List<Status>) {
val size = posts.size posts.clear()
posts.addAll(newPosts) posts.addAll(newPosts)
notifyItemRangeInserted(size, newPosts.size) notifyDataSetChanged()
} }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProfilePostViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProfilePostViewHolder {
@ -41,6 +41,8 @@ class ProfilePostsRecyclerViewAdapter: RecyclerView.Adapter<ProfilePostViewHolde
if(post.media_attachments?.size ?: 0 > 1){ if(post.media_attachments?.size ?: 0 > 1){
holder.albumIcon.visibility = View.VISIBLE holder.albumIcon.visibility = View.VISIBLE
} else {
holder.albumIcon.visibility = View.GONE
} }
holder.postPreview.setOnClickListener { holder.postPreview.setOnClickListener {

View File

@ -1,41 +0,0 @@
package com.h.pixeldroid.fragments
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.h.pixeldroid.R
import com.h.pixeldroid.adapters.ProfilePostsRecyclerViewAdapter
/**
* A fragment representing a list of statuses of a profile.
*/
class ProfilePostsFragment : Fragment() {
private var columnCount = 3
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_profile_posts_list, container, false)
// Set the adapter
if (view is RecyclerView) {
with(view) {
layoutManager = when {
columnCount <= 1 -> LinearLayoutManager(context)
else -> GridLayoutManager(context, columnCount)
}
adapter = ProfilePostsRecyclerViewAdapter()
}
}
return view
}
}

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M19,4L5,4c-1.11,0 -2,0.9 -2,2v12c0,1.1 0.89,2 2,2h4v-2L5,18L5,8h14v10h-4v2h4c1.1,0 2,-0.9 2,-2L21,6c0,-1.1 -0.89,-2 -2,-2zM12,10l-4,4h3v6h2v-6h3l-4,-4z"/>
</vector>

View File

@ -1,164 +1,147 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/profileRefreshLayout"
tools:context=".ProfileActivity"> tools:context=".ProfileActivity">
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<LinearLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/profilePictureImageView"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
<TextView
android:id="@+id/nbPostsTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:gravity="center"
android:text="@string/default_nposts"
app:layout_constraintBottom_toBottomOf="@+id/profilePictureImageView"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toEndOf="@+id/profilePictureImageView"
app:layout_constraintTop_toTopOf="@+id/profilePictureImageView" />
<TextView
android:id="@+id/nbFollowersTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/default_nfollowers"
app:layout_constraintBottom_toBottomOf="@+id/nbPostsTextView"
app:layout_constraintEnd_toStartOf="@+id/nbFollowingTextView"
app:layout_constraintStart_toEndOf="@+id/nbPostsTextView"
app:layout_constraintTop_toTopOf="@+id/nbPostsTextView" />
<TextView
android:id="@+id/nbFollowingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:gravity="center"
android:text="@string/default_nfollowing"
app:layout_constraintBottom_toBottomOf="@+id/nbFollowersTextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/nbFollowersTextView" />
<TextView
android:id="@+id/accountNameTextView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:text="@string/no_username"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/profilePictureImageView"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout <TextView
android:layout_width="match_parent" android:id="@+id/descriptionTextView"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:layout_margin="20dp" android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_marginLeft="20dp"
app:layout_constraintTop_toTopOf="parent"> android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/accountNameTextView"/>
<ImageView <Button
android:id="@+id/profilePictureImageView" android:id="@+id/followButton"
android:layout_width="120dp" android:layout_width="wrap_content"
android:layout_height="120dp" android:layout_height="wrap_content"
android:layout_weight="1" android:backgroundTint="@color/colorButtonBg"
tools:srcCompat="@tools:sample/avatars" /> android:text="@string/follow"
android:textColor="@color/colorButtonText"
android:visibility="invisible"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="185dp"
tools:visibility="visible"
app:layout_constraintStart_toStartOf="@+id/profilePictureImageView"
app:layout_constraintTop_toBottomOf="@+id/descriptionTextView"/>
<LinearLayout <Button
android:layout_width="match_parent" android:id="@+id/editButton"
android:layout_height="match_parent" android:layout_width="wrap_content"
android:layout_weight="10" android:layout_height="wrap_content"
android:orientation="horizontal"> android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:backgroundTint="@color/colorButtonBg"
android:text="@string/edit_profile"
android:textColor="@color/colorButtonText"
android:visibility="gone"
app:icon="@drawable/ic_baseline_open_in_browser_24"
app:iconTint="@color/colorButtonText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/profilePictureImageView"
app:layout_constraintTop_toBottomOf="@+id/descriptionTextView" />
<TextView
android:id="@+id/nbPostsTextView"
android:layout_width="15dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/default_nposts" />
<TextView <ProgressBar
android:id="@+id/nbFollowersTextView" android:id="@+id/profileProgressBar"
android:layout_width="15dp" style="?android:attr/progressBarStyle"
android:layout_height="120dp" android:layout_width="wrap_content"
android:layout_weight="1" android:layout_height="wrap_content"
android:gravity="center" android:layout_marginTop="16dp"
android:text="@string/default_nfollowers" /> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/followButton" />
<TextView <androidx.constraintlayout.motion.widget.MotionLayout
android:id="@+id/nbFollowingTextView" android:id="@+id/motionLayout"
android:layout_width="15dp" android:layout_width="match_parent"
android:layout_height="120dp" android:layout_height="match_parent"
android:layout_weight="1" android:layout_marginTop="8dp"
android:gravity="center" android:visibility="visible"
android:text="@string/default_nfollowing" /> app:layoutDescription="@xml/error_layout_xml_error_scene"
</LinearLayout> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/followButton"
tools:visibility="visible">
</LinearLayout> <include
</androidx.constraintlayout.widget.ConstraintLayout> layout="@layout/error_layout"
tools:layout_editor_absoluteX="50dp" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_marginRight="20dp">
<TextView
android:id="@+id/accountNameTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/no_username"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp">
<TextView
android:id="@+id/descriptionTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginBottom="15dp">
<Button
android:id="@+id/followButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/follow"
android:visibility="invisible"
android:textColor="@color/colorButtonText"
android:backgroundTint="@color/colorButtonBg"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/editButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/colorButtonText"
android:backgroundTint="@color/colorButtonBg"
android:visibility="gone"
android:text="@string/edit_profile"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintTop_toTopOf="parent">
<ImageButton
android:id="@+id/postsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/colorPrimaryTab"
android:src="@android:drawable/ic_dialog_dialer"
android:contentDescription="TODO" />
<ImageButton
android:id="@+id/collectionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/colorPrimaryTab"
android:src="@android:drawable/ic_menu_gallery"
android:contentDescription="TODO" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/profilePostsRecyclerView" android:id="@+id/profilePostsRecyclerView"
@ -167,9 +150,11 @@
android:layout_margin="5dp" android:layout_margin="5dp"
android:nestedScrollingEnabled="false" android:nestedScrollingEnabled="false"
app:layoutManager="LinearLayoutManager" app:layoutManager="LinearLayoutManager"
tools:context=".fragments.ProfileFragment" app:layout_constraintTop_toBottomOf="@id/errorLayout"
tools:listitem="@layout/fragment_profile_posts" /> tools:listitem="@layout/fragment_profile_posts" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.motion.widget.MotionLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/list"
android:name="com.h.pixeldroid.fragments.ProfilePostsFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
app:layoutManager="LinearLayoutManager"
tools:context=".fragments.ProfilePostsFragment"
tools:listitem="@layout/fragment_profile_posts" />

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"> android:layout_gravity="center_horizontal">
@ -45,9 +44,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"
app:layoutDescription="@xml/fragment_search_xml_error_scene" app:layoutDescription="@xml/error_layout_xml_error_scene">
app:layout_constraintBottom_toTopOf="@+id/discoverList"
app:layout_constraintTop_toTopOf="@+id/discoverList">
<include layout="@layout/error_layout"/> <include layout="@layout/error_layout"/>