Fix deeplinking in sample app
This commit is contained in:
parent
b8cb4d1e82
commit
50b3168491
@ -103,7 +103,7 @@ Please visit [documentation] web-site for reference
|
||||
|
||||
|
||||
## Consulting
|
||||
Paid consulting is available. Please Reach me out at [markwon+consulting[at]noties.io](mailto:markwon+consulting@noties.io)
|
||||
Paid consulting is available. Please reach me out at [markwon+consulting[at]noties.io](mailto:markwon+consulting@noties.io)
|
||||
to discuss your idea or a project
|
||||
|
||||
---
|
||||
|
@ -28,7 +28,7 @@ sealed class Deeplink {
|
||||
// https://noties.io/Markwon/app/sample/ID
|
||||
// https://noties.io/Markwon/app/search?a=core
|
||||
val segments = data.pathSegments
|
||||
if (segments.size == 3
|
||||
if (segments.size >= 3
|
||||
&& "Markwon" == segments[0]
|
||||
&& "app" == segments[1]) {
|
||||
when (segments[2]) {
|
||||
@ -41,6 +41,8 @@ sealed class Deeplink {
|
||||
}
|
||||
}
|
||||
else -> null
|
||||
}.also {
|
||||
Debug.i("parsed: $it")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import android.os.Bundle
|
||||
import android.view.Window
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import io.noties.debug.Debug
|
||||
import io.noties.markwon.app.App
|
||||
import io.noties.markwon.app.sample.ui.SampleFragment
|
||||
import io.noties.markwon.app.sample.ui.SampleListFragment
|
||||
@ -21,6 +22,7 @@ class MainActivity : FragmentActivity() {
|
||||
|
||||
// process deeplink if we are not restored
|
||||
val deeplink = Deeplink.parse(intent.data)
|
||||
|
||||
val deepLinkFragment: Fragment? = if (deeplink != null) {
|
||||
when (deeplink) {
|
||||
is Deeplink.Sample -> App.sampleManager.sample(deeplink.id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user