android.view.View#invalidate ( )源码实例Demo

下面列出了android.view.View#invalidate ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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;
}
 
源代码2 项目: XPrivacy   文件: ActivityShare.java
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();
}
 
源代码3 项目: Telegram-FOSS   文件: CheckBoxBase.java
private void invalidate() {
    if (parentView.getParent() != null) {
        View parent = (View) parentView.getParent();
        parent.invalidate();
    }
    parentView.invalidate();
}
 
源代码4 项目: TLint   文件: LabelViewHelper.java
public void setLabelText(View view, String text) {
    if (!TextUtils.equals(this.text, text)) {
        this.text = text;
        Logger.d("setLabelText:" + text);
        view.invalidate();
    }
}
 
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;
}
 
源代码6 项目: geopaparazzi   文件: PointOnSelectionToolGroup.java
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;
}
 
源代码7 项目: KJFrameForAndroid   文件: AnimatorProxy.java
public void setAlpha(float alpha) {
    if (mAlpha != alpha) {
        mAlpha = alpha;
        View view = mView.get();
        if (view != null) {
            view.invalidate();
        }
    }
}
 
源代码8 项目: zen4android   文件: AnimatorProxy.java
public void setAlpha(float alpha) {
    if (mAlpha != alpha) {
        mAlpha = alpha;
        View view = mView.get();
        if (view != null) {
            view.invalidate();
        }
    }
}
 
源代码9 项目: android_tv_metro   文件: MetroCursorView.java
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();
}
 	}
 }
 
源代码10 项目: DanDanPlayForAndroid   文件: LayoutHelper.java
public void setOuterNormalColor(int color) {
    mOuterNormalColor = color;
    View owner = mOwner.get();
    if (owner != null) {
        owner.invalidate();
    }
}
 
public void setAlpha(float alpha) {
    if (mAlpha != alpha) {
        mAlpha = alpha;
        View view = mView.get();
        if (view != null) {
            view.invalidate();
        }
    }
}
 
源代码12 项目: SmileEssence   文件: ListItemClickListener.java
@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();
}
 
源代码13 项目: TLint   文件: LabelViewHelper.java
public void setLabelTextColor(View view, int textColor) {
    if (this.textColor != textColor) {
        this.textColor = textColor;
        view.invalidate();
    }
}
 
源代码14 项目: adt-leanback-support   文件: ViewCompat.java
public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
    view.invalidate(left, top, right, bottom);
}
 
@Override
void onAnimationUpdate(View view, ValueAnimator animation) {
    int currentColor = (int) animation.getAnimatedValue();
    paint.setColorFilter(new PorterDuffColorFilter(currentColor, PorterDuff.Mode.MULTIPLY));
    view.invalidate();
}
 
源代码16 项目: appinventor-extensions   文件: ViewUtil.java
public static void setBackgroundDrawable(View view, Drawable drawable) {
  view.setBackgroundDrawable(drawable);
  view.invalidate();
}
 
源代码17 项目: DanDanPlayForAndroid   文件: LayoutHelper.java
@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();
}
 
源代码18 项目: labelview   文件: LabelViewHelper.java
public void setLabelBackgroundAlpha(View view, int alpha) {
    if (this.alpha != alpha) {
        this.alpha = alpha;
        view.invalidate();
    }
}
 
源代码19 项目: Hangar   文件: ChangeLog.java
@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;
}
 
源代码20 项目: MiBandDecompiled   文件: ad.java
public void a(View view, Paint paint)
{
    a(view, g(view), paint);
    view.invalidate();
}
 
 方法所在类
 同类方法