-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSplashActivity.kt
75 lines (54 loc) · 1.78 KB
/
SplashActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.demo.themoviedb.view.acitivty
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import com.demo.themoviedb.MainActivity
import com.demo.themoviedb.MyApp
import com.demo.themoviedb.R
import com.demo.themoviedb.presenter.SplashPresenter
import com.demo.themoviedb.utils.Coroutines
import com.demo.themoviedb.view.contract.SplashContract
import kotlinx.coroutines.delay
import ru.terrakok.cicerone.Navigator
import ru.terrakok.cicerone.commands.Command
import ru.terrakok.cicerone.commands.Forward
class SplashActivity : AppCompatActivity(),SplashContract.View {
private val navigator:Navigator by lazy { object :Navigator{
override fun applyCommand(command: Command?) {
if (command is Forward)
{
goToMainActivity()
}
}
private fun goToMainActivity() {
startActivity(Intent(this@SplashActivity,MainActivity::class.java))
}
} }
private var presenter : SplashContract.Presenter?=null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
presenter = SplashPresenter(this)
}
override fun onResume() {
super.onResume()
MyApp.INSTANCE.cicerone.navigatorHolder.setNavigator(navigator)
Coroutines.main {
delay(2000)
presenter?.onViewCreated()
}
}
override fun onPause() {
super.onPause()
MyApp.INSTANCE.cicerone.navigatorHolder.removeNavigator()
}
override fun finishView() {
finish()
}
override fun onDestroy() {
super.onDestroy()
presenter?.onDestroy()
presenter=null
}
}