Handle malformed requests in TaskerActivity

This commit is contained in:
Mygod
2017-11-30 21:27:14 -08:00
parent 0171261465
commit 722ca5b4f4
2 changed files with 6 additions and 3 deletions
@@ -82,6 +82,11 @@ class TaskerActivity extends AppCompatActivity {
override def onCreate(savedInstanceState: Bundle) {
super.onCreate(savedInstanceState)
try taskerOption = TaskerSettings.fromIntent(getIntent) catch {
case _: Exception =>
finish()
return
}
setContentView(R.layout.layout_tasker)
val toolbar = findViewById(R.id.toolbar).asInstanceOf[Toolbar]
@@ -89,7 +94,6 @@ class TaskerActivity extends AppCompatActivity {
toolbar.setNavigationIcon(R.drawable.ic_navigation_close)
toolbar.setNavigationOnClickListener(_ => finish())
taskerOption = TaskerSettings.fromIntent(getIntent)
switch = findViewById(R.id.serviceSwitch).asInstanceOf[Switch]
switch.setChecked(taskerOption.switchOn)
val profilesList = findViewById(R.id.list).asInstanceOf[RecyclerView]
@@ -30,8 +30,7 @@ object TaskerSettings {
private val KEY_SWITCH_ON = "switch_on"
private val KEY_PROFILE_ID = "profile_id"
def fromIntent(intent: Intent) = new TaskerSettings(if (intent.hasExtra(ApiIntent.EXTRA_BUNDLE))
intent.getBundleExtra(ApiIntent.EXTRA_BUNDLE) else Bundle.EMPTY)
def fromIntent(intent: Intent) = new TaskerSettings(intent.getBundleExtra(ApiIntent.EXTRA_BUNDLE))
}
class TaskerSettings(bundle: Bundle) {