handle floats

This commit is contained in:
Samy Al Zahrani 2015-12-25 13:11:37 +03:00
parent a2503d0666
commit 872f504797
1 changed files with 12 additions and 12 deletions

View File

@ -17,8 +17,8 @@ public class LinearGradientView extends View {
private Paint mPaint; private Paint mPaint;
private LinearGradient mShader; private LinearGradient mShader;
private float[] mLocations; private float[] mLocations;
private int[] mStartPos; private float[] mStartPos;
private int[] mEndPos; private float[] mEndPos;
private int[] mColors; private int[] mColors;
private int[] mSize; private int[] mSize;
@ -53,31 +53,31 @@ public class LinearGradientView extends View {
try { try {
ReadableArray startPos = props.getArray("start"); ReadableArray startPos = props.getArray("start");
assert startPos != null; assert startPos != null;
mStartPos = new int[]{startPos.getInt(0), startPos.getInt(1)}; mStartPos = new float[]{(float) startPos.getDouble(0), (float) startPos.getDouble(1)};
} catch (Exception e) { } catch (Exception e) {
mStartPos = new int[]{0,0}; mStartPos = new float[]{0,0};
} }
try { try {
ReadableArray endPos = props.getArray("end"); ReadableArray endPos = props.getArray("end");
assert endPos != null; assert endPos != null;
mEndPos= new int[]{endPos.getInt(0), endPos.getInt(1)}; mEndPos= new float[]{(float) endPos.getDouble(0), (float) endPos.getDouble(1)};
} catch (Exception e) { } catch (Exception e) {
//default to full height. //default to full height.
mEndPos = new int[]{0, getMeasuredHeight()}; mEndPos = new float[]{0, getMeasuredHeight()};
} }
mSize = new int[]{0, 0}; mSize = new int[]{0, 0};
drawGradient(); drawGradient();
} }
public void updateStartPosition(ReadableArray startPos) { public void updateStartPosition(ReadableArray startPos) {
int[] _startPos; float[] _startPos;
try { try {
assert startPos != null; assert startPos != null;
_startPos= new int[]{startPos.getInt(0), startPos.getInt(1)}; _startPos= new float[]{(float) startPos.getDouble(0), (float) startPos.getDouble(1)};
} catch (Exception e) { } catch (Exception e) {
_startPos = new int[]{0,0}; _startPos = new float[]{0,0};
} }
mStartPos = _startPos; mStartPos = _startPos;
drawGradient(); drawGradient();
@ -85,12 +85,12 @@ public class LinearGradientView extends View {
public void updateEndPosition(ReadableArray endPos) { public void updateEndPosition(ReadableArray endPos) {
int[] _endPos; float[] _endPos;
try { try {
assert endPos != null; assert endPos != null;
_endPos= new int[]{endPos.getInt(0), endPos.getInt(1)}; _endPos= new float[]{(float) endPos.getDouble(0), (float) endPos.getDouble(1)};
} catch (Exception e) { } catch (Exception e) {
_endPos = new int[]{0,0}; _endPos = new float[]{0,0};
} }
mEndPos = _endPos; mEndPos = _endPos;
drawGradient(); drawGradient();