Exemplo n.º 1
0
 private void changeToolBarByDirection() {
   switch (mState) {
     case DIRECTION_DOWN:
       Log.e("changetoolbar", "down");
       mObjectAnimator =
           ObjectAnimator.ofFloat(
               mToolbar, "translationY", mToolbar.getTranslationY(), -mToolbar.getHeight());
       break;
     case DIRECTION_UP:
       Log.e("changetoolbar", "up");
       mObjectAnimator =
           ObjectAnimator.ofFloat(mToolbar, "translationY", mToolbar.getTranslationY(), 0);
       break;
   }
   mObjectAnimator.start();
 }
 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   if (AndroidUtils.isLollipop()) {
     outState.putFloat(STATE_TOOLBAR_ELEVATION, tToolbar.getElevation());
   }
   outState.putFloat(STATE_TOOLBAR_TRANSLATION_Y, tToolbar.getTranslationY());
   outState.putInt(STATE_VERTICAL_OFFSET, verticalOffset);
   outState.putInt(STATE_SCROLLING_OFFSET, scrollingOffset);
   outState.putParcelable(STATE_RECYCLER_VIEW, rvCities.getLayoutManager().onSaveInstanceState());
   super.onSaveInstanceState(outState);
 }
Exemplo n.º 3
0
 private boolean isToolbarShown() {
   return mToolbar != null && mToolbar.getTranslationY() >= 0;
 }