com.taobao.weex.ui.animation.WXAnimationBean Java Examples
The following examples show how to use
com.taobao.weex.ui.animation.WXAnimationBean.
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: WXParallax.java From incubator-weex-playground with Apache License 2.0 | 6 votes |
TransformCreator(String type, JSONObject object) { transformType = type; JSONArray in = object.getJSONArray("in"); input = parseParamArray(in); JSONArray out = object.getJSONArray("out"); output = parseParamArray(out); switch (transformType) { case WXAnimationBean.Style.WX_TRANSLATE: fromTranslateX = output[0]; fromTranslateY = output[1]; break; case WXAnimationBean.Style.WX_SCALE: fromScaleX = output[0]; fromScaleY = output[1]; break; case WXAnimationBean.Style.WX_ROTATE: fromRotate = output[0]; break; case WX_OPACITY: fromOpacity = output[0]; break; } }
Example #2
Source File: DOMActionContextImpl.java From ucar-weex-core with Apache License 2.0 | 6 votes |
private WXAnimationBean createAnimationBean(String ref,Map<String, Object> style){ if (style != null) { try { Object transform = style.get(WXDomObject.TRANSFORM); if (transform instanceof String && !TextUtils.isEmpty((String) transform)) { String transformOrigin = (String) style.get(WXDomObject.TRANSFORM_ORIGIN); WXAnimationBean animationBean = new WXAnimationBean(); WXDomObject domObject = mRegistry.get(ref); int width = (int) domObject.getLayoutWidth(); int height = (int) domObject.getLayoutHeight(); animationBean.styles = new WXAnimationBean.Style(); animationBean.styles.init(transformOrigin, (String) transform, width, height,WXSDKManager.getInstanceViewPortWidth(mInstanceId)); return animationBean; } }catch (RuntimeException e){ WXLogUtils.e("", e); return null; } } return null; }
Example #3
Source File: WXDomStatement.java From weex-uikit with MIT License | 6 votes |
private WXAnimationBean createAnimationBean(String ref,Map<String, Object> style){ if (style != null) { try { Object transform = style.get(WXDomObject.TRANSFORM); if (transform instanceof String && !TextUtils.isEmpty((String) transform)) { String transformOrigin = (String) style.get(WXDomObject.TRANSFORM_ORIGIN); WXAnimationBean animationBean = new WXAnimationBean(); WXDomObject domObject = mRegistry.get(ref); int width = (int) domObject.getLayoutWidth(); int height = (int) domObject.getLayoutHeight(); animationBean.styles = new WXAnimationBean.Style(); animationBean.styles.init(transformOrigin, (String) transform, width, height,WXSDKManager.getInstance().getSDKInstance(mInstanceId).getViewPortWidth()); return animationBean; } }catch (RuntimeException e){ WXLogUtils.e("", e); return null; } } return null; }
Example #4
Source File: WXDomStatement.java From weex-uikit with MIT License | 6 votes |
private WXAnimationBean createAnimationBean(String ref, String animation){ try { WXAnimationBean animationBean = JSONObject.parseObject(animation, WXAnimationBean.class); if (animationBean != null && animationBean.styles != null) { WXDomObject domObject=mRegistry.get(ref); int width=(int)domObject.getLayoutWidth(); int height=(int)domObject.getLayoutHeight(); animationBean.styles.init(animationBean.styles.transformOrigin, animationBean.styles.transform,width,height,WXSDKManager.getInstance().getSDKInstance(mInstanceId).getViewPortWidth()); } return animationBean; } catch (RuntimeException e) { WXLogUtils.e("", e); return null; } }
Example #5
Source File: AnimationAction.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@Override public void executeDom(DOMActionContext context) { try { WXDomObject domObject; if (!context.isDestory() && !TextUtils.isEmpty(animation) && (domObject = context.getDomByRef(ref)) != null) { WXAnimationBean animationBean = JSONObject.parseObject(animation, WXAnimationBean.class); if (animationBean != null && animationBean.styles != null) { int width = (int) domObject.getLayoutWidth(); int height = (int) domObject.getLayoutHeight(); animationBean.styles.init(animationBean.styles.transformOrigin, animationBean.styles.transform, width, height, context.getInstance().getInstanceViewPortWidth()); mAnimationBean = animationBean; context.postRenderTask(this); } } } catch (RuntimeException e) { WXLogUtils.e(TAG, WXLogUtils.getStackTrace(e)); } }
Example #6
Source File: WXDomStatement.java From weex-uikit with MIT License | 6 votes |
void startAnimation(@NonNull final String ref, @NonNull String animation, @Nullable final String callBack){ if (mDestroy) { return; } WXDomObject domObject = mRegistry.get(ref); if (domObject == null) { return; } final WXAnimationBean animationBean=createAnimationBean(ref, animation); if(animationBean!=null) { mNormalTasks.add(new IWXRenderTask() { @Override public void execute() { mWXRenderManager.startAnimation(mInstanceId, ref, animationBean, callBack); } @Override public String toString() { return "startAnimationByCall"; } }); mDirty=true; } }
Example #7
Source File: WXDomStatement.java From weex-uikit with MIT License | 6 votes |
private void parseAnimation() { for(final Pair<String, Map<String, Object>> pair:animations) { if (!TextUtils.isEmpty(pair.first)) { final WXAnimationBean animationBean = createAnimationBean(pair.first, pair.second); if (animationBean != null) { mNormalTasks.add(new IWXRenderTask() { @Override public void execute() { mWXRenderManager.startAnimation(mInstanceId, pair.first, animationBean, null); } @Override public String toString() { return "startAnimationByStyle"; } }); } } } }
Example #8
Source File: DOMActionContextImpl.java From ucar-weex-core with Apache License 2.0 | 5 votes |
private void parseAnimation() { for (final Pair<String, Map<String, Object>> pair : animations) { if (!TextUtils.isEmpty(pair.first)) { final WXAnimationBean animationBean = createAnimationBean(pair.first, pair.second); if (animationBean != null) { postRenderTask(Actions.getAnimationAction(pair.first, animationBean)); } } } }
Example #9
Source File: WXRenderStatement.java From weex with Apache License 2.0 | 5 votes |
void startAnimation(String ref, String animation, String callBack) { WXComponent component = mRegistry.get(ref); if (component == null || component.getRealView() == null) { return; } else { try { WXAnimationBean animationBean = WXAnimationModule.parseAnimation(animation, component.getRealView().getLayoutParams()); if (animationBean != null) { Animator animator = WXAnimationModule.createAnimator(animationBean, component.getRealView()); if (animator != null) { Animator.AnimatorListener animatorListener = WXAnimationModule.createAnimatorListener(mWXSDKInstance, callBack); Interpolator interpolator = WXAnimationModule.createTimeInterpolator(animationBean); if (animatorListener != null) { animator.addListener(animatorListener); } if (interpolator != null) { animator.setInterpolator(interpolator); } animator.setDuration(animationBean.duration); animator.start(); } } } catch (RuntimeException e) { WXLogUtils.e(WXLogUtils.getStackTrace(e)); } } }
Example #10
Source File: WXRenderManager.java From weex-uikit with MIT License | 5 votes |
public void startAnimation(String instanceId, @NonNull String ref, @NonNull WXAnimationBean animationBean, @Nullable String callBack) { WXRenderStatement statement = mRegistries.get(instanceId); if (statement == null) { return; } statement.startAnimation(ref, animationBean, callBack); }
Example #11
Source File: AnimationAction.java From ucar-weex-core with Apache License 2.0 | 5 votes |
private @Nullable Interpolator createTimeInterpolator() { String interpolator = mAnimationBean.timingFunction; if (!TextUtils.isEmpty(interpolator)) { switch (interpolator) { case WXAnimationBean.EASE_IN: return new AccelerateInterpolator(); case WXAnimationBean.EASE_OUT: return new DecelerateInterpolator(); case WXAnimationBean.EASE_IN_OUT: return new AccelerateDecelerateInterpolator(); case WXAnimationBean.LINEAR: return new LinearInterpolator(); default: //Parse cubic-bezier try { SingleFunctionParser<Float> parser = new SingleFunctionParser<>( mAnimationBean.timingFunction, new SingleFunctionParser.FlatMapper<Float>() { @Override public Float map(String raw) { return Float.parseFloat(raw); } }); List<Float> params = parser.parse(WXAnimationBean.CUBIC_BEZIER); if (params != null && params.size() == WXAnimationBean.NUM_CUBIC_PARAM) { return PathInterpolatorCompat.create( params.get(0), params.get(1), params.get(2), params.get(3)); } else { return null; } } catch (RuntimeException e) { return null; } } } return null; }
Example #12
Source File: AnimationAction.java From ucar-weex-core with Apache License 2.0 | 5 votes |
AnimationAction(@NonNull String ref, @NonNull WXAnimationBean animationBean, @Nullable final String callBack) { this.ref = ref; this.mAnimationBean = animationBean; this.callback = callBack; this.animation = null; }
Example #13
Source File: AnimationAction.java From ucar-weex-core with Apache License 2.0 | 4 votes |
private @Nullable ObjectAnimator createAnimator(final View target, final int viewPortWidth) { if (target == null) { return null; } WXAnimationBean.Style style = mAnimationBean.styles; if (style != null) { ObjectAnimator animator; List<PropertyValuesHolder> holders = style.getHolders(); if (!TextUtils.isEmpty(style.backgroundColor)) { BorderDrawable borderDrawable; if ((borderDrawable = WXViewUtils.getBorderDrawable(target)) != null) { holders.add(PropertyValuesHolder.ofObject( new BackgroundColorProperty(), new ArgbEvaluator(), borderDrawable.getColor(), WXResourceUtils.getColor(style.backgroundColor))); } else if (target.getBackground() instanceof ColorDrawable) { holders.add(PropertyValuesHolder.ofObject( new BackgroundColorProperty(), new ArgbEvaluator(), ((ColorDrawable) target.getBackground()).getColor(), WXResourceUtils.getColor(style.backgroundColor))); } } if (target.getLayoutParams() != null && (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) { ViewGroup.LayoutParams layoutParams = target.getLayoutParams(); if (!TextUtils.isEmpty(style.width)) { holders.add(PropertyValuesHolder.ofInt(new WidthProperty(), layoutParams.width, (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width), viewPortWidth))); } if (!TextUtils.isEmpty(style.height)) { holders.add(PropertyValuesHolder.ofInt(new HeightProperty(), layoutParams.height, (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height), viewPortWidth))); } } if (style.getPivot() != null) { Pair<Float, Float> pair = style.getPivot(); target.setPivotX(pair.first); target.setPivotY(pair.second); } animator = ObjectAnimator.ofPropertyValuesHolder( target, holders.toArray(new PropertyValuesHolder[holders.size()])); animator.setStartDelay(mAnimationBean.delay); return animator; } else { return null; } }
Example #14
Source File: AnimationAction.java From ucar-weex-core with Apache License 2.0 | 4 votes |
AnimationAction(@NonNull String ref, @NonNull WXAnimationBean animationBean) { this(ref, animationBean, null); }
Example #15
Source File: Actions.java From ucar-weex-core with Apache License 2.0 | 4 votes |
public static RenderAction getAnimationAction(@NonNull String ref, @NonNull final WXAnimationBean animationBean, @Nullable String callback){ return new AnimationAction(ref, animationBean, callback); }
Example #16
Source File: WXRenderStatement.java From weex-uikit with MIT License | 4 votes |
void startAnimation(@NonNull String ref, @NonNull WXAnimationBean animationBean, @Nullable String callBack) { WXAnimationModule.startAnimation(mWXSDKInstance, mRegistry.get(ref), animationBean, callBack); }
Example #17
Source File: Actions.java From ucar-weex-core with Apache License 2.0 | 4 votes |
public static RenderAction getAnimationAction(@NonNull String ref, @NonNull final WXAnimationBean animationBean){ return new AnimationAction(ref, animationBean); }