mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 14:31:30 +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
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n") // I do not care
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
@ -126,8 +125,6 @@ GestureDetector.OnDoubleTapListener {
|
||||||
if (!sharedPref.getBoolean("startedBefore", false))
|
if (!sharedPref.getBoolean("startedBefore", false))
|
||||||
startActivity(Intent(this, FirstStartupActivity::class.java))
|
startActivity(Intent(this, FirstStartupActivity::class.java))
|
||||||
|
|
||||||
loadSettings(sharedPref)
|
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
window.setFlags(
|
window.setFlags(
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||||
|
@ -135,18 +132,29 @@ GestureDetector.OnDoubleTapListener {
|
||||||
)
|
)
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
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 dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
|
||||||
val timeFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault())
|
val timeFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault())
|
||||||
|
|
||||||
fixedRateTimer("timer", false, 0L, 1000) {
|
fixedRateTimer("timer", false, 0L, 1000) {
|
||||||
this@MainActivity.runOnUiThread {
|
this@MainActivity.runOnUiThread {
|
||||||
dateView.text = dateFormat.format(Date())
|
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 = GestureDetectorCompat(this, this)
|
||||||
mDetector.setOnDoubleTapListener(this)
|
mDetector.setOnDoubleTapListener(this)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue