Exemplo n.º 1
0
    @Override
    public void onBindViewHolder(final ItemViewHolder viewHolder, final IItem item) {

      viewHolder.vTitle.setText(item.getTitle());
      viewHolder.vDesc.setText(item.getDesc());

      int bal = item.getBalls();
      if (bal == -1) viewHolder.vBalls.setText(R.string.not_defined);
      else viewHolder.vBalls.setText(String.valueOf(bal));
      viewHolder.vStatus.setText(item.getStatus().toString());
      viewHolder.itemView.setTag(item.getId());
      viewHolder.vDate.setText(item.getStringDate());

      viewHolder.vUserSet.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              showPopupMenu(view, item.getId());
            }
          });

      try {

        viewHolder.vImage.post(
            new Runnable() {
              @Override
              public void run() {
                viewHolder.vImage.setImageBitmap(item.getBitmapInView(viewHolder.vImage));
              }
            });

        Palette.generateAsync(
            item.getBitmap(),
            new Palette.PaletteAsyncListener() {
              public void onGenerated(Palette palette) {

                //  int bgColor = palette.getMutedColor(ContextCompat.getColor(mContext,
                // R.color.colorPrimary));
                //  viewHolder.vDesc.setBackgroundColor(bgColor);

              }
            });
      } catch (Exception a) {
        viewHolder.vImage.setScaleType(ImageView.ScaleType.CENTER);
        viewHolder.vImage.setImageDrawable(
            new IconicsDrawable(getActivity())
                .icon(GoogleMaterial.Icon.gmd_error)
                .color(getResources().getColor(R.color.md_red_500))
                .sizeDpX(40)
                .sizeDpY(40));
      }
    }
 private void setSwipeRefreshLayoutSchemeColors() {
   Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
   Palette.generateAsync(
       bitmap,
       new Palette.PaletteAsyncListener() {
         @Override
         public void onGenerated(Palette palette) {
           Palette.Swatch swatch1 = palette.getVibrantSwatch();
           Palette.Swatch swatch2 = palette.getLightVibrantSwatch();
           Palette.Swatch swatch3 = palette.getDarkVibrantSwatch();
           mSwipeRefreshLayout.setColorSchemeColors(swatch1.getRgb(), swatch2.getRgb());
         }
       });
 }
Exemplo n.º 3
0
  // 3
  @Override
  public void onBindViewHolder(final ViewHolder holder, final int position) {
    final Place place = new PlaceData().placeList().get(position);
    holder.placeName.setText(place.name);
    Picasso.with(mContext).load(place.getImageResourceId(mContext)).into(holder.placeImage);
    Bitmap photo =
        BitmapFactory.decodeResource(mContext.getResources(), place.getImageResourceId(mContext));

    Palette.generateAsync(
        photo,
        new Palette.PaletteAsyncListener() {
          public void onGenerated(Palette palette) {
            int bgColor =
                palette.getMutedColor(mContext.getResources().getColor(android.R.color.black));
            holder.placeNameHolder.setBackgroundColor(bgColor);
          }
        });
  }
    @Override
    public void onCreate(SurfaceHolder holder) {
      if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "onCreate");
      }
      super.onCreate(holder);

      setWatchFaceStyle(
          new WatchFaceStyle.Builder(SweepWatchFaceService.this)
              .setCardPeekMode(WatchFaceStyle.PEEK_MODE_SHORT)
              .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
              .setShowSystemUiTime(false)
              .build());

      mBackgroundPaint = new Paint();
      mBackgroundPaint.setColor(Color.BLACK);
      mBackgroundBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.bg);

      /* Set defaults for colors */
      mWatchHandColor = Color.WHITE;
      mWatchHandHighlightColor = Color.RED;
      mWatchHandShadowColor = Color.BLACK;

      mHourPaint = new Paint();
      mHourPaint.setColor(mWatchHandColor);
      mHourPaint.setStrokeWidth(HOUR_STROKE_WIDTH);
      mHourPaint.setAntiAlias(true);
      mHourPaint.setStrokeCap(Paint.Cap.ROUND);
      mHourPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);

      mMinutePaint = new Paint();
      mMinutePaint.setColor(mWatchHandColor);
      mMinutePaint.setStrokeWidth(MINUTE_STROKE_WIDTH);
      mMinutePaint.setAntiAlias(true);
      mMinutePaint.setStrokeCap(Paint.Cap.ROUND);
      mMinutePaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);

      mSecondPaint = new Paint();
      mSecondPaint.setColor(mWatchHandHighlightColor);
      mSecondPaint.setStrokeWidth(SECOND_TICK_STROKE_WIDTH);
      mSecondPaint.setAntiAlias(true);
      mSecondPaint.setStrokeCap(Paint.Cap.ROUND);
      mSecondPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);

      mTickAndCirclePaint = new Paint();
      mTickAndCirclePaint.setColor(mWatchHandColor);
      mTickAndCirclePaint.setStrokeWidth(SECOND_TICK_STROKE_WIDTH);
      mTickAndCirclePaint.setAntiAlias(true);
      mTickAndCirclePaint.setStyle(Paint.Style.STROKE);
      mTickAndCirclePaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);

      /* Extract colors from background image to improve watchface style. */
      Palette.generateAsync(
          mBackgroundBitmap,
          new Palette.PaletteAsyncListener() {
            @Override
            public void onGenerated(Palette palette) {
              if (palette != null) {
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                  Log.d(TAG, "Palette: " + palette);
                }

                mWatchHandHighlightColor = palette.getVibrantColor(Color.RED);
                mWatchHandColor = palette.getLightVibrantColor(Color.WHITE);
                mWatchHandShadowColor = palette.getDarkMutedColor(Color.BLACK);
                updateWatchHandStyle();
              }
            }
          });

      mCalendar = Calendar.getInstance();
    }