Example #1
0
    @Override
    public void onBindViewHolder(@NonNull final LightningViewHolder holder, int position) {
      holder.exitButton.setTag(position);

      ViewCompat.jumpDrawablesToCurrentState(holder.exitButton);

      LightningView web = mTabsManager.getTabAtPosition(position);
      if (web == null) {
        return;
      }
      holder.txtTitle.setText(web.getTitle());

      final Bitmap favicon = web.getFavicon();
      if (web.isForegroundTab()) {
        Drawable foregroundDrawable = null;
        if (!mDrawerTabs) {
          foregroundDrawable = new BitmapDrawable(getResources(), mForegroundTabBitmap);
          if (!mIsIncognito && mColorMode) {
            foregroundDrawable.setColorFilter(mUiController.getUiColor(), PorterDuff.Mode.SRC_IN);
          }
        }
        if (!mIsIncognito && mColorMode) {
          mUiController.changeToolbarBackground(favicon, foregroundDrawable);
        }

        TextViewCompat.setTextAppearance(holder.txtTitle, R.style.boldText);
        if (!mDrawerTabs) {
          DrawableUtils.setBackground(holder.layout, foregroundDrawable);
        }
        holder.favicon.setImageBitmap(favicon);
      } else {
        TextViewCompat.setTextAppearance(holder.txtTitle, R.style.normalText);
        if (!mDrawerTabs) {
          DrawableUtils.setBackground(holder.layout, mBackgroundTabDrawable);
        }
        holder.favicon.setImageBitmap(getDesaturatedBitmap(favicon));
      }

      if (mDrawerTabs) {
        BackgroundDrawable verticalBackground = (BackgroundDrawable) holder.layout.getBackground();
        verticalBackground.setCrossFadeEnabled(false);
        if (web.isForegroundTab()) {
          verticalBackground.startTransition(200);
        } else {
          verticalBackground.reverseTransition(200);
        }
      }
    }
 public static void setTextStyle(TextView textView) {
   Context context = textView.getContext();
   String size = Preferences.getFontSize(context);
   int sizeId;
   if (size.equals("small")) sizeId = android.R.style.TextAppearance_Small;
   else if (size.equals("large")) sizeId = android.R.style.TextAppearance_Large;
   else sizeId = android.R.style.TextAppearance;
   TextViewCompat.setTextAppearance(textView, sizeId);
   // setEmojiconSize((int) getTextSize());
 }