Handle malformed requests in TaskerActivity
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user