dont show toolbar for splash screen
This commit is contained in:
parent
3ea33b460c
commit
2925cb459d
|
@ -5,12 +5,23 @@ import android.view.Menu
|
|||
import android.view.MenuItem
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import kotlinx.android.synthetic.main.activity_hash_tag_it.*
|
||||
|
||||
|
||||
class HashTagItActivity : AppCompatActivity() {
|
||||
|
||||
fun showToolbar(toggle: Boolean) {
|
||||
if (toggle) {
|
||||
supportActionBar?.hide()
|
||||
} else {
|
||||
supportActionBar?.show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_hash_tag_it)
|
||||
setSupportActionBar(toolbar)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import kotlinx.coroutines.*
|
||||
|
@ -20,6 +19,9 @@ class SplashFragment: Fragment() {
|
|||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
|
||||
(activity as? HashTagItActivity)?.showToolbar(true)
|
||||
|
||||
uiScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
delay(2000)
|
||||
|
@ -31,6 +33,8 @@ class SplashFragment: Fragment() {
|
|||
override fun onPause() {
|
||||
super.onPause()
|
||||
|
||||
(activity as? HashTagItActivity)?.showToolbar(false)
|
||||
|
||||
// make sure if user leaves screen to early before delay, we have killed the couroutine
|
||||
job.cancel()
|
||||
}
|
||||
|
|
|
@ -7,6 +7,15 @@
|
|||
android:id="@+id/activityContainer"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:elevation="4dp"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||
android:layout_width="match_parent"/>
|
||||
|
||||
<fragment
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
|
||||
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
|
|
Reference in New Issue