/**
   * Sets up the height / position of the fab and tray
   *
   * <p>Returns true if it requires a relayout
   */
  protected void initializeLayout() {
    CalculatorPadLayout layout = (CalculatorPadLayout) findViewById(R.id.pad_advanced);
    int rows = layout.getRows();
    int columns = layout.getColumns();

    View parent = (View) mFab.getParent();
    mFab.setTranslationX((mFab.getWidth() - parent.getWidth() / columns) / 2);
    mFab.setTranslationY((mFab.getHeight() - parent.getHeight() / rows) / 2);
  }
 @Override
 public boolean onDependentViewChanged(
     CoordinatorLayout parent, FloatingActionButton fab, View dependency) {
   boolean returnValue = super.onDependentViewChanged(parent, fab, dependency);
   if (dependency instanceof AppBarLayout) {
     CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
     int fabBottomMargin = lp.bottomMargin;
     int distanceToScroll = fab.getHeight() + fabBottomMargin;
     float ratio = (float) dependency.getY() / (float) toolbarHeight;
     fab.setTranslationY(-distanceToScroll * ratio);
   }
   return returnValue;
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.wishlist_and_cart_activity_layout);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    appBarLayout = (AppBarLayout) findViewById(R.id.appbarlayout);
    viewPager = (ViewPager) findViewById(R.id.pager_shopandcart);
    pagerSlidingTabStrip = (PagerSlidingTabStrip) findViewById(R.id.tabstripcartwishlist);
    floatingActionButton = (FloatingActionButton) findViewById(R.id.fab_cart);
    coordinatorLayout = (CoordinatorLayout) findViewById(R.id.cordinatorwishlist);

    floatingActionButton.setOnClickListener(this);

    toolbar
        .getViewTreeObserver()
        .addOnGlobalLayoutListener(
            new OnGlobalLayoutListener() {

              @Override
              public void onGlobalLayout() {
                toolbarHeight = toolbar.getHeight();
              }
            });

    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle("");
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    toolbar.setBackgroundColor(getResources().getColor(R.color.PrimaryColor));

    adapter = new MyPagerAdapter(getSupportFragmentManager());
    viewPager.setAdapter(adapter);
    pagerSlidingTabStrip.setTextColor(getResources().getColor(R.color.bnc_white_transparency));
    pagerSlidingTabStrip.setViewPager(viewPager);

    try {
      if (getIntent().getExtras().getBoolean("wishlist")) {
        floatingActionButton.setTranslationY(
            getResources().getDimensionPixelSize(R.dimen.bnc_button_height));
        viewPager.setCurrentItem(1);
      }
    } catch (Exception e) {
    }

    pagerSlidingTabStrip.setOnPageChangeListener(this);
  }
 @Override
 public void onActivityCreated(@Nullable Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   mFabButton.setTranslationY(2 * getResources().getDimensionPixelOffset(R.dimen.btn_fab_size));
   doSearch(getString(R.string.default_search_keyword));
 }