Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ private fun TopAppBar(
IconButton(
onClick = {
if (uiState.success) {
onSettingsClick(uiState.shop.getData()?.id!!)
uiState.shop.getData()?.id?.let { onSettingsClick(it) }
}
},
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private fun ShopSettingsContentView(
dialogTitle = stringResource(R.string.are_you_sure),
confirmButtonTitle = stringResource(R.string.title_reset_number_tags),
onDismissRequest = { isShowingResetConfirmationDialog = false },
onConfirmation = { viewModel.resetShop(uiState.shop.getData()?.id!!) },
onConfirmation = { uiState.shop.getData()?.id?.let { viewModel.resetShop(it) } },
icon = Icons.Outlined.AddAlert,
)
}
Expand All @@ -179,7 +179,7 @@ private fun ShopSettingsContentView(
dialogTitle = stringResource(R.string.are_you_sure),
confirmButtonTitle = stringResource(R.string.title_delete_shop),
onDismissRequest = { isShowingDeleteConfirmationDialog = false },
onConfirmation = { viewModel.deleteShop(uiState.shop.getData()?.id!!) },
onConfirmation = { uiState.shop.getData()?.id?.let { viewModel.deleteShop(it) } },
icon = Icons.Outlined.AddAlert,
)
}
Expand Down Expand Up @@ -230,7 +230,7 @@ private fun ShopSettingsContentView(
)
},
modifier = Modifier
.clickable { onShowBasicSettingsClick(uiState.shop.getData()?.id!!) },
.clickable { uiState.shop.getData()?.id?.let { onShowBasicSettingsClick(it) } },
)

HorizontalDivider()
Expand Down Expand Up @@ -265,7 +265,7 @@ private fun ShopSettingsContentView(
)
},
modifier = Modifier
.clickable { onShowItemTagListClick(uiState.shop.getData()?.id!!) },
.clickable { uiState.shop.getData()?.id?.let { onShowItemTagListClick(it) } },
)

HorizontalDivider()
Expand Down Expand Up @@ -300,7 +300,7 @@ private fun ShopSettingsContentView(
)
},
modifier = Modifier
.clickable { onShowNumberTagsWebpageListClick(uiState.shop.getData()?.id!!) },
.clickable { uiState.shop.getData()?.id?.let { onShowNumberTagsWebpageListClick(it) } },
)

HorizontalDivider()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,10 @@ object Utility {
// https://stackoverflow.com/a/75714502/1160200
// https://qiita.com/irgaly/items/b942bd985a4647e372ea
fun Context.shareImage(title: String, image: ImageBitmap, filename: String) {
val file = try {
val outputFile = File(cacheDir, "$filename.png")
val outPutStream = FileOutputStream(outputFile)
image.asAndroidBitmap().compress(Bitmap.CompressFormat.PNG, 100, outPutStream)
outPutStream.flush()
outPutStream.close()
outputFile
} catch (e: Throwable) {
throw e
val file = File(cacheDir, "$filename.png").also { outputFile ->
FileOutputStream(outputFile).use { outputStream ->
image.asAndroidBitmap().compress(Bitmap.CompressFormat.PNG, 100, outputStream)
}
}

val uri = file.toUriCompat(this)
Expand All @@ -145,8 +140,8 @@ object Utility {
// https://stackoverflow.com/a/78039163/1160200
fun Context.restartApp() {
val packageManager = packageManager
val intent = packageManager.getLaunchIntentForPackage(packageName)!!
val componentName = intent.component!!
val intent = packageManager.getLaunchIntentForPackage(packageName) ?: return
val componentName = intent.component ?: return
val restartIntent = Intent.makeRestartActivityTask(componentName)
startActivity(restartIntent)
Runtime.getRuntime().exit(0)
Expand Down
Loading