@Override
  public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY;
    setFillViewport(lockedExpanded);

    final int childCount = mTabLayout.getChildCount();
    if (childCount > 1 && (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST)) {
      if (childCount > 2) {
        //                mMaxTabWidth = (int)(MeasureSpec.getSize(widthMeasureSpec) * 0.4f);
      } else {
        mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec) / 2;
      }
    } else {
      mMaxTabWidth = -1;
    }

    final int oldWidth = getMeasuredWidth();
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    final int newWidth = getMeasuredWidth();

    if (lockedExpanded && oldWidth != newWidth) {
      // Recenter the tab display if we're at a new (scrollable) size.
      setCurrentItem(mSelectedTabIndex);
    }
  }
 @Override
 public void onPageSelected(int arg0) {
   setCurrentItem(arg0);
   if (mListener != null) {
     mListener.onPageSelected(arg0);
   }
 }
 public void notifyDataSetChanged() {
   mTabLayout.removeAllViews();
   PagerAdapter adapter = mViewPager.getAdapter();
   IconPagerAdapter iconAdapter = null;
   if (adapter instanceof IconPagerAdapter) {
     iconAdapter = (IconPagerAdapter) adapter;
   }
   final int count = adapter.getCount();
   for (int i = 0; i < count; i++) {
     CharSequence title = adapter.getPageTitle(i);
     if (title == null) {
       title = EMPTY_TITLE;
     }
     int iconResId = 0;
     if (iconAdapter != null) {
       iconResId = iconAdapter.getIconResId(i);
     }
     addTab(i, title, iconResId);
   }
   if (mSelectedTabIndex > count) {
     mSelectedTabIndex = count - 1;
   }
   setCurrentItem(mSelectedTabIndex);
   requestLayout();
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    if (DEBUG) {
      MinicRPCLog.d(TAG, "onCreateView");
    }

    View view = View.inflate(getActivity(), R.layout.fragment_smsbless, null);
    ButterKnife.inject(this, view);

    // init fragments
    mFragments[0] = new FA();
    mFragments[1] = new FB();
    mFragments[2] = new FC();
    mFragments[3] = new FD();

    // init
    mTitle = getActivity().getResources().getStringArray(R.array.sms_bless);

    if (DEBUG) {
      MinicRPCLog.d(TAG, "%s, %s, %s, %s", mTitle);
    }

    mAdapter = new MyAdapter(getChildFragmentManager());
    mPager.setAdapter(mAdapter);
    mIndicator.setViewPager(mPager);
    mIndicator.setCurrentItem(0);
    return view;
  }
 @Override
 public void setViewPager(ViewPager view, int initialPosition) {
   setViewPager(view);
   setCurrentItem(initialPosition);
 }