public void processProperties(KrollDict d) { if (d.containsKey(TiC.PROPERTY_LAYOUT)) { String layout = TiConvert.toString(d, TiC.PROPERTY_LAYOUT); if (nativeView instanceof TiCompositeLayout) { ((TiCompositeLayout) nativeView).setLayoutArrangement(layout); } } if (TiConvert.fillLayout(d, layoutParams)) { if (nativeView != null) { nativeView.requestLayout(); } } Integer bgColor = null; // Default background processing. // Prefer image to color. if (hasImage(d) || hasColorState(d) || hasBorder(d)) { handleBackgroundImage(d); } else if (d.containsKey(TiC.PROPERTY_BACKGROUND_COLOR)) { bgColor = TiConvert.toColor(d, TiC.PROPERTY_BACKGROUND_COLOR); nativeView.setBackgroundColor(bgColor); } if (d.containsKey(TiC.PROPERTY_OPACITY)) { if (nativeView != null) { setOpacity(TiConvert.toFloat(d, TiC.PROPERTY_OPACITY)); } } if (d.containsKey(TiC.PROPERTY_VISIBLE)) { nativeView.setVisibility( TiConvert.toBoolean(d, TiC.PROPERTY_VISIBLE) ? View.VISIBLE : View.INVISIBLE); } if (d.containsKey(TiC.PROPERTY_ENABLED)) { nativeView.setEnabled(TiConvert.toBoolean(d, TiC.PROPERTY_ENABLED)); } if (d.containsKey(TiC.PROPERTY_FOCUSABLE)) { boolean focusable = TiConvert.toBoolean(d, TiC.PROPERTY_FOCUSABLE); nativeView.setFocusable(focusable); if (focusable) { registerForKeyClick(nativeView); } else { nativeView.setOnClickListener(null); } } initializeBorder(d, bgColor); if (d.containsKey(TiC.PROPERTY_TRANSFORM)) { animBuilder = new TiAnimationBuilder(); animBuilder.applyOptions(d); AnimationSet as = animBuilder.render(proxy, nativeView); nativeView.startAnimation(as); } }
public void animate() { TiAnimationBuilder builder = proxy.getPendingAnimation(); if (builder != null && nativeView != null) { AnimationSet as = builder.render(proxy, nativeView); if (DBG) { Log.d(LCAT, "starting animation: " + as); } nativeView.startAnimation(as); // Clean up proxy proxy.clearAnimation(builder); } }
@Kroll.method public void animate(Object arg, @Kroll.argument(optional = true) KrollFunction callback) { synchronized (pendingAnimationLock) { if (arg instanceof HashMap) { HashMap options = (HashMap) arg; pendingAnimation = new TiAnimationBuilder(); pendingAnimation.applyOptions(options); if (callback != null) { pendingAnimation.setCallback(callback); } } else if (arg instanceof TiAnimation) { TiAnimation anim = (TiAnimation) arg; pendingAnimation = new TiAnimationBuilder(); pendingAnimation.applyAnimation(anim); } else { throw new IllegalArgumentException( "Unhandled argument to animate: " + arg.getClass().getSimpleName()); } handlePendingAnimation(false); } }
protected void applyTransform(Ti2DMatrix matrix) { layoutParams.optionTransform = matrix; if (animBuilder == null) { animBuilder = new TiAnimationBuilder(); } if (nativeView != null) { if (matrix != null) { TiMatrixAnimation matrixAnimation = animBuilder.createMatrixAnimation(matrix); matrixAnimation.interpolate = false; matrixAnimation.setDuration(1); matrixAnimation.setFillAfter(true); nativeView.startAnimation(matrixAnimation); } else { nativeView.clearAnimation(); } } }