Detect when the app previously crashed
This commit is contained in:
parent
c8254dedfe
commit
0ab09c1f16
1 changed files with 17 additions and 12 deletions
|
@ -15,6 +15,7 @@ import eu.depau.ddroid.utils.*
|
||||||
import eu.depau.ddroid.values.FlashMethod
|
import eu.depau.ddroid.values.FlashMethod
|
||||||
import eu.depau.ddroid.values.WizardStep
|
import eu.depau.ddroid.values.WizardStep
|
||||||
import kotlinx.android.synthetic.main.fragment_confirminfo.view.*
|
import kotlinx.android.synthetic.main.fragment_confirminfo.view.*
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A placeholder fragment containing a simple view.
|
* A placeholder fragment containing a simple view.
|
||||||
|
@ -63,21 +64,25 @@ class ConfirmInfoFragment : WizardFragment() {
|
||||||
|
|
||||||
view.confirm_sel_usbdev.text = StateKeeper.usbDevice?.name
|
view.confirm_sel_usbdev.text = StateKeeper.usbDevice?.name
|
||||||
|
|
||||||
StateKeeper.usbMassStorageDevice!!.init()
|
try {
|
||||||
val blockDev = StateKeeper.usbMassStorageDevice?.blockDevice
|
StateKeeper.usbMassStorageDevice!!.init()
|
||||||
|
val blockDev = StateKeeper.usbMassStorageDevice?.blockDevice
|
||||||
|
|
||||||
if (blockDev != null) {
|
if (blockDev != null) {
|
||||||
val devSize = (blockDev.size.toLong() * blockDev.blockSize.toLong())
|
val devSize = (blockDev.size.toLong() * blockDev.blockSize.toLong())
|
||||||
view.confirm_sel_usbdev_size.text = devSize.toHRSize()
|
view.confirm_sel_usbdev_size.text = devSize.toHRSize()
|
||||||
|
|
||||||
if (imgSize!! > devSize)
|
if (imgSize!! > devSize)
|
||||||
view.confirm_extra_info.text = getString(R.string.image_bigger_than_usb)
|
view.confirm_extra_info.text = getString(R.string.image_bigger_than_usb)
|
||||||
else {
|
else {
|
||||||
view.confirm_extra_info.text = getString(R.string.tap_next_to_write)
|
view.confirm_extra_info.text = getString(R.string.tap_next_to_write)
|
||||||
canContinue = true
|
canContinue = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
view.confirm_extra_info.text = getString(R.string.cant_read_usbdev)
|
||||||
}
|
}
|
||||||
} else {
|
} catch (e: IOException) {
|
||||||
view.confirm_extra_info.text = getString(R.string.cant_read_usbdev)
|
view.confirm_extra_info.text = "Could not access USB device. Maybe you ran the app previously and it crashed? Remove and reinsert the USB drive, then restart the app."
|
||||||
}
|
}
|
||||||
|
|
||||||
return view
|
return view
|
||||||
|
|
Loading…
Reference in a new issue