Created
April 24, 2020 09:11
-
-
Save alirezanazari/e7b731ba8f895034fe48292b55f4693b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.moviom.ui | |
import android.os.Bundle | |
import androidx.appcompat.app.AppCompatActivity | |
import com.moviom.R | |
import com.moviom.internal.Navigator | |
import com.moviom.internal.Theme | |
import com.moviom.ui.pages.main.MainFragment | |
import com.moviom.ui.pages.splash.SplashFragment | |
import org.koin.android.ext.android.inject | |
class MainActivity : AppCompatActivity() { | |
private val theme: Theme by inject() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
setupTheme() | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
loadSplashFragment() | |
} | |
private fun loadSplashFragment() { | |
Navigator.openSplashFragment(supportFragmentManager) | |
} | |
private fun setupTheme() { | |
this.setTheme(theme.getTheme()) | |
} | |
override fun onBackPressed() { | |
if(supportFragmentManager.backStackEntryCount == 1){ | |
val fragment = supportFragmentManager.findFragmentById(R.id.fragment_container) | |
if(fragment is MainFragment){ | |
if(fragment.isAllowToBackPressed()) finish() | |
return | |
}else { | |
finish() | |
return | |
} | |
} | |
super.onBackPressed() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment