-
Notifications
You must be signed in to change notification settings - Fork 433
Home
this is a simple wiki that show you all library functionality
A section is a simple element of your navigation drawer list. There are two type of section at this time:
- Text Section
- Text and Icon Section
Every section could have a notifications number.
There are two different lists where you can add your section:
- Top list (default list)
- Bottom List
It is a list used exclusively for About, Settings or other things like this.
// only text section, it opens an activity
public MaterialSection newSection(String title,Intent target)
// only text section, it opens a fragment
public MaterialSection newSection(String title,Fragment target)
// only text section, it calls target.onClick() method when section is clicked
public MaterialSection newSection(String title,MaterialSectionListener target)
// icon bitmap and text section, it opens an activity
public MaterialSection newSection(String title, Bitmap icon,Intent target)
// icon bitmap and text section, it opens a fragment
public MaterialSection newSection(String title, Bitmap icon,Fragment target)
// icon bitmap and text section, it calls target.onClick() method when section is clicked
public MaterialSection newSection(String title, Bitmap icon,MaterialSectionListener target)
// icon drawable and text section, it opens an activity
public MaterialSection newSection(String title, Drawable icon, Intent target)
// icon drawable and text section, it opens a fragment
public MaterialSection newSection(String title, Drawable icon, Fragment target)
// icon drawable and text section, it calls target.onClick() method when section is clicked
public MaterialSection newSection(String title, Drawable icon, MaterialSectionListener target)
// add section to the top list
public void addSection(MaterialSection section)
// add section to the bottom list
public void addBottomSection(MaterialSection section)
NOTE that the first section you added is opened when the activity starts, so it must have a Fragment as target.
When a section that has a color is opened, the toolbar background color is setted to this value, and the status bar color is setted with the value of colorDark.
If a section with color is clicked the text color (into the drawer) is colored with his color. If the section has an icon, the icon have the color of the section.
mySection.setSectionColor(color,colorDark);
int number = 4;
mySection.setNotifications(number);
int notifications = mySection.getNotifications();
@Override
public void init(Bundle savedInstanceState) {
this.addSubheader("Subheader title");
}
A separator (or divisor) is a simple grey line used for diversify group of sections.
@Override
public void init(Bundle savedInstanceState) {
this.addDivisor();
}
A collection of user data.
This library not implements an Android Account, it allows only to set user data in your navigation drawer.
NB At this time you can add accounts until a max number of 3 accounts.
public MaterialAccount(String title, String subTitle, Drawable photo,Bitmap background)
public MaterialAccount(String title, String subTitle, Drawable photo,Drawable background)
public MaterialAccount(String title, String subTitle, Bitmap photo, Drawable background)
public MaterialAccount(String title, String subTitle, Bitmap photo, Bitmap background)
MaterialAccount account;
this.addAccount(account);
implements MaterialAccountListener
in your MaterialNavigationDrawer
and then connect your listener to the navigation drawer
// set listener
this.setAccountListener(this);
From your Activity:
// get toolbar
this.getToolbar();
// get Action Bar
this.getSupportActionBar();
From your Fragment:
// get toolbar
((MaterialNavigationDrawer)this.getActivity()).getToolbar();
// get action bar
this.getActivity().getSupportActionBar();
From your Activity:
this.getCurrentSection();
From your Fragment:
((MaterialNavigationDrawer)this.getActivity()).getCurrentSection();
When your image is loaded from the web, in your async Thread change your account information like this:
// set photo
account.setPhoto(photo);
// set background
account.setBackground(background);
And then call the notifyAccountDataChanged
method on ui thread:
runOnUiThread(new Runnable() {
@Override
public void run() {
notifyAccountDataChanged();
}
});
From your Activity:
this.getCurrentAccount();
From your Fragment:
((MaterialNavigationDrawer)this.getActivity()).getCurrentAccount();
From your Activity:
int position;
this.getAccountAtCurrentPosition(position);
From your Fragment:
((MaterialNavigationDrawer)this.getActivity()).getAccountAtCurrentPosition(position);
Yes, of course.
multi pane support makes the drawer always open on the left, but only with tablet in landscape mode.
for activate it, add this method to your init()
addMultiPaneSupport();
for default, it is disabled.
If you want to re-enable it add this to your init()
method:
allowArrowAnimation();
Well, if you want to follow exactly the material design guidelines you have not to do it. If you want to mock this functionality, on your extended Fragment class insert this code:
@Override
public void onResume() {
super.onResume();
((MaterialNavigationDrawer)this.getActivity()).changeToolbarColor(primaryColor,primaryColorDark);
}
You can simple use this method instead adding Accounts:
this.replaceDrawerHeader(header);
where header is the bitmap or drawable used for the header of your drawer.