Commit 0aca8f0a authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

floating close button least

parent 198311a2
package com.biganto.visual.roompark.presentation.screen.article package com.biganto.visual.roompark.presentation.screen.article
import android.os.Bundle import android.os.Bundle
import android.text.Html
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.webkit.WebView
import android.widget.ImageView import android.widget.ImageView
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
...@@ -111,34 +111,21 @@ class ArticleScreenController : ...@@ -111,34 +111,21 @@ class ArticleScreenController :
} }
private fun render(viewState: ArticleScreenViewState.ArticleLoaded) { private fun render(viewState: ArticleScreenViewState.ArticleLoaded) {
title.text = viewState.item.title title.text = viewState.item.title
// val imageGetter = PicassoImageGetter() val z = viewState.item.htmlBody
.replace("<\\br>","\n")
val _escaped = Html.escapeHtml(viewState.item.htmlBody)
val charset = Charsets.UTF_8
val reg = "<img\\b(?=\\s)(?=(?:[^>=]|='[^']*'|=\"[^\"]*\"|=[^'\"][^\\s>]*)*?\\ssrc=['\"]([^\"]*)['\"]?)(?:[^>=]|='[^']*'|=\"[^\"]*\"|=[^'\"\\s]*)*\"\\s?\\/?>"
.toRegex()
val _esc =_escaped.toByteArray(charset).contentToString()
val z = viewState.item.htmlBody.replace("<\\br>","\n")
.replace("<br>","\n") .replace("<br>","\n")
.replace("</br>","\n").toString() .replace("</br>","\n")
.replace("<p>","")
Timber.d(" escaped lines: ${z}") .replace("</p>","")
val tags = z.lines().map{ val tags = z.lines().map {
val r = reg.matchEntire(it)?.groupValues?.last() if (it.startsWith("<img"))
Timber.d("matched: $r") HtmlTag.ImageSource(it.substringAfter("src=\"").substringBefore("\""))
val result = if (r == null) HtmlTag.Text(it) else HtmlTag.Text(it)
else HtmlTag.ImageSource(r)
Timber.d(" result: ${result}")
result
}.toList() }.toList()
(articleRecyclerView.adapter as HtmlPageAdapter).setItems(tags) (articleRecyclerView.adapter as HtmlPageAdapter).setItems(tags)
......
...@@ -7,9 +7,8 @@ import android.widget.ImageView ...@@ -7,9 +7,8 @@ import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import butterknife.ButterKnife import butterknife.ButterKnife
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
import com.squareup.picasso.Picasso
import timber.log.Timber
/** /**
* Created by Vladislav Bogdashkin on 29.01.2020. * Created by Vladislav Bogdashkin on 29.01.2020.
...@@ -22,11 +21,8 @@ sealed class HtmlTag { ...@@ -22,11 +21,8 @@ sealed class HtmlTag {
class ImageSource(val src:String):HtmlTag() class ImageSource(val src:String):HtmlTag()
} }
class HtmlPageAdapter : RecyclerView.Adapter<HtmlTagViewHolder<HtmlTag>>() { class HtmlPageAdapter : RecyclerView.Adapter<HtmlTagViewHolder<HtmlTag>>() {
private val list = mutableListOf<HtmlTag>() private val list = mutableListOf<HtmlTag>()
override fun getItemViewType(position: Int): Int { override fun getItemViewType(position: Int): Int {
...@@ -37,7 +33,7 @@ class HtmlPageAdapter : RecyclerView.Adapter<HtmlTagViewHolder<HtmlTag>>() { ...@@ -37,7 +33,7 @@ class HtmlPageAdapter : RecyclerView.Adapter<HtmlTagViewHolder<HtmlTag>>() {
} }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HtmlTagViewHolder<HtmlTag> { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HtmlTagViewHolder<HtmlTag> {
val ret = when (HtmlViewType.fromInt(viewType)) { return when (HtmlViewType.fromInt(viewType)) {
HtmlViewType.TEXT -> HtmlViewType.TEXT ->
HtmlTextViewHolder( HtmlTextViewHolder(
LayoutInflater.from(parent.context) LayoutInflater.from(parent.context)
...@@ -49,15 +45,9 @@ class HtmlPageAdapter : RecyclerView.Adapter<HtmlTagViewHolder<HtmlTag>>() { ...@@ -49,15 +45,9 @@ class HtmlPageAdapter : RecyclerView.Adapter<HtmlTagViewHolder<HtmlTag>>() {
.inflate(R.layout.htlm_image_viewholder, parent, false) .inflate(R.layout.htlm_image_viewholder, parent, false)
) as HtmlTagViewHolder<HtmlTag> ) as HtmlTagViewHolder<HtmlTag>
} }
return ret
} }
override fun onBindViewHolder(holder: HtmlTagViewHolder<HtmlTag>, position: Int) { override fun onBindViewHolder(holder: HtmlTagViewHolder<HtmlTag>, position: Int) {
Timber.d(list[position].toString())
Timber.d(" holder: ${holder::class} - list: ${list[position]::class}")
Timber.d("position - $position")
holder.bindModel(list[position]) holder.bindModel(list[position])
} }
...@@ -81,7 +71,6 @@ abstract class HtmlTagViewHolder<M:HtmlTag>(itemView: View) : RecyclerView.ViewH ...@@ -81,7 +71,6 @@ abstract class HtmlTagViewHolder<M:HtmlTag>(itemView: View) : RecyclerView.ViewH
onViewBound(model) onViewBound(model)
} }
protected lateinit var bindedModel: M protected lateinit var bindedModel: M
} }
...@@ -95,14 +84,19 @@ class HtmlTextViewHolder(itemView: View) : HtmlTagViewHolder<HtmlTag.Text>(itemV ...@@ -95,14 +84,19 @@ class HtmlTextViewHolder(itemView: View) : HtmlTagViewHolder<HtmlTag.Text>(itemV
class HtmlImageViewHolder(itemView: View) :HtmlTagViewHolder<HtmlTag.ImageSource>(itemView) { class HtmlImageViewHolder(itemView: View) :HtmlTagViewHolder<HtmlTag.ImageSource>(itemView) {
private val picassoAsync by lazy {
return@lazy RoomParkApplication.component.providePicassoAsync()
}
override fun onViewBound(model: HtmlTag.ImageSource) { override fun onViewBound(model: HtmlTag.ImageSource) {
Picasso.get().load( val url = "https://room-park.ru${model.src}"
"https://room-park.ru${model.src}" picassoAsync
) .load(url)
.into(itemView as ImageView) .into(itemView as ImageView)
} }
} }
private enum class HtmlViewType(val viewType:Int){ private enum class HtmlViewType(val viewType:Int){
TEXT(0), TEXT(0),
......
...@@ -18,8 +18,7 @@ ...@@ -18,8 +18,7 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/feed_title_info_text_view" app:layout_constraintEnd_toStartOf="@+id/feed_title_info_text_view"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
app:srcCompat="@drawable/ic_favorites" />
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline" android:id="@+id/guideline"
......
...@@ -13,12 +13,10 @@ ...@@ -13,12 +13,10 @@
android:layout_height="60dp" android:layout_height="60dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:background="@color/colorAccentSecondary"
app:image_corner_radius="4dp" app:image_corner_radius="4dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
app:srcCompat="@drawable/ic_favorites" />
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline" android:id="@+id/guideline"
......
...@@ -14,12 +14,10 @@ ...@@ -14,12 +14,10 @@
android:layout_height="60dp" android:layout_height="60dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:background="@color/colorAccentSecondary"
app:image_corner_radius="4dp" app:image_corner_radius="4dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
app:srcCompat="@drawable/ic_favorites" />
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline" android:id="@+id/guideline"
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView xmlns:android="http://schemas.android.com/apk/res/android" <com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto" android:adjustViewBounds="true"
android:scaleType="fitStart"
app:image_corner_radius="4dp" /> app:image_corner_radius="4dp" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" style="@style/Default_HtmlView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/Default_TextView.Header_Text" android:layout_marginStart="16dp"
android:minHeight="16dp" android:layout_marginEnd="16dp"
/> android:minHeight="16dp" />
\ No newline at end of file \ No newline at end of file
...@@ -287,8 +287,13 @@ ...@@ -287,8 +287,13 @@
<item name="android:textColor">@color/colorAccent</item> <item name="android:textColor">@color/colorAccent</item>
</style> </style>
<style name="Default_HtmlView" parent="Base.Widget.AppCompat.TextView.AcromRegularTextView">
<item name="android:textSize">@dimen/accent_header</item>
</style>
<style name="Default_TextView" parent="Base.Widget.AppCompat.TextView.AcromMediumTextView"> <style name="Default_TextView" parent="Base.Widget.AppCompat.TextView.AcromMediumTextView">
<item name="android:textSize">@dimen/accent_header</item> <item name="android:textSize">@dimen/accent_header</item>
<item name="android:textColor">@color/colorHeaderText</item>
</style> </style>
<style name="Default_TextView.Accent_Text"> <style name="Default_TextView.Accent_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