This commit is contained in:
Erik Cavazos 2023-08-15 00:02:29 -06:00
parent 94d9998f67
commit 80f2739cd2
30 changed files with 500 additions and 36 deletions

View File

@ -0,0 +1,6 @@
package com.isolaatti.common
enum class ListUpdateEvent {
ItemUpdated,
ItemsAdded
}

View File

@ -0,0 +1,12 @@
package com.isolaatti.common
import com.isolaatti.profile.domain.entity.ProfileListItem
interface UserItemCallback {
enum class FollowButtonAction {
Follow, Unfollow
}
fun itemClick(userId: Int)
fun followButtonClick(user: ProfileListItem, action: FollowButtonAction)
}

View File

@ -0,0 +1,66 @@
package com.isolaatti.common
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.content.res.ResourcesCompat
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.isolaatti.R
import com.isolaatti.databinding.ItemUserListBinding
import com.isolaatti.profile.domain.entity.ProfileListItem
import com.isolaatti.utils.UrlGen
import com.squareup.picasso.Picasso
class UserListRecyclerViewAdapter(private val callback: UserItemCallback) : ListAdapter<ProfileListItem, UserListRecyclerViewAdapter.UserListViewHolder>(diffCallback) {
inner class UserListViewHolder(val item: ItemUserListBinding) : ViewHolder(item.root)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): UserListViewHolder {
return UserListViewHolder(ItemUserListBinding.inflate(LayoutInflater.from(parent.context)))
}
override fun onBindViewHolder(holder: UserListViewHolder, position: Int) {
val context = holder.itemView.context
holder.itemView.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT)
getItem(position).let { user ->
holder.item.root.setOnClickListener {
callback.itemClick(user.id)
}
holder.item.name.text = user.name
Picasso.get().load(UrlGen.userProfileImage(user.id)).into(holder.item.image)
if(user.following == true) {
holder.item.followButton.text = context.getText(R.string.unfollow)
holder.item.followButton.setTextColor(ResourcesCompat.getColor(context.resources, R.color.danger, null))
holder.item.followButton.setOnClickListener {
callback.followButtonClick(user, UserItemCallback.FollowButtonAction.Unfollow)
}
} else {
holder.item.followButton.text = context.getText(R.string.follow)
holder.item.followButton.setTextColor(ResourcesCompat.getColor(context.resources, R.color.purple_lighter, null))
holder.item.followButton.setOnClickListener {
callback.followButtonClick(user, UserItemCallback.FollowButtonAction.Follow)
}
}
}
}
companion object {
val diffCallback: DiffUtil.ItemCallback<ProfileListItem> = object: DiffUtil.ItemCallback<ProfileListItem>() {
override fun areItemsTheSame(
oldItem: ProfileListItem,
newItem: ProfileListItem
): Boolean {
return oldItem.id == newItem.id
}
override fun areContentsTheSame(
oldItem: ProfileListItem,
newItem: ProfileListItem
): Boolean {
return oldItem == newItem
}
}
}
}

View File

