use of com.taobao.weex.ui.component.WXRefresh in project weex-example by KalicyZhou.
the class BasicListComponent method onBindViewHolder.
/**
* Bind the component of the position to the holder. Then flush the view.
*
* @param holder viewHolder, which holds reference to the view
* @param position position of component in WXListComponent
*/
@Override
public void onBindViewHolder(ListBaseViewHolder holder, int position) {
if (holder == null)
return;
holder.setComponentUsing(true);
WXComponent component = getChild(position);
if (component == null || (component instanceof WXRefresh) || (component instanceof WXLoading) || (component.getDomObject() != null && component.getDomObject().isFixed())) {
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d(TAG, "Bind WXRefresh & WXLoading " + holder);
}
return;
}
if (holder.getComponent() != null && holder.getComponent() instanceof WXCell) {
holder.getComponent().bindData(component);
// holder.getComponent().refreshData(component);
}
}
use of com.taobao.weex.ui.component.WXRefresh in project incubator-weex by apache.
the class BasicListComponent method onBindViewHolder.
/**
* Bind the component of the position to the holder. Then flush the view.
*
* @param holder viewHolder, which holds reference to the view
* @param position position of component in list
*/
@Override
public void onBindViewHolder(final ListBaseViewHolder holder, int position) {
if (holder == null)
return;
holder.setComponentUsing(true);
WXComponent component = getChild(position);
if (component == null || (component instanceof WXRefresh) || (component instanceof WXLoading) || (component.getDomObject() != null && component.getDomObject().isFixed())) {
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d(TAG, "Bind WXRefresh & WXLoading " + holder);
}
if (component instanceof WXBaseRefresh && holder.getView() != null && component.getDomObject() != null && (component.getDomObject().getAttrs().get("holderBackground") != null)) {
Object holderBackground = component.getDomObject().getAttrs().get("holderBackground");
int color = WXResourceUtils.getColor(holderBackground.toString(), Color.WHITE);
holder.getView().setBackgroundColor(color);
holder.getView().setVisibility(View.VISIBLE);
holder.getView().postInvalidate();
}
return;
}
if (holder.getComponent() != null && holder.getComponent() instanceof WXCell) {
if (holder.isRecycled()) {
holder.bindData(component);
component.onRenderFinish(STATE_UI_FINISH);
}
if (mDragHelper == null || !mDragHelper.isDraggable()) {
return;
}
mTriggerType = (mTriggerType == null) ? DEFAULT_TRIGGER_TYPE : mTriggerType;
WXCell cell = (WXCell) holder.getComponent();
boolean isExcluded = DEFAULT_EXCLUDED;
if (cell.getDomObject() != null) {
WXAttr cellAttrs = cell.getDomObject().getAttrs();
isExcluded = WXUtils.getBoolean(cellAttrs.get(EXCLUDED), DEFAULT_EXCLUDED);
}
mDragHelper.setDragExcluded(holder, isExcluded);
// NOTICE: event maybe consumed by other views
if (DragTriggerType.PAN.equals(mTriggerType)) {
mDragHelper.setLongPressDragEnabled(false);
WXComponent anchorComponent = findComponentByAnchorName(cell, DRAG_ANCHOR);
if (anchorComponent != null && anchorComponent.getHostView() != null && !isExcluded) {
View anchor = anchorComponent.getHostView();
anchor.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
mDragHelper.startDrag(holder);
}
return true;
}
});
} else {
if (WXEnvironment.isApkDebugable()) {
if (!isExcluded) {
WXLogUtils.e(TAG, "[error] onBindViewHolder: the anchor component or view is not found");
} else {
WXLogUtils.d(TAG, "onBindViewHolder: position " + position + " is drag excluded");
}
}
}
} else if (DragTriggerType.LONG_PRESS.equals(mTriggerType)) {
mDragHelper.setLongPressDragEnabled(true);
}
}
}
use of com.taobao.weex.ui.component.WXRefresh in project weex-example by KalicyZhou.
the class WXListComponent method createChildViewAt.
@Override
public void createChildViewAt(int index) {
int indexToCreate = index;
if (indexToCreate < 0) {
indexToCreate = childCount() - 1;
if (indexToCreate < 0) {
return;
}
}
final WXComponent child = getChild(indexToCreate);
if (child instanceof WXBaseRefresh) {
child.createView();
if (child instanceof WXRefresh) {
getHostView().setOnRefreshListener((WXRefresh) child);
getHostView().postDelayed(new Runnable() {
@Override
public void run() {
getHostView().setHeaderView(child);
}
}, 100);
} else if (child instanceof WXLoading) {
getHostView().setOnLoadingListener((WXLoading) child);
getHostView().postDelayed(new Runnable() {
@Override
public void run() {
getHostView().setFooterView(child);
}
}, 100);
}
} else {
super.createChildViewAt(indexToCreate);
}
}
use of com.taobao.weex.ui.component.WXRefresh in project incubator-weex by apache.
the class WXListComponent method createChildViewAt.
@Override
public void createChildViewAt(int index) {
Pair<WXComponent, Integer> ret = rearrangeIndexAndGetChild(index);
if (ret.first != null) {
final WXComponent child = getChild(ret.second);
if (child instanceof WXBaseRefresh) {
child.createView();
if (child instanceof WXRefresh) {
getHostView().setOnRefreshListener((WXRefresh) child);
getHostView().postDelayed(WXThread.secure(new Runnable() {
@Override
public void run() {
getHostView().setHeaderView(child);
}
}), 100);
} else if (child instanceof WXLoading) {
getHostView().setOnLoadingListener((WXLoading) child);
getHostView().postDelayed(WXThread.secure(new Runnable() {
@Override
public void run() {
getHostView().setFooterView(child);
}
}), 100);
}
} else {
super.createChildViewAt(ret.second);
}
}
}
Aggregations