/** @see android.view.View#postInvalidateOnAnimation() */ public static void postInvalidateOnAnimation(View view) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.postInvalidateOnAnimation(); } else { view.postInvalidate(); } }
@Override protected void onPostExecute(Bitmap b) { if (b == null) { return; } if (!isCancelled() && !mOptions.mCancel) { // Help the GC if (mBitmap != null) { mBitmap.recycle(); } View v = getView(); if (v != null) { mBitmap = b; mWallpaperDrawable.setBitmap(b); v.postInvalidate(); } else { mBitmap = null; mWallpaperDrawable.setBitmap(null); } mLoader = null; } else { b.recycle(); } }
private void disableLocation() { myLocationOverlay.mLocationListener = null; // Update the screen to see changes take effect if (mapView instanceof View) { ((View) mapView).postInvalidate(); } }
@Override public void postInvalidate(int left, int top, int right, int bottom) { super.postInvalidate(left, top, right, bottom); if (getParent() == null || !(getParent() instanceof View)) return; if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) ((View) getParent()).postInvalidate(left, top, right, bottom); }
@Override public void postInvalidate() { super.postInvalidate(); if (getParent() == null || !(getParent() instanceof View)) return; if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) ((View) getParent()).postInvalidate(); }
/** Stop showing the progress animation. */ void stop() { if (mRunning) { mTriggerPercentage = 0; mFinishTime = AnimationUtils.currentAnimationTimeMillis(); mRunning = false; mParent.postInvalidate(); } }
/** Start showing the progress animation. */ void start() { if (!mRunning) { mTriggerPercentage = 0; mStartTime = AnimationUtils.currentAnimationTimeMillis(); mRunning = true; mParent.postInvalidate(); } }
@Override public void postInvalidate(View view, UpdateMode mode) { switch (mode) { case GU: case GU_FAST: view.postInvalidate(); break; case GC: view.postInvalidate(); epdControlApi.epdRedraw(); break; case DW: view.postInvalidate(); break; default: break; } return; }
public static void setSignOut(boolean paramBoolean) { Log.d("AppHelper", "Signout: " + paramBoolean); View localView = application.findViewById(2131230895); localView.setEnabled(paramBoolean); Drawable localDrawable = localView.getBackground(); if (paramBoolean) {} for (int i = 255; ; i = 79) { localDrawable.setAlpha(i); localView.postInvalidate(); return; } }
public void redraw_OSD_view(int i) { // child1 = Navit.Global_Navit_Object.findViewById(R.id.top_bar); // streetname // child2 = Navit.Global_Navit_Object.findViewById(R.id.osd_compass_new); // child3 = Navit.Global_Navit_Object.findViewById(R.id.osd_nextturn_new); // child4 = Navit.Global_Navit_Object.findViewById(R.id.osd_timetoturn_new); // child5 = Navit.Global_Navit_Object.findViewById(R.id.osd_timetodest_new); // child6 = Navit.Global_Navit_Object.findViewById(R.id.osd_roaddistance_new); // child7 = Navit.Global_Navit_Object.findViewById(R.id.osd_eta_new); // child8 = Navit.Global_Navit_Object.findViewById(R.id.view_speeding); // child9 = Navit.Global_Navit_Object.findViewById(R.id.view_laneassist); switch (i) { case 1: child1.postInvalidate(); break; case 2: child2.postInvalidate(); break; case 3: child3.postInvalidate(); break; case 4: child4.postInvalidate(); break; case 5: child5.postInvalidate(); break; case 6: child6.postInvalidate(); break; case 7: child7.postInvalidate(); break; case 8: child8.postInvalidate(); break; case 9: child9.postInvalidate(); break; } }
public static void postInvalidateOnAnimation( View view, int left, int top, int right, int bottom) { view.postInvalidate(left, top, right, bottom); }
public final void a(View paramView, int paramInt1, int paramInt2, int paramInt3, int paramInt4) { paramView.postInvalidate(paramInt1, paramInt2, paramInt3, paramInt4); }
@Override public void postInvalidate() { if (!mNoInvalidate) { super.postInvalidate(); } }
/** 刷新view */ public void postInvalidate() { mTarget.postInvalidate(); }
@Override public void onDraw(Canvas c) { // System.out.println("XYZ:ZANaviLinearLayout -> onDraw"); // if (2 == 1 + 1) // { // return; // } if (this.need_size_change) { // System.out.println("XYZ:ZANaviLinearLayout -> onDraw [need_size_change]"); int w = this.getWidth(); int h = this.getHeight(); float draw_factor = 1.0f; if (Navit.my_display_density.compareTo("mdpi") == 0) { draw_factor = 1.0f; } else if (Navit.my_display_density.compareTo("ldpi") == 0) { draw_factor = 0.7f; } else if (Navit.my_display_density.compareTo("hdpi") == 0) { draw_factor = 1.5f; } float draw_factor2 = draw_factor; // correct for ultra high DPI if (Navit.metrics.densityDpi >= 320) // && (Navit.PREF_shrink_on_high_dpi)) { draw_factor2 = 1.8f * Navit.metrics.densityDpi / NavitGraphics.Global_want_dpi_other; NavitOSDJava.NavitStreetFontLetterWidth = (int) ((float) NavitOSDJava.NavitStreetFontLetterWidth_base * Navit.metrics.densityDpi / NavitGraphics.Global_want_dpi_other); } float real_factor = draw_factor2 / 1.5f; // // // sat_status_lt_w = (int) (8f * draw_factor); sat_status_lt_h = (int) (h * 0.35); sat_status_lt_x = (int) (2f * draw_factor); sat_status_lt_y = (int) ((h / 2) - (sat_status_lt_h / 2)); r1.set( sat_status_lt_x, sat_status_lt_y, sat_status_lt_x + sat_status_lt_w, sat_status_lt_y + sat_status_lt_h); int mCanvasWidth = w; int mCanvasHeight = h; LayoutParams params = null; // child1 = Navit.Global_Navit_Object.findViewById(R.id.top_bar); child2 = Navit.Global_Navit_Object.findViewById(R.id.osd_compass_new); child3 = Navit.Global_Navit_Object.findViewById(R.id.osd_nextturn_new); child4 = Navit.Global_Navit_Object.findViewById(R.id.osd_timetoturn_new); child5 = Navit.Global_Navit_Object.findViewById(R.id.osd_timetodest_new); child6 = Navit.Global_Navit_Object.findViewById(R.id.osd_roaddistance_new); child7 = Navit.Global_Navit_Object.findViewById(R.id.osd_eta_new); child8 = Navit.Global_Navit_Object.findViewById(R.id.view_speeding); child9 = Navit.Global_Navit_Object.findViewById(R.id.view_laneassist); // this.need_size_change = false; } super.onDraw(c); // System.out.println("onDraw:ZANaviLinearLayout"); try { if (!Navit.PAINT_OLD_API) { child1.postInvalidate(); child2.postInvalidate(); child3.postInvalidate(); child4.postInvalidate(); child5.postInvalidate(); child6.postInvalidate(); child7.postInvalidate(); child8.postInvalidate(); child9.postInvalidate(); } else { // child1.postInvalidate(); // child2.postInvalidate(); // child3.postInvalidate(); // child4.postInvalidate(); // child5.postInvalidate(); // child6.postInvalidate(); // child7.postInvalidate(); // child8.postInvalidate(); // child9.postInvalidate(); } } catch (Exception e) { } try { if (Navit.p.PREF_show_sat_status) { if (Navit.sats > sat_status_max_sats) { sat_status_max_sats = Navit.sats; } // old status NavitVehicle.sat_status_icon_last = NavitVehicle.sat_status_icon_now; // get new status // if (Navit.satsInFix > 3) if (Navit.isGPSFix) { // GPS found position NavitVehicle.sat_status_icon_now = 1; } else { // GPS lost position NavitVehicle.sat_status_icon_now = 0; } if (NavitVehicle.sat_status_icon_now != NavitVehicle.sat_status_icon_last) { try { // if (NavitVehicle.sat_status_icon_now == 1) if (Navit.isGPSFix) { Navit.Global_Navit_Object.getSupportActionBar() .setIcon(R.drawable.ic_action_location_found); } else { Navit.Global_Navit_Object.getSupportActionBar() .setIcon(R.drawable.ic_action_location_searching); } } catch (Exception e) { e.printStackTrace(); } } r2.set( sat_status_lt_x, sat_status_lt_y + sat_status_lt_h - (sat_status_lt_h / sat_status_max_sats * Navit.sats), sat_status_lt_x + sat_status_lt_w, sat_status_lt_y + sat_status_lt_h); r3.set( sat_status_lt_x, sat_status_lt_y + sat_status_lt_h - (sat_status_lt_h / sat_status_max_sats * Navit.satsInFix), sat_status_lt_x + sat_status_lt_w, sat_status_lt_y + sat_status_lt_h); r4.set( sat_status_lt_x, sat_status_lt_y, sat_status_lt_x + sat_status_lt_w, sat_status_lt_y + sat_status_lt_h); // fill rect paint_sat_status.setColor(Color.GRAY); paint_sat_status.setStyle(Paint.Style.FILL); paint_sat_status.setStrokeWidth(0); paint_sat_status.setAntiAlias(true); c.drawRect(r1, paint_sat_status); // fill inactive sats paint_sat_status.setColor(Color.YELLOW); paint_sat_status.setStyle(Paint.Style.FILL); paint_sat_status.setStrokeWidth(0); paint_sat_status.setAntiAlias(true); c.drawRect(r2, paint_sat_status); // fill active sats paint_sat_status.setColor(Color.GREEN); paint_sat_status.setStyle(Paint.Style.FILL); paint_sat_status.setStrokeWidth(0); paint_sat_status.setAntiAlias(true); c.drawRect(r3, paint_sat_status); // black rect around it all paint_sat_status.setColor(Color.BLACK); paint_sat_status.setStyle(Paint.Style.STROKE); paint_sat_status.setStrokeWidth(1); paint_sat_status.setAntiAlias(true); c.drawRect(r4, paint_sat_status); } else // sat status is turned off! { // old status NavitVehicle.sat_status_icon_last = NavitVehicle.sat_status_icon_now; // get new status NavitVehicle.sat_status_icon_now = -1; if (NavitVehicle.sat_status_icon_now != NavitVehicle.sat_status_icon_last) { try { Navit.Global_Navit_Object.getSupportActionBar().setIcon(R.drawable.icon); } catch (Exception e) { } } } } catch (Exception e) { // e.printStackTrace(); } if (!Navit.p.PREF_follow_gps) { if (!NavitGraphics.MAP_DISPLAY_OFF) { // show cross hair delta_1 = 8; delta_2 = 35; if (Navit.metrics.densityDpi >= 320) // && (Navit.PREF_shrink_on_high_dpi)) { paint_crosshair.setStrokeWidth(2); delta_1 = 8 * 2; delta_2 = 35 * 2; } else { paint_crosshair.setStrokeWidth(1); } paint_crosshair.setAntiAlias(true); c.drawLine(wm - delta_1, hm, wm - delta_2, hm, paint_crosshair); c.drawLine(wm + delta_1, hm, wm + delta_2, hm, paint_crosshair); c.drawLine(wm, hm - delta_1, wm, hm - delta_2, paint_crosshair); c.drawLine(wm, hm + delta_1, wm, hm + delta_2, paint_crosshair); } } }
/** {@inheritDoc} */ @Override public void onPreviewFrame(byte[] data, Camera cam) { if (data == null) throw new NullPointerException(); Camera.Size size = cam.getParameters().getPreviewSize(); if (size == null) throw new NullPointerException(); if (!processing.compareAndSet(false, true)) return; int width = size.width; int height = size.height; int imgAvg = HeartRateImageProcessing.decodeYUV420SPtoRedAvg(data.clone(), height, width); // Log.i(TAG, "imgAvg="+imgAvg); if (imgAvg == 0 || imgAvg == 255) { processing.set(false); return; } int averageArrayAvg = 0; int averageArrayCnt = 0; for (int i = 0; i < averageArray.length; i++) { if (averageArray[i] > 0) { averageArrayAvg += averageArray[i]; averageArrayCnt++; } } int rollingAverage = (averageArrayCnt > 0) ? (averageArrayAvg / averageArrayCnt) : 0; TYPE newType = currentType; if (imgAvg < rollingAverage) { newType = TYPE.RED; if (newType != currentType) { beats++; // Log.d(TAG, "BEAT!! beats="+beats); } } else if (imgAvg > rollingAverage) { newType = TYPE.GREEN; } if (averageIndex == averageArraySize) averageIndex = 0; averageArray[averageIndex] = imgAvg; averageIndex++; // Transitioned from one state to another to the same if (newType != currentType) { currentType = newType; image.postInvalidate(); } long endTime = System.currentTimeMillis(); double totalTimeInSecs = (endTime - startTime) / 1000d; if (totalTimeInSecs >= 10) { double bps = (beats / totalTimeInSecs); int dpm = (int) (bps * 60d); if (dpm < 30 || dpm > 180) { startTime = System.currentTimeMillis(); beats = 0; processing.set(false); return; } // Log.d(TAG, // "totalTimeInSecs="+totalTimeInSecs+" beats="+beats); if (beatsIndex == beatsArraySize) beatsIndex = 0; beatsArray[beatsIndex] = dpm; beatsIndex++; int beatsArrayAvg = 0; int beatsArrayCnt = 0; for (int i = 0; i < beatsArray.length; i++) { if (beatsArray[i] > 0) { beatsArrayAvg += beatsArray[i]; beatsArrayCnt++; } } int beatsAvg = (beatsArrayAvg / beatsArrayCnt); // text.setText("Your heart rate\n"+String.valueOf(beatsAvg)); heartRate = "Your heart rate\n" + String.valueOf(beatsAvg); startTime = System.currentTimeMillis(); beats = 0; } processing.set(false); }
public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) { if (key.equals(TiC.PROPERTY_LEFT)) { if (newValue != null) { layoutParams.optionLeft = TiConvert.toTiDimension(TiConvert.toString(newValue), TiDimension.TYPE_LEFT); } else { layoutParams.optionLeft = null; } layoutNativeView(); } else if (key.equals(TiC.PROPERTY_TOP)) { if (newValue != null) { layoutParams.optionTop = TiConvert.toTiDimension(TiConvert.toString(newValue), TiDimension.TYPE_TOP); } else { layoutParams.optionTop = null; } layoutNativeView(); } else if (key.equals(TiC.PROPERTY_CENTER)) { TiConvert.updateLayoutCenter(newValue, layoutParams); layoutNativeView(); } else if (key.equals(TiC.PROPERTY_RIGHT)) { if (newValue != null) { layoutParams.optionRight = TiConvert.toTiDimension(TiConvert.toString(newValue), TiDimension.TYPE_RIGHT); } else { layoutParams.optionRight = null; } layoutNativeView(); } else if (key.equals(TiC.PROPERTY_BOTTOM)) { if (newValue != null) { layoutParams.optionBottom = TiConvert.toTiDimension(TiConvert.toString(newValue), TiDimension.TYPE_BOTTOM); } else { layoutParams.optionBottom = null; } layoutNativeView(); } else if (key.equals(TiC.PROPERTY_SIZE)) { if (newValue instanceof HashMap) { HashMap<String, Object> d = (HashMap) newValue; propertyChanged(TiC.PROPERTY_WIDTH, oldValue, d.get(TiC.PROPERTY_WIDTH), proxy); propertyChanged(TiC.PROPERTY_HEIGHT, oldValue, d.get(TiC.PROPERTY_HEIGHT), proxy); } else if (newValue != null) { Log.w( LCAT, "Unsupported property type (" + (newValue.getClass().getSimpleName()) + ") for key: " + key + ". Must be an object/dictionary"); } } else if (key.equals(TiC.PROPERTY_HEIGHT)) { if (newValue != null) { if (!newValue.equals(TiC.SIZE_AUTO)) { layoutParams.optionHeight = TiConvert.toTiDimension(TiConvert.toString(newValue), TiDimension.TYPE_HEIGHT); layoutParams.autoHeight = false; } else { layoutParams.optionHeight = null; layoutParams.autoHeight = true; } } else { layoutParams.optionHeight = null; } layoutNativeView(); } else if (key.equals(TiC.PROPERTY_WIDTH)) { if (newValue != null) { if (!newValue.equals(TiC.SIZE_AUTO)) { layoutParams.optionWidth = TiConvert.toTiDimension(TiConvert.toString(newValue), TiDimension.TYPE_WIDTH); layoutParams.autoWidth = false; } else { layoutParams.optionWidth = null; layoutParams.autoWidth = true; } } else { layoutParams.optionWidth = null; } layoutNativeView(); } else if (key.equals(TiC.PROPERTY_ZINDEX)) { if (newValue != null) { layoutParams.optionZIndex = TiConvert.toInt(newValue); } else { layoutParams.optionZIndex = 0; } layoutNativeView(true); } else if (key.equals(TiC.PROPERTY_FOCUSABLE)) { boolean focusable = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_FOCUSABLE)); nativeView.setFocusable(focusable); if (focusable) { registerForKeyClick(nativeView); } else { // nativeView.setOnClickListener(null); // ? mistake? I assume OnKeyListener was meant nativeView.setOnKeyListener(null); } } else if (key.equals(TiC.PROPERTY_TOUCH_ENABLED)) { doSetClickable(TiConvert.toBoolean(newValue)); } else if (key.equals(TiC.PROPERTY_VISIBLE)) { nativeView.setVisibility(TiConvert.toBoolean(newValue) ? View.VISIBLE : View.INVISIBLE); } else if (key.equals(TiC.PROPERTY_ENABLED)) { nativeView.setEnabled(TiConvert.toBoolean(newValue)); } else if (key.startsWith(TiC.PROPERTY_BACKGROUND_PADDING)) { Log.i(LCAT, key + " not yet implemented."); } else if (key.equals(TiC.PROPERTY_OPACITY) || key.startsWith(TiC.PROPERTY_BACKGROUND_PREFIX) || key.startsWith(TiC.PROPERTY_BORDER_PREFIX)) { // Update first before querying. proxy.setProperty(key, newValue); KrollDict d = proxy.getProperties(); boolean hasImage = hasImage(d); boolean hasColorState = hasColorState(d); boolean hasBorder = hasBorder(d); boolean requiresCustomBackground = hasImage || hasColorState || hasBorder; if (!requiresCustomBackground) { if (background != null) { background.releaseDelegate(); background.setCallback(null); background = null; } if (d.containsKeyAndNotNull(TiC.PROPERTY_BACKGROUND_COLOR)) { Integer bgColor = TiConvert.toColor(d, TiC.PROPERTY_BACKGROUND_COLOR); if (nativeView != null) { nativeView.setBackgroundColor(bgColor); nativeView.postInvalidate(); } } else { if (key.equals(TiC.PROPERTY_OPACITY)) { setOpacity(TiConvert.toFloat(newValue)); } if (nativeView != null) { nativeView.setBackgroundDrawable(null); nativeView.postInvalidate(); } } } else { boolean newBackground = background == null; if (newBackground) { background = new TiBackgroundDrawable(); } Integer bgColor = null; if (!hasColorState) { if (d.get(TiC.PROPERTY_BACKGROUND_COLOR) != null) { bgColor = TiConvert.toColor(d, TiC.PROPERTY_BACKGROUND_COLOR); if (newBackground || (key.equals(TiC.PROPERTY_OPACITY) || key.equals(TiC.PROPERTY_BACKGROUND_COLOR))) { background.setBackgroundColor(bgColor); } } } if (hasImage || hasColorState) { if (newBackground || key.startsWith(TiC.PROPERTY_BACKGROUND_PREFIX)) { handleBackgroundImage(d); } } if (hasBorder) { if (newBackground) { initializeBorder(d, bgColor); } else if (key.startsWith(TiC.PROPERTY_BORDER_PREFIX)) { handleBorderProperty(key, newValue); } } applyCustomBackground(); } if (nativeView != null) { nativeView.postInvalidate(); } } else if (key.equals(TiC.PROPERTY_SOFT_KEYBOARD_ON_FOCUS)) { Log.w( LCAT, "Focus state changed to " + TiConvert.toString(newValue) + " not honored until next focus event."); } else if (key.equals(TiC.PROPERTY_TRANSFORM)) { if (nativeView != null) { applyTransform((Ti2DMatrix) newValue); } } else if (key.equals(TiC.PROPERTY_KEEP_SCREEN_ON)) { if (nativeView != null) { nativeView.setKeepScreenOn(TiConvert.toBoolean(newValue)); } } else { TiViewProxy viewProxy = getProxy(); if (viewProxy != null && viewProxy.isLocalizedTextId(key)) { viewProxy.setLocalizedText(key, TiConvert.toString(newValue)); } else { if (DBG) { Log.d(LCAT, "Unhandled property key: " + key); } } } }