MCPcopy Create free account
hub / github.com/cinit/TMoe / onDraw

Method onDraw

app/src/main/java/cc/ioctl/tmoe/ui/wrapper/component/Switch.java:347–516  ·  view source on GitHub ↗
(Canvas canvas)

Source from the content-addressed store, hash-verified

345 }
346
347 @Override
348 protected void onDraw(Canvas canvas) {
349 if (getVisibility() != VISIBLE) {
350 return;
351 }
352
353 int width = LayoutHelper.dp(31);
354 int thumb = LayoutHelper.dp(20);
355 int x = (getMeasuredWidth() - width) / 2;
356 float y = (getMeasuredHeight() - LayoutHelper.dpf2(14)) / 2;
357 int tx = x + LayoutHelper.dp(7) + (int) (LayoutHelper.dp(17) * progress);
358 int ty = getMeasuredHeight() / 2;
359
360
361 int color1;
362 int color2;
363 float colorProgress;
364 int r1;
365 int r2;
366 int g1;
367 int g2;
368 int b1;
369 int b2;
370 int a1;
371 int a2;
372 int red;
373 int green;
374 int blue;
375 int alpha;
376 int color;
377
378 for (int a = 0; a < 2; a++) {
379 if (a == 1 && overrideColorProgress == 0) {
380 continue;
381 }
382 Canvas canvasToDraw = a == 0 ? canvas : overlayCanvas[0];
383
384 if (a == 1) {
385 overlayBitmap[0].eraseColor(0);
386 paint.setColor(0xff000000);
387 overlayMaskCanvas.drawRect(0, 0, overlayMaskBitmap.getWidth(), overlayMaskBitmap.getHeight(), paint);
388 overlayMaskCanvas.drawCircle(overlayCx - getX(), overlayCy - getY(), overlayRad, overlayEraserPaint);
389 }
390 if (overrideColorProgress == 1) {
391 colorProgress = a == 0 ? 0 : 1;
392 } else if (overrideColorProgress == 2) {
393 colorProgress = a == 0 ? 1 : 0;
394 } else {
395 colorProgress = progress;
396 }
397
398 color1 = Theme.getColor(trackColorKey);
399 color2 = Theme.getColor(trackCheckedColorKey);
400 if (a == 0 && iconDrawable != null && lastIconColor != (isChecked ? color2 : color1)) {
401 iconDrawable.setColorFilter(new PorterDuffColorFilter(lastIconColor = (isChecked ? color2 : color1), PorterDuff.Mode.MULTIPLY));
402 }
403
404 r1 = Color.red(color1);

Callers

nothing calls this directly

Calls 10

dpMethod · 0.95
dpf2Method · 0.95
getColorMethod · 0.95
getIntrinsicWidthMethod · 0.80
getIntrinsicHeightMethod · 0.80
setColorFilterMethod · 0.45
setMethod · 0.45
drawMethod · 0.45
setAlphaMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected