mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Show all images in message
This commit is contained in:
@@ -20,16 +20,12 @@ package presentation.common.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.moez.QKSMS.R
|
||||
import common.di.appComponent
|
||||
import common.util.GlideApp
|
||||
import common.util.extensions.mapNotNull
|
||||
import common.util.extensions.setVisible
|
||||
import data.model.MmsPart
|
||||
import kotlinx.android.synthetic.main.mms_preview_view.view.*
|
||||
import presentation.common.Navigator
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -45,21 +41,23 @@ class MmsPreviewView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
|
||||
init {
|
||||
appComponent.inject(this)
|
||||
View.inflate(context, R.layout.mms_preview_view, this)
|
||||
|
||||
image.clicks()
|
||||
.mapNotNull { parts.firstOrNull { it.image != null } }
|
||||
.map { part -> part.id }
|
||||
.doOnNext { partId -> navigator.showImage(partId) }
|
||||
.subscribe()
|
||||
orientation = LinearLayout.VERTICAL
|
||||
}
|
||||
|
||||
private fun updateView() {
|
||||
val images = parts.mapNotNull { it.image }
|
||||
val images = parts.filter { it.image != null }
|
||||
setVisible(images.isNotEmpty())
|
||||
|
||||
images.firstOrNull()?.let {
|
||||
GlideApp.with(context).load(it).fitCenter().into(image)
|
||||
if (childCount > 0) {
|
||||
removeAllViews()
|
||||
}
|
||||
|
||||
images.forEach { image ->
|
||||
addView(ImageView(context).apply {
|
||||
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
|
||||
GlideApp.with(context).load(image.image).fitCenter().into(this)
|
||||
setOnClickListener { navigator.showImage(image.id) }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
~
|
||||
~ This file is part of QKSMS.
|
||||
~
|
||||
~ QKSMS is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ QKSMS is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<merge 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"
|
||||
tools:parentTag="presentation.common.widget.MmsPreviewView">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</merge>
|
||||
Reference in New Issue
Block a user