use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class PathMeasure_Delegate method native_isClosed.
@LayoutlibDelegate
static /*package*/
boolean native_isClosed(long native_instance) {
PathMeasure_Delegate pathMeasure = sManager.getDelegate(native_instance);
assert pathMeasure != null;
Path_Delegate path = Path_Delegate.getDelegate(pathMeasure.mNativePath);
if (path == null) {
return false;
}
int type = 0;
float[] segment = new float[6];
for (PathIterator pi = path.getJavaShape().getPathIterator(null); !pi.isDone(); pi.next()) {
type = pi.currentSegment(segment);
}
// A path is a closed path if the last element is SEG_CLOSE
return type == PathIterator.SEG_CLOSE;
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class PathMeasure_Delegate method native_getSegment.
@LayoutlibDelegate
static /*package*/
boolean native_getSegment(long native_instance, float startD, float stopD, long native_dst_path, boolean startWithMoveTo) {
if (startD < 0) {
startD = 0;
}
if (startD >= stopD) {
return false;
}
PathMeasure_Delegate pathMeasure = sManager.getDelegate(native_instance);
assert pathMeasure != null;
CachedPathIterator iterator = pathMeasure.mOriginalPathIterator.iterator();
float accLength = startD;
// Whether the output has zero length or not
boolean isZeroLength = true;
float[] points = new float[6];
iterator.jumpToSegment(accLength);
while (!iterator.isDone() && (stopD - accLength > 0.1f)) {
int type = iterator.currentSegment(points, stopD - accLength);
if (accLength - iterator.getCurrentSegmentLength() <= stopD) {
if (startWithMoveTo) {
startWithMoveTo = false;
// a first moveto
if (type != PathIterator.SEG_MOVETO) {
float[] lastPoint = new float[2];
iterator.getCurrentSegmentEnd(lastPoint);
Path_Delegate.native_moveTo(native_dst_path, lastPoint[0], lastPoint[1]);
}
}
isZeroLength = isZeroLength && iterator.getCurrentSegmentLength() > 0;
switch(type) {
case PathIterator.SEG_MOVETO:
Path_Delegate.native_moveTo(native_dst_path, points[0], points[1]);
break;
case PathIterator.SEG_LINETO:
Path_Delegate.native_lineTo(native_dst_path, points[0], points[1]);
break;
case PathIterator.SEG_CLOSE:
Path_Delegate.native_close(native_dst_path);
break;
case PathIterator.SEG_CUBICTO:
Path_Delegate.native_cubicTo(native_dst_path, points[0], points[1], points[2], points[3], points[4], points[5]);
break;
case PathIterator.SEG_QUADTO:
Path_Delegate.native_quadTo(native_dst_path, points[0], points[1], points[2], points[3]);
break;
default:
assert false;
}
}
accLength += iterator.getCurrentSegmentLength();
iterator.next();
}
return !isZeroLength;
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class Resources_Delegate method getTextArray.
@LayoutlibDelegate
static CharSequence[] getTextArray(Resources resources, int id) throws NotFoundException {
ResourceValue resValue = getArrayResourceValue(resources, id);
if (resValue == null) {
// Error already logged by getArrayResourceValue.
return new CharSequence[0];
} else if (!(resValue instanceof ArrayResourceValue)) {
return new CharSequence[] { resolveReference(resources, resValue.getValue(), resValue.isFramework()) };
}
ArrayResourceValue arv = ((ArrayResourceValue) resValue);
return fillValues(resources, arv, new CharSequence[arv.getElementCount()]);
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class Resources_Delegate method getInteger.
@LayoutlibDelegate
static int getInteger(Resources resources, int id) throws NotFoundException {
Pair<String, ResourceValue> value = getResourceValue(resources, id, mPlatformResourceFlag);
if (value != null) {
ResourceValue resValue = value.getSecond();
assert resValue != null;
if (resValue != null) {
String v = resValue.getValue();
if (v != null) {
try {
return getInt(v);
} catch (NumberFormatException e) {
// return exception below
}
}
}
}
// id was not found or not resolved. Throw a NotFoundException.
throwException(resources, id);
// this is not used since the method above always throws
return 0;
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class Resources_Delegate method getStringArray.
@LayoutlibDelegate
static String[] getStringArray(Resources resources, int id) throws NotFoundException {
ResourceValue resValue = getArrayResourceValue(resources, id);
if (resValue == null) {
// Error already logged by getArrayResourceValue.
return new String[0];
} else if (!(resValue instanceof ArrayResourceValue)) {
return new String[] { resolveReference(resources, resValue.getValue(), resValue.isFramework()) };
}
ArrayResourceValue arv = ((ArrayResourceValue) resValue);
return fillValues(resources, arv, new String[arv.getElementCount()]);
}
Aggregations