mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Create mms preview view
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package presentation.common.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import com.moez.QKSMS.R
|
||||
import common.util.GlideApp
|
||||
import common.util.extensions.setVisible
|
||||
import data.model.MmsPart
|
||||
import kotlinx.android.synthetic.main.mms_preview_view.view.*
|
||||
|
||||
class MmsPreviewView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LinearLayout(context, attrs) {
|
||||
|
||||
var parts: List<MmsPart> = ArrayList()
|
||||
set(value) {
|
||||
field = value
|
||||
|
||||
val images = value.mapNotNull { it.image }
|
||||
setVisible(images.isNotEmpty())
|
||||
|
||||
images.firstOrNull()?.let {
|
||||
GlideApp.with(context).load(it).into(image)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
View.inflate(context, R.layout.mms_preview_view, this)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -27,7 +27,6 @@ import com.jakewharton.rxbinding2.view.RxView
|
||||
import com.moez.QKSMS.R
|
||||
import common.util.Colors
|
||||
import common.util.DateFormatter
|
||||
import common.util.GlideApp
|
||||
import common.util.extensions.dpToPx
|
||||
import common.util.extensions.setBackgroundTint
|
||||
import common.util.extensions.setPadding
|
||||
@@ -114,7 +113,7 @@ class MessagesAdapter @Inject constructor(
|
||||
}
|
||||
RxView.longClicks(view).subscribe { longClicks.onNext(message) }
|
||||
|
||||
bindImages(view, position)
|
||||
bindMmsPreview(view, position)
|
||||
bindStatus(view, position)
|
||||
bindGrouping(view, position)
|
||||
|
||||
@@ -124,7 +123,7 @@ class MessagesAdapter @Inject constructor(
|
||||
view.timestamp.text = dateFormatter.getMessageTimestamp(message.date)
|
||||
}
|
||||
|
||||
private fun bindImages(view: View, position: Int) {
|
||||
private fun bindMmsPreview(view: View, position: Int) {
|
||||
val message = getItem(position)!!
|
||||
|
||||
// If it's an MMS and the parts haven't been loaded, kick off a load
|
||||
@@ -132,11 +131,7 @@ class MessagesAdapter @Inject constructor(
|
||||
loadMmsParts.execute(message.id)
|
||||
}
|
||||
|
||||
view.image.setVisible(false)
|
||||
message.parts.firstOrNull { it.image != null }?.let { part ->
|
||||
view.image.setVisible(true)
|
||||
GlideApp.with(context).load(part.image).into(view.image)
|
||||
}
|
||||
view.mmsPreview.parts = message.parts
|
||||
}
|
||||
|
||||
private fun bindStatus(view: View, position: Int) {
|
||||
|
||||
Reference in New Issue
Block a user