@ -3,31 +3,43 @@ package com.isolaatti.followers.data
import com.isolaatti.followers.data.remote.FollowersApi
import com.isolaatti.followers.domain.FollowersRepository
import com.isolaatti.profile.data.remote.ProfileListItemDto
import com.isolaatti.profile.domain.entity.ProfileListItem
import com.isolaatti.utils.IntIdentificationWrapper
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import retrofit2.awaitResponse
import javax.inject.Inject
class FollowersRepositoryImpl @Inject constructor(private val followersApi: FollowersApi) : FollowersRepository {
override fun getFollowersOfUser(userId: Int): Flow<List<ProfileListItemDto>> = flow {
val response = followersApi.getFollowersOfUser(userId).awaitResponse()
override fun getFollowersOfUser(userId: Int, after: Int): Flow<List<ProfileListItem>> = flow {
val response = followersApi.getFollowersOfUser(userId, after).awaitResponse()
if(response.isSuccessful) {
response.body()?.let { emit(response.body()!!) }
response.body()?.let { emit(response.body()!!.map { ProfileListItem.fromDto(it) }) }
}
}
override fun getFollowingsOfUser(userId: Int): Flow<List<ProfileListItemDto>> = flow {
val response = followersApi.getFollowingsOfUser(userId).awaitResponse()
override fun getFollowingsOfUser(userId: Int, after: Int): Flow<List<ProfileListItem>> = flow {
val response = followersApi.getFollowingsOfUser(userId, after).awaitResponse()
if(response.isSuccessful) {
response.body()?.let { emit(response.body()!!.map { ProfileListItem.fromDto(it) }) }
}
}
override fun followUser(userId: Int): Flow<Boolean> = flow {
val response = followersApi.followUser(IntIdentificationWrapper(userId)).awaitResponse()
if(response.isSuccessful) {
emit(true)
} else {
emit(false)
}
}
override fun unfollowUser(userId: Int): Flow<Boolean> = flow {
val response = followersApi.unfollowUser(IntIdentificationWrapper(userId)).awaitResponse()
if(response.isSuccessful) {
emit(true)
} else {
emit(false)
}
}
}

View File

@ -7,17 +7,18 @@ import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
interface FollowersApi {
@GET("Following/FollowersOf/{userId}")
fun getFollowersOfUser(@Path("userId") userId: Int): Call<List<ProfileListItemDto>>
fun getFollowersOfUser(@Path("userId") userId: Int, @Query("lastId") lastId: Int): Call<List<ProfileListItemDto>>
@GET("Following/FollowingsOf/{userId}")
fun getFollowingsOfUser(@Path("userId") userId: Int): Call<List<ProfileListItemDto>>
fun getFollowingsOfUser(@Path("userId") userId: Int, @Query("lastId") lastId: Int): Call<List<ProfileListItemDto>>
@POST("Following/Follow")
fun followUser(@Body id: IntIdentificationWrapper): Call<Nothing>
fun followUser(@Body id: IntIdentificationWrapper): Call<Any>
@POST("Following/Unfollow")
fun unfollowUser(@Body id: IntIdentificationWrapper): Call<Nothing>
fun unfollowUser(@Body id: IntIdentificationWrapper): Call<Any>
}

View File

@ -0,0 +1,14 @@
package com.isolaatti.followers.domain
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject
class FollowUserUseCase @Inject constructor(private val followersRepository: FollowersRepository) {
fun follow(userId: Int): Flow<Boolean> {
return followersRepository.followUser(userId)
}
fun unfollow(userId: Int): Flow<Boolean> {
return followersRepository.unfollowUser(userId)
}
}

View File

@ -1,11 +1,11 @@
package com.isolaatti.followers.domain
import com.isolaatti.profile.data.remote.ProfileListItemDto
import com.isolaatti.profile.domain.entity.ProfileListItem
import kotlinx.coroutines.flow.Flow
interface FollowersRepository {
fun getFollowersOfUser(userId: Int): Flow<List<ProfileListItemDto>>
fun getFollowingsOfUser(userId: Int): Flow<List<ProfileListItemDto>>
fun getFollowersOfUser(userId: Int, after: Int): Flow<List<ProfileListItem>>
fun getFollowingsOfUser(userId: Int, after: Int): Flow<List<ProfileListItem>>
fun followUser(userId: Int): Flow<Boolean>
fun unfollowUser(userId: Int): Flow<Boolean>
}

View File

@ -1,16 +1,120 @@
package com.isolaatti.followers.presentation
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.isolaatti.profile.data.remote.ProfileListItemDto
import androidx.lifecycle.viewModelScope
import com.isolaatti.followers.domain.FollowUserUseCase
import com.isolaatti.followers.domain.FollowersRepository
import com.isolaatti.profile.domain.entity.ProfileListItem
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import javax.inject.Inject
@HiltViewModel
class FollowersViewModel @Inject constructor() : ViewModel() {
class FollowersViewModel @Inject constructor(private val followersRepository: FollowersRepository, private val followUserUseCase: FollowUserUseCase) : ViewModel() {
var userId: Int = 0
val followers: MutableLiveData<List<ProfileListItemDto>> = MutableLiveData()
val followings: MutableLiveData<List<ProfileListItemDto>> = MutableLiveData()
private val followersList: MutableList<ProfileListItem> = mutableListOf()
private val followingsList: MutableList<ProfileListItem> = mutableListOf()
private val _followers: MutableLiveData<List<ProfileListItem>> = MutableLiveData()
private val _followings: MutableLiveData<List<ProfileListItem>> = MutableLiveData()
val followers: LiveData<List<ProfileListItem>> get() = _followers
val followings: LiveData<List<ProfileListItem>> get() = _followings
private fun getFollowersLastId(): Int {
if(followersList.isEmpty()) {
return 0
}
return followersList.last().id
}
private fun getFollowingsLastId(): Int {
if(followingsList.isEmpty()) {
return 0
}
return followingsList.last().id
}
fun fetchFollowers() {
if(userId <= 0) {
return
}
viewModelScope.launch {
followersRepository.getFollowersOfUser(userId, getFollowersLastId()).onEach {
followersList.addAll(it)
_followers.postValue(followersList)
}.flowOn(Dispatchers.IO).launchIn(this)
}
}
fun fetchFollowings() {
if(userId <= 0) {
return
}
viewModelScope.launch {
followersRepository.getFollowingsOfUser(userId, getFollowingsLastId()).onEach {
followingsList.addAll(it)
_followings.postValue(followingsList)
}.flowOn(Dispatchers.IO).launchIn(this)
}
}
private fun replaceOnLists(user: ProfileListItem) {
val followersIndex = followersList.indexOf(user)
val followingsIndex = followingsList.indexOf(user)
if(followersIndex >= 0) {
followersList[followersIndex] = user
_followers.postValue(followersList)
}
if(followingsIndex >= 0) {
followingsList[followingsIndex] = user
_followings.postValue(followingsList)
}
}
fun followUser(user: ProfileListItem) {
user.updatingFollowState = true
replaceOnLists(user)
viewModelScope.launch {
followUserUseCase.follow(user.id).onEach {
user.following = true
user.updatingFollowState = false
replaceOnLists(user)
}.flowOn(Dispatchers.IO).launchIn(this)
}
}
fun unfollowUser(user: ProfileListItem) {
user.updatingFollowState = true
replaceOnLists(user)
viewModelScope.launch {
followUserUseCase.unfollow(user.id).onEach {
user.following = false
user.updatingFollowState = false
replaceOnLists(user)
}.flowOn(Dispatchers.IO).launchIn(this)
}
}
}

View File

@ -6,12 +6,17 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.isolaatti.common.UserItemCallback
import com.isolaatti.common.UserListRecyclerViewAdapter
import com.isolaatti.databinding.FragmentFollowersBinding
import com.isolaatti.followers.presentation.FollowersViewModel
import com.isolaatti.profile.domain.entity.ProfileListItem
class FollowersFragment : Fragment() {
class FollowersFragment : Fragment(), UserItemCallback {
private lateinit var binding: FragmentFollowersBinding
private val viewModel: FollowersViewModel by viewModels({ requireParentFragment() })
private lateinit var adapter: UserListRecyclerViewAdapter
override fun onCreateView(
inflater: LayoutInflater,
@ -21,4 +26,35 @@ class FollowersFragment : Fragment() {
binding = FragmentFollowersBinding.inflate(inflater)
return binding.root
}
private fun setObservers() {
viewModel.followers.observe(viewLifecycleOwner) {
adapter.submitList(it)
}
}
private fun bind() {
adapter = UserListRecyclerViewAdapter(this)
binding.recyclerUsers.adapter = adapter
binding.recyclerUsers.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
bind()
setObservers()
viewModel.fetchFollowers()
}
override fun itemClick(userId: Int) {
}
override fun followButtonClick(user: ProfileListItem, action: UserItemCallback.FollowButtonAction) {
when(action) {
UserItemCallback.FollowButtonAction.Follow -> viewModel.followUser(user)
UserItemCallback.FollowButtonAction.Unfollow -> viewModel.unfollowUser(user)
}
}
}

View File

@ -6,12 +6,17 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.isolaatti.common.UserItemCallback
import com.isolaatti.common.UserListRecyclerViewAdapter
import com.isolaatti.databinding.FragmentFollowersBinding
import com.isolaatti.followers.presentation.FollowersViewModel
import com.isolaatti.profile.domain.entity.ProfileListItem
class FollowingFragment : Fragment() {
class FollowingFragment : Fragment(), UserItemCallback {
private lateinit var binding: FragmentFollowersBinding
private val viewModel: FollowersViewModel by viewModels({ requireParentFragment() })
private lateinit var adapter: UserListRecyclerViewAdapter
override fun onCreateView(
inflater: LayoutInflater,
@ -21,4 +26,35 @@ class FollowingFragment : Fragment() {
binding = FragmentFollowersBinding.inflate(inflater)
return binding.root
}
private fun setObservers() {
viewModel.followings.observe(viewLifecycleOwner) {
adapter.submitList(it)
}
}
private fun bind() {
adapter = UserListRecyclerViewAdapter(this)
binding.recyclerUsers.adapter = adapter
binding.recyclerUsers.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
bind()
setObservers()
viewModel.fetchFollowings()
}
override fun itemClick(userId: Int) {
}
override fun followButtonClick(user: ProfileListItem, action: UserItemCallback.FollowButtonAction) {
when(action) {
UserItemCallback.FollowButtonAction.Follow -> viewModel.followUser(user)
UserItemCallback.FollowButtonAction.Unfollow -> viewModel.unfollowUser(user)
}
}
}

View File

@ -32,6 +32,10 @@ class MainFollowersFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
arguments?.getInt(ARGUMENT_USER_ID)?.let {
viewModel.userId = it
}
binding.viewPagerFollowersMain.adapter = FollowersViewPagerAdapter(this)
TabLayoutMediator(binding.tabLayoutFollowers, binding.viewPagerFollowersMain) { tab, position ->
when(position) {
@ -40,4 +44,8 @@ class MainFollowersFragment : Fragment() {
}
}.attach()
}
companion object {
const val ARGUMENT_USER_ID = "userId"
}
}

View File

@ -15,6 +15,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.isolaatti.BuildConfig
import com.isolaatti.R
import com.isolaatti.common.ErrorMessageViewModel
@ -131,18 +132,12 @@ class FeedFragment : Fragment(), OnUserInteractedWithPostCallback {
viewBinding.feedRecyclerView.adapter = adapter
viewBinding.feedRecyclerView.layoutManager = LinearLayoutManager(requireContext())
// viewBinding.refreshButton.setOnClickListener {
// viewModel.getFeed(refresh = true)
// }
viewBinding.swipeToRefresh.setOnRefreshListener {
viewModel.getFeed(refresh = true)
viewBinding.swipeToRefresh.isRefreshing = false
}
// viewBinding.loadMoreButton.setOnClickListener {
// viewModel.getFeed(refresh = false)
// }
viewBinding.topAppBar.setOnMenuItemClickListener {
when(it.itemId) {
@ -174,11 +169,12 @@ class FeedFragment : Fragment(), OnUserInteractedWithPostCallback {
viewModel.posts.observe(viewLifecycleOwner){
if (it?.first != null) {
adapter.updateList(it.first!!, it.second)
adapter.newContentRequestFinished()
}
}
viewModel.loadingPosts.observe(viewLifecycleOwner) {
viewBinding.swipeToRefresh.isRefreshing = it
viewBinding.loadingIndicator.visibility = if(it) View.VISIBLE else View.GONE
}
@ -215,4 +211,8 @@ class FeedFragment : Fragment(), OnUserInteractedWithPostCallback {
override fun onProfileClick(userId: Int) {
ProfileActivity.startActivity(requireContext(), userId)
}
override fun onLoadMore() {
viewModel.getFeed(false)
}
}

View File

@ -40,6 +40,7 @@ class FeedViewModel @Inject constructor(
}
is Resource.Loading -> {
if(!refresh)
loadingPosts.postValue(true)
}
@ -47,6 +48,7 @@ class FeedViewModel @Inject constructor(
errorLoading.postValue(feedDtoResource.errorType)
}
}
isLoadingFromScrolling = false
}.flowOn(Dispatchers.IO).launchIn(this)
}
}

View File

@ -124,4 +124,8 @@ class BottomSheetPostComments() : BottomSheetDialogFragment(), OnUserInteractedC
override fun onProfileClick(userId: Int) {
ProfileActivity.startActivity(requireContext(), userId)
}
override fun onLoadMore() {
TODO("Not yet implemented")
}
}

View File

@ -3,4 +3,5 @@ package com.isolaatti.posting.common.domain
interface OnUserInteractedCallback {
fun onOptions(postId: Long)
fun onProfileClick(userId: Int)
fun onLoadMore()
}

View File

@ -29,6 +29,7 @@ abstract class PostListingViewModelBase : ViewModel() {
val noMoreContent = MutableLiveData(false)
val errorLoading: MutableLiveData<Resource.Error.ErrorType?> = MutableLiveData()
var isLoadingFromScrolling = false
fun getLastId(): Long = try { posts.value?.first?.data?.last()?.post?.id ?: 0 } catch (e: NoSuchElementException) { 0 }

View File

@ -167,7 +167,23 @@ class PostsRecyclerViewAdapter (private val markwon: Markwon, private val callba
override fun onBindViewHolder(holder: FeedViewHolder, position: Int) {}
private var requestedNewContent = false
/**
* Call this method when new content has been added on onLoadMore() callback
*/
fun newContentRequestFinished() {
requestedNewContent = false
}
override fun onBindViewHolder(holder: FeedViewHolder, position: Int, payloads: List<Any>) {
holder.bindView(feedDto?.data?.get(position) ?: return, payloads)
val totalItems = feedDto?.data?.size
if(totalItems != null && totalItems > 0 && !requestedNewContent) {
if(position == totalItems - 1) {
requestedNewContent = true
callback.onLoadMore()
}
}
}
}

View File

@ -3,5 +3,6 @@ package com.isolaatti.profile.data.remote
data class ProfileListItemDto(
val id: Int,
val name: String,
val profileImageId: String?
val profileImageId: String?,
val following: Boolean
)

View File

@ -0,0 +1,41 @@
package com.isolaatti.profile.domain.entity
import com.isolaatti.profile.data.remote.ProfileListItemDto
class ProfileListItem(
val id: Int,
val name: String,
val profileImageId: String?,
var following: Boolean?
) {
var updatingFollowState = false
companion object {
fun fromDto(dto: ProfileListItemDto) = ProfileListItem(
dto.id,dto.name, dto.profileImageId, dto.following
)
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as ProfileListItem
if (id != other.id) return false
if (name != other.name) return false
if (profileImageId != other.profileImageId) return false
if (following != other.following) return false
return true
}
override fun hashCode(): Int {
var result = id
result = 31 * result + name.hashCode()
result = 31 * result + (profileImageId?.hashCode() ?: 0)
result = 31 * result + (following?.hashCode() ?: 0)
return result
}
}

View File

@ -74,6 +74,7 @@ class ProfileMainFragment : Fragment() {
private val postsObserver: Observer<Pair<FeedDto?, UpdateEvent>?> = Observer {
if(it?.first != null) {
postsAdapter.updateList(it.first!!, it.second)
postsAdapter.newContentRequestFinished()
}
}
@ -121,6 +122,10 @@ class ProfileMainFragment : Fragment() {
private fun bind() {
if(userId == null) {
return
}
viewBinding.topAppBar.setNavigationOnClickListener {
findNavController().popBackStack()
@ -142,7 +147,7 @@ class ProfileMainFragment : Fragment() {
}
viewBinding.goToFollowersBtn.setOnClickListener {
findNavController().navigate(ProfileMainFragmentDirections.actionDiscussionsFragmentToMainFollowersFragment())
findNavController().navigate(ProfileMainFragmentDirections.actionDiscussionsFragmentToMainFollowersFragment(userId!!))
}
viewBinding.feedRecyclerView.adapter = postsAdapter
@ -158,7 +163,7 @@ class ProfileMainFragment : Fragment() {
viewModel.posts.observe(viewLifecycleOwner, postsObserver)
viewModel.followingState.observe(viewLifecycleOwner, followingStateObserver)
viewModel.loadingPosts.observe(viewLifecycleOwner) {
viewBinding.swipeToRefresh.isRefreshing = it
viewBinding.loadingIndicator.visibility = if(it) View.VISIBLE else View.GONE
}
}
@ -216,6 +221,10 @@ class ProfileMainFragment : Fragment() {
override fun onProfileClick(userId: Int) {
//ProfileActivity.startActivity(requireContext(), userId)
}
override fun onLoadMore() {
viewModel.getFeed(false)
}
}
}

View File

@ -4,4 +4,5 @@ import com.isolaatti.connectivity.RetrofitClient.Companion.BASE_URL
object UrlGen {
fun userProfileImage(userId: Int) = "${BASE_URL}images/profile_image/of_user/$userId?mode=small"
fun imageUrl(imageId: String) = "${BASE_URL}images/image/${imageId}"
}

View File

@ -59,7 +59,12 @@
android:layout_height="match_parent" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/loading_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
android:layout_gravity="bottom"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView

View File

@ -119,6 +119,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/loading_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
app:layout_anchor="@id/swipe_to_refresh"
app:layout_anchorGravity="bottom"/>
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottomAppBar"

View File

@ -46,7 +46,12 @@
android:layout_height="match_parent" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/loading_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
android:layout_gravity="bottom"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -3,4 +3,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_to_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_users"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -9,6 +9,7 @@
<com.google.android.material.appbar.MaterialToolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/people"
app:navigationIcon="@drawable/baseline_arrow_back_24"
app:navigationIconTint="@color/on_surface"/>
<com.google.android.material.tabs.TabLayout

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.material.card.MaterialCardView
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_margin="8dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/image"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearance="@style/ShapeAppearanceOverlay.Avatar"
tools:srcCompat="@tools:sample/avatars" />
<TextView
android:id="@+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="4dp"
app:layout_constraintStart_toEndOf="@id/image"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/follow_button"
tools:text="name"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/follow_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
style="@style/Widget.Material3.Button.TextButton"
android:textColor="@color/danger"
tools:text="Unfollow"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</FrameLayout>

View File

@ -25,7 +25,9 @@
app:destination="@id/userLinkFragment" />
<action
android:id="@+id/action_discussionsFragment_to_mainFollowersFragment"
app:destination="@id/mainFollowersFragment" />
app:destination="@id/mainFollowersFragment">
</action>
</fragment>
<fragment
android:id="@+id/audiosFragment"
@ -50,5 +52,9 @@
<fragment
android:id="@+id/mainFollowersFragment"
android:name="com.isolaatti.followers.ui.MainFollowersFragment"
android:label="MainFollowersFragment" />
android:label="MainFollowersFragment">
<argument
android:name="userId"
app:argType="integer" />
</fragment>
</navigation>

View File

@ -4,4 +4,5 @@
<color name="purple_lighter">#7015ea</color>
<color name="surface">@color/design_default_color_background</color>
<color name="on_surface">#000000</color>
<color name="danger">#BA0606</color>
</resources>

View File

@ -63,4 +63,5 @@
<string name="go_to_followers_btn_text">Followers: %s Following: %s</string>
<string name="thousand_suffix">K</string>
<string name="million_suffix">M</string>
<string name="people">People</string>
</resources>