Skip to content

Commit

Permalink
Update code.
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitjakhar committed Jun 6, 2024
1 parent d5461e4 commit c107409
Showing 1 changed file with 46 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,46 +193,12 @@ internal class MainActivity :
}

R.id.share_text -> {
showDialog(
getExportDialogData(
if (viewModel.isItemSelected.value == true) {
R.string.chucker_export_text_selected_http_confirmation
} else {
R.string.chucker_export_text_http_confirmation
},
),
onPositiveClick = {
exportTransactions(EXPORT_TXT_FILE_NAME) { transactions ->
TransactionListDetailsSharable(transactions, encodeUrls = false)
}
},
onNegativeClick = null,
)
showShareTextDialog()
true
}

R.id.share_har -> {
showDialog(
getExportDialogData(
if (viewModel.isItemSelected.value == true) {
R.string.chucker_export_har_selected_http_confirmation
} else {
R.string.chucker_export_har_http_confirmation
},
),
onPositiveClick = {
exportTransactions(EXPORT_HAR_FILE_NAME) { transactions ->
TransactionDetailsHarSharable(
HarUtils.harStringFromTransactions(
transactions,
getString(R.string.chucker_name),
getString(R.string.chucker_version),
),
)
}
},
onNegativeClick = null,
)
showShareHarDialog()
true
}

Expand All @@ -252,10 +218,53 @@ internal class MainActivity :
}
}

private fun showShareHarDialog() {
showDialog(
getExportDialogData(
if (viewModel.isItemSelected.value == true) {
R.string.chucker_export_har_selected_http_confirmation
} else {
R.string.chucker_export_har_http_confirmation
},
),
onPositiveClick = {
exportTransactions(EXPORT_HAR_FILE_NAME) { transactions ->
TransactionDetailsHarSharable(
HarUtils.harStringFromTransactions(
transactions,
getString(R.string.chucker_name),
getString(R.string.chucker_version),
),
)
}
},
onNegativeClick = null,
)
}

private fun showShareTextDialog() {
showDialog(
getExportDialogData(
if (viewModel.isItemSelected.value == true) {
R.string.chucker_export_text_selected_http_confirmation
} else {
R.string.chucker_export_text_http_confirmation
},
),
onPositiveClick = {
exportTransactions(EXPORT_TXT_FILE_NAME) { transactions ->
TransactionListDetailsSharable(transactions, encodeUrls = false)
}
},
onNegativeClick = null,
)
}

override fun onSaveInstanceState(outState: Bundle) {
outState.putIntArray("selectedItems", (transactionsAdapter.getSelectedItem().toIntArray()));
outState.putIntArray("selectedItems", (transactionsAdapter.getSelectedItem().toIntArray()))
super.onSaveInstanceState(outState)
}

override fun onRestoreInstanceState(savedInstanceState: Bundle) {
super.onRestoreInstanceState(savedInstanceState)
val itemList = savedInstanceState.getIntArray("selectedItems")
Expand Down

0 comments on commit c107409

Please sign in to comment.