Skip to content

Commit

Permalink
update ui on resume
Browse files Browse the repository at this point in the history
  • Loading branch information
eycorsican committed Feb 24, 2019
1 parent fbf4e94 commit f6ba086
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class MainActivity : AppCompatActivity() {
var running = false
private var starting = false
private var stopping = false
private lateinit var configString: String

// val mNotificationId = 1
// var mNotificationManager: NotificationManager? = null

Expand Down Expand Up @@ -81,6 +83,15 @@ class MainActivity : AppCompatActivity() {
}
}

private fun updateUI() {
configString = Preferences.getString(applicationContext, Constants.PREFERENCE_CONFIG_KEY, Constants.DEFAULT_CONFIG)
configString?.let {
formatJsonString(it).let {
configView.setText(it, TextView.BufferType.EDITABLE)
}
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Expand All @@ -100,12 +111,7 @@ class MainActivity : AppCompatActivity() {

sendBroadcast(Intent("ping"))

var configString = Preferences.getString(applicationContext, Constants.PREFERENCE_CONFIG_KEY, Constants.DEFAULT_CONFIG)
configString?.let {
formatJsonString(it).let {
configView.setText(it, TextView.BufferType.EDITABLE)
}
}
updateUI()

fab.setOnClickListener { view ->
if (!running && !starting) {
Expand Down Expand Up @@ -135,6 +141,7 @@ class MainActivity : AppCompatActivity() {

override fun onResume() {
super.onResume()
updateUI()
sendBroadcast(Intent("ping"))
}

Expand Down

0 comments on commit f6ba086

Please sign in to comment.