Java Code Examples for android.widget.TextView.getResources()

The following are Jave code examples for showing how to use getResources() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: cnBetaGeek   File: LoadFromUriAsyncTask.java   Source Code and License Vote up 6 votes
@Override
protected void onPostExecute(Bitmap result) {
    if (result == null) {
        return;
    }
    if (mTextViewRef.get() == null) {
        return;
    }
    TextView textView = mTextViewRef.get();
    // change the reference of the current mDrawable to the result
    // from the HTTP call
    mUrlDrawable.mDrawable = new BitmapDrawable(textView.getResources(), result);
    // set bound to scale image to fit width and keep aspect ratio
    // according to the result from HTTP call
    int width = textView.getWidth();
    int height = Math.round(1.0f * width *
            mUrlDrawable.mDrawable.getIntrinsicHeight() /
            mUrlDrawable.mDrawable.getIntrinsicWidth());
    mUrlDrawable.setBounds(0, 0, width, height);
    mUrlDrawable.mDrawable.setBounds(0, 0, width, height);
    // force redrawing bitmap by setting text
    textView.setText(textView.getText());
}
 
Example 2
Project: Aequorea   File: DefaultImageGetter.java   Source Code and License Vote up 5 votes
@NonNull
private Drawable loadFromMemory(ImageHolder holder, TextView textView, DrawableWrapper drawableWrapper) {
    BitmapWrapper bitmapWrapper = BitmapPool.getPool().get(holder.getKey(), false, true);
    Bitmap bitmap = bitmapWrapper.getBitmap();
    BitmapDrawable bitmapDrawable = new BitmapDrawable(textView.getResources(), bitmap);
    bitmapDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
    drawableWrapper.setDrawable(bitmapDrawable);
    BitmapWrapper.SizeCacheHolder sizeCacheHolder = bitmapWrapper.getSizeCacheHolder();
    drawableWrapper.setBounds(sizeCacheHolder.rect);
    drawableWrapper.setScaleType(sizeCacheHolder.scaleType);
    drawableWrapper.calculate();
    return drawableWrapper;
}
 
Example 3
Project: boohee_v5.6   File: TitleChanger.java   Source Code and License Vote up 5 votes
public TitleChanger(TextView title) {
    this.title = title;
    Resources res = title.getResources();
    this.animDelay = 400;
    this.animDuration = res.getInteger(17694720) / 2;
    this.yTranslate = (int) TypedValue.applyDimension(1, 20.0f, res.getDisplayMetrics());
}
 
Example 4
Project: AOSP-Kayboard-7.1.2   File: SuggestionStripLayoutHelper.java   Source Code and License Vote up 4 votes
public SuggestionStripLayoutHelper(final Context context, final AttributeSet attrs,
        final int defStyle, final ArrayList<TextView> wordViews,
        final ArrayList<View> dividerViews, final ArrayList<TextView> debugInfoViews) {
    mWordViews = wordViews;
    mDividerViews = dividerViews;
    mDebugInfoViews = debugInfoViews;

    final TextView wordView = wordViews.get(0);
    final View dividerView = dividerViews.get(0);
    mPadding = wordView.getCompoundPaddingLeft() + wordView.getCompoundPaddingRight();
    dividerView.measure(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mDividerWidth = dividerView.getMeasuredWidth();

    final Resources res = wordView.getResources();
    mSuggestionsStripHeight = res.getDimensionPixelSize(
            R.dimen.config_suggestions_strip_height);

    final TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.SuggestionStripView, defStyle, R.style.SuggestionStripView);
    mSuggestionStripOptions = a.getInt(
            R.styleable.SuggestionStripView_suggestionStripOptions, 0);
    mAlphaObsoleted = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_alphaObsoleted, 1.0f);
    mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0);
    mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0);
    mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0);
    mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0);
    mSuggestionsCountInStrip = a.getInt(
            R.styleable.SuggestionStripView_suggestionsCountInStrip,
            DEFAULT_SUGGESTIONS_COUNT_IN_STRIP);
    mCenterSuggestionWeight = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_centerSuggestionPercentile,
            DEFAULT_CENTER_SUGGESTION_PERCENTILE);
    mMaxMoreSuggestionsRow = a.getInt(
            R.styleable.SuggestionStripView_maxMoreSuggestionsRow,
            DEFAULT_MAX_MORE_SUGGESTIONS_ROW);
    mMinMoreSuggestionsWidth = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_minMoreSuggestionsWidth, 1.0f);
    a.recycle();

    mMoreSuggestionsHint = getMoreSuggestionsHint(res,
            res.getDimension(R.dimen.config_more_suggestions_hint_text_size),
            mColorAutoCorrect);
    mCenterPositionInStrip = mSuggestionsCountInStrip / 2;
    // Assuming there are at least three suggestions. Also, note that the suggestions are
    // laid out according to script direction, so this is left of the center for LTR scripts
    // and right of the center for RTL scripts.
    mTypedWordPositionWhenAutocorrect = mCenterPositionInStrip - 1;
    mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(
            R.dimen.config_more_suggestions_bottom_gap);
    mMoreSuggestionsRowHeight = res.getDimensionPixelSize(
            R.dimen.config_more_suggestions_row_height);
}
 
Example 5
Project: GitHub   File: TitleChanger.java   Source Code and License Vote up 3 votes
public TitleChanger(TextView title) {
    this.title = title;

    Resources res = title.getResources();

    animDelay = DEFAULT_ANIMATION_DELAY;

    animDuration = res.getInteger(android.R.integer.config_shortAnimTime) / 2;

    translate = (int) TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP, DEFAULT_Y_TRANSLATION_DP, res.getDisplayMetrics()
    );
}
 
Example 6
Project: calendarview2   File: TitleChanger.java   Source Code and License Vote up 3 votes
public TitleChanger(TextView title) {
    this.title = title;

    Resources res = title.getResources();

    animDelay = DEFAULT_ANIMATION_DELAY;

    animDuration = res.getInteger(android.R.integer.config_shortAnimTime) / 2;

    translate = (int) TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP, DEFAULT_Y_TRANSLATION_DP, res.getDisplayMetrics()
    );
}