Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not update item name in a drawer. #2208

Closed
parmarravi opened this issue Feb 7, 2018 · 17 comments
Closed

Can not update item name in a drawer. #2208

parmarravi opened this issue Feb 7, 2018 · 17 comments
Assignees
Labels

Comments

@parmarravi
Copy link

Hello Mike,
Thank you for such a great library, i am having some issue when trying to update the name of an item in a drawer .this is what i am using
deviceAdd.updateName(Currentpos, new StringHolder("Name"));
It seems this code is not working .Is there any solution?

@mikepenz
Copy link
Owner

mikepenz commented Feb 7, 2018

@parmarravi which version of the library?

Currentpos is an identifier? (the name suggest otherwise)

Your items need to have an identifier, and you can use this identifier then to update. As the javadoc already shows:
https://github.com/mikepenz/MaterialDrawer/blob/develop/library/src/main/java/com/mikepenz/materialdrawer/Drawer.java#L681

@mikepenz mikepenz self-assigned this Feb 7, 2018
@parmarravi
Copy link
Author

what will be the identifier ? i am storing position of an item in Currentpos.

 deviceAdd.setOnDrawerItemLongClickListener(new Drawer.OnDrawerItemLongClickListener() {
            @Override
            public boolean onItemLongClick(View view, int position, IDrawerItem drawerItem) {
                String tx = ((Nameable)drawerItem).getName().toString();
                String ipd= db.HomeLightDao().getDeviceFromName(tx).getDevip();
                Currentpos = position;
                System.out.println("LongPos:"+position);

                AddNewNavigation_items addNewNavigation_items = new AddNewNavigation_items(getApplicationContext(),ipd);
                addNewNavigation_items.show(getFragmentManager(),"edit name");
                return false;
            }
        });
}

@mikepenz
Copy link
Owner

mikepenz commented Feb 7, 2018

As shown in the README you can define whatever identifier you want: https://github.com/mikepenz/MaterialDrawer#add-items-and-adding-some-functionality

If not, a identifier is automatically given to the item (after it was added to the drawer)
You can get the identifier by drawerItem.getIdentifier()

@parmarravi
Copy link
Author

Is there any code to refresh the layout ? Item name is still not getting updated.

@mikepenz
Copy link
Owner

mikepenz commented Feb 7, 2018

You used the identifier (after the item was added to the drawer) (can you check that the identifier is != 0)
and then you called the update method on the UI thread?
Which version of the drawer do you use?

@parmarravi
Copy link
Author

Identifier is -12 .I am using latest version of drawer and updating method on ui thread.
Right now i used the previous code and passed the identifier instead of the position.
Currentpos = drawerItem.getIdentifier();

@mikepenz
Copy link
Owner

mikepenz commented Feb 7, 2018

So you use 6.0.5?

@parmarravi
Copy link
Author

Yes

@mikepenz
Copy link
Owner

mikepenz commented Feb 7, 2018

Ok let me have a closer look. I'll let you know.

@mikepenz
Copy link
Owner

mikepenz commented Feb 7, 2018

Ok I was able to identify a regression in the notify here: https://github.com/mikepenz/FastAdapter/blob/develop/library-core/src/main/java/com/mikepenz/fastadapter/utils/DefaultItemListImpl.java#L94

Will create an update ASAP and inform you when it's ready

@parmarravi
Copy link
Author

Thank you mike .

@mikepenz
Copy link
Owner

mikepenz commented Feb 7, 2018

Fixed in FastAdapter. will update the MaterialDrawer too soon

@parmarravi
Copy link
Author

With the help of this Mike , (Nameable) drawerItem) .getName().getText(MainActivity.this) I am able to get log and toast message now. only thing is, it's not getting updated to UI.

@mikepenz
Copy link
Owner

mikepenz commented Feb 7, 2018

don't do that :D

I released a new FastAdapter version here: mikepenz/FastAdapter@1ecad22

and will update the drawer soon. Maven Central only needs a bit to sync releases

@mikepenz
Copy link
Owner

mikepenz commented Feb 7, 2018

New release done: https://github.com/mikepenz/MaterialDrawer/releases/tag/v6.0.6

It will take ~30 minutes until maven has synced and you can use it

@parmarravi
Copy link
Author

Its Working Mike thank you for the update .

@simonlaalo
Copy link

Thanks so much for this fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants