Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
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
Administrator
Magisk
Commits
1f75e63c
Commit
1f75e63c
authored
Aug 02, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix crashes in MarkdownWindow
Fix #1628
parent
cb3f9b97
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
19 deletions
+30
-19
build.gradle
app/build.gradle
+1
-1
MarkDownWindow.kt
...src/main/java/com/topjohnwu/magisk/view/MarkDownWindow.kt
+29
-18
No files found.
app/build.gradle
View file @
1f75e63c
...
@@ -39,7 +39,7 @@ android {
...
@@ -39,7 +39,7 @@ android {
exclude
'/META-INF/*.kotlin_module'
exclude
'/META-INF/*.kotlin_module'
exclude
'/META-INF/rxkotlin.properties'
exclude
'/META-INF/rxkotlin.properties'
exclude
'/androidsupportmultidexversion.txt'
exclude
'/androidsupportmultidexversion.txt'
exclude
'/org/**'
exclude
'/org/
bouncycastle/
**'
exclude
'/kotlin/**'
exclude
'/kotlin/**'
exclude
'/kotlinx/**'
exclude
'/kotlinx/**'
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/view/MarkDownWindow.kt
View file @
1f75e63c
...
@@ -8,11 +8,13 @@ import com.skoumal.teanity.extensions.subscribeK
...
@@ -8,11 +8,13 @@ import com.skoumal.teanity.extensions.subscribeK
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.data.repository.StringRepository
import
com.topjohnwu.magisk.data.repository.StringRepository
import
com.topjohnwu.magisk.extensions.inject
import
com.topjohnwu.magisk.extensions.inject
import
io.reactivex.Completable
import
io.reactivex.Single
import
io.reactivex.Single
import
ru.noties.markwon.Markwon
import
ru.noties.markwon.Markwon
import
ru.noties.markwon.html.HtmlPlugin
import
ru.noties.markwon.html.HtmlPlugin
import
ru.noties.markwon.image.ImagesPlugin
import
ru.noties.markwon.image.ImagesPlugin
import
ru.noties.markwon.image.svg.SvgPlugin
import
ru.noties.markwon.image.svg.SvgPlugin
import
timber.log.Timber
import
java.io.InputStream
import
java.io.InputStream
import
java.util.*
import
java.util.*
...
@@ -33,26 +35,35 @@ object MarkDownWindow {
...
@@ -33,26 +35,35 @@ object MarkDownWindow {
}
}
fun
show
(
activity
:
Context
,
title
:
String
?,
content
:
Single
<
String
>)
{
fun
show
(
activity
:
Context
,
title
:
String
?,
content
:
Single
<
String
>)
{
content
.
subscribeK
{
val
markwon
=
Markwon
.
builder
(
activity
)
val
markwon
=
Markwon
.
builder
(
activity
)
.
usePlugin
(
HtmlPlugin
.
create
())
.
usePlugin
(
HtmlPlugin
.
create
())
.
usePlugin
(
ImagesPlugin
.
create
(
activity
))
.
usePlugin
(
ImagesPlugin
.
create
(
activity
))
.
usePlugin
(
SvgPlugin
.
create
(
activity
.
resources
))
.
usePlugin
(
SvgPlugin
.
create
(
activity
.
resources
))
.
build
()
.
build
()
val
mv
=
LayoutInflater
.
from
(
activity
).
inflate
(
R
.
layout
.
markdown_window
,
null
)
val
alert
=
AlertDialog
.
Builder
(
activity
)
val
tv
=
mv
.
findViewById
<
TextView
>(
R
.
id
.
md_txt
)
alert
.
setTitle
(
title
)
val
mv
=
LayoutInflater
.
from
(
activity
).
inflate
(
R
.
layout
.
markdown_window
,
null
)
content
.
map
{
val
tv
=
mv
.
findViewById
<
TextView
>(
R
.
id
.
md_txt
)
runCatching
{
try
{
markwon
.
setMarkdown
(
tv
,
it
)
markwon
.
setMarkdown
(
tv
,
it
)
}
catch
(
e
:
ExceptionInInitializerError
)
{
}.
onFailure
{
//Nothing we can do about this error other than show error message
Timber
.
e
(
it
)
tv
.
setText
(
R
.
string
.
download_file_error
)
// Always wrap the actual exception as it could be ExceptionInInitializerError,
// which is a fatal error and RxJava will send it to the global handler and crash
throw
MarkwonException
(
it
)
}
}
}.
ignoreElement
().
onErrorResumeNext
{
alert
.
setView
(
mv
)
// Nothing we can actually do other than show error message
alert
.
setNegativeButton
(
R
.
string
.
close
)
{
dialog
,
_
->
dialog
.
dismiss
()
}
tv
.
setText
(
R
.
string
.
download_file_error
)
alert
.
show
()
Completable
.
complete
()
}.
subscribeK
{
AlertDialog
.
Builder
(
activity
)
.
setTitle
(
title
)
.
setView
(
mv
)
.
setNegativeButton
(
R
.
string
.
close
)
{
dialog
,
_
->
dialog
.
dismiss
()
}
.
show
()
}
}
}
}
class
MarkwonException
(
e
:
Throwable
):
Exception
(
e
)
}
}
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