private void initRecyclerView(Context context) {
    if (mRecyclerView == null) return;
    mRecyclerView.setBackgroundColor(mBackgroundColor);
    mRecyclerView.setHasFixedSize(true);
    mLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);

    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setAdapter(createAdapter());
    mRecyclerView.setNestedScrollingEnabled(isNestedScrollEnable());

    //        mRecyclerView.getItemAnimator().setSupportsChangeAnimations(true);
    RecyclerView.ItemAnimator animator = mRecyclerView.getItemAnimator();
    if (animator instanceof SimpleItemAnimator) {
      ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
    }
    onRecyclerViewInit(mRecyclerView);
  }
示例#2
0
 @Nullable
 @Override
 public View onCreateView(
     @NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   final View view;
   final LayoutManager layoutManager;
   if (mShowInNavigationDrawer) {
     view = inflater.inflate(R.layout.tab_drawer, container, false);
     layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
     setupFrameLayoutButton(view, R.id.tab_header_button, R.id.plusIcon);
     setupFrameLayoutButton(view, R.id.new_tab_button, R.id.icon_plus);
     setupFrameLayoutButton(view, R.id.action_back, R.id.icon_back);
     setupFrameLayoutButton(view, R.id.action_forward, R.id.icon_forward);
     setupFrameLayoutButton(view, R.id.action_home, R.id.icon_home);
   } else {
     view = inflater.inflate(R.layout.tab_strip, container, false);
     layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
     ImageView newTab = (ImageView) view.findViewById(R.id.new_tab_button);
     newTab.setColorFilter(ThemeUtils.getIconDarkThemeColor(getActivity()));
     newTab.setOnClickListener(
         new View.OnClickListener() {
           @Override
           public void onClick(View v) {
             mUiController.newTabButtonClicked();
           }
         });
   }
   mRecyclerView = (RecyclerView) view.findViewById(R.id.tabs_list);
   SimpleItemAnimator animator;
   if (mShowInNavigationDrawer) {
     animator = new VerticalItemAnimator();
   } else {
     animator = new HorizontalItemAnimator();
   }
   animator.setSupportsChangeAnimations(false);
   animator.setAddDuration(200);
   animator.setChangeDuration(0);
   animator.setRemoveDuration(200);
   animator.setMoveDuration(200);
   mRecyclerView.setLayerType(View.LAYER_TYPE_NONE, null);
   mRecyclerView.setItemAnimator(animator);
   mRecyclerView.setLayoutManager(layoutManager);
   mTabsAdapter = new LightningViewAdapter(mShowInNavigationDrawer);
   mRecyclerView.setAdapter(mTabsAdapter);
   mRecyclerView.setHasFixedSize(true);
   return view;
 }