Skip to content

Commit

Permalink
MainActivity: set option events earlier
Browse files Browse the repository at this point in the history
Should fix a potential crash
  • Loading branch information
kdrag0n committed Aug 22, 2018
1 parent aaf2341 commit 8a87d6d
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions app/src/main/java/com/kdrag0n/tipatch/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,6 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
opts.registerOnSharedPreferenceChangeListener(this)

optFrag = OptionFragment()
optFrag.retainInstance = true

fragmentManager
.beginTransaction()
.add(R.id.opt_container, optFrag)
.commit()

if (savedInstanceState == null) {
asyncExec {
try {
if (Shell.rootAccess()) {
hasRoot()
} else {
noRoot()
}
} catch (e: Exception) {
noRoot()
}
}
} else {
isRooted = savedInstanceState.getBoolean("rooted", false)
inputSource = ImageLocation.valueOf(savedInstanceState.getString("input", "FILE"))
outputDest = ImageLocation.valueOf(savedInstanceState.getString("output", "FILE"))
}

optFrag.inputEvent = {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
intent.addCategory(Intent.CATEGORY_OPENABLE)
Expand Down Expand Up @@ -117,6 +92,31 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
errorDialog(R.string.err_no_file_handler())
}
}

optFrag.retainInstance = true

fragmentManager
.beginTransaction()
.add(R.id.opt_container, optFrag)
.commit()

if (savedInstanceState == null) {
asyncExec {
try {
if (Shell.rootAccess()) {
hasRoot()
} else {
noRoot()
}
} catch (e: Exception) {
noRoot()
}
}
} else {
isRooted = savedInstanceState.getBoolean("rooted", false)
inputSource = ImageLocation.valueOf(savedInstanceState.getString("input", "FILE"))
outputDest = ImageLocation.valueOf(savedInstanceState.getString("output", "FILE"))
}

patch_dial.addActionItem(SpeedDialActionItem.Builder(R.id.fab_patch, R.drawable.ic_apply)
.setFabBackgroundColor(ContextCompat.getColor(this, R.color.btn_green))
Expand Down

0 comments on commit 8a87d6d

Please sign in to comment.