use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.
the class UpdateStyleAction method executeRender.
@Override
public void executeRender(RenderActionContext context) {
WXComponent component = context.getComponent(mRef);
if (component == null) {
return;
}
component.updateProperties(mData);
if (mData.containsKey(Constants.Name.PADDING) || mData.containsKey(Constants.Name.PADDING_TOP) || mData.containsKey(Constants.Name.PADDING_LEFT) || mData.containsKey(Constants.Name.PADDING_RIGHT) || mData.containsKey(Constants.Name.PADDING_BOTTOM) || mData.containsKey(Constants.Name.BORDER_WIDTH)) {
Spacing padding = mPadding;
Spacing border = mBorder;
component.setPadding(padding, border);
}
}
use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.
the class WXTransition method doTransitionAnimation.
/**
* doTransitionAnimation include transform and layout animation.
* 1. put pre transition updates from target style to dom style
* 2. do transform animation and layout animation
*/
private void doTransitionAnimation(final int token) {
final View taregtView = getTargetView();
if (taregtView == null) {
return;
}
if (targetStyles.size() > 0) {
for (String property : properties) {
if (!(LAYOUT_PROPERTIES.contains(property) || TRANSFORM_PROPERTIES.contains(property))) {
continue;
}
if (layoutPendingUpdates.containsKey(property)) {
continue;
}
if (transformPendingUpdates.containsKey(property)) {
continue;
}
synchronized (targetStyles) {
if (targetStyles.containsKey(property)) {
// reset pre transition style
Object targetValue = targetStyles.remove(property);
domObject.getStyles().put(property, targetValue);
WXComponent component = getComponent();
if (component != null && component.getDomObject() != null) {
component.getDomObject().getStyles().put(property, targetValue);
}
}
}
}
}
if (transitionEndEvent != null) {
taregtView.removeCallbacks(transitionEndEvent);
}
if (transitionEndEvent == null && duration > Float.MIN_NORMAL) {
transitionEndEvent = new Runnable() {
@Override
public void run() {
transitionEndEvent = null;
if (duration < Float.MIN_NORMAL) {
return;
}
WXComponent component = getComponent();
if (component != null && domObject.getEvents().contains(Constants.Event.ON_TRANSITION_END)) {
component.fireEvent(Constants.Event.ON_TRANSITION_END);
}
}
};
}
if (transformAnimationRunnable != null) {
taregtView.removeCallbacks(transformAnimationRunnable);
}
transformAnimationRunnable = new Runnable() {
@Override
public void run() {
synchronized (lockToken) {
if (token == lockToken.get()) {
doPendingTransformAnimation(token);
}
}
}
};
taregtView.post(transformAnimationRunnable);
doPendingLayoutAnimation();
}
use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.
the class WXTransition method onTransitionAnimationEnd.
private synchronized void onTransitionAnimationEnd() {
if (duration > 0) {
if (transitionEndEvent != null) {
View view = getTargetView();
if (view != null && transitionEndEvent != null) {
view.post(transitionEndEvent);
}
transitionEndEvent = null;
}
}
synchronized (targetStyles) {
if (targetStyles.size() > 0) {
WXComponent component = getComponent();
for (String property : properties) {
if (targetStyles.containsKey(property)) {
Object targetValue = targetStyles.remove(property);
domObject.getStyles().put(property, targetValue);
if (component != null && component.getDomObject() != null) {
component.getDomObject().getStyles().put(property, targetValue);
}
}
}
targetStyles.clear();
}
}
}
use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.
the class RenderActionContextImpl method setExtra.
/**
* set extra information of View
*/
void setExtra(String ref, Object extra) {
WXComponent component = mRegistry.get(ref);
if (component == null) {
return;
}
component.updateExtra(extra);
}
use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.
the class SimpleComponentHolder method createInstance.
@Override
public synchronized WXComponent createInstance(WXSDKInstance instance, WXDomObject node, WXVContainer parent) throws IllegalAccessException, InvocationTargetException, InstantiationException {
WXComponent component = mCreator.createInstance(instance, node, parent);
component.bindHolder(this);
return component;
}
Aggregations