Exemplo n.º 1
0
  @Override
  protected void dispatchDraw(Canvas canvas) {
    final int saveCount = canvas.save();

    final Matrix m = mController.getEffectsMatrix();
    if (!m.isIdentity()) canvas.concat(m);

    final float alpha = mController.getEffectsAlpha();
    if (alpha != 1f)
      canvas.saveLayerAlpha(
          0,
          0,
          canvas.getWidth(),
          canvas.getHeight(),
          (int) (255 * alpha),
          Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);

    super.dispatchDraw(canvas);

    final int fadeFactor = mController.getFadeFactor();
    if (fadeFactor > 0f) {
      mFadePaint.setColor(Color.argb(fadeFactor, 0, 0, 0));
      canvas.drawRect(0, 0, getWidth(), getHeight(), mFadePaint);
    }

    canvas.restoreToCount(saveCount);
  }
 @Override
 protected void onDraw(Canvas canvas) {
   // TODO Auto-generated method stub
   super.onDraw(canvas);
   if (mMoveDeltX > 0 || mMoveDeltX == 0 && mSwitchOn) {
     if (mSrc != null) {
       mSrc.set(
           mMoveLength - mMoveDeltX,
           0,
           mSwitchBottom.getWidth() - mMoveDeltX,
           mSwitchFrame.getHeight());
     }
   } else if (mMoveDeltX < 0 || mMoveDeltX == 0 && !mSwitchOn) {
     if (mSrc != null) {
       mSrc.set(-mMoveDeltX, 0, mSwitchFrame.getWidth() - mMoveDeltX, mSwitchFrame.getHeight());
     }
   }
   Log.d("mAlpha", "mAlpha:" + mAlpha);
   canvas.saveLayerAlpha(
       new RectF(mDest),
       mAlpha,
       Canvas.MATRIX_SAVE_FLAG
           | Canvas.CLIP_SAVE_FLAG
           | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG
           | Canvas.FULL_COLOR_LAYER_SAVE_FLAG
           | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
   canvas.drawBitmap(mSwitchBottom, mSrc, mDest, null);
   canvas.drawBitmap(mSwitchThumb, mSrc, mDest, null);
   canvas.drawBitmap(mSwitchFrame, 0, 0, null);
   canvas.drawBitmap(mSwitchMask, 0, 0, mPaint);
   canvas.restore();
 }
  @Override
  protected void onDraw(Canvas canvas) {
    if (user == null && chat == null && encryptedChat == null) {
      return;
    }

    if (cellLayout == null) {
      requestLayout();
      return;
    }

    if (useSeparator) {
      int h = getMeasuredHeight();
      if (!usePadding) {
        canvas.drawLine(0, h - 1, getMeasuredWidth(), h - 1, linePaint);
      } else {
        canvas.drawLine(
            AndroidUtilities.dp(11),
            h - 1,
            getMeasuredWidth() - AndroidUtilities.dp(11),
            h - 1,
            linePaint);
      }
    }

    if (drawAlpha != 1) {
      canvas.saveLayerAlpha(
          0,
          0,
          canvas.getWidth(),
          canvas.getHeight(),
          (int) (255 * drawAlpha),
          Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
    }

    if (cellLayout.drawNameLock) {
      setDrawableBounds(lockDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
      lockDrawable.draw(canvas);
    } else if (cellLayout.drawNameGroup) {
      setDrawableBounds(groupDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
      groupDrawable.draw(canvas);
    } else if (cellLayout.drawNameBroadcast) {
      setDrawableBounds(broadcastDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
      broadcastDrawable.draw(canvas);
    }

    canvas.save();
    canvas.translate(cellLayout.nameLeft, cellLayout.nameTop);
    cellLayout.nameLayout.draw(canvas);
    canvas.restore();

    if (cellLayout.onlineLayout != null) {
      canvas.save();
      canvas.translate(cellLayout.onlineLeft, cellLayout.onlineTop);
      cellLayout.onlineLayout.draw(canvas);
      canvas.restore();
    }

    avatarImage.draw(canvas);
  }
Exemplo n.º 4
0
 @Override
 public void draw(Canvas canvas) {
   Rect bounds = getBounds();
   canvas.saveLayerAlpha(
       bounds.left, bounds.top, bounds.right, bounds.bottom, mAlpha, Canvas.ALL_SAVE_FLAG);
   super.draw(canvas);
   canvas.restore();
 }
Exemplo n.º 5
0
 protected void dispatchDraw(Canvas paramCanvas) {
   if ((!this.hasAlpha) && (this.alpha != 255))
     paramCanvas.saveLayerAlpha(new RectF(paramCanvas.getClipBounds()), this.alpha, 31);
   while (true) {
     if ((!this.hasScaled) && (this.scale != 1.0F))
       paramCanvas.scale(this.scale, this.scale, this.centerPoint.x, this.centerPoint.y);
     super.dispatchDraw(paramCanvas);
     paramCanvas.restore();
     return;
     paramCanvas.save();
   }
 }
Exemplo n.º 6
0
  @Override
  protected void onDraw(Canvas canvas) {
    canvas.saveLayerAlpha(
        mSaveLayerRectF,
        mAlpha,
        Canvas.MATRIX_SAVE_FLAG
            | Canvas.CLIP_SAVE_FLAG
            | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG
            | Canvas.FULL_COLOR_LAYER_SAVE_FLAG
            | Canvas.CLIP_TO_LAYER_SAVE_FLAG);

    // 绘制底部图片
    canvas.drawBitmap(bmCurBgPic, 0, 0, mPaint);

    // 绘制按钮
    canvas.drawBitmap(bmCurBtnPic, curBtnPos, 0, mPaint);

    canvas.restore();
  }
Exemplo n.º 7
0
 @Override
 protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
   if (CROSSFADE) {
     int alpha;
     int l = child.getLeft();
     int t = child.getTop();
     if (mFadeStartTime > 0) {
       alpha = (int) (((drawingTime - mFadeStartTime) * 255) / FADE_DURATION);
       if (alpha > 255) {
         alpha = 255;
       }
       Log.d(TAG, "drawChild alpha=" + alpha + " l=" + l + " t=" + t + " w=" + child.getWidth());
       if (alpha != 255 && mOld != null) {
         mOldPaint.setAlpha(255 - alpha);
         // canvas.drawBitmap(mOld, l, t, mOldPaint);
       }
     } else {
       alpha = 255;
     }
     int restoreTo =
         canvas.saveLayerAlpha(
             l,
             t,
             child.getWidth(),
             child.getHeight(),
             alpha,
             Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
     boolean rv = super.drawChild(canvas, child, drawingTime);
     canvas.restoreToCount(restoreTo);
     if (alpha < 255) {
       invalidate();
     } else {
       mFadeStartTime = -1;
       if (mOld != null) {
         mOld.recycle();
         mOld = null;
       }
     }
     return rv;
   } else {
     return super.drawChild(canvas, child, drawingTime);
   }
 }
Exemplo n.º 8
0
 public void draw(Canvas paramCanvas) {
   this.hasScaled = false;
   this.hasAlpha = false;
   if (this.alpha != 255) {
     this.hasAlpha = true;
     paramCanvas.saveLayerAlpha(new RectF(paramCanvas.getClipBounds()), this.alpha, 31);
   }
   while (true) {
     if (this.scale != 1.0F) {
       this.hasScaled = true;
       paramCanvas.scale(this.scale, this.scale, this.centerPoint.x, this.centerPoint.y);
     }
     super.draw(paramCanvas);
     paramCanvas.restore();
     this.hasScaled = false;
     return;
     paramCanvas.save();
   }
 }
Exemplo n.º 9
0
  @Override
  protected void dispatchDraw(Canvas canvas) {
    final int saveCount = canvas.save();
    canvas.concat(mEffectsController.getEffectsMatrix());
    canvas.saveLayerAlpha(
        0,
        0,
        canvas.getWidth(),
        canvas.getHeight(),
        (int) (255 * mEffectsController.getEffectsAlpha()),
        Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);

    super.dispatchDraw(canvas);

    if (mFadeFactor > 0f) {
      mFadePaint.setColor(Color.argb(mFadeFactor, 0, 0, 0));
      canvas.drawRect(0, 0, getWidth(), getHeight(), mFadePaint);
    }

    canvas.restoreToCount(saveCount);
  }
Exemplo n.º 10
0
  @Override
  protected void onDraw(Canvas canvas) {
    canvas.saveLayerAlpha(
        mSaveLayerRectF,
        mAlpha,
        Canvas.MATRIX_SAVE_FLAG
            | Canvas.CLIP_SAVE_FLAG
            | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG
            | Canvas.FULL_COLOR_LAYER_SAVE_FLAG
            | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
    // 绘制蒙板
    canvas.drawBitmap(mMask, 0, mExtendOffsetY, mPaint);
    mPaint.setXfermode(mXfermode);

    // 绘制底部图片
    canvas.drawBitmap(mBottom, mRealPos, mExtendOffsetY, mPaint);
    mPaint.setXfermode(null);
    // 绘制边框
    canvas.drawBitmap(mFrame, 0, mExtendOffsetY, mPaint);

    // 绘制按钮
    canvas.drawBitmap(mCurBtnPic, mRealPos, mExtendOffsetY, mPaint);
    canvas.restore();
  }
  @Override
  protected void dispatchDraw(Canvas canvas) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
      scrollChanged(getFirstVisiblePosition());
    }

    // Mask the region where we will draw the header later, but only if we
    // will draw a header.
    boolean willDrawStickiedHeader = mStickiedHeader != null && mAreHeadersSticky;
    int headerHeight = getHeaderHeight();
    int top = mHeaderBottomPosition - headerHeight;

    if (willDrawStickiedHeader) {
      mClippingRect.left = getPaddingLeft();
      mClippingRect.right = getWidth() - getPaddingRight();
      mClippingRect.top = mHeaderBottomPosition;
      mClippingRect.bottom = getHeight();

      canvas.save();
      canvas.clipRect(mClippingRect);
    }

    // ...and draw the grid view.
    super.dispatchDraw(canvas);

    // Find headers.
    List<Integer> headerPositions = new ArrayList<Integer>();
    int vi = 0;
    for (int i = getFirstVisiblePosition(); i <= getLastVisiblePosition(); ) {
      long id = getItemIdAtPosition(i);
      if (id == StickyGridHeadersBaseAdapterWrapper.ID_HEADER) {
        headerPositions.add(vi);
      }
      i += mNumMeasuredColumns;
      vi += mNumMeasuredColumns;
    }

    // Draw headers in list.
    for (int i = 0; i < headerPositions.size(); i++) {
      View frame = getChildAt(headerPositions.get(i));
      View header;
      try {
        header = (View) frame.getTag();
      } catch (Exception e) {
        return;
      }

      int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY);
      int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
      header.measure(widthMeasureSpec, heightMeasureSpec);
      header.layout(
          getLeft() + getPaddingLeft(), 0, getRight() - getPaddingRight(), frame.getHeight());

      mClippingRect.left = getPaddingLeft();
      mClippingRect.right = getWidth() - getPaddingRight();
      mClippingRect.bottom = frame.getBottom();
      mClippingRect.top = frame.getTop();
      canvas.save();
      canvas.clipRect(mClippingRect);
      canvas.translate(getPaddingLeft(), frame.getTop());
      header.draw(canvas);
      canvas.restore();
    }

    if (willDrawStickiedHeader) {
      canvas.restore();
    } else {
      // Done.
      return;
    }

    // Draw stickied header.
    mClippingRect.left = getPaddingLeft();
    mClippingRect.right = getWidth() - getPaddingRight();
    mClippingRect.bottom = top + headerHeight;
    if (mClippingToPadding) {
      mClippingRect.top = getPaddingTop();
    } else {
      mClippingRect.top = 0;
    }

    canvas.save();
    canvas.clipRect(mClippingRect);
    canvas.translate(getPaddingLeft(), top);
    canvas.saveLayerAlpha(
        0,
        0,
        canvas.getWidth(),
        canvas.getHeight(),
        (int) (0xff * (float) mHeaderBottomPosition / headerHeight),
        Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
    mStickiedHeader.draw(canvas);
    canvas.restore();
    canvas.restore();
  }
Exemplo n.º 12
0
 @Override
 protected void dispatchDraw(final Canvas canvas) {
   canvas.saveLayerAlpha(null, mFadeFactor, Canvas.ALL_SAVE_FLAG);
   super.dispatchDraw(canvas);
   canvas.restore();
 }
Exemplo n.º 13
0
  @Override
  protected void onDraw(Canvas canvas) {
    if (user == null && chat == null && encryptedChat == null) {
      return;
    }

    if (useSeparator) {
      if (LocaleController.isRTL) {
        canvas.drawLine(
            0,
            getMeasuredHeight() - 1,
            getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.leftBaseline),
            getMeasuredHeight() - 1,
            linePaint);
      } else {
        canvas.drawLine(
            AndroidUtilities.dp(AndroidUtilities.leftBaseline),
            getMeasuredHeight() - 1,
            getMeasuredWidth(),
            getMeasuredHeight() - 1,
            linePaint);
      }
    }

    if (drawAlpha != 1) {
      canvas.saveLayerAlpha(
          0,
          0,
          canvas.getWidth(),
          canvas.getHeight(),
          (int) (255 * drawAlpha),
          Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
    }

    if (drawNameLock) {
      setDrawableBounds(lockDrawable, nameLockLeft, nameLockTop);
      lockDrawable.draw(canvas);
    } else if (drawNameGroup) {
      setDrawableBounds(groupDrawable, nameLockLeft, nameLockTop);
      groupDrawable.draw(canvas);
    } else if (drawNameBroadcast) {
      setDrawableBounds(broadcastDrawable, nameLockLeft, nameLockTop);
      broadcastDrawable.draw(canvas);
    } else if (drawNameBot) {
      setDrawableBounds(botDrawable, nameLockLeft, nameLockTop);
      botDrawable.draw(canvas);
    }

    if (nameLayout != null) {
      canvas.save();
      canvas.translate(nameLeft, nameTop);
      nameLayout.draw(canvas);
      canvas.restore();
      if (drawCheck) {
        if (LocaleController.isRTL) {
          setDrawableBounds(
              checkDrawable,
              nameLeft - AndroidUtilities.dp(4) - checkDrawable.getIntrinsicWidth(),
              nameLockTop);
        } else {
          setDrawableBounds(
              checkDrawable,
              nameLeft + (int) nameLayout.getLineWidth(0) + AndroidUtilities.dp(4),
              nameLockTop);
        }
        checkDrawable.draw(canvas);
      }
    }

    if (onlineLayout != null) {
      canvas.save();
      canvas.translate(onlineLeft, AndroidUtilities.dp(40));
      onlineLayout.draw(canvas);
      canvas.restore();
    }

    if (countLayout != null) {
      if (MessagesController.getInstance().isDialogMuted(dialog_id)) {
        setDrawableBounds(
            countDrawableGrey,
            countLeft - AndroidUtilities.dp(5.5f),
            countTop,
            countWidth + AndroidUtilities.dp(11),
            countDrawableGrey.getIntrinsicHeight());
        countDrawableGrey.draw(canvas);
      } else {
        setDrawableBounds(
            countDrawable,
            countLeft - AndroidUtilities.dp(5.5f),
            countTop,
            countWidth + AndroidUtilities.dp(11),
            countDrawable.getIntrinsicHeight());
        countDrawable.draw(canvas);
      }
      canvas.save();
      canvas.translate(countLeft, countTop + AndroidUtilities.dp(4));
      countLayout.draw(canvas);
      canvas.restore();
    }

    avatarImage.draw(canvas);
  }
Exemplo n.º 14
0
 protected final int i(int paramInt, Object... paramVarArgs) {
   switch (paramInt) {
   }
   for (; ; ) {
     return 0;
     return 96;
     return 96;
     Canvas localCanvas = (Canvas) paramVarArgs[0];
     paramVarArgs = (Looper) paramVarArgs[1];
     Object localObject1 = c.d(paramVarArgs);
     Object localObject3 = c.c(paramVarArgs);
     Object localObject2 = c.g(paramVarArgs);
     ((Paint) localObject2).setFlags(385);
     ((Paint) localObject2).setStyle(Paint.Style.FILL);
     Paint localPaint = c.g(paramVarArgs);
     localPaint.setFlags(385);
     localPaint.setStyle(Paint.Style.STROKE);
     ((Paint) localObject2).setColor(-16777216);
     localPaint.setStrokeWidth(1.0F);
     localPaint.setStrokeCap(Paint.Cap.BUTT);
     localPaint.setStrokeJoin(Paint.Join.MITER);
     localPaint.setStrokeMiter(4.0F);
     localPaint.setPathEffect(null);
     c.a(localPaint, paramVarArgs).setStrokeWidth(1.0F);
     localCanvas.save();
     localObject2 = c.a((Paint) localObject2, paramVarArgs);
     ((Paint) localObject2).setColor(-8355712);
     localObject3 = c.a((float[]) localObject3, 1.0F, 0.0F, 15.0F, 0.0F, 1.0F, 18.0F);
     ((Matrix) localObject1).reset();
     ((Matrix) localObject1).setValues((float[]) localObject3);
     localCanvas.concat((Matrix) localObject1);
     localCanvas.saveLayerAlpha(null, 128, 4);
     localCanvas.save();
     localObject1 = c.a((Paint) localObject2, paramVarArgs);
     localObject3 = c.h(paramVarArgs);
     ((Path) localObject3).moveTo(45.0F, -3.5527137E-15F);
     ((Path) localObject3).cubicTo(52.34879F, 6.1744103F, 59.68439F, 12.328806F, 67.0F, 19.0F);
     ((Path) localObject3).cubicTo(59.704376F, 24.717655F, 52.3388F, 30.832024F, 45.0F, 37.0F);
     ((Path) localObject3).cubicTo(45.003197F, 33.33381F, 45.023186F, 29.661186F, 45.0F, 26.0F);
     ((Path) localObject3).cubicTo(38.3272F, 26.168692F, 31.08155F, 26.34882F, 25.0F, 30.0F);
     ((Path) localObject3).cubicTo(21.237457F, 33.02359F, 19.078753F, 37.666904F, 17.0F, 42.0F);
     ((Path) localObject3).cubicTo(17.209873F, 31.952824F, 20.138117F, 20.87491F, 29.0F, 15.0F);
     ((Path) localObject3).cubicTo(33.270237F, 11.037884F, 39.36658F, 10.717655F, 45.0F, 11.0F);
     ((Path) localObject3)
         .cubicTo(45.023186F, 7.345247F, 45.003197F, 3.6726234F, 45.0F, -3.5527137E-15F);
     ((Path) localObject3).lineTo(45.0F, -3.5527137E-15F);
     ((Path) localObject3).close();
     WeChatSVGRenderC2Java.setFillType((Path) localObject3, 2);
     localCanvas.drawPath((Path) localObject3, (Paint) localObject1);
     localCanvas.restore();
     localCanvas.save();
     localObject1 = c.a((Paint) localObject2, paramVarArgs);
     localObject2 = c.h(paramVarArgs);
     ((Path) localObject2).moveTo(-3.5527137E-15F, 15.0F);
     ((Path) localObject2).cubicTo(-0.25992802F, 13.123616F, 0.9487858F, 10.94681F, 3.0F, 11.0F);
     ((Path) localObject2).cubicTo(8.960261F, 10.916854F, 14.983851F, 11.076619F, 21.0F, 11.0F);
     ((Path) localObject2).cubicTo(19.209354F, 13.133601F, 17.690971F, 15.480158F, 16.0F, 18.0F);
     ((Path) localObject2).cubicTo(13.345594F, 18.00645F, 10.198943F, 18.00645F, 7.0F, 18.0F);
     ((Path) localObject2).cubicTo(7.0423017F, 29.31985F, 7.0423017F, 40.63325F, 7.0F, 52.0F);
     ((Path) localObject2).cubicTo(22.356007F, 51.956635F, 37.669712F, 51.956635F, 53.0F, 52.0F);
     ((Path) localObject2).cubicTo(53.003395F, 48.002438F, 52.983418F, 44.058224F, 53.0F, 40.0F);
     ((Path) localObject2).cubicTo(55.32093F, 38.126926F, 57.658443F, 36.1698F, 60.0F, 34.0F);
     ((Path) localObject2).cubicTo(59.92603F, 41.49199F, 60.085857F, 48.79128F, 60.0F, 56.0F);
     ((Path) localObject2).cubicTo(59.985966F, 58.057682F, 57.85823F, 59.275894F, 56.0F, 59.0F);
     ((Path) localObject2).cubicTo(38.348988F, 58.916424F, 20.617857F, 59.016273F, 3.0F, 59.0F);
     ((Path) localObject2)
         .cubicTo(0.89883894F, 58.996304F, -0.25992802F, 56.779556F, -3.5527137E-15F, 55.0F);
     ((Path) localObject2)
         .cubicTo(0.049742464F, 41.64177F, 0.039753094F, 28.271389F, -3.5527137E-15F, 15.0F);
     ((Path) localObject2).lineTo(-3.5527137E-15F, 15.0F);
     ((Path) localObject2).close();
     WeChatSVGRenderC2Java.setFillType((Path) localObject2, 2);
     localCanvas.drawPath((Path) localObject2, (Paint) localObject1);
     localCanvas.restore();
     localCanvas.restore();
     localCanvas.restore();
     c.f(paramVarArgs);
   }
 }
Exemplo n.º 15
0
  void draw(Canvas var1) {
    int var4 = this.mBounds.width();
    int var9 = this.mBounds.height();
    int var7 = var4 / 2;
    int var8 = var9 / 2;
    boolean var6 = false;
    int var5 = var1.save();
    var1.clipRect(this.mBounds);
    if (!this.mRunning && this.mFinishTime <= 0L) {
      var4 = var5;
      if (this.mTriggerPercentage > 0.0F) {
        var4 = var5;
        if ((double) this.mTriggerPercentage <= 1.0D) {
          this.drawTrigger(var1, var7, var8);
          var4 = var5;
        }
      }
    } else {
      long var10 = AnimationUtils.currentAnimationTimeMillis();
      long var12 = this.mStartTime;
      long var14 = (var10 - this.mStartTime) / 2000L;
      float var2 = (float) ((var10 - var12) % 2000L) / 20.0F;
      float var3;
      if (!this.mRunning) {
        if (var10 - this.mFinishTime >= 1000L) {
          this.mFinishTime = 0L;
          return;
        }

        var3 = (float) ((var10 - this.mFinishTime) % 1000L) / 10.0F / 100.0F;
        var3 = (float) (var4 / 2) * INTERPOLATOR.getInterpolation(var3);
        this.mClipRect.set((float) var7 - var3, 0.0F, (float) var7 + var3, (float) var9);
        var1.saveLayerAlpha(this.mClipRect, 0, 0);
        var6 = true;
      }

      if (var14 == 0L) {
        var1.drawColor(this.mColor1);
      } else if (var2 >= 0.0F && var2 < 25.0F) {
        var1.drawColor(this.mColor4);
      } else if (var2 >= 25.0F && var2 < 50.0F) {
        var1.drawColor(this.mColor1);
      } else if (var2 >= 50.0F && var2 < 75.0F) {
        var1.drawColor(this.mColor2);
      } else {
        var1.drawColor(this.mColor3);
      }

      if (var2 >= 0.0F && var2 <= 25.0F) {
        var3 = (25.0F + var2) * 2.0F / 100.0F;
        this.drawCircle(var1, (float) var7, (float) var8, this.mColor1, var3);
      }

      if (var2 >= 0.0F && var2 <= 50.0F) {
        var3 = 2.0F * var2 / 100.0F;
        this.drawCircle(var1, (float) var7, (float) var8, this.mColor2, var3);
      }

      if (var2 >= 25.0F && var2 <= 75.0F) {
        var3 = (var2 - 25.0F) * 2.0F / 100.0F;
        this.drawCircle(var1, (float) var7, (float) var8, this.mColor3, var3);
      }

      if (var2 >= 50.0F && var2 <= 100.0F) {
        var3 = (var2 - 50.0F) * 2.0F / 100.0F;
        this.drawCircle(var1, (float) var7, (float) var8, this.mColor4, var3);
      }

      if (var2 >= 75.0F && var2 <= 100.0F) {
        var2 = (var2 - 75.0F) * 2.0F / 100.0F;
        this.drawCircle(var1, (float) var7, (float) var8, this.mColor1, var2);
      }

      var4 = var5;
      if (this.mTriggerPercentage > 0.0F) {
        var4 = var5;
        if (var6) {
          var1.restoreToCount(var5);
          var4 = var1.save();
          var1.clipRect(this.mBounds);
          this.drawTrigger(var1, var7, var8);
        }
      }

      ViewCompat.postInvalidateOnAnimation(
          this.mParent,
          this.mBounds.left,
          this.mBounds.top,
          this.mBounds.right,
          this.mBounds.bottom);
    }

    var1.restoreToCount(var4);
  }
  @Override
  protected void dispatchDraw(Canvas canvas) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
      scrollChanged(getFirstVisiblePosition());
    }

    boolean drawStickiedHeader =
        mStickiedHeader != null
            && mAreHeadersSticky
            && mStickiedHeader.getVisibility() == View.VISIBLE;
    int headerHeight = getHeaderHeight();
    int top = mHeaderBottomPosition - headerHeight;

    // Mask the region where we will draw the header later, but only if we
    // will draw a header and masking is requested.
    if (drawStickiedHeader && mMaskStickyHeaderRegion) {
      if (mHeadersIgnorePadding) {
        mClippingRect.left = 0;
        mClippingRect.right = getWidth();
      } else {
        mClippingRect.left = getPaddingLeft();
        mClippingRect.right = getWidth() - getPaddingRight();
      }
      mClippingRect.top = mHeaderBottomPosition;
      mClippingRect.bottom = getHeight();

      canvas.save();
      canvas.clipRect(mClippingRect);
    }

    // ...and draw the grid view.
    super.dispatchDraw(canvas);

    // Find headers.
    List<Integer> headerPositions = new ArrayList<Integer>();
    int vi = 0;
    for (int i = getFirstVisiblePosition(); i <= getLastVisiblePosition(); ) {
      long id = getItemIdAtPosition(i);
      if (id == StickyGridHeadersBaseAdapterWrapper.ID_HEADER) {
        headerPositions.add(vi);
      }
      i += mNumMeasuredColumns;
      vi += mNumMeasuredColumns;
    }

    // Draw headers in list.
    for (int i = 0; i < headerPositions.size(); i++) {
      View frame = getChildAt(headerPositions.get(i));
      View header;
      try {
        header = (View) frame.getTag();
      } catch (Exception e) {
        return;
      }

      boolean headerIsStickied =
          ((HeaderFillerView) frame).getHeaderId() == mCurrentHeaderId
              && frame.getTop() < 0
              && mAreHeadersSticky;
      if (header.getVisibility() != View.VISIBLE || headerIsStickied) {
        continue;
      }

      int widthMeasureSpec;
      if (mHeadersIgnorePadding) {
        widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY);
      } else {
        widthMeasureSpec =
            MeasureSpec.makeMeasureSpec(
                getWidth() - getPaddingLeft() - getPaddingRight(), MeasureSpec.EXACTLY);
      }

      int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
      header.measure(MeasureSpec.makeMeasureSpec(0, 0), MeasureSpec.makeMeasureSpec(0, 0));
      header.measure(widthMeasureSpec, heightMeasureSpec);

      if (mHeadersIgnorePadding) {
        header.layout(getLeft(), 0, getRight(), frame.getHeight());
      } else {
        header.layout(
            getLeft() + getPaddingLeft(), 0, getRight() - getPaddingRight(), frame.getHeight());
      }

      if (mHeadersIgnorePadding) {
        mClippingRect.left = 0;
        mClippingRect.right = getWidth();
      } else {
        mClippingRect.left = getPaddingLeft();
        mClippingRect.right = getWidth() - getPaddingRight();
      }

      mClippingRect.bottom = frame.getBottom();
      mClippingRect.top = frame.getTop();
      canvas.save();
      canvas.clipRect(mClippingRect);
      if (mHeadersIgnorePadding) {
        canvas.translate(0, frame.getTop());
      } else {
        canvas.translate(getPaddingLeft(), frame.getTop());
      }
      header.draw(canvas);
      canvas.restore();
    }

    if (drawStickiedHeader && mMaskStickyHeaderRegion) {
      canvas.restore();
    } else if (!drawStickiedHeader) {
      // Done.
      return;
    }

    // Draw stickied header.
    int wantedWidth;
    if (mHeadersIgnorePadding) {
      wantedWidth = getWidth();
    } else {
      wantedWidth = getWidth() - getPaddingLeft() - getPaddingRight();
    }
    if (mStickiedHeader.getWidth() != wantedWidth) {
      int widthMeasureSpec;
      if (mHeadersIgnorePadding) {
        widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY);
      } else {
        widthMeasureSpec =
            MeasureSpec.makeMeasureSpec(
                getWidth() - getPaddingLeft() - getPaddingRight(), MeasureSpec.EXACTLY); // Bug here
      }
      int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
      mStickiedHeader.measure(MeasureSpec.makeMeasureSpec(0, 0), MeasureSpec.makeMeasureSpec(0, 0));
      mStickiedHeader.measure(widthMeasureSpec, heightMeasureSpec);
      if (mHeadersIgnorePadding) {
        mStickiedHeader.layout(getLeft(), 0, getRight(), mStickiedHeader.getHeight());
      } else {
        mStickiedHeader.layout(
            getLeft() + getPaddingLeft(),
            0,
            getRight() - getPaddingRight(),
            mStickiedHeader.getHeight());
      }
    }

    if (mHeadersIgnorePadding) {
      mClippingRect.left = 0;
      mClippingRect.right = getWidth();
    } else {
      mClippingRect.left = getPaddingLeft();
      mClippingRect.right = getWidth() - getPaddingRight();
    }
    mClippingRect.bottom = top + headerHeight;
    if (mClippingToPadding) {
      mClippingRect.top = getPaddingTop();
    } else {
      mClippingRect.top = 0;
    }

    canvas.save();
    canvas.clipRect(mClippingRect);

    if (mHeadersIgnorePadding) {
      canvas.translate(0, top);
    } else {
      canvas.translate(getPaddingLeft(), top);
    }

    if (mHeaderBottomPosition != headerHeight) {
      canvas.saveLayerAlpha(
          0,
          0,
          canvas.getWidth(),
          canvas.getHeight(),
          255 * mHeaderBottomPosition / headerHeight,
          Canvas.ALL_SAVE_FLAG);
    }

    mStickiedHeader.draw(canvas);

    if (mHeaderBottomPosition != headerHeight) {
      canvas.restore();
    }
    canvas.restore();
  }
    void draw(Canvas canvas) {
      final int width = mBounds.width();
      final int height = mBounds.height();
      final int cx = width / 2;
      final int cy = height / 2;
      boolean drawTriggerWhileFinishing = false;
      int restoreCount = canvas.save();
      canvas.clipRect(mBounds);

      if (mRunning || (mFinishTime > 0)) {
        long now = AnimationUtils.currentAnimationTimeMillis();
        long elapsed = (now - mStartTime) % ANIMATION_DURATION_MS;
        long iterations = (now - mStartTime) / ANIMATION_DURATION_MS;
        float rawProgress = (elapsed / (ANIMATION_DURATION_MS / 100f));

        // If we're not running anymore, that means we're running through
        // the finish animation.
        if (!mRunning) {
          // If the finish animation is done, don't draw anything, and
          // don't repost.
          if ((now - mFinishTime) >= FINISH_ANIMATION_DURATION_MS) {
            mFinishTime = 0;
            return;
          }

          // Otherwise, use a 0 opacity alpha layer to clear the animation
          // from the inside out. This layer will prevent the circles from
          // drawing within its bounds.
          long finishElapsed = (now - mFinishTime) % FINISH_ANIMATION_DURATION_MS;
          float finishProgress = (finishElapsed / (FINISH_ANIMATION_DURATION_MS / 100f));
          float pct = (finishProgress / 100f);
          // Radius of the circle is half of the screen.
          float clearRadius = width / 2 * INTERPOLATOR.getInterpolation(pct);
          mClipRect.set(cx - clearRadius, 0, cx + clearRadius, height);
          canvas.saveLayerAlpha(mClipRect, 0, 0);
          // Only draw the trigger if there is a space in the center of
          // this refreshing view that needs to be filled in by the
          // trigger. If the progress view is just still animating, let it
          // continue animating.
          drawTriggerWhileFinishing = true;
        }

        // First fill in with the last color that would have finished drawing.
        if (iterations == 0) {
          canvas.drawColor(mColor1);
        } else {
          if (rawProgress >= 0 && rawProgress < 25) {
            canvas.drawColor(mColor4);
          } else if (rawProgress >= 25 && rawProgress < 50) {
            canvas.drawColor(mColor1);
          } else if (rawProgress >= 50 && rawProgress < 75) {
            canvas.drawColor(mColor2);
          } else {
            canvas.drawColor(mColor3);
          }
        }

        // Then draw up to 4 overlapping concentric circles of varying radii, based on how far
        // along we are in the cycle.
        // progress 0-50 draw mColor2
        // progress 25-75 draw mColor3
        // progress 50-100 draw mColor4
        // progress 75 (wrap to 25) draw mColor1
        if ((rawProgress >= 0 && rawProgress <= 25)) {
          float pct = (((rawProgress + 25) * 2) / 100f);
          drawCircle(canvas, cx, cy, mColor1, pct);
        }
        if (rawProgress >= 0 && rawProgress <= 50) {
          float pct = ((rawProgress * 2) / 100f);
          drawCircle(canvas, cx, cy, mColor2, pct);
        }
        if (rawProgress >= 25 && rawProgress <= 75) {
          float pct = (((rawProgress - 25) * 2) / 100f);
          drawCircle(canvas, cx, cy, mColor3, pct);
        }
        if (rawProgress >= 50 && rawProgress <= 100) {
          float pct = (((rawProgress - 50) * 2) / 100f);
          drawCircle(canvas, cx, cy, mColor4, pct);
        }
        if ((rawProgress >= 75 && rawProgress <= 100)) {
          float pct = (((rawProgress - 75) * 2) / 100f);
          drawCircle(canvas, cx, cy, mColor1, pct);
        }
        if (mTriggerPercentage > 0 && drawTriggerWhileFinishing) {
          // There is some portion of trigger to draw. Restore the canvas,
          // then draw the trigger. Otherwise, the trigger does not appear
          // until after the bar has finished animating and appears to
          // just jump in at a larger width than expected.
          canvas.restoreToCount(restoreCount);
          restoreCount = canvas.save();
          canvas.clipRect(mBounds);
          drawTrigger(canvas, cx, cy);
        }
        // Keep running until we finish out the last cycle.
        ViewCompat.postInvalidateOnAnimation(mParent);
      } else {
        // Otherwise if we're in the middle of a trigger, draw that.
        if (mTriggerPercentage > 0 && mTriggerPercentage <= 1.0) {
          drawTrigger(canvas, cx, cy);
        }
      }
      canvas.restoreToCount(restoreCount);
    }
Exemplo n.º 18
0
 void draw(Canvas paramCanvas) {
   int i = this.mBounds.width();
   int i1 = this.mBounds.height();
   int m = i / 2;
   int n = i1 / 2;
   int k = 0;
   int j = paramCanvas.save();
   paramCanvas.clipRect(this.mBounds);
   float f1;
   if ((this.mRunning) || (this.mFinishTime > 0L)) {
     long l1 = AnimationUtils.currentAnimationTimeMillis();
     long l2 = this.mStartTime;
     long l3 = (l1 - this.mStartTime) / 2000L;
     f1 = (float) ((l1 - l2) % 2000L) / 20.0F;
     float f2;
     if (!this.mRunning) {
       if (l1 - this.mFinishTime >= 1000L) {
         this.mFinishTime = 0L;
         return;
       }
       f2 = (float) ((l1 - this.mFinishTime) % 1000L) / 10.0F / 100.0F;
       f2 = i / 2 * INTERPOLATOR.getInterpolation(f2);
       this.mClipRect.set(m - f2, 0.0F, m + f2, i1);
       paramCanvas.saveLayerAlpha(this.mClipRect, 0, 0);
       k = 1;
     }
     if (l3 == 0L) {
       paramCanvas.drawColor(this.mColor1);
       if ((f1 >= 0.0F) && (f1 <= 25.0F)) {
         f2 = (25.0F + f1) * 2.0F / 100.0F;
         drawCircle(paramCanvas, m, n, this.mColor1, f2);
       }
       if ((f1 >= 0.0F) && (f1 <= 50.0F)) {
         f2 = 2.0F * f1 / 100.0F;
         drawCircle(paramCanvas, m, n, this.mColor2, f2);
       }
       if ((f1 >= 25.0F) && (f1 <= 75.0F)) {
         f2 = (f1 - 25.0F) * 2.0F / 100.0F;
         drawCircle(paramCanvas, m, n, this.mColor3, f2);
       }
       if ((f1 >= 50.0F) && (f1 <= 100.0F)) {
         f2 = (f1 - 50.0F) * 2.0F / 100.0F;
         drawCircle(paramCanvas, m, n, this.mColor4, f2);
       }
       if ((f1 >= 75.0F) && (f1 <= 100.0F)) {
         f1 = (f1 - 75.0F) * 2.0F / 100.0F;
         drawCircle(paramCanvas, m, n, this.mColor1, f1);
       }
       i = j;
       if (this.mTriggerPercentage > 0.0F) {
         i = j;
         if (k != 0) {
           paramCanvas.restoreToCount(j);
           i = paramCanvas.save();
           paramCanvas.clipRect(this.mBounds);
           drawTrigger(paramCanvas, m, n);
         }
       }
       ViewCompat.postInvalidateOnAnimation(
           this.mParent,
           this.mBounds.left,
           this.mBounds.top,
           this.mBounds.right,
           this.mBounds.bottom);
     }
   }
   while (true) {
     paramCanvas.restoreToCount(i);
     return;
     if ((f1 >= 0.0F) && (f1 < 25.0F)) {
       paramCanvas.drawColor(this.mColor4);
       break;
     }
     if ((f1 >= 25.0F) && (f1 < 50.0F)) {
       paramCanvas.drawColor(this.mColor1);
       break;
     }
     if ((f1 >= 50.0F) && (f1 < 75.0F)) {
       paramCanvas.drawColor(this.mColor2);
       break;
     }
     paramCanvas.drawColor(this.mColor3);
     break;
     i = j;
     if (this.mTriggerPercentage <= 0.0F) continue;
     i = j;
     if (this.mTriggerPercentage > 1.0D) continue;
     drawTrigger(paramCanvas, m, n);
     i = j;
   }
 }