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);
        }
      }
    }
Example #2
0
 @NonNull
 @Override
 public LightningViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
   LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
   View view = inflater.inflate(mLayoutResourceId, viewGroup, false);
   if (mDrawerTabs) {
     DrawableUtils.setBackground(view, new BackgroundDrawable(view.getContext()));
   }
   return new LightningViewHolder(view);
 }