Search in sources :

Example 6 with MaterialAccount

use of it.neokree.materialnavigationdrawer.elements.MaterialAccount in project MaterialNavigationDrawer by neokree.

the class MaterialNavigationDrawer method onSaveInstanceState.

@Override
protected void onSaveInstanceState(Bundle outState) {
    int position = 0;
    int type = 0;
    Element e = findElementBySection(currentSection);
    switch(e.getType()) {
        default:
        case Element.TYPE_SECTION:
            position = sectionList.indexOf(currentSection);
            break;
        case Element.TYPE_BOTTOM_SECTION:
            position = bottomSectionList.indexOf(currentSection);
            break;
    }
    type = e.getType();
    outState.putInt(STATE_LIST, type);
    outState.putInt(STATE_SECTION, position);
    ArrayList<Integer> list = new ArrayList<>();
    for (MaterialAccount account : accountManager) list.add(account.getAccountNumber());
    outState.putIntegerArrayList(STATE_ACCOUNT, list);
    super.onSaveInstanceState(outState);
}
Also used : Element(it.neokree.materialnavigationdrawer.elements.Element) ArrayList(java.util.ArrayList) MaterialAccount(it.neokree.materialnavigationdrawer.elements.MaterialAccount) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 7 with MaterialAccount

use of it.neokree.materialnavigationdrawer.elements.MaterialAccount in project MaterialNavigationDrawer by neokree.

the class MaterialNavigationDrawer method removeAccount.

public void removeAccount(MaterialAccount account) {
    int size = accountManager.size();
    // si rimuovono le viste gia inserite che stanno per essere cambiate
    if (size <= 3 && size > 0) {
        this.setThirdAccountPhoto(null);
        this.setSecondAccountPhoto(null);
        this.setFirstAccountPhoto(null);
    }
    // si ricalcolano gli indici degli account
    for (int i = 0; i < size; i++) {
        MaterialAccount a = accountManager.get(i);
        if (a.getAccountNumber() > account.getAccountNumber()) {
            a.setAccountNumber(a.getAccountNumber() - 1);
        }
    }
    // si rimuove dalla lista degli account e si esegue il recycle sulle sue view
    accountManager.remove(account);
    account.recycle();
    if (account.getAccountNumber() == 0)
        currentAccount = findAccountNumber(0);
}
Also used : MaterialAccount(it.neokree.materialnavigationdrawer.elements.MaterialAccount) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 8 with MaterialAccount

use of it.neokree.materialnavigationdrawer.elements.MaterialAccount in project MaterialNavigationDrawer by neokree.

the class CustomAccountSection method init.

@Override
public void init(Bundle savedInstanceState) {
    // add accounts
    MaterialAccount account = new MaterialAccount(this.getResources(), "NeoKree", "neokree@gmail.com", R.drawable.photo, R.drawable.bamboo);
    this.addAccount(account);
    MaterialAccount account2 = new MaterialAccount(this.getResources(), "Hatsune Miky", "hatsune.miku@example.com", R.drawable.photo2, R.drawable.mat2);
    this.addAccount(account2);
    MaterialAccount account3 = new MaterialAccount(this.getResources(), "Example", "example@example.com", R.drawable.photo, R.drawable.mat3);
    this.addAccount(account3);
    // add account sections
    this.addAccountSection(newSection("Account settings", R.drawable.ic_settings_black_24dp, new MaterialSectionListener() {

        @Override
        public void onClick(MaterialSection section) {
            Toast.makeText(CustomAccountSection.this, "Account settings clicked", Toast.LENGTH_SHORT).show();
            // for default section is selected when you click on it
            // so deselect the section if you want
            section.unSelect();
        }
    }));
    // create sections
    this.addSection(newSection("Section 1", new FragmentIndex()));
    this.addSection(newSection("Section 2", new FragmentIndex()));
    this.addSection(newSection("Section 3", R.drawable.ic_mic_white_24dp, new FragmentButton()).setSectionColor(Color.parseColor("#9c27b0")));
    this.addSection(newSection("Section", R.drawable.ic_hotel_grey600_24dp, new FragmentButton()).setSectionColor(Color.parseColor("#03a9f4")));
    // create bottom section
    this.addBottomSection(newSection("Bottom Section", R.drawable.ic_settings_black_24dp, new Intent(this, Settings.class)));
}
Also used : FragmentButton(it.neokree.example.mockedFragments.FragmentButton) MaterialSection(it.neokree.materialnavigationdrawer.elements.MaterialSection) FragmentIndex(it.neokree.example.mockedFragments.FragmentIndex) Intent(android.content.Intent) MaterialAccount(it.neokree.materialnavigationdrawer.elements.MaterialAccount) MaterialSectionListener(it.neokree.materialnavigationdrawer.elements.listeners.MaterialSectionListener)

Example 9 with MaterialAccount

use of it.neokree.materialnavigationdrawer.elements.MaterialAccount in project MaterialNavigationDrawer by neokree.

the class MultiPane method init.

@Override
public void init(Bundle savedInstanceState) {
    // add accounts
    MaterialAccount account = new MaterialAccount(this.getResources(), "NeoKree", "neokree@gmail.com", R.drawable.photo, R.drawable.bamboo);
    this.addAccount(account);
    MaterialAccount account2 = new MaterialAccount(this.getResources(), "Hatsune Miky", "hatsune.miku@example.com", R.drawable.photo2, R.drawable.mat2);
    this.addAccount(account2);
    MaterialAccount account3 = new MaterialAccount(this.getResources(), "Example", "example@example.com", R.drawable.photo, R.drawable.mat3);
    this.addAccount(account3);
    // create sections
    this.addSection(newSection("Section 1", new FragmentIndex()));
    this.addSection(newSection("Section 2", new FragmentIndex()));
    this.addSection(newSection("Section 3", R.drawable.ic_mic_white_24dp, new FragmentButton()).setSectionColor(Color.parseColor("#9c27b0")));
    this.addSection(newSection("Section", R.drawable.ic_hotel_grey600_24dp, new FragmentButton()).setSectionColor(Color.parseColor("#03a9f4")));
    // create bottom section
    this.addBottomSection(newSection("Bottom Section", R.drawable.ic_settings_black_24dp, new Intent(this, Settings.class)));
}
Also used : FragmentButton(it.neokree.example.mockedFragments.FragmentButton) FragmentIndex(it.neokree.example.mockedFragments.FragmentIndex) Intent(android.content.Intent) MaterialAccount(it.neokree.materialnavigationdrawer.elements.MaterialAccount)

Aggregations

MaterialAccount (it.neokree.materialnavigationdrawer.elements.MaterialAccount)9 Intent (android.content.Intent)5 FragmentButton (it.neokree.example.mockedFragments.FragmentButton)5 FragmentIndex (it.neokree.example.mockedFragments.FragmentIndex)5 SuppressLint (android.annotation.SuppressLint)3 Point (android.graphics.Point)3 MaterialSection (it.neokree.materialnavigationdrawer.elements.MaterialSection)2 Resources (android.content.res.Resources)1 TypedArray (android.content.res.TypedArray)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 DrawerLayout (android.support.v4.widget.DrawerLayout)1 TypedValue (android.util.TypedValue)1 View (android.view.View)1 ViewTreeObserver (android.view.ViewTreeObserver)1 Window (android.view.Window)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 RelativeLayout (android.widget.RelativeLayout)1 TextView (android.widget.TextView)1 FragmentList (it.neokree.example.mockedFragments.FragmentList)1