Shorten code
This commit is contained in:
parent
413df5f2ef
commit
480868c699
2 changed files with 7 additions and 10 deletions
|
@ -93,7 +93,7 @@ class BarcodeEditController(val rootView: View, internal val context: AppCompatA
|
|||
}
|
||||
|
||||
fun refresh() {
|
||||
val barcodeUIController = BarcodeUIController(rootView, barCode, context, PassViewHelper(context))
|
||||
val barcodeUIController = BarcodeUIController(rootView, getBarCode(), context, PassViewHelper(context))
|
||||
val isBarcodeShown = barcodeUIController.getBarcodeView().visibility == View.VISIBLE
|
||||
|
||||
if (!isBarcodeShown) {
|
||||
|
@ -103,13 +103,10 @@ class BarcodeEditController(val rootView: View, internal val context: AppCompatA
|
|||
}
|
||||
}
|
||||
|
||||
val barCode: BarCode
|
||||
get() {
|
||||
val barCode = BarCode(barcodeFormat, rootView.messageInput.text.toString())
|
||||
val alternativeText = rootView.alternativeMessageInput.text.toString()
|
||||
if (!alternativeText.isEmpty()) {
|
||||
barCode.alternativeText = alternativeText
|
||||
}
|
||||
return barCode
|
||||
fun getBarCode() = BarCode(barcodeFormat, rootView.messageInput.text.toString()).apply {
|
||||
val newAlternativeText = rootView.alternativeMessageInput.text.toString()
|
||||
if (!newAlternativeText.isEmpty()) {
|
||||
alternativeText = newAlternativeText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ fun showBarcodeEditDialog(context: AppCompatActivity, bus: EventBus, pass: Pass,
|
|||
.setTitle(R.string.edit_barcode_dialog_title)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(android.R.string.ok) { dialog, which ->
|
||||
pass.barCode = barcodeEditController.barCode
|
||||
pass.barCode = barcodeEditController.getBarCode()
|
||||
bus.post(PassRefreshEvent(pass))
|
||||
}
|
||||
.show()
|
||||
|
|
Loading…
Reference in a new issue