Java Code Examples for android.view.View#invalidate()

The following examples show how to use android.view.View#invalidate() . 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: UserDictionarySettings.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
@Override
public boolean setViewValue(final View v, final Cursor c, final int columnIndex) {
    if (!IS_SHORTCUT_API_SUPPORTED) {
        // just let SimpleCursorAdapter set the view values
        return false;
    }
    if (columnIndex == INDEX_SHORTCUT) {
        final String shortcut = c.getString(INDEX_SHORTCUT);
        if (TextUtils.isEmpty(shortcut)) {
            v.setVisibility(View.GONE);
        } else {
            ((TextView)v).setText(shortcut);
            v.setVisibility(View.VISIBLE);
        }
        v.invalidate();
        return true;
    }

    return false;
}
 
Example 2
Source File: ActivityShare.java    From XPrivacy with GNU General Public License v3.0 6 votes vote down vote up
private void blueStreakOfProgress(Integer current, Integer max) {
	// Set up the progress bar
	if (mProgressWidth == 0) {
		final View vShareProgressEmpty = (View) findViewById(R.id.vShareProgressEmpty);
		mProgressWidth = vShareProgressEmpty.getMeasuredWidth();
	}
	// Display stuff
	if (max == 0)
		max = 1;
	int width = (int) ((float) mProgressWidth) * current / max;

	View vShareProgressFull = (View) findViewById(R.id.vShareProgressFull);
	vShareProgressFull.getLayoutParams().width = width;
	vShareProgressFull.invalidate();
	vShareProgressFull.requestLayout();
}
 
Example 3
Source File: ListItemClickListener.java    From SmileEssence with MIT License 5 votes vote down vote up
@Override
public void onClick(final View v) {
    final int currentBgColor = ((ColorDrawable) v.getBackground()).getColor();
    v.setBackgroundColor(activity.getResources().getColor(R.color.metro_blue));
    v.invalidate();
    new UIHandler() {

        @Override
        public void run() {
            v.setBackgroundColor(currentBgColor);
            callback.run();
        }
    }.post();
}
 
Example 4
Source File: CheckBoxBase.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void invalidate() {
    if (parentView.getParent() != null) {
        View parent = (View) parentView.getParent();
        parent.invalidate();
    }
    parentView.invalidate();
}
 
Example 5
Source File: AnimatorProxy.java    From Libraries-for-Android-Developers with MIT License 5 votes vote down vote up
public void setAlpha(float alpha) {
    if (mAlpha != alpha) {
        mAlpha = alpha;
        View view = mView.get();
        if (view != null) {
            view.invalidate();
        }
    }
}
 
Example 6
Source File: LayoutHelper.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
public void setOuterNormalColor(int color) {
    mOuterNormalColor = color;
    View owner = mOwner.get();
    if (owner != null) {
        owner.invalidate();
    }
}
 
Example 7
Source File: MetroCursorView.java    From android_tv_metro with Apache License 2.0 5 votes vote down vote up
public void setFocusView(View view){
 	if(mFocusView != view){
  	mFocusView = view;	
  	//mMirror = mirror;
  	mScaleUp = 1.0f;
  	//anim.setStartDelay(50);
  	anim.start();
         animUpdate.start();
if(view instanceof MirrorItemView ){
	((MirrorItemView)view).setReflection(false);
	view.invalidate();
}
 	}
 }
 
Example 8
Source File: AnimatorProxy.java    From zen4android with MIT License 5 votes vote down vote up
public void setAlpha(float alpha) {
    if (mAlpha != alpha) {
        mAlpha = alpha;
        View view = mView.get();
        if (view != null) {
            view.invalidate();
        }
    }
}
 
Example 9
Source File: AnimatorProxy.java    From KJFrameForAndroid with Apache License 2.0 5 votes vote down vote up
public void setAlpha(float alpha) {
    if (mAlpha != alpha) {
        mAlpha = alpha;
        View view = mView.get();
        if (view != null) {
            view.invalidate();
        }
    }
}
 
