Commit 7fcc5468 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

out of memmory issue noticed. Full article manual parsing needed

parent 726b46dd
......@@ -121,7 +121,7 @@ class ArticleScreenController :
val imageGetter = PicassoImageGetter(contentView)
val parsedHtml = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
Html.fromHtml(viewState.item.htmlBody,
Html.fromHtml(viewState.item.htmlBody.replace("<br>","<br />"),
HtmlCompat.FROM_HTML_MODE_COMPACT
,
imageGetter
......@@ -135,7 +135,7 @@ class ArticleScreenController :
//// .current
// }
, null)
else Html.fromHtml(viewState.item.htmlBody
else Html.fromHtml(viewState.item.htmlBody.replace("<br>","<br />")
,
imageGetter
// Html.ImageGetter { url ->
......
......@@ -11,7 +11,7 @@ import com.biganto.visual.roompark.base.RoomParkApplication
import com.google.android.material.textview.MaterialTextView
import com.squareup.picasso.Picasso
import com.squareup.picasso.Target
import kotlin.math.min
import timber.log.Timber
class PicassoImageGetter(private val target: MaterialTextView) : Html.ImageGetter {
......@@ -41,18 +41,23 @@ class PicassoImageGetter(private val target: MaterialTextView) : Html.ImageGette
this._drawable = drawable
var width = drawable.intrinsicWidth
var height = drawable.intrinsicHeight
target.let {
val aspect = it.width.toFloat()/width.toFloat()
Timber.d("WE GONNA WORK WITH DATA: ${target.width} / ${target.height}")
Timber.d("WE GONNA WORK WITH M DATA: ${target.measuredWidth} / ${target.measuredHeight}")
target.width.let{
val aspect = width.toFloat()/it.toFloat()
Timber.d("aspect is $aspect")
val imgWider = width>it
Timber.d("imgWider is $imgWider")
height = if (imgWider) (height.toFloat()/aspect).toInt()
else (height.toFloat()*aspect).toInt()
width = if (imgWider) it else it//imgWider
height = if (width>it.width) (height*min(aspect,1.0f)).toInt()
else (height.toFloat()*aspect).toInt()
width = if (width>it.width) width
else it.width
drawable.setBounds(0, 0, width, height)
setBounds(0, 0, width, height)
it.text=it.text
}
target.text=target.text
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment