Advertisement

自定义底部导航栏控件NavigationButton

阅读量:

首先为什么要自定义一个

1.体现了模块性

2.NavigationButton内部维护一个碎片实例,并保证了碎片的单例性

  1. NavigationButton是一个封装式组件,并不受参数影响,在遵循了开闭原则的基础上具备了强可重用性

内部模块支持执行多种操作,并且允许在特定情况下阻止用户进行底部点击的交互

5.直接利用NavigationButton初始化了碎片的add

NavigationButton

复制代码
    public class extends private mFragment null;
    private mClx;
    private mIconView;
    private mTitleView;
    private mTag;
    
    public NavigationButtonsuper;
        ;
    public NavigationButton, super, ;
        ;
    public NavigationButton, , int super, , ;
        ;
    @RequiresApiapi _LOLLIPOP_ public NavigationButton, , int , int super, , , ;
        ;
    private void initfrom;
        _nav_item_ , this, true;
    
        mIconView _nav_icon_ ;
        mTitleView _nav_title_ ;
    public void setSelectedboolean super;
        mIconView;
        mTitleView;
    public void init@DrawableRes int , @StringRes int , mIconView;
        mTitleView;
        mClx ;
        mTag mClx;
    public getClxreturn mClx;
    public getFragmentreturn mFragment;
    public void setFragmentthismFragment ;
    public getTagreturn mTag;

NavFragment

复制代码
    public class extends implements @BindView _nav_course_ mNavBook;
    @BindView _nav_tweet_ mNavFind;
    @BindView _nav_me_ mNavMe;
    
    private mContext;
    private int mContainerId;
    private mFragmentManager;
    private mCurrentNavButton;
    //    private OnNavigationReselectListener mOnNavigationReselectListener;
    
    public NavFragment// Required empty public constructor
    @Override
    protected int getLayoutIdreturn _fragment_nav_ ;
    @SuppressWarnings"deprecation"@Override
    protected void initWidgetsuper;
    
        mNavBook _ic_launcher_round_ ,
                _tab_course_ ,
                class;
    
        mNavFind _ic_launcher_round_ ,
                _tab_tweet_ ,
                class;
    
        mNavMe _ic_launcher_round_ ,
                _tab_me_ ,
                class;
    
        // do select first
        mNavBook;
    @OnClick _nav_course_ , _nav_tweet_ , _nav_me_ @Override
    public void onClickif instanceof ;
            ;
        public void setup, , int mContext ;
        mFragmentManager ;
        mContainerId ;
    //        mOnNavigationReselectListener = listener;
    
        // do clear
        ;
    //    public void select(int index) {
    //        if (mNavMe != null)
    //            doSelect(mNavMe);
    //    }
    
    @SuppressWarnings"RestrictedApi"private void clearOldFragmentmFragmentManager;
        mFragmentManager;
        if null null 0return;
        boolean false;
        for if this null;
                true;
            if ;
    private void doSelect// If the new navigation is me info fragment, we intercept it
        /*
        if (newNavButton == mNavMe) {
            if (interceptMessageSkip())
                return;
        }
        */
    
        null;
        if mCurrentNavButton nullmCurrentNavButton;
            if //                onReselect(oldNavButton);
                return;
            false;
        //newNavButton.setSelected(true);
        , ;
        mCurrentNavButton ;
    private void doTabChanged, mFragmentManager;
        if nullif null;
            if nullif nullinstantiatemContext,
                        , null;
                mContainerId, , ;
                ;
            else ;
            ;
    //    private void onReselect(NavigationButton navigationButton) {
    //        OnNavigationReselectListener listener = mOnNavigationReselectListener;
    //        if (listener != null) {
    //            listener.onReselect(navigationButton);
    //        }
    //    }
    //
    //    public interface OnNavigationReselectListener {
    //        void onReselect(NavigationButton navigationButton);
    //    }

全部评论 (0)

还没有任何评论哟~