-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
package com.oztechan.ccc.android.ui.mobile.util | ||
|
||
import android.content.ActivityNotFoundException | ||
import android.content.Context | ||
import android.content.Intent | ||
import co.touchlab.kermit.Logger | ||
|
||
@Suppress("TooGenericExceptionCaught") | ||
fun Context.resolveAndStartIntent(intent: Intent) { | ||
intent.resolveActivity(packageManager)?.let { | ||
startActivity(intent) | ||
} ?: Exception("No activity found to handle the intent: $intent").let { | ||
try { | ||
intent.resolveActivity(packageManager)?.let { | ||
startActivity(intent) | ||
null | ||
} ?: Exception("No activity found to handle the intent: $intent") | ||
Check warning on line 14 in android/ui/mobile/src/main/kotlin/com/oztechan/ccc/android/ui/mobile/util/IntentUtil.kt Codecov / codecov/patchandroid/ui/mobile/src/main/kotlin/com/oztechan/ccc/android/ui/mobile/util/IntentUtil.kt#L12-L14
|
||
} catch (e: ActivityNotFoundException) { | ||
Exception("Unable to open link", e) | ||
Check warning on line 16 in android/ui/mobile/src/main/kotlin/com/oztechan/ccc/android/ui/mobile/util/IntentUtil.kt Codecov / codecov/patchandroid/ui/mobile/src/main/kotlin/com/oztechan/ccc/android/ui/mobile/util/IntentUtil.kt#L16
|
||
} catch (e: Exception) { | ||
Exception("An error occurred", e) | ||
}.let { | ||
Check warning on line 19 in android/ui/mobile/src/main/kotlin/com/oztechan/ccc/android/ui/mobile/util/IntentUtil.kt Codecov / codecov/patchandroid/ui/mobile/src/main/kotlin/com/oztechan/ccc/android/ui/mobile/util/IntentUtil.kt#L18-L19
|
||
Logger.e(it) { it.message.orEmpty() } | ||
} | ||
} |