EtchDroid/app/src/main/java/eu/depau/etchdroid/abc/WizardActivity.kt

47 lines
2 KiB
Kotlin
Raw Normal View History

2018-08-15 17:04:45 +00:00
package eu.depau.etchdroid.abc
2018-08-12 14:33:11 +00:00
import android.content.Intent
2018-08-16 14:21:43 +00:00
import android.os.Bundle
2018-08-12 14:33:11 +00:00
import android.support.v7.app.AppCompatActivity
import android.view.View
2018-08-16 14:21:43 +00:00
import com.github.isabsent.filepicker.SimpleFilePickerDialog
2018-08-15 17:04:45 +00:00
import eu.depau.etchdroid.StateKeeper
2018-08-12 14:33:11 +00:00
2018-08-16 14:21:43 +00:00
abstract class WizardActivity : AppCompatActivity(), SimpleFilePickerDialog.InteractionListenerString {
override fun onResult(dialogTag: String, which: Int, extras: Bundle): Boolean {
if (StateKeeper.currentFragment is SimpleFilePickerDialog.InteractionListenerString)
return (StateKeeper.currentFragment as SimpleFilePickerDialog.InteractionListenerString).onResult(dialogTag, which, extras)
throw RuntimeException("Wrong fragment type")
}
override fun showListItemDialog(title: String?, folderPath: String?, mode: SimpleFilePickerDialog.CompositeMode?, dialogTag: String?) {
if (StateKeeper.currentFragment is SimpleFilePickerDialog.InteractionListenerString)
return (StateKeeper.currentFragment as SimpleFilePickerDialog.InteractionListenerString).showListItemDialog(title, folderPath, mode, dialogTag)
}
2018-08-12 14:33:11 +00:00
abstract fun goToNewFragment(fragment: WizardFragment)
open fun onCheckBoxClicked(view: View) {
StateKeeper.currentFragment?.onCheckBoxClicked(view)
}
open fun onButtonClicked(view: View) {
StateKeeper.currentFragment?.onButtonClicked(view)
}
open fun onRadioButtonClicked(view: View) {
StateKeeper.currentFragment?.onRadioButtonClicked(view)
}
open fun nextStep(view: View) {
StateKeeper.currentFragment?.nextStep(view)
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
StateKeeper.currentFragment?.onRequestPermissionsResult(requestCode, permissions, grantResults)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
StateKeeper.currentFragment?.onActivityResult(requestCode, resultCode, data)
}
}