mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
Add onStart function
Add the OnStart function (see lifecylce), which will be executed after `onCreate` and when the app is restarted (from inactivity)
This commit is contained in:
parent
73d01a8b46
commit
9f48a13d33
1 changed files with 14 additions and 6 deletions
|
@ -114,7 +114,6 @@ GestureDetector.OnDoubleTapListener {
|
|||
return true
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n") // I do not care
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
|
@ -126,8 +125,6 @@ GestureDetector.OnDoubleTapListener {
|
|||
if (!sharedPref.getBoolean("startedBefore", false))
|
||||
startActivity(Intent(this, FirstStartupActivity::class.java))
|
||||
|
||||
loadSettings(sharedPref)
|
||||
|
||||
// Flags
|
||||
window.setFlags(
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
|
@ -135,18 +132,29 @@ GestureDetector.OnDoubleTapListener {
|
|||
)
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
|
||||
setContentView(R.layout.activity_main)
|
||||
}
|
||||
|
||||
// After the app is created or when it restarts (inactivity) - Fixes Issue #9
|
||||
override fun onStart(){
|
||||
super.onStart()
|
||||
|
||||
// Preferences
|
||||
val sharedPref = this.getSharedPreferences(
|
||||
getString(R.string.preference_file_key), Context.MODE_PRIVATE)
|
||||
|
||||
loadSettings(sharedPref)
|
||||
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
|
||||
val timeFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault())
|
||||
|
||||
fixedRateTimer("timer", false, 0L, 1000) {
|
||||
this@MainActivity.runOnUiThread {
|
||||
dateView.text = dateFormat.format(Date())
|
||||
timeView.text = timeFormat.format(Date()) // not " GMT"
|
||||
timeView.text = timeFormat.format(Date())
|
||||
}
|
||||
}
|
||||
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
mDetector = GestureDetectorCompat(this, this)
|
||||
mDetector.setOnDoubleTapListener(this)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue