本文整理汇总了Java中com.taobao.weex.ui.component.WXComponent.getHostView方法的典型用法代码示例。如果您正苦于以下问题:Java WXComponent.getHostView方法的具体用法?Java WXComponent.getHostView怎么用?Java WXComponent.getHostView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.taobao.weex.ui.component.WXComponent
的用法示例。
在下文中一共展示了WXComponent.getHostView方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: procSticky
import com.taobao.weex.ui.component.WXComponent; //导入方法依赖的package包/类
private View procSticky(Map<String, HashMap<String, WXComponent>> mStickyMap) {
if (mStickyMap == null) {
return null;
}
HashMap<String, WXComponent> stickyMap = mStickyMap.get(mWAScroller.getRef());
if (stickyMap == null) {
return null;
}
Iterator<Entry<String, WXComponent>> iterator = stickyMap.entrySet().iterator();
Entry<String, WXComponent> entry = null;
WXComponent stickyData;
while (iterator.hasNext()) {
entry = iterator.next();
stickyData = entry.getValue();
getLocationOnScreen(stickyScrollerP);
stickyData.getHostView().getLocationOnScreen(stickyViewP);
int parentH = 0;
if(stickyData.getParent()!=null && stickyData.getParent().getRealView()!=null){
parentH=stickyData.getParent().getRealView().getHeight();
}
int stickyViewH = stickyData.getHostView().getHeight();
int stickyShowPos = stickyScrollerP[1];
int stickyStartHidePos = -parentH + stickyScrollerP[1] + stickyViewH;
if (stickyViewP[1] <= stickyShowPos && stickyViewP[1] >= (stickyStartHidePos - stickyViewH)) {
mStickyOffset = stickyViewP[1] - stickyStartHidePos;
return stickyData.getHostView();
}
}
return null;
}
示例2: checkLastSticky
import com.taobao.weex.ui.component.WXComponent; //导入方法依赖的package包/类
/**
* Check last Sticky after scrollTo
* @param position scroll to position
*/
public void checkLastSticky(final int position) {
bounceRecyclerView.clearSticky();
for (int i = 0; i <= position; i++) {
WXComponent component = getChild(i);
if (component.isSticky() && component instanceof WXCell) {
if (component.getHostView() == null) {
return;
}
bounceRecyclerView.notifyStickyShow((WXCell) component);
}
}
}
示例3: onBeforeScroll
import com.taobao.weex.ui.component.WXComponent; //导入方法依赖的package包/类
@Override
public void onBeforeScroll(int dx, int dy) {
if (mStickyMap == null) {
return;
}
HashMap<String, WXComponent> stickyMap = mStickyMap.get(getRef());
if (stickyMap == null) {
return;
}
Iterator<Map.Entry<String, WXComponent>> iterator = stickyMap.entrySet().iterator();
Map.Entry<String, WXComponent> entry;
WXComponent stickyComponent;
while (iterator.hasNext()) {
entry = iterator.next();
stickyComponent = entry.getValue();
if (stickyComponent != null && stickyComponent.getDomObject() != null
&& stickyComponent instanceof WXCell) {
if (stickyComponent.getHostView() == null) {
return;
}
int[] location = new int[2];
stickyComponent.getHostView().getLocationOnScreen(location);
int[] parentLocation = new int[2];
stickyComponent.getParentScroller().getView().getLocationOnScreen(parentLocation);
int top = location[1] - parentLocation[1];
boolean showSticky = ((WXCell) stickyComponent).lastLocationY > 0 && top <= 0 && dy > 0;
boolean removeSticky = ((WXCell) stickyComponent).lastLocationY <= 0 && top > 0 && dy < 0;
if (showSticky) {
bounceRecyclerView.notifyStickyShow((WXCell) stickyComponent);
} else if (removeSticky) {
bounceRecyclerView.notifyStickyRemove((WXCell) stickyComponent);
}
((WXCell) stickyComponent).lastLocationY = top;
}
}
}
示例4: notifyAppearStateChange
import com.taobao.weex.ui.component.WXComponent; //导入方法依赖的package包/类
@Override
public void notifyAppearStateChange(int firstVisible, int lastVisible, int directionX, int directionY) {
//notify appear state
Iterator<AppearanceHelper> it = mAppearComponents.values().iterator();
String direction = directionY > 0 ? "up" : "down";
if (getOrientation() == Constants.Orientation.HORIZONTAL) {
direction = directionX > 0 ? "left" : "right";
}
while (it.hasNext()) {
AppearanceHelper item = it.next();
WXComponent component = item.getAwareChild();
if (!item.isWatch()) {
continue;
}
boolean outOfVisibleRange = item.getCellPositionINScollable() < firstVisible || item.getCellPositionINScollable() > lastVisible;
View view = component.getHostView();
if (view == null) {
continue;
}
boolean visible = (!outOfVisibleRange) && item.isViewVisible();
int result = item.setAppearStatus(visible);
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d("appear", "item " + item.getCellPositionINScollable() + " result " + result);
}
if (result == AppearanceHelper.RESULT_NO_CHANGE) {
continue;
}
component.notifyAppearStateChange(result == AppearanceHelper.RESULT_APPEAR ? Constants.Event.APPEAR : Constants.Event.DISAPPEAR, direction);
}
}
示例5: startAnimation
import com.taobao.weex.ui.component.WXComponent; //导入方法依赖的package包/类
private void startAnimation(@NonNull WXSDKInstance instance, @Nullable WXComponent component) {
if (component != null) {
if (mAnimationBean != null) {
component.setNeedLayoutOnAnimation(mAnimationBean.needLayout);
}
if (component.getHostView() == null) {
WXAnimationModule.AnimationHolder holder = new WXAnimationModule.AnimationHolder(mAnimationBean, callback);
component.postAnimation(holder);
} else {
try {
Animator animator = createAnimator(component.getHostView(), instance
.getInstanceViewPortWidth());
if (animator != null) {
Animator.AnimatorListener animatorCallback = createAnimatorListener(instance, callback);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2 && component
.isLayerTypeEnabled() ) {
component.getHostView().setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
Interpolator interpolator = createTimeInterpolator();
if (animatorCallback != null) {
animator.addListener(animatorCallback);
}
if (interpolator != null) {
animator.setInterpolator(interpolator);
}
animator.setDuration(mAnimationBean.duration);
animator.start();
}
} catch (RuntimeException e) {
WXLogUtils.e(TAG, WXLogUtils.getStackTrace(e));
}
}
}
}
示例6: procSticky
import com.taobao.weex.ui.component.WXComponent; //导入方法依赖的package包/类
private View procSticky(Map<String, Map<String, WXComponent>> mStickyMap) {
if (mStickyMap == null) {
return null;
}
Map<String, WXComponent> stickyMap = mStickyMap.get(mWAScroller.getRef());
if (stickyMap == null) {
return null;
}
Iterator<Entry<String, WXComponent>> iterator = stickyMap.entrySet().iterator();
Entry<String, WXComponent> entry = null;
WXComponent stickyData;
while (iterator.hasNext()) {
entry = iterator.next();
stickyData = entry.getValue();
getLocationOnScreen(stickyScrollerP);
stickyData.getHostView().getLocationOnScreen(stickyViewP);
int parentH = 0;
if(stickyData.getParent()!=null && stickyData.getParent().getRealView()!=null){
parentH=stickyData.getParent().getRealView().getHeight();
}
int stickyViewH = stickyData.getHostView().getHeight();
int stickyShowPos = stickyScrollerP[1];
int stickyStartHidePos = -parentH + stickyScrollerP[1] + stickyViewH;
if (stickyViewP[1] <= stickyShowPos && stickyViewP[1] >= (stickyStartHidePos - stickyViewH)) {
mStickyOffset = stickyViewP[1] - stickyStartHidePos;
stickyData.setStickyOffset(stickyViewP[1]-stickyScrollerP[1]);
return stickyData.getHostView();
}else{
stickyData.setStickyOffset(0);
}
}
return null;
}
示例7: notifyAppearStateChange
import com.taobao.weex.ui.component.WXComponent; //导入方法依赖的package包/类
@Override
public void notifyAppearStateChange(int firstVisible, int lastVisible, int directionX, int directionY) {
//notify appear state
Iterator<AppearanceHelper> it = mAppearComponents.values().iterator();
String direction = directionY > 0 ? Constants.Value.DIRECTION_UP :
directionY < 0 ? Constants.Value.DIRECTION_DOWN : null;
if (getOrientation() == Constants.Orientation.HORIZONTAL && directionX != 0) {
direction = directionX > 0 ? Constants.Value.DIRECTION_LEFT : Constants.Value.DIRECTION_RIGHT;
}
if (mColumnCount > 0)
visibleCellCount = (lastVisible - firstVisible) * mColumnCount;
while (it.hasNext()) {
AppearanceHelper item = it.next();
WXComponent component = item.getAwareChild();
if (!item.isWatch()) {
continue;
}
boolean outOfVisibleRange = item.getCellPositionINScollable() < firstVisible || item.getCellPositionINScollable() > lastVisible;
View view = component.getHostView();
if (view == null) {
continue;
}
boolean visible = (!outOfVisibleRange) && item.isViewVisible();
int result = item.setAppearStatus(visible);
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d("appear", "item " + item.getCellPositionINScollable() + " result " + result);
}
if (result == AppearanceHelper.RESULT_NO_CHANGE) {
continue;
}
component.notifyAppearStateChange(result == AppearanceHelper.RESULT_APPEAR ? Constants.Event.APPEAR : Constants.Event.DISAPPEAR, direction);
}
}
示例8: startAnimation
import com.taobao.weex.ui.component.WXComponent; //导入方法依赖的package包/类
public static void startAnimation(WXSDKInstance mWXSDKInstance, WXComponent component,
@NonNull WXAnimationBean animationBean, @Nullable String callback) {
if(component == null){
return;
}
if (component.getHostView() == null) {
AnimationHolder holder = new AnimationHolder(animationBean, callback);
component.postAnimation(holder);
return;
}
try {
Animator animator = createAnimator(animationBean, component.getHostView(),mWXSDKInstance.getViewPortWidth());
if (animator != null) {
Animator.AnimatorListener animatorCallback = createAnimatorListener(mWXSDKInstance, callback);
if(Build.VERSION.SDK_INT<Build.VERSION_CODES.JELLY_BEAN_MR2) {
component.getHostView().setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
Interpolator interpolator = createTimeInterpolator(animationBean);
if (animatorCallback != null) {
animator.addListener(animatorCallback);
}
if (interpolator != null) {
animator.setInterpolator(interpolator);
}
animator.setDuration(animationBean.duration);
animator.start();
}
} catch (RuntimeException e) {
e.printStackTrace();
WXLogUtils.e("", e);
}
}
示例9: notifyAppearStateChange
import com.taobao.weex.ui.component.WXComponent; //导入方法依赖的package包/类
@Override
public void notifyAppearStateChange(int firstVisible, int lastVisible, int directionX, int directionY) {
//notify appear state
Iterator<AppearanceHelper> it = mAppearComponents.values().iterator();
String direction = directionY > 0 ? Constants.Value.DIRECTION_UP :
directionY < 0 ? Constants.Value.DIRECTION_DOWN : null;
if (getOrientation() == Constants.Orientation.HORIZONTAL && directionX != 0) {
direction = directionX > 0 ? Constants.Value.DIRECTION_LEFT : Constants.Value.DIRECTION_RIGHT;
}
while (it.hasNext()) {
AppearanceHelper item = it.next();
WXComponent component = item.getAwareChild();
if (!item.isWatch()) {
continue;
}
boolean outOfVisibleRange = item.getCellPositionINScollable() < firstVisible || item.getCellPositionINScollable() > lastVisible;
View view = component.getHostView();
if (view == null) {
continue;
}
boolean visible = (!outOfVisibleRange) && item.isViewVisible();
int result = item.setAppearStatus(visible);
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d("appear", "item " + item.getCellPositionINScollable() + " result " + result);
}
if (result == AppearanceHelper.RESULT_NO_CHANGE) {
continue;
}
component.notifyAppearStateChange(result == AppearanceHelper.RESULT_APPEAR ? Constants.Event.APPEAR : Constants.Event.DISAPPEAR, direction);
}
}
示例10: ListBaseViewHolder
import com.taobao.weex.ui.component.WXComponent; //导入方法依赖的package包/类
public ListBaseViewHolder(WXComponent component, int viewType) {
super(component.getHostView());
mViewType = viewType;
mComponent = new WeakReference(component);
}
示例11: onBindViewHolder
import com.taobao.weex.ui.component.WXComponent; //导入方法依赖的package包/类
/**
* 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);
}
return;
}
if (holder.getComponent() != null && holder.getComponent() instanceof WXCell) {
if(holder.isRecycled()) {
holder.bindData(component);
}
if (mDragHelper == null || !mDragHelper.isDraggable()) {
return;
}
mTriggerType = (mTriggerType == null) ? DEFAULT_TRIGGER_TYPE : mTriggerType;
WXCell cell = (WXCell) holder.getComponent();
boolean isExcluded = isDragExcluded(cell.getDomObject());
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);
}
}
}
示例12: onBeforeScroll
import com.taobao.weex.ui.component.WXComponent; //导入方法依赖的package包/类
@Override
public void onBeforeScroll(int dx, int dy) {
if (mStickyMap == null) {
return;
}
HashMap<String, WXComponent> stickyMap = mStickyMap.get(getRef());
if (stickyMap == null) {
return;
}
Iterator<Map.Entry<String, WXComponent>> iterator = stickyMap.entrySet().iterator();
Map.Entry<String, WXComponent> entry;
WXComponent stickyComponent;
while (iterator.hasNext()) {
entry = iterator.next();
stickyComponent = entry.getValue();
if (stickyComponent != null && stickyComponent.getDomObject() != null
&& stickyComponent instanceof WXCell) {
WXCell cell = (WXCell) stickyComponent;
if (cell.getHostView() == null) {
return;
}
if (stickyComponent != null && stickyComponent.getDomObject() != null
&& stickyComponent instanceof WXCell) {
if (stickyComponent.getHostView() == null) {
return;
}
RecyclerView.LayoutManager layoutManager;
boolean beforeFirstVisibleItem = false;
if ((layoutManager = getHostView().getInnerView().getLayoutManager()) instanceof LinearLayoutManager) {
int fVisible = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
int pos = mChildren.indexOf(cell);
if (pos <= fVisible) {
beforeFirstVisibleItem = true;
}
}
int[] location = new int[2];
stickyComponent.getHostView().getLocationOnScreen(location);
int[] parentLocation = new int[2];
stickyComponent.getParentScroller().getView().getLocationOnScreen(parentLocation);
int top = location[1] - parentLocation[1];
boolean showSticky = beforeFirstVisibleItem && cell.getLocationFromStart() >= 0 && top <= 0 && dy >= 0;
boolean removeSticky = cell.getLocationFromStart() <= 0 && top > 0 && dy <= 0;
if (showSticky) {
bounceRecyclerView.notifyStickyShow(cell);
} else if (removeSticky) {
bounceRecyclerView.notifyStickyRemove(cell);
}
cell.setLocationFromStart(top);
}
}
}
}