@@ -10,35 +10,32 @@ class SplashActivity : AppCompatActivity() {
10
10
companion object {
11
11
private const val TIME_FOR_SPLASH = 3000L
12
12
private const val VERSION = BuildConfig .VERSION_NAME
13
-
14
- /* private class SplashHandler(activity: SplashActivity): Handler(Looper.getMainLooper()) {
15
- private val weakReference: WeakReference<SplashActivity> = WeakReference(activity)
16
-
17
- override fun handleMessage(msg: Message) {
18
- //super.handleMessage(msg)
19
- val activity = weakReference.get()
20
- Intent(activity, MainActivity::class.java)
21
- activity?.splashBinding?.progress?.stop()
22
- }
23
- }*/
24
13
}
25
- private lateinit var splashBinding: ActivitySplashBinding
14
+
15
+ private var _splashBinding : ActivitySplashBinding ? = null
16
+ private val splashBinding get() = _splashBinding !!
26
17
27
18
override fun onCreate (savedInstanceState : Bundle ? ) {
28
19
super .onCreate(savedInstanceState)
29
- splashBinding = ActivitySplashBinding .inflate(layoutInflater)
20
+ _splashBinding = ActivitySplashBinding .inflate(layoutInflater)
30
21
setContentView(splashBinding.root)
31
22
32
- splashBinding.buildVersion.text = VERSION
23
+ val splashHandler = Handler (mainLooper)
33
24
34
- val handler = Handler (mainLooper)
25
+ splashBinding.buildVersion.text = VERSION
35
26
splashBinding.progress.start()
36
27
splashBinding.progress.loadingColor = R .color.colorAccent
37
- handler.postDelayed({
28
+
29
+ splashHandler.postDelayed({
30
+ splashBinding.progress.stop()
38
31
val intent = Intent (this @SplashActivity, MainActivity ::class .java)
39
32
startActivity(intent)
40
- splashBinding.progress.stop()
41
33
finish()
42
34
}, TIME_FOR_SPLASH )
43
35
}
36
+
37
+ override fun onDestroy () {
38
+ _splashBinding = null
39
+ super .onDestroy()
40
+ }
44
41
}
0 commit comments