Skip to content

Commit

Permalink
Handle malformed requests in TaskerActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
Mygod committed Dec 1, 2017
1 parent 0171261 commit 722ca5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,18 @@ 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]
toolbar.setTitle(R.string.app_name)
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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 722ca5b

Please sign in to comment.