diff --git a/entry/src/main/java/com/wordplat/quickstart/wight/navigation/BottomNavigation.java b/entry/src/main/java/com/wordplat/quickstart/wight/navigation/BottomNavigation.java index 09b75c6e71604b4f9cf04b936f23cf10624bef36..5583d05bb9f239bbdbdcea891c88098c3ac0cf57 100644 --- a/entry/src/main/java/com/wordplat/quickstart/wight/navigation/BottomNavigation.java +++ b/entry/src/main/java/com/wordplat/quickstart/wight/navigation/BottomNavigation.java @@ -220,9 +220,9 @@ public class BottomNavigation extends Component implements Component.DrawTask, C selectBackgroundPaint.setColor(new Color(0x17000000)); canvas.drawRect( new RectFloat( - (float) ((double) getCurrentCenterX(mPosition, mPosition) - (double) selectedItemWidth / (double) 2), + getCurrentCenterX(mPosition, mPosition) - selectedItemWidth / 2, 0, - (float) ((double) getCurrentCenterX(mPosition, mPosition) + (double) selectedItemWidth / (double) 2), + getCurrentCenterX(mPosition, mPosition) + selectedItemWidth / 2, bottomNavigationHeight), selectBackgroundPaint); } @@ -237,38 +237,37 @@ public class BottomNavigation extends Component implements Component.DrawTask, C topOff = alwaysShowTopInactive; } else if (i == mPosition) { topOff = - (float) ((double) alwaysShowTopInactive - + ((double) alwaysShowTopActive - (double) alwaysShowTopInactive) * (double) changePose); + alwaysShowTopInactive + + (alwaysShowTopActive - alwaysShowTopInactive) * changePose; } else if (i == lastPosition) { topOff = - (float) ((double) alwaysShowTopActive - + ((double) alwaysShowTopInactive - (double) alwaysShowTopActive) * (double) changePose); + alwaysShowTopActive + + (alwaysShowTopInactive - alwaysShowTopActive) * changePose; } } else { if (i != lastPosition && i != mPosition) { topOff = showWhenActiveForceTopInactive; } else if (i == mPosition) { topOff = - (float) ((double) showWhenActiveForceTopInactive - + ((double) showWhenActiveForceTopActive - (double) showWhenActiveForceTopInactive) - * (double) changePose); + showWhenActiveForceTopInactive + + (showWhenActiveForceTopActive - showWhenActiveForceTopInactive) + * changePose; } else if (i == lastPosition) { topOff = - (float) ((double) showWhenActiveForceTopActive - + ((double) showWhenActiveForceTopInactive - (double) showWhenActiveForceTopActive) - * (double) changePose); + showWhenActiveForceTopActive + + (showWhenActiveForceTopInactive - showWhenActiveForceTopActive) + * changePose; } } PixelMap pixelMap = bottomNavigationItem.getOrgPixelMap(); float centerX = - (float) (getCurrentCenterX(i, lastPosition) + getCurrentCenterX(i, lastPosition) + (getCurrentCenterX(i, mPosition) - getCurrentCenterX(i, lastPosition)) - * (double) changePose); + * changePose; if (touchEffect && i == downPosition) { mPaint.setColor(new Color(0x20000000)); - canvas.drawCircle( - centerX, bottomNavigationHeight / (float)2, (float) ((double) notSelectedItemWidth * (double) 0.6f), mPaint); + centerX, bottomNavigationHeight / 2, notSelectedItemWidth * 0.6f, mPaint); } if (forceTint) { @@ -300,18 +299,18 @@ public class BottomNavigation extends Component implements Component.DrawTask, C if (pixelMap != null) { RectFloat rectFloat = new RectFloat(); rectFloat.left = - (float) (getCurrentCenterX(i, lastPosition) + getCurrentCenterX(i, lastPosition) + (getCurrentCenterX(i, mPosition) - getCurrentCenterX(i, lastPosition)) - * (double) changePose - - (double) iconSize / 2); + * changePose + - iconSize / 2; rectFloat.right = - (float) (getCurrentCenterX(i, lastPosition) + getCurrentCenterX(i, lastPosition) + (getCurrentCenterX(i, mPosition) - getCurrentCenterX(i, lastPosition)) - * (double) changePose - + (double) iconSize / 2); + * changePose + + iconSize / 2; rectFloat.top = topOff; - rectFloat.bottom = (float) ((double) topOff + (double) iconSize); + rectFloat.bottom = topOff + iconSize; mPaint.setColor(new Color(0xffffffff)); canvas.drawPixelMapHolderRect( new PixelMapHolder(pixelMap), @@ -343,9 +342,9 @@ public class BottomNavigation extends Component implements Component.DrawTask, C if (i != lastPosition && i != mPosition) { textSize = inactiveSize; } else if (i == mPosition) { - textSize = (float) ((double) inactiveSize + ((double) activeSize - (double) inactiveSize) * (double) changePose); + textSize = inactiveSize + (activeSize - inactiveSize) * changePose; } else if (i == lastPosition) { - textSize = (float) ((double) activeSize + ((double) inactiveSize - (double) activeSize) * (double) changePose); + textSize = activeSize + (inactiveSize - activeSize) * changePose; } } else { textSize = activeSize; @@ -354,19 +353,19 @@ public class BottomNavigation extends Component implements Component.DrawTask, C } else if (i == mPosition) { alpha = changePose * alpha; } else if (i == lastPosition) { - alpha = (float) ((1 - (double) changePose) * (double) alpha); + alpha = (1 - changePose) * alpha; } } if (alpha != 0) { mTextPaint.setAlpha(alpha); mTextPaint.setTextSize((int) textSize); float textWidth = mTextPaint.measureText(bottomNavigationItem.getTitle()); - float textHeight = (float) ((double) mTextPaint.descent() - (double) mTextPaint.ascent()); + float textHeight = mTextPaint.descent() - mTextPaint.ascent(); canvas.drawText( mTextPaint, bottomNavigationItem.getTitle(), - (float) ((double) centerX - (double) (textWidth / 2)), - (float) ((double) textCenterY + (double) textHeight / (double) 4)); + centerX - textWidth / 2, + textCenterY + textHeight / 4); } } @@ -386,26 +385,26 @@ public class BottomNavigation extends Component implements Component.DrawTask, C if (!notification.isEmpty()) { float textWidth = notificationTextPaint.measureText(notification.getText()); - float textHeight = (float) ((double) notificationTextPaint.descent() - (double) notificationTextPaint.ascent()); + float textHeight = notificationTextPaint.descent() - notificationTextPaint.ascent(); float notificationCenterX = centerX; - float marginTop = (float) ((double) topOff + (double) notificationMarginTop); - notificationCenterX = (float) ((double) centerX + (double) notificationMarginLeft); + float marginTop = topOff + notificationMarginTop; + notificationCenterX = centerX + notificationMarginLeft; RectFloat rectFloat = new RectFloat(); if (textWidth > textHeight) { - rectFloat.left = (float) ((double) notificationCenterX - (double) textWidth / (double) 2 - (double) dp2px(1)); - rectFloat.right = (float) ((double) notificationCenterX + (double) textWidth / (double) 2 + (double) dp2px(1)); + rectFloat.left = notificationCenterX - textWidth / 2 - dp2px(1); + rectFloat.right = notificationCenterX + textWidth / 2 + dp2px(1); } else { - rectFloat.left = (float) ((double) notificationCenterX - (double) textHeight / (double) 2 - (double) dp2px(1)); - rectFloat.right = (float) ((double) notificationCenterX + (double) textHeight / (double) 2 + (double) dp2px(1)); + rectFloat.left = notificationCenterX - textHeight / 2 - dp2px(1); + rectFloat.right = notificationCenterX + textHeight / 2 + dp2px(1); } - rectFloat.top = (float) ((double) marginTop - (double) dp2px(1)); - rectFloat.bottom = (float) ((double) marginTop + (double) textHeight + (double) dp2px(1)); + rectFloat.top = marginTop - dp2px(1); + rectFloat.bottom = marginTop + textHeight + dp2px(1); canvas.drawRoundRect(rectFloat, dp2px(8), dp2px(8), notificationBackgroundPaint); canvas.drawText( notificationTextPaint, notification.getText(), - (float) ((double) notificationCenterX - (double) textWidth / (double) 2), - (float) ((double) marginTop + (double) textHeight * (double) 3 / (double) 4)); + notificationCenterX - textWidth / 2, + marginTop + textHeight * 3 / 4); } } } @@ -503,7 +502,7 @@ public class BottomNavigation extends Component implements Component.DrawTask, C mOverPaint); canvas.drawCircle( getCurrentCenterX(mPosition, mPosition), - (float) ((double) bottomNavigationHeight / 2), + bottomNavigationHeight / 2, getWidth() * overPose, mOverPaint); canvas.restore(); @@ -941,7 +940,7 @@ public class BottomNavigation extends Component implements Component.DrawTask, C new AnimatorValue.ValueUpdateListener() { @Override public void onUpdate(AnimatorValue animatorValue, float v) { - showBottom = (int) ((double) start + ((double) end - (double) start) * (double) v); + showBottom = (int) (start + (end - start) * v); ComponentContainer.LayoutConfig layoutConfig = getLayoutConfig(); layoutConfig.setMarginBottom(-showBottom); setLayoutConfig(layoutConfig); @@ -1233,14 +1232,14 @@ public class BottomNavigation extends Component implements Component.DrawTask, C return; } - double itemWidth = layoutWidth / (double)items.size(); + float itemWidth = layoutWidth / items.size(); if (itemWidth < minWidth) { itemWidth = minWidth; } else if (itemWidth > maxWidth) { itemWidth = maxWidth; } - selectedItemWidth = (float) itemWidth; - notSelectedItemWidth = (float) itemWidth; + selectedItemWidth = itemWidth; + notSelectedItemWidth = itemWidth; } else { float minWidth = dp2px(64); float maxWidth = dp2px(96); @@ -1250,7 +1249,7 @@ public class BottomNavigation extends Component implements Component.DrawTask, C return; } - float itemWidth = layoutWidth / (float)items.size(); + float itemWidth = layoutWidth / items.size(); if (itemWidth < minWidth) { itemWidth = minWidth; @@ -1259,8 +1258,8 @@ public class BottomNavigation extends Component implements Component.DrawTask, C } float difference = dp2px(10); - selectedItemWidth = (float) ((double) itemWidth + (double) items.size() * (double) difference); - itemWidth -= (double) difference; + selectedItemWidth = itemWidth + items.size() * difference; + itemWidth -= difference; notSelectedItemWidth = itemWidth; if (titleState == TitleState.ALWAYS_HIDE) { @@ -1269,7 +1268,7 @@ public class BottomNavigation extends Component implements Component.DrawTask, C } } - offsetX = (float) (((double) getWidth() - ((double) selectedItemWidth + (double) notSelectedItemWidth * ((double) items.size() - (double) 1))) / (double) 2); + offsetX = (getWidth() - (selectedItemWidth + notSelectedItemWidth * (items.size() - 1))) / 2; } private int getCurrentCenterX(int index, int selectIndex) { @@ -1278,15 +1277,15 @@ public class BottomNavigation extends Component implements Component.DrawTask, C for (int i = 0; i < items.size() && i <= index; i++) { if (index == i) { if (selectIndex == i) { - x += (double) selectedItemWidth / (double) 2; + x += selectedItemWidth / 2; } else { - x += (double) notSelectedItemWidth / (double) 2; + x += notSelectedItemWidth / 2; } } else { if (selectIndex == i) { - x += (double) selectedItemWidth; + x += selectedItemWidth; } else { - x += (double) notSelectedItemWidth; + x += notSelectedItemWidth; } } } @@ -1355,7 +1354,7 @@ public class BottomNavigation extends Component implements Component.DrawTask, C if (touchEvent.getPointerCount() > index) { int[] xy = getLocationOnScreen(); if (xy != null && xy.length == 2) { - y = (float) ((double) touchEvent.getPointerScreenPosition(index).getY() - xy[1]); + y = touchEvent.getPointerScreenPosition(index).getY() - xy[1]; } else { y = touchEvent.getPointerPosition(index).getY(); } @@ -1370,6 +1369,6 @@ public class BottomNavigation extends Component implements Component.DrawTask, C * @return int */ protected int dp2px(float dp) { - return (int) (getResourceManager().getDeviceCapability().screenDensity / (double)(160 * dp)); + return (int) (getResourceManager().getDeviceCapability().screenDensity / 160 * dp); } } diff --git a/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/drawing/BOLLDrawing.java b/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/drawing/BOLLDrawing.java index 7d065353c8e4fe8520b258cb1e40aba0a1fc2e98..6b3e773080a2e7de8cf652aeb31e94707997b87d 100644 --- a/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/drawing/BOLLDrawing.java +++ b/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/drawing/BOLLDrawing.java @@ -111,9 +111,9 @@ public class BOLLDrawing implements IDrawing { final int i = currentIndex - minIndex; if (currentIndex < maxIndex - 1) { - xPointBuffer[i * 4 + 0] = (float) ((double)currentIndex + (double)0.5f); + xPointBuffer[i * 4 + 0] = currentIndex + 0.5f; xPointBuffer[i * 4 + 1] = 0; - xPointBuffer[i * 4 + 2] = (float) ((double)currentIndex + (double)1 + (double)0.5f); + xPointBuffer[i * 4 + 2] = currentIndex + 1 + 0.5f; xPointBuffer[i * 4 + 3] = 0; r1Buffer[i * 4 + 0] = 0; @@ -141,7 +141,7 @@ public class BOLLDrawing implements IDrawing { canvas.drawRect(indexRect, axisPaint); gridBuffer[0] = 0; - gridBuffer[1] = (float) (((double)maxY + (double)minY) / (double)2); + gridBuffer[1] = (maxY + minY) / 2; render.mapPoints(null, gridBuffer); canvas.drawLine(indexRect.left, gridBuffer[1], indexRect.right, gridBuffer[1], axisPaint); diff --git a/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/drawing/CandleDrawing.java b/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/drawing/CandleDrawing.java index 14b2791b115882f67dcfe7a46e027cd57b8cbd6d..7ede4679cc16146f03fa50ca26b023b2c3975041 100644 --- a/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/drawing/CandleDrawing.java +++ b/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/drawing/CandleDrawing.java @@ -122,10 +122,10 @@ public class CandleDrawing implements IDrawing { Entry entry = ViewUtils.setUpCandlePaint(candlePaint, entrySet, iindex, sizeColor); // 绘制 影线 - candleLineBuffer[0] = (float) ((double) iindex + (double) 0.5f); - candleLineBuffer[2] = (float) ((double) iindex + (double) 0.5f); - candleLineBuffer[4] = (float) ((double) iindex + (double) 0.5f); - candleLineBuffer[6] = (float) ((double) iindex + (double) 0.5f); + candleLineBuffer[0] = iindex + 0.5f; + candleLineBuffer[2] = iindex + 0.5f; + candleLineBuffer[4] = iindex + 0.5f; + candleLineBuffer[6] = iindex + 0.5f; if (entry.getOpen() > entry.getClose()) { candleLineBuffer[1] = entry.getHigh(); candleLineBuffer[3] = entry.getOpen(); @@ -178,7 +178,7 @@ public class CandleDrawing implements IDrawing { * 绘制 蜡烛图的矩形 */ candleRectBuffer[0] = iindex + candleSpace; - candleRectBuffer[2] = iindex + 1 + candleSpace; + candleRectBuffer[2] = iindex + 1 - candleSpace; if (entry.getOpen() > entry.getClose()) { candleRectBuffer[1] = entry.getOpen(); diff --git a/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/entry/EntrySet.java b/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/entry/EntrySet.java index 803c23d7b6a880415113c03de92b9921063bc0ca..5fd633aab8b186916ad24f67520a5727ccf70e84 100644 --- a/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/entry/EntrySet.java +++ b/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/entry/EntrySet.java @@ -321,18 +321,18 @@ public class EntrySet { for (int i = 0; i < entries.size(); i++) { Entry entry = entries.get(i); - ma5 += (double)entry.getClose(); - ma10 += (double)entry.getClose(); - ma20 += (double)entry.getClose(); + ma5 += entry.getClose(); + ma10 += entry.getClose(); + ma20 += entry.getClose(); - volumeMa5 += (double)entry.getVolume(); - volumeMa10 += (double)entry.getVolume(); + volumeMa5 += entry.getVolume(); + volumeMa10 += entry.getVolume(); if (i >= 5) { - ma5 -= (double)entries.get(i - 5).getClose(); + ma5 -= entries.get(i - 5).getClose(); entry.setMa5(ma5 / 5f); - volumeMa5 -= (double)entries.get(i - 5).getVolume(); + volumeMa5 -= entries.get(i - 5).getVolume(); entry.setVolumeMa5(volumeMa5 / 5f); } else { entry.setMa5(ma5 / (i + 1f)); @@ -341,10 +341,10 @@ public class EntrySet { } if (i >= 10) { - ma10 -= (double)entries.get(i - 10).getClose(); + ma10 -= entries.get(i - 10).getClose(); entry.setMa10(ma10 / 10f); - volumeMa10 -= (double)entries.get(i - 10).getVolume(); + volumeMa10 -= entries.get(i - 10).getVolume(); entry.setVolumeMa10(volumeMa10 / 5f); } else { entry.setMa10(ma10 / (i + 1f)); @@ -353,7 +353,7 @@ public class EntrySet { } if (i >= 20) { - ma20 -= (double)entries.get(i - 20).getClose(); + ma20 -= entries.get(i - 20).getClose(); entry.setMa20(ma20 / 20f); } else { entry.setMa20(ma20 / (i + 1f)); diff --git a/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/marker/YAxisTextMarkerView.java b/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/marker/YAxisTextMarkerView.java index 81e71908bdee2a020d54cd2bf70590bebfd2709c..9d156dce89d3a3ebfc7eecce96207d4542f4e24e 100644 --- a/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/marker/YAxisTextMarkerView.java +++ b/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/marker/YAxisTextMarkerView.java @@ -106,9 +106,8 @@ public class YAxisTextMarkerView implements IMarkerView { String value = decimalFormatter.format(pointCache[1]); float width = markerTextPaint.measureText(value) + 50; - double y = highlightPointY; - double h = height / (double)2; - highlightPointY = (float) (y - h); + + highlightPointY = highlightPointY - height / 2; if (highlightPointY < contentRect.top) { highlightPointY = contentRect.top; } diff --git a/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/render/AbstractRender.java b/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/render/AbstractRender.java index e77b40f3643c10183071fdb06c38cd8704032229..712d33bf567fed72b3ce5abfe4685f707a566980 100644 --- a/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/render/AbstractRender.java +++ b/ikvStockChart/src/main/java/com/wordplat/ikvstockchart/render/AbstractRender.java @@ -303,12 +303,15 @@ public abstract class AbstractRender { * @return boolean */ public boolean canScroll(float dx) { - final double offset = (double) touchValues[MTRANS_X] - (double) dx; + final float offset = touchValues[MTRANS_X] - dx; if (-maxScrollOffset > offset && touchValues[MTRANS_X] <= -maxScrollOffset) { return false; } - return !(offset > minScrollOffset) || !(touchValues[MTRANS_X] >= minScrollOffset); + if (offset > minScrollOffset && touchValues[MTRANS_X] >= minScrollOffset) { + return false; + } + return true; } /** @@ -336,7 +339,7 @@ public abstract class AbstractRender { * @param dx 变化量 */ public void updateOverScrollOffset(float dx) { - overScrollOffset += (double) -dx; + overScrollOffset += -dx; } /** @@ -365,7 +368,7 @@ public abstract class AbstractRender { public void updateCurrentTransX(float dx) { matrixTouch.getData(); - touchValues[MTRANS_X] += (double) -dx; + touchValues[MTRANS_X] += -dx; matrixTouch.setMatrix(new Matrix(touchValues)); } @@ -398,7 +401,7 @@ public abstract class AbstractRender { matrixTouch.getData(); - return (float) ((double)touchValues[MTRANS_X] + (double)touchPts[0]); + return touchValues[MTRANS_X] + touchPts[0]; } /** @@ -409,7 +412,7 @@ public abstract class AbstractRender { public void scroll(float dx) { matrixTouch.getData(); - touchValues[MTRANS_X] += (double)-dx; + touchValues[MTRANS_X] += -dx; overScrollOffset = 0; if (touchValues[MTRANS_X] < -maxScrollOffset) { @@ -610,7 +613,7 @@ public abstract class AbstractRender { /** * 左滑加载完成之后定位到之前滚动的位置 */ - matrixTouch.postTranslate((float) ((double)touchValues[MTRANS_X] - ((double) maxScrollOffset - (double) lastMaxScrollOffset)), 0); + matrixTouch.postTranslate(touchValues[MTRANS_X] - (maxScrollOffset - lastMaxScrollOffset), 0); } else if (touchValues[MTRANS_X] < 0) { if (overScrollOffset != 0 && !viewRectChange) { @@ -663,7 +666,7 @@ public abstract class AbstractRender { if (entrySetSize <= visibleCount) { return 0; } - float result = (float) ((double)maxScrollOffset * (double)entryIndex / ((double)entrySetSize - (double)visibleCount)); + float result = maxScrollOffset * entryIndex / (entrySetSize - visibleCount); result = Math.min(maxScrollOffset, result); return -result; @@ -681,7 +684,7 @@ public abstract class AbstractRender { lastMaxScrollOffset = 0; maxScrollOffset = 0; } else { - maxScrollOffset = (float) ((double)width * ((double)scaleX - (double)1f)); + maxScrollOffset = width * (scaleX - 1f); } } @@ -706,8 +709,8 @@ public abstract class AbstractRender { * @param extremumYDelta extremumYDelta */ protected void computeExtremumValue(float[] extremumY, float minY, float deltaY, float extremumYScale, float extremumYDelta) { - final float deltaYScale = (float) ((double)deltaY * (double)extremumYScale - (double)deltaY); - extremumY[0] = (float) ((double)minY - ((double)deltaYScale / 2) - (double)extremumYDelta); - extremumY[1] = (float) ((double)deltaY +(double) deltaYScale + (double)extremumYDelta); + final float deltaYScale = deltaY * extremumYScale - deltaY; + extremumY[0] = minY - deltaYScale / 2 - extremumYDelta; + extremumY[1] = deltaY + deltaYScale + extremumYDelta; } }