Closed ronjunevaldoz closed 4 years ago
@ronjunelopez that's interesting. The same seems to not happen in the sample app. have you compared your code?
@ronjunelopez that's interesting. The same seems to not happen in the sample app. have you compared your code?
Unfortunately I can't find the problem in my code. I am using custom nav host fragment to fill my navigation items. It is working fine, the problem is the bug is intermittent.
Additional details
using this reference https://github.com/mikepenz/MaterialDrawer/blob/develop/app/src/main/java/com/mikepenz/materialdrawer/app/NavControllerActivity.kt
private fun initDrawer(savedInstanceState: Bundle?) {
val toolbar = findViewById<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar)
DrawerImageLoader.init(object : AbstractDrawerImageLoader() {
override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable) {
Glide
.with(this@MainActivity)
.load(uri)
.centerCrop()
.placeholder(placeholder)
.apply(RequestOptions.circleCropTransform())
.override(128, 128)
.into(imageView)
}
override fun cancel(imageView: ImageView) {
}
})
// Create the AccountHeader
accountHeader = AccountHeaderBuilder()
.withActivity(this)
.withOnAccountHeaderListener(object : AccountHeader.OnAccountHeaderListener {
override fun onProfileChanged(view: View?, profile: IProfile<*>, current: Boolean): Boolean {
return false
}
})
.build()
drawer = DrawerBuilder(this)
.withRootView(R.id.drawer_container)
.withAccountHeader(accountHeader)
.withToolbar(toolbar)
.withDisplayBelowStatusBar(false)
.withActionBarDrawerToggle(true)
.withActionBarDrawerToggleAnimated(true)
.withDrawerLayout(R.layout.material_drawer_fits_not)
.addDrawerItems(
NavigationDrawerItem(
R.id.home_fragment,
PrimaryDrawerItem()
.withName(R.string.drawer_item_home)
.withIcon(FontAwesome.Icon.faw_home)
),
DividerDrawerItem(),
NavigationDrawerItem(
R.id.privacy_settings_fragment,
PrimaryDrawerItem()
.withName(R.string.drawer_item_privacy_settings)
.withIcon(FontAwesome.Icon.faw_cog)
)
)
.withOnDrawerItemClickListener(object : Drawer.OnDrawerItemClickListener {
override fun onItemClick(view: View?, position: Int, drawerItem: IDrawerItem<*>): Boolean {
if (drawerItem.identifier == 21L) {
presenter.onToolbarOptionSignOutClick()
}
return false
}
})
.withSavedInstance(savedInstanceState)
.build()
navController = findNavController(R.id.nav_host_fragment)
drawer.setupWithNavController(navController)
}
Also I am using custom nav hot fragment
<fragment
android:id="@+id/nav_host_fragment"
android:name="com.ronscript.bountytips.ui.navigation.InjectingNavHostFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:defaultNavHost="true"
app:navGraph="@navigation/navigation_graph"/>`
Can you help me provide test details, I want to test drawer items. Im gonna use espresso
@Test fun testDrawer() { onView(withId(R.id.material_drawer_layout)).perform(DrawerActions.open()) onView(withText(R.string.drawer_item_privacy_settings)).perform(click()) }
This test is failing on drawer items
Getting same issue using NavController....drawer item selection & fragment backstack seems broken..need some workaround with issue.
Can you somehow reproduce the issue in the sample app?
Getting same issue using NavController....drawer item selection & fragment backstack seems broken..need some workaround with issue.
due to critical issue, It s better to use the basics from Navigation-UI.
we can not reproduce this in the sample app. please add more details or a full (runnable) sample app which showcases the problem
I m having the same issue with the highlight. When I click on any button other than the home, buttons are been highlighted and not cleared. On any button click, it should select the clicked one and cleared the others.
@kareemzok can you please try to reproduce this in the sample app? or adjust the sample app so it showcases your issue?
I've yet to see this problem :/
Hello @mikepenz ,
On the sample app it works fine but on my app not. Should we add something or its included already..
Please advise.
Well I need help to reproduce the problem to be able to investigate. I have not enough information to figure out what might be going on.
You can see the samples code here: https://github.com/mikepenz/MaterialDrawer/blob/develop/app/src/main/java/com/mikepenz/materialdrawer/app/NavControllerActivity.kt
perhaps you can find what you di dofferent, or adjust it to make it behave the same as in your app
In my app I have the item shown in the image above when I click on an item and go to new activity then go back to the home activity I open the drawer, I click on another item and then go back to the home activity I got 2 item clicked selected while the first selected one should be cleared.
As per your example, I m doing same for the java code, not kotlin but I don't have fragment, its activities
I was able to solve it, the issue was from my side as when I defined the item I added the identifier number for all which is 2. After I gave each item an identifier the selection work perfectly now.
Awesome :)
Screenshot
About this issue
Details
Code
DrawerNavigationUI.setupWithNavController(drawer, navController)