mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-23 21:45:42 +03:00
add fallback images for mimetypes if no preview image was found
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
e1703aac24
commit
3a1f3242d8
1 changed files with 35 additions and 15 deletions
|
@ -10,6 +10,7 @@ import com.facebook.drawee.interfaces.DraweeController
|
|||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.facebook.imagepipeline.common.RotationOptions
|
||||
import com.facebook.imagepipeline.request.ImageRequestBuilder
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.databinding.AttachmentItemBinding
|
||||
import com.nextcloud.talk.repositories.SharedItem
|
||||
import com.nextcloud.talk.utils.FileViewerUtils
|
||||
|
@ -48,23 +49,42 @@ class SharedItemsAdapter : RecyclerView.Adapter<SharedItemsAdapter.ViewHolder>()
|
|||
.setImageRequest(imageRequest)
|
||||
.build()
|
||||
holder.binding.image.controller = draweeController
|
||||
|
||||
holder.binding.image.setOnClickListener {
|
||||
val fileViewerUtils = FileViewerUtils(it.context, currentItem.userEntity)
|
||||
|
||||
fileViewerUtils.openFile(
|
||||
currentItem.id,
|
||||
currentItem.name,
|
||||
currentItem.fileSize,
|
||||
currentItem.path,
|
||||
currentItem.link,
|
||||
currentItem.mimeType,
|
||||
null,
|
||||
null,
|
||||
it as SimpleDraweeView
|
||||
)
|
||||
} else {
|
||||
when (currentItem.mimeType) {
|
||||
"video/mp4",
|
||||
"video/quicktime",
|
||||
"video/ogg"
|
||||
-> holder.binding.image.setImageResource(R.drawable.ic_mimetype_video)
|
||||
"audio/mpeg",
|
||||
"audio/wav",
|
||||
"audio/ogg",
|
||||
-> holder.binding.image.setImageResource(R.drawable.ic_mimetype_audio)
|
||||
"image/png",
|
||||
"image/jpeg",
|
||||
"image/gif"
|
||||
-> holder.binding.image.setImageResource(R.drawable.ic_mimetype_image)
|
||||
"text/markdown",
|
||||
"text/plain"
|
||||
-> holder.binding.image.setImageResource(R.drawable.ic_mimetype_text)
|
||||
else
|
||||
-> holder.binding.image.setImageResource(R.drawable.ic_mimetype_file)
|
||||
}
|
||||
}
|
||||
holder.binding.image.setOnClickListener {
|
||||
val fileViewerUtils = FileViewerUtils(it.context, currentItem.userEntity)
|
||||
|
||||
fileViewerUtils.openFile(
|
||||
currentItem.id,
|
||||
currentItem.name,
|
||||
currentItem.fileSize,
|
||||
currentItem.path,
|
||||
currentItem.link,
|
||||
currentItem.mimeType,
|
||||
null,
|
||||
null,
|
||||
it as SimpleDraweeView
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
|
|
Loading…
Reference in a new issue