Java Code Examples for com.google.android.material.appbar.AppBarLayout#LayoutParams

The following examples show how to use com.google.android.material.appbar.AppBarLayout#LayoutParams . 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: DesignModuleAttributeHelper.java    From proteus with Apache License 2.0 6 votes vote down vote up
static void setLayoutScrollFlags(View v, String scrollFlags) {
  AppBarLayout.LayoutParams layoutParams = getLayoutParams(v);
  if (null != layoutParams && !TextUtils.isEmpty(scrollFlags)) {
    String[] listFlags = scrollFlags.split("\\|");
    int scrollFlag = 0;
    for (String flag : listFlags) {
      Integer flags = sScrollFlagMap.get(flag.trim());
      if (null != flags) {
        scrollFlag |= flags;
      }
    }

    if (scrollFlag != 0) {
      layoutParams.setScrollFlags(scrollFlag);
    }
  }
}
 
Example 2
Source File: UserProfileFragment.java    From edx-app-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onChildScrollingPreferenceChanged() {
    final int position = viewHolder.profileSectionTabs.getSelectedTabPosition();
    @AppBarLayout.LayoutParams.ScrollFlags
    final int scrollFlags;
    final Fragment fragment = (((StaticFragmentPagerAdapter) viewHolder.profileSectionPager.getAdapter()).getFragment(position));
    if (fragment != null) {
        if (position >= 0 &&
                ((ScrollingPreferenceChild) fragment).prefersScrollingHeader()) {
            scrollFlags = AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL;
        } else {
            scrollFlags = 0;
        }
        final AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) viewHolder.profileHeader.getLayoutParams();
        params.setScrollFlags(scrollFlags);
        viewHolder.profileHeader.setLayoutParams(params);
    }
}
 
Example 3
Source File: MainActivity.java    From MyBookshelf with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void bindView() {
    super.bindView();
    setSupportActionBar(toolbar);
    setupActionBar();
    cardSearch.setCardBackgroundColor(ThemeStore.primaryColorDark(this));
    initDrawer();
    initTabLayout();
    upGroup(group);
    moDialogHUD = new MoDialogHUD(this);
    if (!preferences.getBoolean("behaviorMain", true)) {
        AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
        params.setScrollFlags(0);
    }
    //点击跳转搜索页
    cardSearch.setOnClickListener(view -> startActivityByAnim(new Intent(this, SearchBookActivity.class),
            toolbar, "sharedView", android.R.anim.fade_in, android.R.anim.fade_out));
}
 
Example 4
Source File: OdysseyMainActivity.java    From odyssey with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setupToolbarImage(Bitmap bm) {
    ImageView collapsingImage = findViewById(R.id.collapsing_image);
    if (collapsingImage != null) {
        collapsingImage.setImageBitmap(bm);

        // FIXME DIRTY HACK: Manually fix the toolbar size to the screen width
        CollapsingToolbarLayout toolbar = findViewById(R.id.collapsing_toolbar);
        AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();

        params.height = getWindow().getDecorView().getMeasuredWidth();

        // Always expand the toolbar to show the complete image
        AppBarLayout appbar = findViewById(R.id.appbar);
        appbar.setExpanded(true, false);
    }
}
 
Example 5
Source File: MainActivity.java    From revolution-irc with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    StyledAttributesHelper ta = StyledAttributesHelper.obtainStyledAttributes(this,
            new int[] { R.attr.actionBarSize });
    ViewGroup.LayoutParams params = mFakeToolbar.getLayoutParams();
    params.height = ta.getDimensionPixelSize(R.attr.actionBarSize, 0);
    mFakeToolbar.setLayoutParams(params);
    ta.recycle();
    if (mToolbar != null) {
        ViewGroup group = (ViewGroup) mToolbar.getParent();
        int i = group.indexOfChild(mToolbar);
        group.removeViewAt(i);
        Toolbar replacement = new Toolbar(group.getContext());
        replacement.setPopupTheme(mToolbar.getPopupTheme());
        AppBarLayout.LayoutParams toolbarParams = new AppBarLayout.LayoutParams(
                AppBarLayout.LayoutParams.MATCH_PARENT, params.height);
        replacement.setLayoutParams(toolbarParams);
        for (int j = 0; j < mToolbar.getChildCount(); j++) {
            View v = mToolbar.getChildAt(j);
            if (v instanceof TabLayout) {
                mToolbar.removeViewAt(j);
                replacement.addView(v);
                j--;
            }
        }
        group.addView(replacement, i);
        setSupportActionBar(replacement);
        addActionBarDrawerToggle(replacement);
    }
}
 
Example 6
Source File: DesignModuleAttributeHelper.java    From proteus with Apache License 2.0 5 votes vote down vote up
private static AppBarLayout.LayoutParams getLayoutParams(View v) {
  initialize();
  AppBarLayout.LayoutParams result = null;
  ViewGroup.LayoutParams layoutParams = v.getLayoutParams();
  if (null != layoutParams && layoutParams instanceof AppBarLayout.LayoutParams) {
    result = (AppBarLayout.LayoutParams) layoutParams;
  }
  return result;
}
 
Example 7
Source File: BaseActivity.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
protected void setAppBarCollapsible(boolean collapsible) {
    AppBarLayout.LayoutParams params =
            (AppBarLayout.LayoutParams) mToolbar.getLayoutParams();
    if (collapsible) {
        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL
                | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS
                | AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP);
    } else {
        params.setScrollFlags(0);
    }
    mToolbar.setLayoutParams(params);
}
 
Example 8
Source File: TopBarTest.java    From react-native-navigation with MIT License 5 votes vote down vote up
@Test
public void disableCollapse_scrollIsDisabled() {
    AppBarLayout.LayoutParams lp = (AppBarLayout.LayoutParams) uut.getChildAt(0).getLayoutParams();
    uut.enableCollapse(Mockito.mock(ScrollEventListener.class));
    assertThat(lp.getScrollFlags()).isEqualTo(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL);

    uut.disableCollapse();
    assertThat(lp.getScrollFlags()).isZero();
}
 
Example 9
Source File: ScreenStackFragment.java    From react-native-screens with MIT License 5 votes vote down vote up
public void setToolbar(Toolbar toolbar) {
  if (mAppBarLayout != null) {
    mAppBarLayout.addView(toolbar);
  }
  mToolbar = toolbar;
  AppBarLayout.LayoutParams params = new AppBarLayout.LayoutParams(
          AppBarLayout.LayoutParams.MATCH_PARENT, AppBarLayout.LayoutParams.WRAP_CONTENT);
  params.setScrollFlags(0);
  mToolbar.setLayoutParams(params);
}
 
Example 10
Source File: DynamicActivity.java    From dynamic-support with Apache License 2.0 5 votes vote down vote up
/**
 * Set layout scroll flags for the toolbar.
 * <p>Useful to change the collapse mode dynamically.
 *
 * @param flags The scroll flags for the collapsing toolbar layout.
 */
public void setToolbarLayoutFlags(@AppBarLayout.LayoutParams.ScrollFlags int flags) {
    if (mToolbar != null) {
        AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams)
                mToolbar.getLayoutParams();
        params.setScrollFlags(flags);
        mToolbar.setLayoutParams(params);
    }
}
 
Example 11
Source File: DynamicActivity.java    From dynamic-support with Apache License 2.0 5 votes vote down vote up
/**
 * Set layout scroll flags for the collapsing toolbar layout.
 * <p>Useful to change the collapse mode dynamically.
 *
 * @param flags The scroll flags for the collapsing toolbar layout.
 */
public void setCollapsingToolbarLayoutFlags(@AppBarLayout.LayoutParams.ScrollFlags int flags) {
    if (mCollapsingToolbarLayout != null) {
        AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams)
                mCollapsingToolbarLayout.getLayoutParams();
        params.setScrollFlags(flags);
        mCollapsingToolbarLayout.setLayoutParams(params);
    }
}
 
Example 12
Source File: ViewMultiRedditDetailActivity.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    ((Infinity) getApplication()).getAppComponent().inject(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_multi_reddit_detail);

    ButterKnife.bind(this);

    applyCustomTheme();

    if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
        Slidr.attach(this);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        Window window = getWindow();

        if (isChangeStatusBarIconColor()) {
            addOnOffsetChangedListener(appBarLayout);
        }

        if (isImmersiveInterface()) {
            window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
            adjustToolbar(toolbar);
        }
    }

    MultiReddit multiReddit = getIntent().getParcelableExtra(EXTRA_MULTIREDDIT_DATA);
    if (multiReddit == null) {
        multiPath = getIntent().getStringExtra(EXTRA_MULTIREDDIT_PATH);
        if (multiPath != null) {
            toolbar.setTitle(multiPath.substring(multiPath.lastIndexOf("/", multiPath.length() - 2) + 1));
        } else {
            Toast.makeText(this, R.string.error_getting_multi_reddit_data, Toast.LENGTH_SHORT).show();
            finish();
            return;
        }
    } else {
        multiPath = multiReddit.getPath();
        toolbar.setTitle(multiReddit.getDisplayName());
    }

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setToolbarGoToTop(toolbar);

    if (savedInstanceState != null) {
        mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
        mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
        mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE);
        isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);

        mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE_KEY);
        getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_multi_reddit_detail_activity, mFragment).commit();

        if (!mNullAccessToken && mAccessToken == null) {
            getCurrentAccountAndInitializeFragment();
        }
    } else {
        getCurrentAccountAndInitializeFragment();
    }

    sortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
    Bundle bottomSheetBundle = new Bundle();
    bottomSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
    bottomSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_RANDOM_TYPE, true);
    sortTypeBottomSheetFragment.setArguments(bottomSheetBundle);

    sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();

    postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();

    params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
}
 
Example 13
Source File: OdysseyMainActivity.java    From odyssey with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setupToolbar(String title, boolean scrollingEnabled, boolean drawerIndicatorEnabled, boolean showImage) {
    // set drawer state
    mDrawerToggle.setDrawerIndicatorEnabled(drawerIndicatorEnabled);

    ImageView collapsingImage = findViewById(R.id.collapsing_image);
    View collapsingImageGradientTop = findViewById(R.id.collapsing_image_gradient_top);
    View collapsingImageGradientBottom = findViewById(R.id.collapsing_image_gradient_bottom);
    if (collapsingImage != null && collapsingImageGradientTop != null && collapsingImageGradientBottom != null) {
        if (showImage) {
            collapsingImage.setVisibility(View.VISIBLE);
            collapsingImageGradientTop.setVisibility(View.VISIBLE);
            collapsingImageGradientBottom.setVisibility(View.VISIBLE);
        } else {
            collapsingImage.setVisibility(View.GONE);
            collapsingImage.setImageDrawable(null);
            collapsingImageGradientTop.setVisibility(View.GONE);
            collapsingImageGradientBottom.setVisibility(View.GONE);
        }
    }
    // set scrolling behaviour
    CollapsingToolbarLayout toolbar = findViewById(R.id.collapsing_toolbar);
    AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
    params.height = -1;

    if (scrollingEnabled && !showImage) {
        toolbar.setTitleEnabled(false);
        setTitle(title);

        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL + AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED + AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
    } else if (!scrollingEnabled && showImage && collapsingImage != null) {
        toolbar.setTitleEnabled(true);
        toolbar.setTitle(title);

        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED + AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL);
    } else {
        toolbar.setTitleEnabled(false);
        setTitle(title);
        params.setScrollFlags(0);
    }
}
 
Example 14
Source File: AccountPostsActivity.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    ((Infinity) getApplication()).getAppComponent().inject(this);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_account_posts);

    ButterKnife.bind(this);

    EventBus.getDefault().register(this);

    applyCustomTheme();

    if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
        Slidr.attach(this);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        Window window = getWindow();

        if (isChangeStatusBarIconColor()) {
            addOnOffsetChangedListener(appBarLayout);
        }

        if (isImmersiveInterface()) {
            window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
            adjustToolbar(toolbar);
        }
    }

    mUserWhere = getIntent().getExtras().getString(EXTRA_USER_WHERE);
    if (mUserWhere.equals(PostDataSource.USER_WHERE_UPVOTED)) {
        toolbar.setTitle(R.string.upvoted);
    } else if (mUserWhere.equals(PostDataSource.USER_WHERE_DOWNVOTED)) {
        toolbar.setTitle(R.string.downvoted);
    } else if (mUserWhere.equals(PostDataSource.USER_WHERE_HIDDEN)) {
        toolbar.setTitle(R.string.hidden);
    } else if (mUserWhere.equals(PostDataSource.USER_WHERE_GILDED)) {
        toolbar.setTitle(R.string.gilded);
    }

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setToolbarGoToTop(toolbar);

    params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();

    postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();

    if (savedInstanceState != null) {
        mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
        mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
        mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE);
        isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
        mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
        getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_account_posts_activity, mFragment).commit();
        if (!mNullAccessToken && mAccessToken == null) {
            getCurrentAccountAndInitializeFragment();
        }
    } else {
        getCurrentAccountAndInitializeFragment();
    }
}
 
Example 15
Source File: FilteredThingActivity.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    ((Infinity) getApplication()).getAppComponent().inject(this);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_filtered_thing);

    ButterKnife.bind(this);

    EventBus.getDefault().register(this);

    applyCustomTheme();

    if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
        Slidr.attach(this);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        Window window = getWindow();

        if (isChangeStatusBarIconColor()) {
            addOnOffsetChangedListener(appBarLayout);
        }

        if (isImmersiveInterface()) {
            window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
            adjustToolbar(toolbar);
        }
    }

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setToolbarGoToTop(toolbar);

    params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();

    name = getIntent().getStringExtra(EXTRA_NAME);
    postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostDataSource.TYPE_FRONT_PAGE);
    int filter = getIntent().getIntExtra(EXTRA_FILTER, Post.TEXT_TYPE);

    if (postType == PostDataSource.TYPE_USER) {
        userWhere = getIntent().getStringExtra(EXTRA_USER_WHERE);
        if (userWhere != null && !PostDataSource.USER_WHERE_SUBMITTED.equals(userWhere) && mMenu != null) {
            mMenu.findItem(R.id.action_sort_filtered_thing_activity).setVisible(false);
        }
    }

    if (savedInstanceState != null) {
        isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
        mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
        mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);

        mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
        getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_filtered_posts_activity, mFragment).commit();

        if (!mNullAccessToken && mAccessToken == null) {
            getCurrentAccountAndBindView(filter);
        } else {
            bindView(filter, false);
        }
    } else {
        getCurrentAccountAndBindView(filter);
    }

    postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
}
 
Example 16
Source File: TopicListFragment.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void hideLoadingView() {
    AppBarLayout.LayoutParams lp = (AppBarLayout.LayoutParams) mToolbar.getLayoutParams();
    lp.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
    super.hideLoadingView();
}
 
Example 17
Source File: AccountSavedThingActivity.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    ((Infinity) getApplication()).getAppComponent().inject(this);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_account_saved_thing);

    ButterKnife.bind(this);

    EventBus.getDefault().register(this);

    applyCustomTheme();

    if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
        mSlidrInterface = Slidr.attach(this);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        Window window = getWindow();

        if (isChangeStatusBarIconColor()) {
            addOnOffsetChangedListener(appBarLayout);
        }

        if (isImmersiveInterface()) {
            window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
            adjustToolbar(toolbar);
        }
    }

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setToolbarGoToTop(toolbar);

    params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();

    if (savedInstanceState != null) {
        mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
        mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
        mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE);
        isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
        if (!mNullAccessToken && mAccessToken == null) {
            getCurrentAccountAndInitializeViewPager();
        } else {
            initializeViewPager();
        }
    } else {
        getCurrentAccountAndInitializeViewPager();
    }
}
 
Example 18
Source File: MainActivity.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    ((Infinity) getApplication()).getAppComponent().inject(this);

    setTheme(R.style.AppTheme_NoActionBarWithTransparentStatusBar);

    setHasDrawerLayout();

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    ButterKnife.bind(this);

    EventBus.getDefault().register(this);

    applyCustomTheme();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        Window window = getWindow();

        if (isChangeStatusBarIconColor()) {
            addOnOffsetChangedListener(appBarLayout);
        }

        if (isImmersiveInterface()) {
            window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
            adjustToolbar(toolbar);

            int navBarHeight = getNavBarHeight();
            if (navBarHeight > 0) {
                linearLayoutBottomAppBar.setPadding(0,
                        (int) (6 * getResources().getDisplayMetrics().density), 0, navBarHeight);
                navDrawerRecyclerView.setPadding(0, 0, 0, navBarHeight);
            }
        }
    }

    postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();

    bestSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
    Bundle bestBundle = new Bundle();
    bestBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, false);
    bestSortTypeBottomSheetFragment.setArguments(bestBundle);

    popularAndAllSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
    Bundle popularBundle = new Bundle();
    popularBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
    popularAndAllSortTypeBottomSheetFragment.setArguments(popularBundle);

    sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
    postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();

    setSupportActionBar(toolbar);
    setToolbarGoToTop(toolbar);

    drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    toggle.getDrawerArrowDrawable().setColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor());
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();

    showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
    mConfirmToExit = mSharedPreferences.getBoolean(SharedPreferencesUtils.CONFIRM_TO_EXIT, false);
    mLockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);

    if (savedInstanceState != null) {
        mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
        mFetchSubscriptionsSuccess = savedInstanceState.getBoolean(FETCH_SUBSCRIPTIONS_STATE);
        mDrawerOnAccountSwitch = savedInstanceState.getBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE);
        isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
        mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
        mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
        mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE);
        mProfileImageUrl = savedInstanceState.getString(ACCOUNT_PROFILE_IMAGE_URL_STATE);
        mBannerImageUrl = savedInstanceState.getString(ACCOUNT_BANNER_IMAGE_URL_STATE);
        mKarma = savedInstanceState.getInt(ACCOUNT_KARMA_STATE);
        mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
        mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);

        if (!mNullAccessToken && mAccessToken == null) {
            getCurrentAccountAndBindView();
        } else {
            bindView();
        }
    } else {
        mMessageFullname = getIntent().getStringExtra(EXTRA_MESSSAGE_FULLNAME);
        mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
        getCurrentAccountAndBindView();
    }
}