mirror of
https://github.com/imcarlost/Friendlists.git
synced 2026-04-10 02:46:54 -04:00
implement the album feature
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.hako.userlist.domain.usecase
|
||||
|
||||
import com.hako.base.domain.UseCase
|
||||
import com.hako.base.domain.database.dao.UserDao
|
||||
import com.hako.userlist.domain.datasource.UserlistRemoteApi
|
||||
import com.hako.userlist.model.UserViewable
|
||||
@@ -11,12 +10,11 @@ import io.reactivex.schedulers.Schedulers
|
||||
import org.koin.core.KoinComponent
|
||||
import org.koin.core.get
|
||||
|
||||
class GetUsers(private val dao: UserDao) : KoinComponent,
|
||||
UseCase<UserViewable> {
|
||||
class GetUsers(private val dao: UserDao) : KoinComponent {
|
||||
|
||||
private val api: UserlistRemoteApi = get()
|
||||
|
||||
override fun execute(
|
||||
fun execute(
|
||||
onSuccess: (List<UserViewable>) -> Unit,
|
||||
onError: (Throwable) -> Unit,
|
||||
onLoading: () -> Unit
|
||||
@@ -25,7 +23,7 @@ class GetUsers(private val dao: UserDao) : KoinComponent,
|
||||
.subscribeOn(Schedulers.io())
|
||||
.doOnError { onError(it) }
|
||||
.doOnSuccess { dbUsers ->
|
||||
if (dbUsers.isEmpty() || dbUsers.count() == 0) {
|
||||
if (dbUsers.isEmpty()) {
|
||||
api.getUsers()
|
||||
.doOnSuccess {
|
||||
dao.saveAll(it.map { user -> user.toUserEntity() })
|
||||
|
||||
@@ -22,7 +22,7 @@ import timber.log.Timber
|
||||
class UserlistFragment : Fragment() {
|
||||
|
||||
private val viewModel: UserlistViewmodel by viewModel()
|
||||
private val chatAdapter by lazy { UserlistAdapter() }
|
||||
private val listAdapter by lazy { UserlistAdapter() }
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
@@ -63,13 +63,13 @@ class UserlistFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun handleFetchSuccess(users: List<UserViewable>) {
|
||||
chatAdapter.addAll(users)
|
||||
listAdapter.addAll(users)
|
||||
}
|
||||
|
||||
private fun setRecycler() {
|
||||
fragment_userlist_recycler_container.apply {
|
||||
layoutManager = LinearLayoutManager(context)
|
||||
adapter = chatAdapter.apply {
|
||||
adapter = listAdapter.apply {
|
||||
onItemClick = {
|
||||
context.toast(it.realName)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Real Name" />
|
||||
@@ -27,7 +28,7 @@
|
||||
android:id="@+id/item_user_card_user_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="12sp"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintStart_toStartOf="@+id/item_user_card_real_name"
|
||||
app:layout_constraintTop_toBottomOf="@+id/item_user_card_real_name"
|
||||
tools:text="User Name" />
|
||||
|
||||
Reference in New Issue
Block a user