Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Room Park Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav Bogdashkin
Room Park Android
Commits
0aca8f0a
Commit
0aca8f0a
authored
Jan 30, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
floating close button least
parent
198311a2
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
38 additions
and
54 deletions
+38
-54
ScreenController.kt
.../roompark/presentation/screen/article/ScreenController.kt
+11
-24
textAdapter.kt
.../roompark/presentation/screen/article/util/textAdapter.kt
+10
-16
feed_direct_viewholder.xml
app/src/main/res/layout/feed_direct_viewholder.xml
+1
-2
feed_preview_viewholder.xml
app/src/main/res/layout/feed_preview_viewholder.xml
+1
-3
feed_viewholder.xml
app/src/main/res/layout/feed_viewholder.xml
+1
-3
htlm_image_viewholder.xml
app/src/main/res/layout/htlm_image_viewholder.xml
+4
-1
htlm_text_viewholder.xml
app/src/main/res/layout/htlm_text_viewholder.xml
+5
-5
styles.xml
app/src/main/res/values/styles.xml
+5
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/article/ScreenController.kt
View file @
0aca8f0a
package
com.biganto.visual.roompark.presentation.screen.article
import
android.os.Bundle
import
android.text.Html
import
android.view.View
import
android.view.ViewGroup
import
android.webkit.WebView
import
android.widget.ImageView
import
androidx.core.os.bundleOf
import
androidx.recyclerview.widget.LinearLayoutManager
...
...
@@ -111,34 +111,21 @@ class ArticleScreenController :
}
private
fun
render
(
viewState
:
ArticleScreenViewState
.
ArticleLoaded
)
{
title
.
text
=
viewState
.
item
.
title
// val imageGetter = PicassoImageGetter()
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"
)
val
z
=
viewState
.
item
.
htmlBody
.
replace
(
"<\\br>"
,
"\n"
)
.
replace
(
"<br>"
,
"\n"
)
.
replace
(
"</br>"
,
"\n"
).
toString
()
Timber
.
d
(
" escaped lines: ${z}"
)
val
tags
=
z
.
lines
().
map
{
val
r
=
reg
.
matchEntire
(
it
)
?.
groupValues
?.
last
()
Timber
.
d
(
"matched: $r"
)
val
result
=
if
(
r
==
null
)
HtmlTag
.
Text
(
it
)
else
HtmlTag
.
ImageSource
(
r
)
Timber
.
d
(
" result: ${result}"
)
result
.
replace
(
"</br>"
,
"\n"
)
.
replace
(
"<p>"
,
""
)
.
replace
(
"</p>"
,
""
)
val
tags
=
z
.
lines
().
map
{
if
(
it
.
startsWith
(
"<img"
))
HtmlTag
.
ImageSource
(
it
.
substringAfter
(
"src=\""
).
substringBefore
(
"\""
))
else
HtmlTag
.
Text
(
it
)
}.
toList
()
(
articleRecyclerView
.
adapter
as
HtmlPageAdapter
).
setItems
(
tags
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/article/util/textAdapter.kt
View file @
0aca8f0a
...
...
@@ -7,9 +7,8 @@ import android.widget.ImageView
import
androidx.recyclerview.widget.RecyclerView
import
butterknife.ButterKnife
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.google.android.material.textview.MaterialTextView
import
com.squareup.picasso.Picasso
import
timber.log.Timber
/**
* Created by Vladislav Bogdashkin on 29.01.2020.
...
...
@@ -22,11 +21,8 @@ sealed class HtmlTag {
class
ImageSource
(
val
src
:
String
):
HtmlTag
()
}
class
HtmlPageAdapter
:
RecyclerView
.
Adapter
<
HtmlTagViewHolder
<
HtmlTag
>>()
{
private
val
list
=
mutableListOf
<
HtmlTag
>()
override
fun
getItemViewType
(
position
:
Int
):
Int
{
...
...
@@ -37,7 +33,7 @@ class HtmlPageAdapter : RecyclerView.Adapter<HtmlTagViewHolder<HtmlTag>>() {
}
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
HtmlTagViewHolder
<
HtmlTag
>
{
val
ret
=
when
(
HtmlViewType
.
fromInt
(
viewType
))
{
return
when
(
HtmlViewType
.
fromInt
(
viewType
))
{
HtmlViewType
.
TEXT
->
HtmlTextViewHolder
(
LayoutInflater
.
from
(
parent
.
context
)
...
...
@@ -49,15 +45,9 @@ class HtmlPageAdapter : RecyclerView.Adapter<HtmlTagViewHolder<HtmlTag>>() {
.
inflate
(
R
.
layout
.
htlm_image_viewholder
,
parent
,
false
)
)
as
HtmlTagViewHolder
<
HtmlTag
>
}
return
ret
}
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
])
}
...
...
@@ -81,7 +71,6 @@ abstract class HtmlTagViewHolder<M:HtmlTag>(itemView: View) : RecyclerView.ViewH
onViewBound
(
model
)
}
protected
lateinit
var
bindedModel
:
M
}
...
...
@@ -95,14 +84,19 @@ class HtmlTextViewHolder(itemView: View) : HtmlTagViewHolder<HtmlTag.Text>(itemV
class
HtmlImageViewHolder
(
itemView
:
View
)
:
HtmlTagViewHolder
<
HtmlTag
.
ImageSource
>(
itemView
)
{
private
val
picassoAsync
by
lazy
{
return
@lazy
RoomParkApplication
.
component
.
providePicassoAsync
()
}
override
fun
onViewBound
(
model
:
HtmlTag
.
ImageSource
)
{
Picasso
.
get
().
load
(
"https://room-park.ru${model.src}"
)
val
url
=
"https://room-park.ru${model.src}"
picassoAsync
.
load
(
url
)
.
into
(
itemView
as
ImageView
)
}
}
private
enum
class
HtmlViewType
(
val
viewType
:
Int
){
TEXT
(
0
),
...
...
app/src/main/res/layout/feed_direct_viewholder.xml
View file @
0aca8f0a
...
...
@@ -18,8 +18,7 @@
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/feed_title_info_text_view"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_favorites"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
<androidx.constraintlayout.widget.Guideline
android:id=
"@+id/guideline"
...
...
app/src/main/res/layout/feed_preview_viewholder.xml
View file @
0aca8f0a
...
...
@@ -13,12 +13,10 @@
android:layout_height=
"60dp"
android:layout_marginTop=
"8dp"
android:layout_marginBottom=
"8dp"
android:background=
"@color/colorAccentSecondary"
app:image_corner_radius=
"4dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_favorites"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
<androidx.constraintlayout.widget.Guideline
android:id=
"@+id/guideline"
...
...
app/src/main/res/layout/feed_viewholder.xml
View file @
0aca8f0a
...
...
@@ -14,12 +14,10 @@
android:layout_height=
"60dp"
android:layout_marginTop=
"8dp"
android:layout_marginBottom=
"8dp"
android:background=
"@color/colorAccentSecondary"
app:image_corner_radius=
"4dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_favorites"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
<androidx.constraintlayout.widget.Guideline
android:id=
"@+id/guideline"
...
...
app/src/main/res/layout/htlm_image_viewholder.xml
View file @
0aca8f0a
<?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"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
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"
/>
\ No newline at end of file
app/src/main/res/layout/htlm_text_viewholder.xml
View file @
0aca8f0a
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.textview.MaterialTextView
xmlns:android=
"http://schemas.android.com/apk/res/android
"
<com.google.android.material.textview.MaterialTextView
xmlns:android=
"http://schemas.android.com/apk/res/android"
style=
"@style/Default_HtmlView
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
style=
"@style/Default_TextView.Header_Text"
android:minHeight=
"16dp"
/>
\ No newline at end of file
android:layout_marginStart=
"16dp"
android:layout_marginEnd=
"16dp"
android:minHeight=
"16dp"
/>
\ No newline at end of file
app/src/main/res/values/styles.xml
View file @
0aca8f0a
...
...
@@ -287,8 +287,13 @@
<item
name=
"android:textColor"
>
@color/colorAccent
</item>
</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"
>
<item
name=
"android:textSize"
>
@dimen/accent_header
</item>
<item
name=
"android:textColor"
>
@color/colorHeaderText
</item>
</style>
<style
name=
"Default_TextView.Accent_Text"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment