Example usage for android.support.v4.content ContextCompat getDrawable

List of usage examples for android.support.v4.content ContextCompat getDrawable

Introduction

In this page you can find the example usage for android.support.v4.content ContextCompat getDrawable.

Prototype

public static final Drawable getDrawable(Context context, int i) 

Source Link

Usage

From source file:com.github.topbottomsnackbar.TBSnackbar.java

public TBSnackbar setIconLeft(@DrawableRes int drawableRes, float sizeDp) {
    final TextView tv = mView.getMessageView();
    Drawable drawable = ContextCompat.getDrawable(mContext, drawableRes);
    if (drawable != null) {
        drawable = fitDrawable(drawable, (int) convertDpToPixel(sizeDp, mContext));
    } else {//from   w  w  w  . jav  a 2 s. c  o  m
        throw new IllegalArgumentException("resource_id is not a valid drawable!");
    }
    final Drawable[] compoundDrawables = tv.getCompoundDrawables();
    tv.setCompoundDrawables(drawable, compoundDrawables[1], compoundDrawables[2], compoundDrawables[3]);
    return this;
}

From source file:com.android.msahakyan.fma.fragment.TrackDetailFragment.java

private void init() {
    mButtonPlayPause.setOnClickListener(this);
    mProgress.setMax(99); // It means 100% .0-99
    mProgress.setPadding(0, 0, 0, 0);/*from  ww w .  ja  v  a  2s  .  c  o m*/
    mProgress.setProgressDrawable(ContextCompat.getDrawable(getContext(), R.drawable.progress_bar));
    mProgress.setOnTouchListener(this);
    mSongTime.setText(item.getDuration());
    updatePlayerPreviousNextButtonsUI();
}

From source file:com.artemchep.horario.ui.activities.SubjectActivity.java

@SuppressLint("NewApi")
private void bind(@NonNull SubjectInfo subject) {
    mCollapsingToolbar.setTitle(subject.name);

    int color = subject.color;
    color |= 0xFF000000; // ignore alpha bits
    final boolean isColorDark = ColorUtil.isColorDark(color);

    if (Device.hasLollipopApi()) {
        int statusBarColor = ColorUtils.blendARGB(color, Color.BLACK, 0.4f);
        getWindow().setStatusBarColor(statusBarColor);
    }// w  w w. j  a  v a2 s.c  o m

    Drawable overflowIcon;
    if (isColorDark) {
        mToolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_white_24dp);
        mCollapsingToolbar.setExpandedTitleColor(Color.WHITE);
        mCollapsingToolbar.setCollapsedTitleTextColor(Color.WHITE);
        overflowIcon = ContextCompat.getDrawable(this, R.drawable.ic_dots_vertical_white_24dp);
        if (mSmartTabLayout != null) {
            mSmartTabLayout.setDefaultTabTextColor(Color.WHITE);
            mSmartTabLayout.setSelectedIndicatorColors(Color.WHITE);
        }
    } else {
        mToolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp);
        mCollapsingToolbar.setExpandedTitleColor(Color.BLACK);
        mCollapsingToolbar.setCollapsedTitleTextColor(Color.BLACK);
        overflowIcon = ContextCompat.getDrawable(this, R.drawable.ic_dots_vertical_black_24dp);
        if (mSmartTabLayout != null) {
            mSmartTabLayout.setDefaultTabTextColor(Color.BLACK);
            mSmartTabLayout.setSelectedIndicatorColors(Color.BLACK);
        }
    }

    mCollapsingToolbar.setContentScrimColor(color);
    if (mBackdropToolbar != null) {
        mBackdropToolbar.setBackgroundColor(color);
    } else
        mAppBar.setBackgroundColor(color);
    mToolbar.setOverflowIcon(overflowIcon);

    mSmartTabLayout.setViewPager(mViewPager);
}

From source file:co.ceryle.segmentedbutton.SegmentedButton.java

/**
 * Sets button's drawable by given drawable id and its position
 *
 * @param drawableId is used to get drawable object
 * @param position   specifies button's drawable position relative to text position.
 *                   These values can be given to position:
 *                   {@link #DRAWABLE_LEFT} sets drawable to the left of button's text
 *                   {@link #DRAWABLE_TOP} sets drawable to the top of button's text
 *                   {@link #DRAWABLE_RIGHT} sets drawable to the right of button's text
 *                   {@link #DRAWABLE_BOTTOM} sets drawable to the bottom of button's text
 */// w ww. java  2 s  . c  o  m
public void setDrawable(int drawableId, int position) {
    setDrawable(ContextCompat.getDrawable(context, drawableId), position);
}

From source file:com.jun.elephant.ui.topic.details.TopicDetailsActivity.java

private void setDrawableTop(TextView textView, int resId) {
    Drawable drawable = ContextCompat.getDrawable(this, resId);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
    textView.setCompoundDrawables(null, drawable, null, null);
}

From source file:com.andremion.floatingnavigationview.FloatingNavigationView.java

private void startOpenAnimations() {

    // Icon/*from  w  ww  .  j a  va 2s .c o m*/
    // Animated Icons
    AnimatedVectorDrawable menuIcon = (AnimatedVectorDrawable) ContextCompat.getDrawable(getContext(),
            R.drawable.ic_menu_animated);
    mFabView.setImageDrawable(menuIcon);
    menuIcon.start();

    // Reveal
    int centerX = mFabRect.centerX();
    int centerY = mFabRect.centerY();
    float startRadius = getMinRadius();
    float endRadius = getMaxRadius();
    Animator reveal = ViewAnimationUtils.createCircularReveal(mNavigationView, centerX, centerY, startRadius,
            endRadius);

    // Fade in
    mNavigationMenuView.setAlpha(0);
    Animator fade = ObjectAnimator.ofFloat(mNavigationMenuView, View.ALPHA, 0, 1);

    // Animations
    AnimatorSet set = new AnimatorSet();
    set.playSequentially(reveal, fade);
    set.start();
}

From source file:com.finchuk.clock2.MainActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final View rootView = ((ViewGroup) findViewById(android.R.id.content)).getChildAt(0);
    // http://stackoverflow.com/a/24035591/5055032
    // http://stackoverflow.com/a/3948036/5055032
    // The views in our layout have begun drawing.
    // There is no lifecycle callback that tells us when our layout finishes drawing;
    // in my own test, drawing still isn't finished by onResume().
    // Post a message in the UI events queue to be executed after drawing is complete,
    // so that we may get their dimensions.
    rootView.post(new Runnable() {
        @Override/* w w  w . j av  a  2  s.c  o  m*/
        public void run() {
            if (mViewPager.getCurrentItem() == mSectionsPagerAdapter.getCount() - 1) {
                // Restore the FAB's translationX from a previous configuration.
                mFab.setTranslationX(mViewPager.getWidth() / -2f + getFabPixelOffsetForXTranslation());
            }
        }
    });

    new Thread(new Runnable() {
        @Override
        public void run() {
            while (true) {
                try {
                    Weather w = readWeather();
                    if (w != null) {
                        weather = w;
                    }
                } finally {
                    try {
                        Thread.sleep(10000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            }
        }
    }).start();
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        /**
         * @param position Either the current page position if the offset is increasing,
         *                 or the previous page position if it is decreasing.
         * @param positionOffset If increasing from [0, 1), scrolling right and position = currentPagePosition
         *                       If decreasing from (1, 0], scrolling left and position = (currentPagePosition - 1)
         */
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            Log.d(TAG, String.format("pos = %d, posOffset = %f, posOffsetPixels = %d", position, positionOffset,
                    positionOffsetPixels));
            int pageBeforeLast = mSectionsPagerAdapter.getCount() - 2;
            if (position <= pageBeforeLast) {
                if (position < pageBeforeLast) {
                    // When the scrolling is due to tab selection between multiple tabs apart,
                    // this callback is called for each intermediate page, but each of those pages
                    // will briefly register a sparsely decreasing range of positionOffsets, always
                    // from (1, 0). As such, you would notice the FAB to jump back and forth between
                    // x-positions as each intermediate page is scrolled through.
                    // This is a visual optimization that ends the translation motion, immediately
                    // returning the FAB to its target position.
                    // TODO: The animation visibly skips to the end. We could interpolate
                    // intermediate x-positions if we cared to smooth it out.
                    mFab.setTranslationX(0);
                } else {
                    // Initially, the FAB's translationX property is zero because, at its original
                    // position, it is not translated. setTranslationX() is relative to the view's
                    // left position, at its original position; this left position is taken to be
                    // the zero point of the coordinate system relative to this view. As your
                    // translationX value is increasingly negative, the view is translated left.
                    // But as translationX is decreasingly negative and down to zero, the view
                    // is translated right, back to its original position.
                    float translationX = positionOffsetPixels / -2f;
                    // NOTE: You MUST scale your own additional pixel offsets by positionOffset,
                    // or else the FAB will immediately translate by that many pixels, appearing
                    // to skip/jump.
                    translationX += positionOffset * getFabPixelOffsetForXTranslation();
                    mFab.setTranslationX(translationX);
                }
            }
        }

        @Override
        public void onPageSelected(int position) {
            Log.d(TAG, "onPageSelected");
            if (position < mSectionsPagerAdapter.getCount() - 1) {
                mFab.setImageDrawable(mAddItemDrawable);
            }
            Fragment f = mSectionsPagerAdapter.getFragment(mViewPager.getCurrentItem());
            // NOTE: This callback is fired after a rotation, right after onStart().
            // Unfortunately, the FragmentManager handling the rotation has yet to
            // tell our adapter to re-instantiate the Fragments, so our collection
            // of fragments is empty. You MUST keep this check so we don't cause a NPE.
            if (f instanceof BaseFragment) {
                ((BaseFragment) f).onPageSelected();
            }
        }
    });

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    ColorStateList tabIconColor = ContextCompat.getColorStateList(this, R.color.tab_icon_color);
    setTabIcon(PAGE_ALARMS, R.drawable.ic_alarm_24dp, tabIconColor);
    setTabIcon(PAGE_TIMERS, R.drawable.ic_timer_24dp, tabIconColor);
    setTabIcon(PAGE_STOPWATCH, R.drawable.ic_stopwatch_24dp, tabIconColor);

    // TODO: @OnCLick instead.
    mFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Fragment f = mSectionsPagerAdapter.getFragment(mViewPager.getCurrentItem());
            if (f instanceof RecyclerViewFragment) {
                ((RecyclerViewFragment) f).onFabClick();
            }
        }
    });

    mAddItemDrawable = ContextCompat.getDrawable(this, R.drawable.ic_add_24dp);
    handleActionScrollToStableId(getIntent(), false);
}

From source file:com.google.android.finsky.detailspage.WarningMessageModule.java

public final void bindView(View paramView) {
      WarningMessageModuleLayout localWarningMessageModuleLayout = (WarningMessageModuleLayout) paramView;
      int j;/* w  w w.  j a v a  2  s  . co  m*/
      if ((!localWarningMessageModuleLayout.mBinded) || (this.mNeedsRefresh)) {
          String str = ((WarningMessageModuleData) this.mModuleData).messageText;
          boolean bool = ((WarningMessageModuleData) this.mModuleData).isMessageLink;
          int i = ((WarningMessageModuleData) this.mModuleData).messageIconResId;
          j = ((WarningMessageModuleData) this.mModuleData).detailsDoc.mDocument.backendId;
          localWarningMessageModuleLayout.mBinded = true;
          localWarningMessageModuleLayout.mWarningMessageText.setText(str);
          localWarningMessageModuleLayout.mWarningMessageIcon.setImageResource(i);
          if (!bool) {
              break label231;
          }
          localWarningMessageModuleLayout.mWarningMessageText.setMovementMethod(LinkMovementMethod.getInstance());
      }
      for (;;) {
          Context localContext = localWarningMessageModuleLayout.getContext();
          ColorStateList localColorStateList = CorpusResourceUtils.getSecondaryTextColor(localContext, j);
          localWarningMessageModuleLayout.mWarningMessageText.setTextColor(localColorStateList);
          int k = UiUtils.interpolateColor$4868c7be(CorpusResourceUtils.getPrimaryColor(localContext, j));
          int m = localWarningMessageModuleLayout.getPaddingTop();
          int n = localWarningMessageModuleLayout.getPaddingBottom();
          int i1 = ViewCompat.getPaddingEnd(localWarningMessageModuleLayout);
          int i2 = ViewCompat.getPaddingStart(localWarningMessageModuleLayout);
          Drawable[] arrayOfDrawable = new Drawable[2];
          arrayOfDrawable[0] = new ColorDrawable(k);
          arrayOfDrawable[1] = ContextCompat.getDrawable(localContext, 2130837958);
          localWarningMessageModuleLayout.setBackgroundDrawable(new LayerDrawable(arrayOfDrawable));
          ViewCompat.setPaddingRelative(localWarningMessageModuleLayout, i2, m, i1, n);
          this.mNeedsRefresh = false;
          return;
          label231: localWarningMessageModuleLayout.mWarningMessageText.setMovementMethod(null);
      }
  }

From source file:babbq.com.searchplace.SearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);
    ButterKnife.bind(this);
    setupSearchView();/*from   ww w  .j av  a2 s.c om*/
    auto = TransitionInflater.from(this).inflateTransition(R.transition.auto);

    mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API)
            .addApi(Places.GEO_DATA_API).addConnectionCallbacks(this).addOnConnectionFailedListener(this)
            .build();

    mAdapter = new TestAdapter(null, v -> {
        int position = results.getChildLayoutPosition(v);
        //Toast.makeText(getActivity(), "#" + position, Toast.LENGTH_SHORT).show();
        PendingResult result = Places.GeoDataApi.getPlaceById(mGoogleApiClient,
                String.valueOf(mAdapter.getElementAt(position).placeId));
        result.setResultCallback(mCoordinatePlaceDetailsCallback);
    }, mGoogleApiClient);

    dataManager = new SearchDataManager(mGoogleApiClient, mCoordinatePlaceDetailsCallback) {

        @Override
        public void onDataLoaded(List<? extends PlaceAutocomplete> data) {
            if (data != null && data.size() > 0) {
                if (results.getVisibility() != View.VISIBLE) {
                    TransitionManager.beginDelayedTransition(container, auto);
                    progress.setVisibility(View.GONE);
                    results.setVisibility(View.VISIBLE);
                    //                        fab.setVisibility(View.VISIBLE);
                    fab.setAlpha(0.6f);
                    fab.setScaleX(0f);
                    fab.setScaleY(0f);
                    fab.animate().alpha(1f).scaleX(1f).scaleY(1f).setStartDelay(800L).setDuration(300L)
                            .setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                                    android.R.interpolator.linear_out_slow_in));
                }
                //                    mAdapter.addAndResort(data);
                mAdapter.setList(data);
            } else {
                TransitionManager.beginDelayedTransition(container, auto);
                progress.setVisibility(View.GONE);
                setNoResultsVisibility(View.VISIBLE);
            }
        }
    };
    //        mAdapter = new FeedAdapter(this, dataManager, columns);
    results.setAdapter(mAdapter);
    GridLayoutManager layoutManager = new GridLayoutManager(this, columns);
    //        layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
    //
    //            @Override
    //            public int getSpanSize(int position) {
    //                return mAdapter.getItemColumnSpan(position);
    //            }
    //        });
    results.setLayoutManager(layoutManager);
    results.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) {

        @Override
        public void onLoadMore() {
            dataManager.loadMore();
        }
    });
    results.setHasFixedSize(true);
    results.addOnScrollListener(gridScroll);

    // extract the search icon's location passed from the launching activity, minus 4dp to
    // compensate for different paddings in the views
    searchBackDistanceX = getIntent().getIntExtra(EXTRA_MENU_LEFT, 0) - (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
    searchIconCenterX = getIntent().getIntExtra(EXTRA_MENU_CENTER_X, 0);

    // translate icon to match the launching screen then animate back into position
    searchBackContainer.setTranslationX(searchBackDistanceX);
    searchBackContainer.animate().translationX(0f).setDuration(650L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in));
    // transform from search icon to back icon
    AnimatedVectorDrawable searchToBack = (AnimatedVectorDrawable) ContextCompat.getDrawable(this,
            R.drawable.avd_search_to_back);
    searchBack.setImageDrawable(searchToBack);
    searchToBack.start();
    // for some reason the animation doesn't always finish (leaving a part arrow!?) so after
    // the animation set a static drawable. Also animation callbacks weren't added until API23
    // so using post delayed :(
    // TODO fix properly!!
    searchBack.postDelayed(new Runnable() {

        @Override
        public void run() {
            searchBack.setImageDrawable(
                    ContextCompat.getDrawable(SearchActivity.this, R.drawable.ic_arrow_back_padded));
        }
    }, 600);

    // fade in the other search chrome
    searchBackground.animate().alpha(1f).setDuration(300L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in));
    searchView.animate().alpha(1f).setStartDelay(400L).setDuration(400L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in))
            .setListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    searchView.requestFocus();
                    ImeUtils.showIme(searchView);
                }
            });

    // animate in a scrim over the content behind
    scrim.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

        @Override
        public boolean onPreDraw() {
            scrim.getViewTreeObserver().removeOnPreDrawListener(this);
            AnimatorSet showScrim = new AnimatorSet();
            showScrim.playTogether(
                    ViewAnimationUtils.createCircularReveal(scrim, searchIconCenterX,
                            searchBackground.getBottom(), 0,
                            (float) Math.hypot(searchBackDistanceX,
                                    scrim.getHeight() - searchBackground.getBottom())),
                    ObjectAnimator.ofArgb(scrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT,
                            ContextCompat.getColor(SearchActivity.this, R.color.scrim)));
            showScrim.setDuration(400L);
            showScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                    android.R.interpolator.linear_out_slow_in));
            showScrim.start();
            return false;
        }
    });
    onNewIntent(getIntent());
}

From source file:com.hippo.nimingban.ui.ListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);

    mNMBClient = NMBApplication.getNMBClient(this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    mSlidingDrawerLayout = (SlidingDrawerLayout) findViewById(R.id.drawer_layout);
    mContentLayout = (ContentLayout) mSlidingDrawerLayout.findViewById(R.id.content_layout);
    mRecyclerView = mContentLayout.getRecyclerView();
    mLeftDrawer = (LeftDrawer) mSlidingDrawerLayout.findViewById(R.id.left_drawer);
    mRightDrawer = (RightDrawer) mSlidingDrawerLayout.findViewById(R.id.right_drawer);

    final GestureDetector gestureDetector = new GestureDetector(this, new SimpleGestureListener());
    gestureDetector.setOnDoubleTapListener(new SimpleDoubleTapListener() {
        @Override/*from w  w w .jav  a  2  s.  com*/
        public boolean onDoubleTap(MotionEvent e) {
            mPostHelper.refresh();
            return true;
        }
    });
    toolbar.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            gestureDetector.onTouchEvent(event);
            return true;
        }
    });
    setSupportActionBar(toolbar);

    mDrawerToggle = new ActionBarDrawerToggle(this, mSlidingDrawerLayout, R.string.drawer_open,
            R.string.drawer_close) {

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            if (mLeftDrawer == drawerView) {
                super.onDrawerSlide(drawerView, slideOffset);
            }
        }

        private void setMenuItemVisible(MenuItem item, boolean visible) {
            if (item != null) {
                item.setVisible(visible);
            }
        }

        @Override
        public void onDrawerClosed(View view) {
            if (mLeftDrawer == view) {
                super.onDrawerClosed(view);
            }
            if (mRightDrawer == view) {
                setMenuItemVisible(mRule, true);
                setMenuItemVisible(mCreatePost, true);
                setMenuItemVisible(mRefresh, true);
                setMenuItemVisible(mSortForumsMenu, false);
            }
        }

        @Override
        public void onDrawerOpened(View view) {
            if (mLeftDrawer == view) {
                // Analysis
                Analysis.action(ListActivity.this, "open_left_drawer");

                super.onDrawerOpened(view);
            }
            if (mRightDrawer == view) {
                // Analysis
                Analysis.action(ListActivity.this, "open_right_drawer");

                setMenuItemVisible(mRule, false);
                setMenuItemVisible(mCreatePost, false);
                setMenuItemVisible(mRefresh, false);
                setMenuItemVisible(mSortForumsMenu, true);
            }
        }
    };
    mSlidingDrawerLayout.setDrawerListener(mDrawerToggle);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }

    mSlidingDrawerLayout.setDrawerShadow(ContextCompat.getDrawable(this, R.drawable.drawer_shadow_left),
            Gravity.LEFT);
    mSlidingDrawerLayout.setDrawerShadow(ContextCompat.getDrawable(this, R.drawable.drawer_shadow_right),
            Gravity.RIGHT);
    mSlidingDrawerLayout.setStatusBarColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimaryDark));

    mPostHelper = new PostHelper();
    mPostHelper.setEmptyString(getString(R.string.no_post));
    mContentLayout.setHelper(mPostHelper);
    if (Settings.getFastScroller()) {
        mContentLayout.showFastScroll();
    } else {
        mContentLayout.hideFastScroll();
    }

    mPostAdapter = new PostAdapter();
    mRecyclerView.setAdapter(mPostAdapter);
    mRecyclerView
            .setSelector(RippleSalon.generateRippleDrawable(ResourcesUtils.getAttrBoolean(this, R.attr.dark)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setOnItemClickListener(new ClickPostListener());
    mRecyclerView.hasFixedSize();
    mRecyclerView.setClipToPadding(false);

    int halfInterval = getResources().getDimensionPixelOffset(R.dimen.card_interval) / 2;
    if (getResources().getBoolean(R.bool.two_way)) {
        mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
        mRecyclerView.addItemDecoration(new MarginItemDecoration(halfInterval));
        mRecyclerView.setPadding(halfInterval, halfInterval, halfInterval, halfInterval);
        mRecyclerView.setItemAnimator(new FloatItemAnimator(mRecyclerView));
    } else {
        mRecyclerView.addItemDecoration(new MarginItemDecoration(0, halfInterval, 0, halfInterval));
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setPadding(0, halfInterval, 0, halfInterval);
    }

    mLeftDrawer.setHelper(this);

    mRightDrawer.setRightDrawerHelper(this);

    if (savedInstanceState == null) {
        int ils = Settings.getImageLoadingStrategy();
        if (ils == Settings.IMAGE_LOADING_STRATEGY_ALL || (ils == Settings.IMAGE_LOADING_STRATEGY_WIFI
                && NMBApplication.isConnectedWifi(ListActivity.this))) {
            mLeftDrawer.loadHeaderImageView();
        }
    }

    updateForums(true);

    checkForAppStart();

    Messenger.getInstance().register(Constants.MESSENGER_ID_CREATE_POST, this);
    Messenger.getInstance().register(Constants.MESSENGER_ID_FAST_SCROLLER, this);

    // Check permission
    PermissionRequester.request(this, Manifest.permission.WRITE_EXTERNAL_STORAGE,
            getString(R.string.write_storage_permission_tip), PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE);

    if (Settings.getGuideListActivity()) {
        showLeftDrawerGuide();
    }
}