Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
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
7fcc5468
Commit
7fcc5468
authored
Dec 03, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
out of memmory issue noticed. Full article manual parsing needed
parent
726b46dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
10 deletions
+15
-10
ScreenController.kt
.../roompark/presentation/screen/article/ScreenController.kt
+2
-2
PicassoImageGetter.kt
...isual/roompark/util/view_utils/html/PicassoImageGetter.kt
+13
-8
No files found.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/article/ScreenController.kt
View file @
7fcc5468
...
@@ -121,7 +121,7 @@ class ArticleScreenController :
...
@@ -121,7 +121,7 @@ class ArticleScreenController :
val
imageGetter
=
PicassoImageGetter
(
contentView
)
val
imageGetter
=
PicassoImageGetter
(
contentView
)
val
parsedHtml
=
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
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
HtmlCompat
.
FROM_HTML_MODE_COMPACT
,
,
imageGetter
imageGetter
...
@@ -135,7 +135,7 @@ class ArticleScreenController :
...
@@ -135,7 +135,7 @@ class ArticleScreenController :
//// .current
//// .current
// }
// }
,
null
)
,
null
)
else
Html
.
fromHtml
(
viewState
.
item
.
htmlBody
else
Html
.
fromHtml
(
viewState
.
item
.
htmlBody
.
replace
(
"<br>"
,
"<br />"
)
,
,
imageGetter
imageGetter
// Html.ImageGetter { url ->
// Html.ImageGetter { url ->
...
...
app/src/main/java/com/biganto/visual/roompark/util/view_utils/html/PicassoImageGetter.kt
View file @
7fcc5468
...
@@ -11,7 +11,7 @@ import com.biganto.visual.roompark.base.RoomParkApplication
...
@@ -11,7 +11,7 @@ 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
com.squareup.picasso.Picasso
import
com.squareup.picasso.Target
import
com.squareup.picasso.Target
import
kotlin.math.min
import
timber.log.Timber
class
PicassoImageGetter
(
private
val
target
:
MaterialTextView
)
:
Html
.
ImageGetter
{
class
PicassoImageGetter
(
private
val
target
:
MaterialTextView
)
:
Html
.
ImageGetter
{
...
@@ -41,18 +41,23 @@ class PicassoImageGetter(private val target: MaterialTextView) : Html.ImageGette
...
@@ -41,18 +41,23 @@ class PicassoImageGetter(private val target: MaterialTextView) : Html.ImageGette
this
.
_drawable
=
drawable
this
.
_drawable
=
drawable
var
width
=
drawable
.
intrinsicWidth
var
width
=
drawable
.
intrinsicWidth
var
height
=
drawable
.
intrinsicHeight
var
height
=
drawable
.
intrinsicHeight
target
.
let
{
Timber
.
d
(
"WE GONNA WORK WITH DATA: ${target.width} / ${target.height}"
)
val
aspect
=
it
.
width
.
toFloat
()/
width
.
toFloat
()
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
)
drawable
.
setBounds
(
0
,
0
,
width
,
height
)
setBounds
(
0
,
0
,
width
,
height
)
setBounds
(
0
,
0
,
width
,
height
)
it
.
text
=
it
.
text
}
}
target
.
text
=
target
.
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