Android Open Source - NavigationDrawerSI Navigation Drawer Item View






From Project

Back to project page NavigationDrawerSI.

License

The source code is released under:

Apache License

If you think the Android project NavigationDrawerSI listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package mmbialas.pl.navigationdrawersi.ui.navigationdrawer;
//  w ww.  j  av a2 s .  c o  m

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import butterknife.ButterKnife;
import butterknife.InjectView;
import mmbialas.pl.navigationdrawersi.R;
import mmbialas.pl.navigationdrawersi.data.model.NavigationDrawerItem;

/**
 * Created by Michal Bialas on 19/07/14.
 */
public class NavigationDrawerItemView extends RelativeLayout {

    @InjectView(R.id.itemRR) RelativeLayout rr;

    @InjectView(R.id.navigationDrawerItemTitleTV)
    TextView itemTitleTV;

    @InjectView(R.id.navigationDrawerItemIconIV)
    ImageView itemIconIV;

    final Resources res;


    public NavigationDrawerItemView(Context context) {
        super(context);
        res = context.getResources();

    }

    public NavigationDrawerItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
        res = context.getResources();
    }

    public NavigationDrawerItemView(Context context, AttributeSet attrs,
            int defStyle) {
        super(context, attrs, defStyle);
        res = context.getResources();
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        ButterKnife.inject(this);
    }

    public void bindTo(NavigationDrawerItem item) {
        requestLayout();
        if (item.isMainItem()) {
            itemTitleTV.setText(item.getItemName());
            itemTitleTV.setTextSize(22);
            itemIconIV.setVisibility(View.GONE);
        } else {
            itemTitleTV.setText(item.getItemName());
            itemTitleTV.setTextSize(14);
            itemIconIV.setImageDrawable(getIcon(item.getItemIcon()));
            itemIconIV.setVisibility(View.VISIBLE);
            rr.setBackgroundColor(res.getColor(R.color.grey_background));
        }

        if(item.isSelected()) {
            itemTitleTV.setTypeface(null, Typeface.BOLD);
        } else {
            itemTitleTV.setTypeface(null, Typeface.NORMAL);
        }

    }

    private Drawable getIcon(int res) {
        return getContext().getResources().getDrawable(res);
    }
}




Java Source Code List

mmbialas.pl.navigationdrawersi.ApplicationTest.java
mmbialas.pl.navigationdrawersi.data.Fragments.java
mmbialas.pl.navigationdrawersi.data.model.NavigationDrawerItem.java
mmbialas.pl.navigationdrawersi.ui.MainActivity.java
mmbialas.pl.navigationdrawersi.ui.fragments.FragmentAbout.java
mmbialas.pl.navigationdrawersi.ui.fragments.FragmentOne.java
mmbialas.pl.navigationdrawersi.ui.fragments.FragmentThree.java
mmbialas.pl.navigationdrawersi.ui.fragments.FragmentTwo.java
mmbialas.pl.navigationdrawersi.ui.misc.BetterViewAnimator.java
mmbialas.pl.navigationdrawersi.ui.misc.BindableAdapter.java
mmbialas.pl.navigationdrawersi.ui.navigationdrawer.NavigationDrawerAdapter.java
mmbialas.pl.navigationdrawersi.ui.navigationdrawer.NavigationDrawerItemView.java
mmbialas.pl.navigationdrawersi.ui.navigationdrawer.NavigationDrawerView.java