2019-01-24 22:17:57 +00:00
|
|
|
package com.eleith.hashtagit
|
2019-01-22 00:28:05 +00:00
|
|
|
|
2019-01-22 17:56:58 +00:00
|
|
|
import android.os.Bundle
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.view.View
|
|
|
|
import android.view.ViewGroup
|
2019-01-22 00:28:05 +00:00
|
|
|
import androidx.fragment.app.Fragment
|
2019-01-22 17:56:58 +00:00
|
|
|
import androidx.navigation.fragment.findNavController
|
|
|
|
import kotlinx.coroutines.*
|
2019-01-22 00:28:05 +00:00
|
|
|
|
|
|
|
class SplashFragment: Fragment() {
|
|
|
|
|
2019-01-22 17:56:58 +00:00
|
|
|
private val job = Job()
|
|
|
|
private val uiScope = CoroutineScope(Dispatchers.Main + job)
|
|
|
|
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
|
|
return inflater.inflate(R.layout.fragment_splash, container, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onStart() {
|
|
|
|
super.onStart()
|
2019-01-25 17:37:00 +00:00
|
|
|
(activity as? HashTagItActivity)?.showToolbar(false)
|
2019-01-25 13:35:48 +00:00
|
|
|
|
2019-01-22 17:56:58 +00:00
|
|
|
uiScope.launch {
|
|
|
|
withContext(Dispatchers.IO) {
|
2019-01-24 22:17:57 +00:00
|
|
|
delay(2000)
|
2019-01-22 17:56:58 +00:00
|
|
|
findNavController().navigate(SplashFragmentDirections.actionSplashFragmentToInputFragment())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-25 17:37:00 +00:00
|
|
|
override fun onStop() {
|
|
|
|
super.onStop()
|
|
|
|
(activity as? HashTagItActivity)?.showToolbar(true)
|
|
|
|
}
|
|
|
|
|
2019-01-22 17:56:58 +00:00
|
|
|
override fun onPause() {
|
|
|
|
super.onPause()
|
|
|
|
|
|
|
|
// make sure if user leaves screen to early before delay, we have killed the couroutine
|
|
|
|
job.cancel()
|
|
|
|
}
|
2019-01-22 00:28:05 +00:00
|
|
|
}
|