Example 10
Source File: PointOnSelectionToolGroup.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
public boolean onTouch(View v, MotionEvent event) {
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN: {
            v.getBackground().setColorFilter(buttonSelectionColor, Mode.SRC_ATOP);
            v.invalidate();
            break;
        }
        case MotionEvent.ACTION_UP: {
            v.getBackground().clearColorFilter();
            v.invalidate();
            break;
        }
    }
    return false;
}
 
Example 11
Source File: PointCreateFeatureToolGroup.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
public boolean onTouch(View v, MotionEvent event) {
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN: {
            v.getBackground().setColorFilter(buttonSelectionColor, Mode.SRC_ATOP);
            v.invalidate();
            break;
        }
        case MotionEvent.ACTION_UP: {
            v.getBackground().clearColorFilter();
            v.invalidate();
            break;
        }
    }
    return false;
}
 
Example 12
Source File: LabelViewHelper.java    From TLint with Apache License 2.0 5 votes vote down vote up
public void setLabelText(View view, String text) {
    if (!TextUtils.equals(this.text, text)) {
        this.text = text;
        Logger.d("setLabelText:" + text);
        view.invalidate();
    }
}
 
Example 13
Source File: ColorUpdateListener.java    From AndroidAnimationsActions with MIT License 4 votes vote down vote up
@Override
void onAnimationUpdate(View view, ValueAnimator animation) {
    int currentColor = (int) animation.getAnimatedValue();
    paint.setColorFilter(new PorterDuffColorFilter(currentColor, PorterDuff.Mode.MULTIPLY));
    view.invalidate();
}
 
Example 14
Source File: ViewUtil.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
public static void setBackgroundDrawable(View view, Drawable drawable) {
  view.setBackgroundDrawable(drawable);
  view.invalidate();
}
 
Example 15
Source File: ViewCompat.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
    view.invalidate(left, top, right, bottom);
}
 
Example 16
Source File: LayoutHelper.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
@Override
public void setRadiusAndShadow(int radius, @ILayout.HideRadiusSide int hideRadiusSide, int shadowElevation, float shadowAlpha) {
    View owner = mOwner.get();
    if (owner == null) {
        return;
    }

    mRadius = radius;
    mHideRadiusSide = hideRadiusSide;

    if (mRadius > 0) {
        if (hideRadiusSide == HIDE_RADIUS_SIDE_TOP) {
            mRadiusArray = new float[]{0, 0, 0, 0, mRadius, mRadius, mRadius, mRadius};
        } else if (hideRadiusSide == HIDE_RADIUS_SIDE_RIGHT) {
            mRadiusArray = new float[]{mRadius, mRadius, 0, 0, 0, 0, mRadius, mRadius};
        } else if (hideRadiusSide == HIDE_RADIUS_SIDE_BOTTOM) {
            mRadiusArray = new float[]{mRadius, mRadius, mRadius, mRadius, 0, 0, 0, 0};
        } else if (hideRadiusSide == HIDE_RADIUS_SIDE_LEFT) {
            mRadiusArray = new float[]{0, 0, mRadius, mRadius, mRadius, mRadius, 0, 0};
        } else {
            mRadiusArray = null;
        }
    }

    mShadowElevation = shadowElevation;
    mShadowAlpha = shadowAlpha;
    if (useFeature()) {
        if (mShadowElevation == 0 || isRadiusWithSideHidden()) {
            owner.setElevation(0);
        } else {
            owner.setElevation(mShadowElevation);
        }

        owner.setOutlineProvider(new ViewOutlineProvider() {
            @Override
            @TargetApi(21)
            public void getOutline(View view, Outline outline) {
                int w = view.getWidth(), h = view.getHeight();
                if (w == 0 || h == 0) {
                    return;
                }
                if (isRadiusWithSideHidden()) {
                    int left = 0, top = 0, right = w, bottom = h;
                    if (mHideRadiusSide == HIDE_RADIUS_SIDE_LEFT) {
                        left -= mRadius;
                    } else if (mHideRadiusSide == HIDE_RADIUS_SIDE_TOP) {
                        top -= mRadius;
                    } else if (mHideRadiusSide == HIDE_RADIUS_SIDE_RIGHT) {
                        right += mRadius;
                    } else if (mHideRadiusSide == HIDE_RADIUS_SIDE_BOTTOM) {
                        bottom += mRadius;
                    }
                    outline.setRoundRect(left, top,
                            right, bottom, mRadius);
                    return;
                }

                int top = mOutlineInsetTop, bottom = Math.max(top + 1, h - mOutlineInsetBottom),
                        left = mOutlineInsetLeft, right = w - mOutlineInsetRight;
                if (mIsOutlineExcludePadding) {
                    left += view.getPaddingLeft();
                    top += view.getPaddingTop();
                    right = Math.max(left + 1, right - view.getPaddingRight());
                    bottom = Math.max(top + 1, bottom - view.getPaddingBottom());
                }
                outline.setAlpha(mShadowAlpha);
                if (mRadius <= 0) {
                    outline.setRect(left, top,
                            right, bottom);
                } else {
                    outline.setRoundRect(left, top,
                            right, bottom, mRadius);
                }
            }
        });

        owner.setClipToOutline(mRadius > 0);

    }
    owner.invalidate();
}
 
