2021-04-30 17:20:15 +00:00
|
|
|
package com.lagradost.cloudstream3
|
|
|
|
|
|
|
|
import android.os.Bundle
|
|
|
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
|
|
import androidx.navigation.findNavController
|
|
|
|
import androidx.navigation.ui.AppBarConfiguration
|
|
|
|
import androidx.navigation.ui.setupWithNavController
|
2021-05-20 21:25:41 +00:00
|
|
|
import com.lagradost.cloudstream3.UIHelper.checkWrite
|
|
|
|
import com.lagradost.cloudstream3.UIHelper.requestRW
|
2021-04-30 17:20:15 +00:00
|
|
|
|
|
|
|
class MainActivity : AppCompatActivity() {
|
2021-05-18 13:43:32 +00:00
|
|
|
private fun AppCompatActivity.backPressed(): Boolean {
|
|
|
|
val currentFragment = supportFragmentManager.fragments.last {
|
|
|
|
it.isVisible
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentFragment != null && supportFragmentManager.fragments.size > 2) {
|
|
|
|
//MainActivity.showNavbar()
|
|
|
|
supportFragmentManager.beginTransaction()
|
|
|
|
.setCustomAnimations(R.anim.enter_anim, R.anim.exit_anim, R.anim.pop_enter, R.anim.pop_exit)
|
|
|
|
.remove(currentFragment)
|
|
|
|
.commitAllowingStateLoss()
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onBackPressed() {
|
|
|
|
if (backPressed()) return
|
|
|
|
super.onBackPressed()
|
|
|
|
}
|
2021-04-30 17:20:15 +00:00
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
setContentView(R.layout.activity_main)
|
|
|
|
val navView: BottomNavigationView = findViewById(R.id.nav_view)
|
|
|
|
|
|
|
|
val navController = findNavController(R.id.nav_host_fragment)
|
|
|
|
// Passing each menu ID as a set of Ids because each
|
|
|
|
// menu should be considered as top level destinations.
|
|
|
|
val appBarConfiguration = AppBarConfiguration(setOf(
|
2021-05-12 21:51:02 +00:00
|
|
|
R.id.navigation_home, R.id.navigation_search, R.id.navigation_notifications))
|
2021-04-30 17:20:15 +00:00
|
|
|
//setupActionBarWithNavController(navController, appBarConfiguration)
|
|
|
|
navView.setupWithNavController(navController)
|
2021-05-20 21:25:41 +00:00
|
|
|
|
|
|
|
if (!checkWrite()) {
|
|
|
|
requestRW()
|
|
|
|
if (checkWrite()) return
|
|
|
|
}
|
2021-04-30 17:20:15 +00:00
|
|
|
}
|
|
|
|
}
|