Java Code Examples for android.content.res.TypedArray#getResources()

The following examples show how to use android.content.res.TypedArray#getResources() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PointerTracker.java    From openboard with GNU General Public License v3.0 6 votes vote down vote up
public static void init(final TypedArray mainKeyboardViewAttr, final TimerProxy timerProxy,
        final DrawingProxy drawingProxy) {
    sParams = new PointerTrackerParams(mainKeyboardViewAttr);
    sGestureStrokeRecognitionParams = new GestureStrokeRecognitionParams(mainKeyboardViewAttr);
    sGestureStrokeDrawingParams = new GestureStrokeDrawingParams(mainKeyboardViewAttr);
    sTypingTimeRecorder = new TypingTimeRecorder(
            sGestureStrokeRecognitionParams.mStaticTimeThresholdAfterFastTyping,
            sParams.mSuppressKeyPreviewAfterBatchInputDuration);

    final Resources res = mainKeyboardViewAttr.getResources();
    sNeedsPhantomSuddenMoveEventHack = Boolean.parseBoolean(
            ResourceUtils.getDeviceOverrideValue(res,
                    R.array.phantom_sudden_move_event_device_list, Boolean.FALSE.toString()));
    BogusMoveEventDetector.init(res);

    sTimerProxy = timerProxy;
    sDrawingProxy = drawingProxy;
}
 
Example 2
Source File: RxAbstractPathAnimator.java    From RxTools-master with Apache License 2.0 6 votes vote down vote up
public static Config fromTypeArray(TypedArray typedArray) {
    Config config = new Config();
    Resources res = typedArray.getResources();
    config.initX = (int) typedArray.getDimension(R.styleable.RxHeartLayout_initX,
            res.getDimensionPixelOffset(R.dimen.heart_anim_init_x));
    config.initY = (int) typedArray.getDimension(R.styleable.RxHeartLayout_initY,
            res.getDimensionPixelOffset(R.dimen.heart_anim_init_y));
    config.xRand = (int) typedArray.getDimension(R.styleable.RxHeartLayout_xRand,
            res.getDimensionPixelOffset(R.dimen.heart_anim_bezier_x_rand));
    config.animLength = (int) typedArray.getDimension(R.styleable.RxHeartLayout_animLength,
            res.getDimensionPixelOffset(R.dimen.heart_anim_length));
    config.animLengthRand = (int) typedArray.getDimension(R.styleable.RxHeartLayout_animLengthRand,
            res.getDimensionPixelOffset(R.dimen.heart_anim_length_rand));
    config.bezierFactor = typedArray.getInteger(R.styleable.RxHeartLayout_bezierFactor,
            res.getInteger(R.integer.heart_anim_bezier_factor));
    config.xPointFactor = (int) typedArray.getDimension(R.styleable.RxHeartLayout_xPointFactor,
            res.getDimensionPixelOffset(R.dimen.heart_anim_x_point_factor));
    config.heartWidth = (int) typedArray.getDimension(R.styleable.RxHeartLayout_heart_width,
            res.getDimensionPixelOffset(R.dimen.heart_size_width));
    config.heartHeight = (int) typedArray.getDimension(R.styleable.RxHeartLayout_heart_height,
            res.getDimensionPixelOffset(R.dimen.heart_size_height));
    config.animDuration = typedArray.getInteger(R.styleable.RxHeartLayout_anim_duration,
            res.getInteger(R.integer.anim_duration));
    return config;
}
 
Example 3
Source File: PointerTracker.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
public static void init(final TypedArray mainKeyboardViewAttr, final TimerProxy timerProxy,
        final DrawingProxy drawingProxy) {
    sParams = new PointerTrackerParams(mainKeyboardViewAttr);
    sGestureStrokeRecognitionParams = new GestureStrokeRecognitionParams(mainKeyboardViewAttr);
    sGestureStrokeDrawingParams = new GestureStrokeDrawingParams(mainKeyboardViewAttr);
    sTypingTimeRecorder = new TypingTimeRecorder(
            sGestureStrokeRecognitionParams.mStaticTimeThresholdAfterFastTyping,
            sParams.mSuppressKeyPreviewAfterBatchInputDuration);

    final Resources res = mainKeyboardViewAttr.getResources();
    sNeedsPhantomSuddenMoveEventHack = Boolean.parseBoolean(
            ResourceUtils.getDeviceOverrideValue(res,
                    R.array.phantom_sudden_move_event_device_list, Boolean.FALSE.toString()));
    BogusMoveEventDetector.init(res);

    sTimerProxy = timerProxy;
    sDrawingProxy = drawingProxy;
}
 
Example 4
Source File: AbstractPathAnimator.java    From KSYMediaPlayer_Android with Apache License 2.0 6 votes vote down vote up
static public Config fromTypeArray(TypedArray typedArray, float x, float y, int pointx, int heartWidth, int heartHeight) {
            Config config = new Config();
            Resources res = typedArray.getResources();
            config.initX = (int) typedArray.getDimension(R.styleable.HeartLayout_initX,
                    x);
            config.initY = (int) typedArray.getDimension(R.styleable.HeartLayout_initY,
                    y);
            config.xRand = (int) typedArray.getDimension(R.styleable.HeartLayout_xRand,
                    res.getDimensionPixelOffset(R.dimen.heart_anim_bezier_x_rand));
            config.animLength = (int) typedArray.getDimension(R.styleable.HeartLayout_animLength,
                    res.getDimensionPixelOffset(R.dimen.heart_anim_length));//动画长度
            config.animLengthRand = (int) typedArray.getDimension(R.styleable.HeartLayout_animLengthRand,
                    res.getDimensionPixelOffset(R.dimen.heart_anim_length_rand));
            config.bezierFactor = typedArray.getInteger(R.styleable.HeartLayout_bezierFactor,
                    res.getInteger(R.integer.heart_anim_bezier_factor));
            config.xPointFactor = pointx;
//            config.heartWidth = (int) typedArray.getDimension(R.styleable.HeartLayout_heart_width,
//                    res.getDimensionPixelOffset(R.dimen.heart_size_width));//动画图片宽度
//            config.heartHeight = (int) typedArray.getDimension(R.styleable.HeartLayout_heart_height,
//                    res.getDimensionPixelOffset(R.dimen.heart_size_height));//动画图片高度
            config.heartWidth = heartWidth;
            config.heartHeight = heartHeight;
            config.animDuration = typedArray.getInteger(R.styleable.HeartLayout_anim_duration,
                    res.getInteger(R.integer.anim_duration));//持续期
            return config;
        }
 
Example 5
Source File: AbstractPathAnimator.java    From MousePaint with MIT License 6 votes vote down vote up
static Config fromTypeArray(TypedArray typedArray) {
    Config config = new Config();
    Resources res = typedArray.getResources();
    config.initX = (int) typedArray.getDimension(R.styleable.HeartLayout_initX,
            res.getDimensionPixelOffset(R.dimen.heart_anim_init_x));
    config.initY = (int) typedArray.getDimension(R.styleable.HeartLayout_initY,
            res.getDimensionPixelOffset(R.dimen.heart_anim_init_y));
    config.xRand = (int) typedArray.getDimension(R.styleable.HeartLayout_xRand,
            res.getDimensionPixelOffset(R.dimen.heart_anim_bezier_x_rand));
    config.animLength = (int) typedArray.getDimension(R.styleable.HeartLayout_animLength,
            res.getDimensionPixelOffset(R.dimen.heart_anim_length));
    config.animLengthRand = (int) typedArray.getDimension(R.styleable.HeartLayout_animLengthRand,
            res.getDimensionPixelOffset(R.dimen.heart_anim_length_rand));
    config.bezierFactor = typedArray.getInteger(R.styleable.HeartLayout_bezierFactor,
            res.getInteger(R.integer.heart_anim_bezier_factor));
    config.xPointFactor = (int) typedArray.getDimension(R.styleable.HeartLayout_xPointFactor,
            res.getDimensionPixelOffset(R.dimen.heart_anim_x_point_factor));
    config.heartWidth = (int) typedArray.getDimension(R.styleable.HeartLayout_heart_width,
            res.getDimensionPixelOffset(R.dimen.heart_size_width));
    config.heartHeight = (int) typedArray.getDimension(R.styleable.HeartLayout_heart_height,
            res.getDimensionPixelOffset(R.dimen.heart_size_height));
    config.animDuration = typedArray.getInteger(R.styleable.HeartLayout_anim_duration,
            res.getInteger(R.integer.anim_duration));
    return config;
}
 
Example 6
Source File: GifTextureView.java    From android-gif-drawable-eclipse-sample with MIT License 6 votes vote down vote up
private static InputSource findSource(final TypedArray textureViewAttributes) {
    final TypedValue value = new TypedValue();
    if (!textureViewAttributes.getValue(R.styleable.GifTextureView_gifSource, value)) {
        return null;
    }

    if (value.resourceId != 0) {
        final String type = textureViewAttributes.getResources().getResourceTypeName(value.resourceId);
        if ("drawable".equals(type) || "raw".equals(type)) {
            return new InputSource.ResourcesSource(textureViewAttributes.getResources(), value.resourceId);
        } else if (!"string".equals(type)) {
            throw new IllegalArgumentException("Expected string, drawable or raw resource, type " + type + " " +
                    "cannot be converted to GIF");
        }
    }
    return new InputSource.AssetSource(textureViewAttributes.getResources().getAssets(), value.string.toString());
}
 
Example 7
Source File: PointerTracker.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
public static void init(final TypedArray mainKeyboardViewAttr, final TimerProxy timerProxy,
        final DrawingProxy drawingProxy) {
    sParams = new PointerTrackerParams(mainKeyboardViewAttr);
    sGestureStrokeRecognitionParams = new GestureStrokeRecognitionParams(mainKeyboardViewAttr);
    sGestureStrokeDrawingParams = new GestureStrokeDrawingParams(mainKeyboardViewAttr);
    sTypingTimeRecorder = new TypingTimeRecorder(
            sGestureStrokeRecognitionParams.mStaticTimeThresholdAfterFastTyping,
            sParams.mSuppressKeyPreviewAfterBatchInputDuration);

    final Resources res = mainKeyboardViewAttr.getResources();
    sNeedsPhantomSuddenMoveEventHack = Boolean.parseBoolean(
            ResourceUtils.getDeviceOverrideValue(res,
                    R.array.phantom_sudden_move_event_device_list, Boolean.FALSE.toString()));
    BogusMoveEventDetector.init(res);

    sTimerProxy = timerProxy;
    sDrawingProxy = drawingProxy;
}
 
Example 8
Source File: GifTextureView.java    From sketch with Apache License 2.0 6 votes vote down vote up
private static InputSource findSource(final TypedArray textureViewAttributes) {
	final TypedValue value = new TypedValue();
	if (!textureViewAttributes.getValue(R.styleable.GifTextureView_gifSource, value)) {
		return null;
	}

	if (value.resourceId != 0) {
		final String resourceTypeName = textureViewAttributes.getResources().getResourceTypeName(value.resourceId);
		if (GifViewUtils.SUPPORTED_RESOURCE_TYPE_NAMES.contains(resourceTypeName)) {
			return new InputSource.ResourcesSource(textureViewAttributes.getResources(), value.resourceId);
		} else if (!"string".equals(resourceTypeName)) {
			throw new IllegalArgumentException(
					"Expected string, drawable, mipmap or raw resource type. '" + resourceTypeName
							+ "' is not supported");
		}
	}
	return new InputSource.AssetSource(textureViewAttributes.getResources().getAssets(), value.string.toString());
}
 
Example 9
Source File: PointerTracker.java    From LokiBoard-Android-Keylogger with Apache License 2.0 5 votes vote down vote up
public static void init(final TypedArray mainKeyboardViewAttr, final TimerProxy timerProxy,
        final DrawingProxy drawingProxy) {
    sParams = new PointerTrackerParams(mainKeyboardViewAttr);

    final Resources res = mainKeyboardViewAttr.getResources();
    BogusMoveEventDetector.init(res);

    sTimerProxy = timerProxy;
    sDrawingProxy = drawingProxy;
}
 
Example 10
Source File: PointerTracker.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
public static void init(final TypedArray mainKeyboardViewAttr, final TimerProxy timerProxy,
        final DrawingProxy drawingProxy) {
    sParams = new PointerTrackerParams(mainKeyboardViewAttr);

    final Resources res = mainKeyboardViewAttr.getResources();
    BogusMoveEventDetector.init(res);

    sTimerProxy = timerProxy;
    sDrawingProxy = drawingProxy;
}