Example 17
Source File: LabelViewHelper.java    From labelview with Apache License 2.0 4 votes vote down vote up
public void setLabelBackgroundAlpha(View view, int alpha) {
    if (this.alpha != alpha) {
        this.alpha = alpha;
        view.invalidate();
    }
}
 
Example 18
Source File: ChangeLog.java    From Hangar with GNU General Public License v3.0 4 votes vote down vote up
@SuppressLint("InflateParams")
protected View getView() {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
    View mChangeLog = inflater.inflate(R.layout.changelog, null);
    LinearLayout mChangeLogRoot = (LinearLayout) mChangeLog.findViewById(R.id.changeParent);

    String[] versionNumbers = context.getResources().getStringArray(R.array.versionNumbers);
    String[] versionSummaries = context.getResources().getStringArray(R.array.versionSummaries);

    for (int i = 0; i < versionNumbers.length; i++) {
        String version = versionNumbers[i];
        String summary = versionSummaries[i];

        LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        llp.topMargin = Tools.dpToPx(context, 10);
        llp.leftMargin = Tools.dpToPx(context, 10);
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);

        ll.setLayoutParams(llp);

        LinearLayout.LayoutParams llttv = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1);
        llttv.bottomMargin = Tools.dpToPx(context, 2);
        TextView titletv = new TextView(context);
        titletv.setLayoutParams(llttv);
        titletv.setText(version);
        titletv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
        titletv.setTypeface(null, Typeface.BOLD);
        titletv.setGravity(Gravity.CENTER_VERTICAL);
        titletv.setSingleLine();

        LinearLayout.LayoutParams llstv = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1);
        TextView summarytv = new TextView(context);
        llstv.bottomMargin = Tools.dpToPx(context, 8);
        summarytv.setLayoutParams(llstv);
        summarytv.setGravity(Gravity.CENTER_VERTICAL);

        summarytv.setText(summary);
        summarytv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);

        ll.addView(titletv);
        ll.addView(summarytv);
        mChangeLogRoot.addView(ll);
    }
    mChangeLog.invalidate();
    return mChangeLog;
}
 
Example 19
Source File: ad.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public void a(View view, Paint paint)
{
    a(view, g(view), paint);
    view.invalidate();
}
 
Example 20
Source File: LabelViewHelper.java    From TLint with Apache License 2.0 4 votes vote down vote up
public void setLabelTextColor(View view, int textColor) {
    if (this.textColor != textColor) {
        this.textColor = textColor;
        view.invalidate();
    }
}