Skip to content

Commit

Permalink
Handle nullable links in share handler
Browse files Browse the repository at this point in the history
  • Loading branch information
msasikanth committed Apr 16, 2024
1 parent cc22f34 commit f8ef24d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import me.tatarka.inject.annotations.Inject
@ActivityScope
class AndroidShareHandler(private val activity: ComponentActivity) : ShareHandler {

override fun share(content: String) {
override fun share(content: String?) {
if (content.isNullOrBlank()) return

val sendIntent =
Intent().apply {
action = Intent.ACTION_SEND
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package dev.sasikanth.rss.reader.share
import androidx.compose.runtime.staticCompositionLocalOf

interface ShareHandler {
fun share(content: String)
fun share(content: String?)
}

val LocalShareHandler =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import platform.UIKit.popoverPresentationController
class IOSShareHandler(private val viewControllerProvider: () -> UIViewController) : ShareHandler {

@OptIn(ExperimentalForeignApi::class)
override fun share(content: String) {
override fun share(content: String?) {
if (content.isNullOrBlank()) return

val viewController = viewControllerProvider()
val items = listOf(content)
val activityController = UIActivityViewController(items, null)
Expand Down

0 comments on commit f8ef24d

Please sign in to comment.