Skip to content

Commit

Permalink
fix redraw and bg color
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed Nov 14, 2022
1 parent 82ab710 commit 15e8f7a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 1.0.0
version: 1.0.1
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86 x86_64
description: ti.lines
Expand Down
1 change: 1 addition & 0 deletions android/src/ti/lines/LineProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ private void clear() {
@Kroll.method
private void redraw() {
if (view != null) {
view.clear();
view.setPoints(points);
}
}
Expand Down
7 changes: 4 additions & 3 deletions android/src/ti/lines/LineView.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.graphics.Shader;
import android.view.View;

import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiDimension;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiConvert;
Expand Down Expand Up @@ -107,10 +108,10 @@ public void setPoints(Object[] pointObject) {
if (fillSpace) {
pathHeight = (viewHeight / maxValue) * localMax + 10;
paintBackground.setStyle(Paint.Style.FILL);
paintBackground.setShader(new LinearGradient(0, 0, 0, pathHeight, new int[]{
paintBackground.setShader(new LinearGradient(0, viewHeight - pathHeight, 0, viewHeight, new int[]{
Color.parseColor("#FF8310"),
Color.argb(0, 253, 200, 48)
}, null, Shader.TileMode.REPEAT));
}, null, Shader.TileMode.CLAMP));
}

int stepX = (viewWidth / (points.length - 1));
Expand Down Expand Up @@ -214,7 +215,7 @@ public void clear() {
pathAxis = new Path();
pathYLines = new Path();

tiPaintView.clear();
//tiPaintView.clear();
}

public class PaintView extends View {
Expand Down
20 changes: 12 additions & 8 deletions example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ outerView.add(Ti.UI.createLabel({
fontSize: 14
}
}));
outerView.add(Ti.UI.createLabel({
bottom: 15,
right: 14,
color: "#000",
text: "click to change",
font: {
fontWeight:"bold",
fontSize: 12
}
}));

win.add(outerView);
win.add(lines.createLine({
Expand Down Expand Up @@ -173,13 +183,7 @@ win.addEventListener("open", function() {
straightLines.redraw()
})

var clear = false;
lineView.addEventListener("click", function() {
if (!clear) {
lineView.clear();
} else {
lineView.values = [1, 1, 4, 2, 5, 3, 2, 1, 1, 2, 4]
lineView.redraw()
}
clear = !clear;
lineView.values = lineView.values.map(() => Math.floor(Math.random() * 8));
lineView.redraw()
})

0 comments on commit 15e8f7a

Please sign in to comment.