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
87390083
Commit
87390083
authored
Dec 02, 2019
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
htmlTagHandler sshould be implemented
parent
51122052
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
2 deletions
+49
-2
ScreenController.kt
.../roompark/presentation/screen/article/ScreenController.kt
+49
-2
No files found.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/article/ScreenController.kt
View file @
87390083
...
...
@@ -4,7 +4,9 @@ import android.text.Html
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
androidx.core.graphics.drawable.toDrawable
import
androidx.core.os.bundleOf
import
androidx.core.text.HtmlCompat
import
butterknife.BindView
import
butterknife.OnClick
import
com.biganto.visual.roompark.R
...
...
@@ -114,7 +116,13 @@ class ArticleScreenController :
private
fun
render
(
viewState
:
ArticleScreenViewState
.
ArticleLoaded
)
{
title
.
text
=
viewState
.
item
.
title
contentView
.
text
=
Html
.
fromHtml
(
viewState
.
item
.
htmlBody
)
contentView
.
text
=
Html
.
fromHtml
(
viewState
.
item
.
htmlBody
,
HtmlCompat
.
FROM_HTML_MODE_LEGACY
,
Html
.
ImageGetter
{
url
->
Picasso
.
get
()
.
load
(
url
)
.
get
()
.
toDrawable
(
resources
!!
)
},
HtmlTa
)
articleDate
.
text
=
viewState
.
item
.
published
.
toString
()
Picasso
.
get
()
...
...
@@ -136,4 +144,43 @@ class ArticleScreenController :
override
fun
getLayoutId
():
Int
=
R
.
layout
.
feed_read_screen
}
\ No newline at end of file
}
public
class
HtmlTagHandler
implements
Html
.
TagHandler
{
@Override
public
void
handleTag
(
boolean
opening
,
String
tag
,
Editable
output
,
XMLReader
xmlReader
)
{
Log
.
e
(
"Tag"
,
tag
);
if
(
tag
.
startsWith
(
"b"
)
)
{
Log
.
e
(
"Tage"
,
"Code tag encountered1"
);
if
(
opening
)
{
Log
.
e
(
"Tage"
,
"Code tag encountered1"
);
output
.
setSpan
(
new
TypefaceSpan
(
"monospace"
),
output
.
length
(),
output
.
length
(),
Spannable
.
SPAN_MARK_MARK
);
}
else
{
Log
.
e
(
"Tage"
,
"Code tag encountered2"
);
Object
obj
=
getLast
(
output
,
TypefaceSpan
.
class
);
int
where
=
output
.
getSpanStart
(
obj
);
output
.
removeSpan
(
obj
);
output
.
setSpan
(
new
TypefaceSpan
(
"monospace"
),
where
,
output
.
length
(),
Spanned
.
SPAN_EXCLUSIVE_EXCLUSIVE
);
}
}
else
{
Log
.
e
(
"Tage"
,
"Code Exited"
);
}
}
private
Object
getLast
(
Editable
text
,
Class
kind
)
{
Object
[]
objs
=
text
.
getSpans
(
0
,
text
.
length
(),
kind
);
if
(
objs
.
length
==
0
)
{
return
null
;
}
else
{
for
(
int
i
=
objs
.
length
;
i
>
0
;
i
--)
{
if
(
text
.
getSpanFlags
(
objs
[
i
-
1
])
==
Spannable
.
SPAN_MARK_MARK
)
{
return
objs
[
i
-
1
];
}
}
return
null
;
}
}
\ No newline at end of file
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