com.flyco.tablayout.listener.CustomTabEntity Java Examples

The following examples show how to use com.flyco.tablayout.listener.CustomTabEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommonTabLayout.java    From likequanmintv with Apache License 2.0 5 votes vote down vote up
public void setTabData(ArrayList<CustomTabEntity> tabEntitys) {
    if (tabEntitys == null || tabEntitys.size() == 0) {
        throw new IllegalStateException("TabEntitys can not be NULL or EMPTY !");
    }

    this.mTabEntitys.clear();
    this.mTabEntitys.addAll(tabEntitys);

    notifyDataSetChanged();
}
 
Example #2
Source File: CommonTabLayout.java    From likequanmintv with Apache License 2.0 5 votes vote down vote up
private void updateTabSelection(int position) {
    for (int i = 0; i < mTabCount; ++i) {
        View tabView = mTabsContainer.getChildAt(i);
        final boolean isSelect = i == position;
        TextView tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
        tab_title.setTextColor(isSelect ? mTextSelectColor : mTextUnselectColor);
        ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
        CustomTabEntity tabEntity = mTabEntitys.get(i);
        iv_tab_icon.setImageResource(isSelect ? tabEntity.getTabSelectedIcon() : tabEntity.getTabUnselectedIcon());
        if (mTextBold == TEXT_BOLD_WHEN_SELECT) {
            tab_title.getPaint().setFakeBoldText(isSelect);
        }
    }
}
 
Example #3
Source File: CommonTabLayout.java    From FlycoTabLayout with MIT License 5 votes vote down vote up
public void setTabData(ArrayList<CustomTabEntity> tabEntitys) {
    if (tabEntitys == null || tabEntitys.size() == 0) {
        throw new IllegalStateException("TabEntitys can not be NULL or EMPTY !");
    }

    this.mTabEntitys.clear();
    this.mTabEntitys.addAll(tabEntitys);

    notifyDataSetChanged();
}
 
Example #4
Source File: CommonTabLayout.java    From FlycoTabLayout with MIT License 5 votes vote down vote up
private void updateTabSelection(int position) {
    for (int i = 0; i < mTabCount; ++i) {
        View tabView = mTabsContainer.getChildAt(i);
        final boolean isSelect = i == position;
        TextView tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
        tab_title.setTextColor(isSelect ? mTextSelectColor : mTextUnselectColor);
        ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
        CustomTabEntity tabEntity = mTabEntitys.get(i);
        iv_tab_icon.setImageResource(isSelect ? tabEntity.getTabSelectedIcon() : tabEntity.getTabUnselectedIcon());
        if (mTextBold == TEXT_BOLD_WHEN_SELECT) {
            tab_title.getPaint().setFakeBoldText(isSelect);
        }
    }
}
 
Example #5
Source File: CommonTabLayout.java    From likequanmintv with Apache License 2.0 4 votes vote down vote up
/** 关联数据支持同时切换fragments */
public void setTabData(ArrayList<CustomTabEntity> tabEntitys, FragmentActivity fa, int containerViewId, ArrayList<Fragment> fragments) {
    mFragmentChangeManager = new FragmentChangeManager(fa.getSupportFragmentManager(), containerViewId, fragments);
    setTabData(tabEntitys);
}
 
Example #6
Source File: CommonTabLayout.java    From likequanmintv with Apache License 2.0 4 votes vote down vote up
private void updateTabStyles() {
        for (int i = 0; i < mTabCount; i++) {
            View tabView = mTabsContainer.getChildAt(i);
            tabView.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
            TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
            tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnselectColor);
            tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
//            tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
            if (mTextAllCaps) {
                tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
            }

            if (mTextBold == TEXT_BOLD_BOTH) {
                tv_tab_title.getPaint().setFakeBoldText(true);
            } else if (mTextBold == TEXT_BOLD_NONE) {
                tv_tab_title.getPaint().setFakeBoldText(false);
            }

            ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
            if (mIconVisible) {
                iv_tab_icon.setVisibility(View.VISIBLE);
                CustomTabEntity tabEntity = mTabEntitys.get(i);
                iv_tab_icon.setImageResource(i == mCurrentTab ? tabEntity.getTabSelectedIcon() : tabEntity.getTabUnselectedIcon());
                LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                        mIconWidth <= 0 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) mIconWidth,
                        mIconHeight <= 0 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) mIconHeight);
                if (mIconGravity == Gravity.LEFT) {
                    lp.rightMargin = (int) mIconMargin;
                } else if (mIconGravity == Gravity.RIGHT) {
                    lp.leftMargin = (int) mIconMargin;
                } else if (mIconGravity == Gravity.BOTTOM) {
                    lp.topMargin = (int) mIconMargin;
                } else {
                    lp.bottomMargin = (int) mIconMargin;
                }

                iv_tab_icon.setLayoutParams(lp);
            } else {
                iv_tab_icon.setVisibility(View.GONE);
            }
        }
    }
 
Example #7
Source File: CommonTabLayout.java    From FlycoTabLayout with MIT License 4 votes vote down vote up
/** 关联数据支持同时切换fragments */
public void setTabData(ArrayList<CustomTabEntity> tabEntitys, FragmentActivity fa, int containerViewId, ArrayList<Fragment> fragments) {
    mFragmentChangeManager = new FragmentChangeManager(fa.getSupportFragmentManager(), containerViewId, fragments);
    setTabData(tabEntitys);
}
 
Example #8
Source File: CommonTabLayout.java    From FlycoTabLayout with MIT License 4 votes vote down vote up
private void updateTabStyles() {
        for (int i = 0; i < mTabCount; i++) {
            View tabView = mTabsContainer.getChildAt(i);
            tabView.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
            TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
            tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnselectColor);
            tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
//            tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
            if (mTextAllCaps) {
                tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
            }

            if (mTextBold == TEXT_BOLD_BOTH) {
                tv_tab_title.getPaint().setFakeBoldText(true);
            } else if (mTextBold == TEXT_BOLD_NONE) {
                tv_tab_title.getPaint().setFakeBoldText(false);
            }

            ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
            if (mIconVisible) {
                iv_tab_icon.setVisibility(View.VISIBLE);
                CustomTabEntity tabEntity = mTabEntitys.get(i);
                iv_tab_icon.setImageResource(i == mCurrentTab ? tabEntity.getTabSelectedIcon() : tabEntity.getTabUnselectedIcon());
                LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                        mIconWidth <= 0 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) mIconWidth,
                        mIconHeight <= 0 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) mIconHeight);
                if (mIconGravity == Gravity.LEFT) {
                    lp.rightMargin = (int) mIconMargin;
                } else if (mIconGravity == Gravity.RIGHT) {
                    lp.leftMargin = (int) mIconMargin;
                } else if (mIconGravity == Gravity.BOTTOM) {
                    lp.topMargin = (int) mIconMargin;
                } else {
                    lp.bottomMargin = (int) mIconMargin;
                }

                iv_tab_icon.setLayoutParams(lp);
            } else {
                iv_tab_icon.setVisibility(View.GONE);
            }
        }
    }