Ejemplo n.º 1
0
 public void setTheme(int theme) {
   if (theme == THEME_LIGHT) {
     if (mStyle == STYLE_CLASSIC) {
       mBackImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_light_icon));
       mVoiceImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_light_icon));
       mEmptyImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_light_icon));
     }
     mSeparatorView.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_light_separator));
     mSuggestionsRecyclerView.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_light_background));
     mCardView.setCardBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_light_background));
     mSearchEditText.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_light_background));
     mSearchEditText.setTextColor(ContextCompat.getColor(mContext, R.color.search_light_text));
     mSearchEditText.setHintTextColor(
         ContextCompat.getColor(mContext, R.color.search_light_text_hint));
   }
   if (theme == THEME_DARK) {
     if (mStyle == STYLE_CLASSIC) {
       mBackImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_dark_icon));
       mVoiceImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_dark_icon));
       mEmptyImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_dark_icon));
     }
     mSeparatorView.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_dark_separator));
     mSuggestionsRecyclerView.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_dark_background));
     mCardView.setCardBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_dark_background));
     mSearchEditText.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_dark_background));
     mSearchEditText.setTextColor(ContextCompat.getColor(mContext, R.color.search_dark_text));
     mSearchEditText.setHintTextColor(
         ContextCompat.getColor(mContext, R.color.search_dark_text_hint));
   }
 }
  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);
  }
 @UiThread
 public WeekdaysDataSource setBackgroundColor(@ColorInt int color) {
   mBackgroundColor = color;
   if (mRecyclerView != null) mRecyclerView.setBackgroundColor(color);
   return this;
 }