Exemplo n.º 1
0
  protected void update() {
    if (moreButton != null) {
      if (exists || pinned) {
        if (!shaded) {
          moreButton.setImageResource(
              exists ? R.drawable.download_cached : R.drawable.download_pinned);
          shaded = true;
        }
      } else {
        if (shaded) {
          moreButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.download_none));
          shaded = false;
        }
      }
    }

    if (starButton != null) {
      if (isStarred) {
        if (!starred) {
          if (starButton.getDrawable() == null) {
            starButton.setImageDrawable(
                DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_star));
          }
          starButton.setVisibility(View.VISIBLE);
          starred = true;
        }
      } else {
        if (starred) {
          starButton.setVisibility(View.GONE);
          starred = false;
        }
      }
    }

    if (ratingBar != null && isRated != rating) {
      if (isRated > 0 && rating == 0) {
        ratingBar.setVisibility(View.VISIBLE);
      } else if (isRated == 0 && rating > 0) {
        ratingBar.setVisibility(View.GONE);
      }

      ratingBar.setRating(isRated);
      rating = isRated;
    }

    if (coverArtView != null && coverArtView instanceof RecyclingImageView) {
      RecyclingImageView recyclingImageView = (RecyclingImageView) coverArtView;
      if (recyclingImageView.isInvalidated()) {
        onUpdateImageView();
      }
    }
  }
Exemplo n.º 2
0
 public void setChecked(boolean checked) {
   View child = getChildAt(0);
   if (checked && startBackgroundDrawable == null) {
     startBackgroundDrawable = child.getBackground();
     child.setBackgroundColor(DrawableTint.getColorRes(context, R.attr.colorPrimary));
   } else if (!checked && startBackgroundDrawable != null) {
     child.setBackgroundDrawable(startBackgroundDrawable);
     startBackgroundDrawable = null;
   }
 }