mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-26 06:55:42 +03:00
Remove 'UserEntity' from 'SharedItem' model
Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
parent
6b9ab738cb
commit
0d65824fa6
9 changed files with 23 additions and 27 deletions
|
@ -76,7 +76,7 @@ class SharedItemsActivity : AppCompatActivity() {
|
|||
LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
|
||||
}
|
||||
|
||||
val adapter = SharedItemsAdapter(showGrid, userEntity.username, userEntity.token).apply {
|
||||
val adapter = SharedItemsAdapter(showGrid, userEntity).apply {
|
||||
items = it.items
|
||||
}
|
||||
binding.imageRecycler.adapter = adapter
|
||||
|
|
|
@ -5,12 +5,12 @@ import android.view.ViewGroup
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.nextcloud.talk.databinding.SharedItemGridBinding
|
||||
import com.nextcloud.talk.databinding.SharedItemListBinding
|
||||
import com.nextcloud.talk.models.database.UserEntity
|
||||
import com.nextcloud.talk.shareditems.model.SharedItem
|
||||
|
||||
class SharedItemsAdapter(
|
||||
private val showGrid: Boolean,
|
||||
private val userName: String,
|
||||
private val userToken: String
|
||||
private val userEntity: UserEntity
|
||||
) : RecyclerView.Adapter<SharedItemsViewHolder>() {
|
||||
|
||||
var items: List<SharedItem> = emptyList()
|
||||
|
@ -24,8 +24,7 @@ class SharedItemsAdapter(
|
|||
parent,
|
||||
false
|
||||
),
|
||||
userName,
|
||||
userToken
|
||||
userEntity
|
||||
)
|
||||
} else {
|
||||
SharedItemsListViewHolder(
|
||||
|
@ -34,8 +33,7 @@ class SharedItemsAdapter(
|
|||
parent,
|
||||
false
|
||||
),
|
||||
userName,
|
||||
userToken
|
||||
userEntity
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,12 @@ import android.view.View
|
|||
import android.widget.ProgressBar
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.nextcloud.talk.databinding.SharedItemGridBinding
|
||||
import com.nextcloud.talk.models.database.UserEntity
|
||||
|
||||
class SharedItemsGridViewHolder(
|
||||
override val binding: SharedItemGridBinding,
|
||||
userName: String,
|
||||
userToken: String
|
||||
) : SharedItemsViewHolder(binding, userName, userToken) {
|
||||
userEntity: UserEntity
|
||||
) : SharedItemsViewHolder(binding, userEntity) {
|
||||
|
||||
override val image: SimpleDraweeView
|
||||
get() = binding.image
|
||||
|
|
|
@ -5,14 +5,14 @@ import android.view.View
|
|||
import android.widget.ProgressBar
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.nextcloud.talk.databinding.SharedItemListBinding
|
||||
import com.nextcloud.talk.models.database.UserEntity
|
||||
import com.nextcloud.talk.shareditems.model.SharedItem
|
||||
import com.nextcloud.talk.utils.DateUtils
|
||||
|
||||
class SharedItemsListViewHolder(
|
||||
override val binding: SharedItemListBinding,
|
||||
userName: String,
|
||||
userToken: String
|
||||
) : SharedItemsViewHolder(binding, userName, userToken) {
|
||||
userEntity: UserEntity
|
||||
) : SharedItemsViewHolder(binding, userEntity) {
|
||||
|
||||
override val image: SimpleDraweeView
|
||||
get() = binding.fileImage
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.facebook.drawee.view.SimpleDraweeView
|
|||
import com.facebook.imagepipeline.common.RotationOptions
|
||||
import com.facebook.imagepipeline.image.ImageInfo
|
||||
import com.facebook.imagepipeline.request.ImageRequestBuilder
|
||||
import com.nextcloud.talk.models.database.UserEntity
|
||||
import com.nextcloud.talk.shareditems.model.SharedItem
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.DrawableUtils
|
||||
|
@ -23,8 +24,7 @@ import com.nextcloud.talk.utils.FileViewerUtils
|
|||
|
||||
abstract class SharedItemsViewHolder(
|
||||
open val binding: ViewBinding,
|
||||
userName: String,
|
||||
userToken: String
|
||||
private val userEntity: UserEntity
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
companion object {
|
||||
|
@ -35,7 +35,12 @@ abstract class SharedItemsViewHolder(
|
|||
abstract val clickTarget: View
|
||||
abstract val progressBar: ProgressBar
|
||||
|
||||
private val authHeader = mapOf(Pair("Authorization", ApiUtils.getCredentials(userName, userToken)))
|
||||
private val authHeader = mapOf(
|
||||
Pair(
|
||||
"Authorization",
|
||||
ApiUtils.getCredentials(userEntity.username, userEntity.token)
|
||||
)
|
||||
)
|
||||
|
||||
open fun onBind(item: SharedItem) {
|
||||
image.hierarchy.setPlaceholderImage(staticImage(item.mimeType, image))
|
||||
|
@ -43,7 +48,7 @@ abstract class SharedItemsViewHolder(
|
|||
image.controller = configurePreview(item)
|
||||
}
|
||||
|
||||
val fileViewerUtils = FileViewerUtils(image.context, item.userEntity)
|
||||
val fileViewerUtils = FileViewerUtils(image.context, userEntity)
|
||||
|
||||
clickTarget.setOnClickListener {
|
||||
fileViewerUtils.openFile(
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.nextcloud.talk.shareditems.model
|
||||
|
||||
import com.nextcloud.talk.models.database.UserEntity
|
||||
|
||||
data class SharedItem(
|
||||
val id: String,
|
||||
val name: String,
|
||||
|
@ -11,6 +9,5 @@ data class SharedItem(
|
|||
val link: String?,
|
||||
val mimeType: String?,
|
||||
val previewAvailable: Boolean?,
|
||||
val previewLink: String,
|
||||
val userEntity: UserEntity,
|
||||
val previewLink: String
|
||||
)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.nextcloud.talk.shareditems.repositories
|
||||
|
||||
import com.nextcloud.talk.models.database.UserEntity
|
||||
import com.nextcloud.talk.shareditems.model.SharedItemType
|
||||
import com.nextcloud.talk.shareditems.model.SharedMediaItems
|
||||
import io.reactivex.Observable
|
||||
|
@ -21,7 +20,6 @@ interface SharedItemsRepository {
|
|||
val userName: String,
|
||||
val userToken: String,
|
||||
val baseUrl: String,
|
||||
val userEntity: UserEntity,
|
||||
val roomToken: String
|
||||
)
|
||||
}
|
||||
|
|
|
@ -69,8 +69,7 @@ class SharedItemsRepositoryImpl @Inject constructor(private val ncApi: NcApi) :
|
|||
fileParameters["link"]!!,
|
||||
fileParameters["mimetype"]!!,
|
||||
previewAvailable,
|
||||
previewLink(fileParameters["id"], parameters.baseUrl),
|
||||
parameters.userEntity
|
||||
previewLink(fileParameters["id"], parameters.baseUrl)
|
||||
)
|
||||
} else {
|
||||
Log.w(TAG, "location and deckcard are not yet supported")
|
||||
|
|
|
@ -6,8 +6,8 @@ import androidx.lifecycle.MutableLiveData
|
|||
import androidx.lifecycle.ViewModel
|
||||
import com.nextcloud.talk.models.database.UserEntity
|
||||
import com.nextcloud.talk.shareditems.model.SharedItemType
|
||||
import com.nextcloud.talk.shareditems.repositories.SharedItemsRepository
|
||||
import com.nextcloud.talk.shareditems.model.SharedMediaItems
|
||||
import com.nextcloud.talk.shareditems.repositories.SharedItemsRepository
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
@ -124,7 +124,6 @@ class SharedItemsViewModel @Inject constructor(
|
|||
userEntity.userId,
|
||||
userEntity.token,
|
||||
userEntity.baseUrl,
|
||||
userEntity,
|
||||
roomToken
|
||||
)
|
||||
_currentItemType = initialType
|
||||
|
|
Loading…
Reference in a new issue