Skip to content

Instantly share code, notes, and snippets.

@jetaggart
Created June 29, 2020 18:40
Show Gist options
  • Select an option

  • Save jetaggart/a89a34fea02aad37ccb47750ed449f27 to your computer and use it in GitHub Desktop.

Select an option

Save jetaggart/a89a34fea02aad37ccb47750ed449f27 to your computer and use it in GitHub Desktop.
// android/app/src/main/java/io/getstream/thestream/AuthedMainActivity.kt:8
class AuthedMainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_authed_main)
val navigation = findViewById<BottomNavigationView>(R.id.navigation)
navigation.setOnNavigationItemSelectedListener(navListener)
addFragment(PeopleFragment())
}
private fun addFragment(fragment: Fragment) {
supportFragmentManager
.beginTransaction()
.setCustomAnimations(
R.anim.design_bottom_sheet_slide_in,
R.anim.design_bottom_sheet_slide_out
)
.replace(R.id.content, fragment, fragment.javaClass.simpleName)
.commit()
}
private val navListener = BottomNavigationView.OnNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.navigation_people -> {
addFragment(PeopleFragment())
return@OnNavigationItemSelectedListener true
}
R.id.navigation_channels -> {
addFragment(ChannelsFragment())
return@OnNavigationItemSelectedListener true
}
}
false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment