Search in sources :

Example 1 with DragShadowBuilder

use of android.view.View.DragShadowBuilder in project android_frameworks_base by ParanoidAndroid.

the class Editor method getTextThumbnailBuilder.

private DragShadowBuilder getTextThumbnailBuilder(CharSequence text) {
    TextView shadowView = (TextView) View.inflate(mTextView.getContext(), com.android.internal.R.layout.text_drag_thumbnail, null);
    if (shadowView == null) {
        throw new IllegalArgumentException("Unable to inflate text drag thumbnail");
    }
    if (text.length() > DRAG_SHADOW_MAX_TEXT_LENGTH) {
        text = text.subSequence(0, DRAG_SHADOW_MAX_TEXT_LENGTH);
    }
    shadowView.setText(text);
    shadowView.setTextColor(mTextView.getTextColors());
    shadowView.setTextAppearance(mTextView.getContext(), R.styleable.Theme_textAppearanceLarge);
    shadowView.setGravity(Gravity.CENTER);
    shadowView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    final int size = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    shadowView.measure(size, size);
    shadowView.layout(0, 0, shadowView.getMeasuredWidth(), shadowView.getMeasuredHeight());
    shadowView.invalidate();
    return new DragShadowBuilder(shadowView);
}
Also used : DragShadowBuilder(android.view.View.DragShadowBuilder) LayoutParams(android.view.ViewGroup.LayoutParams) Paint(android.graphics.Paint)

Example 2 with DragShadowBuilder

use of android.view.View.DragShadowBuilder in project android_frameworks_base by DirtyUnicorns.

the class Editor method getTextThumbnailBuilder.

private DragShadowBuilder getTextThumbnailBuilder(int start, int end) {
    TextView shadowView = (TextView) View.inflate(mTextView.getContext(), com.android.internal.R.layout.text_drag_thumbnail, null);
    if (shadowView == null) {
        throw new IllegalArgumentException("Unable to inflate text drag thumbnail");
    }
    if (end - start > DRAG_SHADOW_MAX_TEXT_LENGTH) {
        final long range = getCharClusterRange(start + DRAG_SHADOW_MAX_TEXT_LENGTH);
        end = TextUtils.unpackRangeEndFromLong(range);
    }
    final CharSequence text = mTextView.getTransformedText(start, end);
    shadowView.setText(text);
    shadowView.setTextColor(mTextView.getTextColors());
    shadowView.setTextAppearance(R.styleable.Theme_textAppearanceLarge);
    shadowView.setGravity(Gravity.CENTER);
    shadowView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    final int size = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    shadowView.measure(size, size);
    shadowView.layout(0, 0, shadowView.getMeasuredWidth(), shadowView.getMeasuredHeight());
    shadowView.invalidate();
    return new DragShadowBuilder(shadowView);
}
Also used : DragShadowBuilder(android.view.View.DragShadowBuilder) LayoutParams(android.view.ViewGroup.LayoutParams) Paint(android.graphics.Paint)

Example 3 with DragShadowBuilder

use of android.view.View.DragShadowBuilder in project android_frameworks_base by ResurrectionRemix.

the class Editor method getTextThumbnailBuilder.

private DragShadowBuilder getTextThumbnailBuilder(int start, int end) {
    TextView shadowView = (TextView) View.inflate(mTextView.getContext(), com.android.internal.R.layout.text_drag_thumbnail, null);
    if (shadowView == null) {
        throw new IllegalArgumentException("Unable to inflate text drag thumbnail");
    }
    if (end - start > DRAG_SHADOW_MAX_TEXT_LENGTH) {
        final long range = getCharClusterRange(start + DRAG_SHADOW_MAX_TEXT_LENGTH);
        end = TextUtils.unpackRangeEndFromLong(range);
    }
    final CharSequence text = mTextView.getTransformedText(start, end);
    shadowView.setText(text);
    shadowView.setTextColor(mTextView.getTextColors());
    shadowView.setTextAppearance(R.styleable.Theme_textAppearanceLarge);
    shadowView.setGravity(Gravity.CENTER);
    shadowView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    final int size = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    shadowView.measure(size, size);
    shadowView.layout(0, 0, shadowView.getMeasuredWidth(), shadowView.getMeasuredHeight());
    shadowView.invalidate();
    return new DragShadowBuilder(shadowView);
}
Also used : DragShadowBuilder(android.view.View.DragShadowBuilder) LayoutParams(android.view.ViewGroup.LayoutParams) Paint(android.graphics.Paint)

Example 4 with DragShadowBuilder

use of android.view.View.DragShadowBuilder in project android_frameworks_base by crdroidandroid.

the class Editor method getTextThumbnailBuilder.

private DragShadowBuilder getTextThumbnailBuilder(int start, int end) {
    TextView shadowView = (TextView) View.inflate(mTextView.getContext(), com.android.internal.R.layout.text_drag_thumbnail, null);
    if (shadowView == null) {
        throw new IllegalArgumentException("Unable to inflate text drag thumbnail");
    }
    if (end - start > DRAG_SHADOW_MAX_TEXT_LENGTH) {
        final long range = getCharClusterRange(start + DRAG_SHADOW_MAX_TEXT_LENGTH);
        end = TextUtils.unpackRangeEndFromLong(range);
    }
    final CharSequence text = mTextView.getTransformedText(start, end);
    shadowView.setText(text);
    shadowView.setTextColor(mTextView.getTextColors());
    shadowView.setTextAppearance(R.styleable.Theme_textAppearanceLarge);
    shadowView.setGravity(Gravity.CENTER);
    shadowView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    final int size = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    shadowView.measure(size, size);
    shadowView.layout(0, 0, shadowView.getMeasuredWidth(), shadowView.getMeasuredHeight());
    shadowView.invalidate();
    return new DragShadowBuilder(shadowView);
}
Also used : DragShadowBuilder(android.view.View.DragShadowBuilder) LayoutParams(android.view.ViewGroup.LayoutParams) Paint(android.graphics.Paint)

Example 5 with DragShadowBuilder

use of android.view.View.DragShadowBuilder in project platform_frameworks_base by android.

the class Editor method getTextThumbnailBuilder.

private DragShadowBuilder getTextThumbnailBuilder(int start, int end) {
    TextView shadowView = (TextView) View.inflate(mTextView.getContext(), com.android.internal.R.layout.text_drag_thumbnail, null);
    if (shadowView == null) {
        throw new IllegalArgumentException("Unable to inflate text drag thumbnail");
    }
    if (end - start > DRAG_SHADOW_MAX_TEXT_LENGTH) {
        final long range = getCharClusterRange(start + DRAG_SHADOW_MAX_TEXT_LENGTH);
        end = TextUtils.unpackRangeEndFromLong(range);
    }
    final CharSequence text = mTextView.getTransformedText(start, end);
    shadowView.setText(text);
    shadowView.setTextColor(mTextView.getTextColors());
    shadowView.setTextAppearance(R.styleable.Theme_textAppearanceLarge);
    shadowView.setGravity(Gravity.CENTER);
    shadowView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    final int size = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    shadowView.measure(size, size);
    shadowView.layout(0, 0, shadowView.getMeasuredWidth(), shadowView.getMeasuredHeight());
    shadowView.invalidate();
    return new DragShadowBuilder(shadowView);
}
Also used : DragShadowBuilder(android.view.View.DragShadowBuilder) LayoutParams(android.view.ViewGroup.LayoutParams) Paint(android.graphics.Paint)

Aggregations

Paint (android.graphics.Paint)6 DragShadowBuilder (android.view.View.DragShadowBuilder)6 LayoutParams (android.view.ViewGroup.LayoutParams)6