本文整理汇总了Java中com.taobao.weex.utils.WXViewUtils.getWebPxByWidth方法的典型用法代码示例。如果您正苦于以下问题:Java WXViewUtils.getWebPxByWidth方法的具体用法?Java WXViewUtils.getWebPxByWidth怎么用?Java WXViewUtils.getWebPxByWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.taobao.weex.utils.WXViewUtils
的用法示例。
在下文中一共展示了WXViewUtils.getWebPxByWidth方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notifyNativeSizeChanged
import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
/**
* Trigger a updateStyle invoke to relayout current page
*/
public void notifyNativeSizeChanged(int w, int h) {
if (!mNeedLayoutOnAnimation) {
return;
}
Message message = Message.obtain();
WXDomTask task = new WXDomTask();
task.instanceId = getInstanceId();
if (task.args == null) {
task.args = new ArrayList<>();
}
JSONObject style = new JSONObject(2);
float webW = WXViewUtils.getWebPxByWidth(w);
float webH = WXViewUtils.getWebPxByWidth(h);
style.put("width", webW);
style.put("height", webH);
task.args.add(getRef());
task.args.add(style);
message.obj = task;
message.what = WXDomHandler.MsgType.WX_DOM_UPDATE_STYLE;
WXSDKManager.getInstance().getWXDomManager().sendMessage(message);
}
示例2: getEventLocInScreenCoordinate
import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
/**
* Get event location in Screen's coordinate, e.g. root(global) coordinate.
* @param eventX {@link MotionEvent#getX()} or {@link MotionEvent#getHistoricalX(int, int)}
* @param eventY {@link MotionEvent#getX()} or {@link MotionEvent#getHistoricalX(int, int)}
* @return the eventLocation in screen's coordinate
* @see {@link #getEventLocInScreenCoordinate(MotionEvent, int, int)}
*/
@NonNull
private PointF getEventLocInScreenCoordinate(float eventX, float eventY) {
globalRect.set(0, 0, 0, 0);
globalOffset.set(0, 0);
globalEventOffset.set((int) eventX, (int) eventY);
component.getRealView().getGlobalVisibleRect(globalRect, globalOffset);
globalEventOffset.offset(globalOffset.x, globalOffset.y);
return new PointF(WXViewUtils.getWebPxByWidth(globalEventOffset.x),
WXViewUtils.getWebPxByWidth(globalEventOffset.y));
}
示例3: getEventLocInPageCoordinate
import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
/**
* Get event's location in Document's (Page) coordinate.
* @param eventX {@link MotionEvent#getX()} or {@link MotionEvent#getHistoricalX(int, int)}
* @param eventY {@link MotionEvent#getX()} or {@link MotionEvent#getHistoricalX(int, int)}
* @return the event location in page's coordinate.
* @see {@link #getEventLocInPageCoordinate(MotionEvent, int, int)}
*/
@NonNull
private PointF getEventLocInPageCoordinate(float eventX, float eventY) {
locEventOffset.set(eventX, eventY);
locLeftTop.set(0, 0);
component.computeVisiblePointInViewCoordinate(locLeftTop);
locEventOffset.offset(locLeftTop.x, locLeftTop.y);
return new PointF(WXViewUtils.getWebPxByWidth(locEventOffset.x),
WXViewUtils.getWebPxByWidth(locEventOffset.y));
}
示例4: setSize
import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
public void setSize(int width, int height) {
if (width < 0 || height < 0) {
return;
}
mGodViewWidth = width;
mGodViewHeight = height;
float realWidth = WXViewUtils.getWebPxByWidth(width);
float realHeight = WXViewUtils.getWebPxByWidth(height);
View godView = mGodCom.getHostView();
if (godView != null) {
ViewGroup.LayoutParams layoutParams = godView.getLayoutParams();
if (layoutParams != null) {
layoutParams.width = width;
layoutParams.height = height;
godView.setLayoutParams(layoutParams);
JSONObject style = new JSONObject();
if (mGodCom instanceof WXVContainer) {
WXComponent rootComponent = ((WXVContainer) mGodCom).getChild(0);
if (rootComponent != null && rootComponent.getDomObject() != null && rootComponent.getDomObject().isModifyHeight()) {
style.put(Constants.Name.HEIGHT, realHeight);
}
if (rootComponent != null && rootComponent.getDomObject() != null && rootComponent.getDomObject().isModifyWidth()) {
style.put(Constants.Name.WIDTH, realWidth);
}
updateRootComponentStyle(style);
}
}
}
}
示例5: preCalculateCellWidth
import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
public void preCalculateCellWidth(){
if (getAttrs() != null) {
mColumnCount = getAttrs().getColumnCount();
mColumnWidth = getAttrs().getColumnWidth();
mColumnGap = getAttrs().getColumnGap();
mAvailableWidth = getStyleWidth()-getPadding().get(Spacing.LEFT)-getPadding().get(Spacing.RIGHT);
mAvailableWidth = WXViewUtils.getWebPxByWidth(mAvailableWidth,getViewPortWidth());
if (Constants.Value.AUTO == mColumnCount && Constants.Value.AUTO == mColumnWidth) {
mColumnCount = Constants.Value.COLUMN_COUNT_NORMAL;
} else if (Constants.Value.AUTO == mColumnWidth && Constants.Value.AUTO != mColumnCount) {
mColumnWidth = (mAvailableWidth - ((mColumnCount - 1) * mColumnGap)) / mColumnCount;
mColumnWidth = mColumnWidth > 0 ? mColumnWidth :0;
} else if (Constants.Value.AUTO != mColumnWidth && Constants.Value.AUTO == mColumnCount) {
mColumnCount = Math.round((mAvailableWidth + mColumnGap) / (mColumnWidth + mColumnGap)-0.5f);
mColumnCount = mColumnCount > 0 ? mColumnCount :1;
if (mColumnCount <= 0)
mColumnCount = Constants.Value.COLUMN_COUNT_NORMAL;
mColumnWidth =((mAvailableWidth + mColumnGap) / mColumnCount) - mColumnGap;
} else if(Constants.Value.AUTO != mColumnWidth && Constants.Value.AUTO != mColumnCount){
int columnCount = Math.round((mAvailableWidth + mColumnGap) / (mColumnWidth + mColumnGap)-0.5f);
mColumnCount = columnCount > mColumnCount ? mColumnCount :columnCount;
if (mColumnCount <= 0)
mColumnCount = Constants.Value.COLUMN_COUNT_NORMAL;
mColumnWidth= ((mAvailableWidth + mColumnGap) / mColumnCount) - mColumnGap;
}
mIsPreCalculateCellWidth = true;
if(WXEnvironment.isApkDebugable()) {
WXLogUtils.d("preCalculateCellWidth mColumnGap :" + mColumnGap + " mColumnWidth:" + mColumnWidth + " mColumnCount:" + mColumnCount);
}
}
}
示例6: getEventLocInScreenCoordinate
import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
/**
* Get event location in Screen's coordinate, e.g. root(global) coordinate.
* @param eventX {@link MotionEvent#getX()} or {@link MotionEvent#getHistoricalX(int, int)}
* @param eventY {@link MotionEvent#getX()} or {@link MotionEvent#getHistoricalX(int, int)}
* @return the eventLocation in screen's coordinate
* @see {@link #getEventLocInScreenCoordinate(MotionEvent, int, int)}
*/
@NonNull
private PointF getEventLocInScreenCoordinate(float eventX, float eventY) {
globalRect.set(0, 0, 0, 0);
globalOffset.set(0, 0);
globalEventOffset.set((int) eventX, (int) eventY);
component.getRealView().getGlobalVisibleRect(globalRect, globalOffset);
globalEventOffset.offset(globalOffset.x, globalOffset.y);
return new PointF(WXViewUtils.getWebPxByWidth(globalEventOffset.x,component.getInstance().getInstanceViewPortWidth()),
WXViewUtils.getWebPxByWidth(globalEventOffset.y,component.getInstance().getInstanceViewPortWidth()));
}
示例7: getEventLocInPageCoordinate
import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
/**
* Get event's location in Document's (Page) coordinate.
* @param eventX {@link MotionEvent#getX()} or {@link MotionEvent#getHistoricalX(int, int)}
* @param eventY {@link MotionEvent#getX()} or {@link MotionEvent#getHistoricalX(int, int)}
* @return the event location in page's coordinate.
* @see {@link #getEventLocInPageCoordinate(MotionEvent, int, int)}
*/
@NonNull
private PointF getEventLocInPageCoordinate(float eventX, float eventY) {
locEventOffset.set(eventX, eventY);
locLeftTop.set(0, 0);
component.computeVisiblePointInViewCoordinate(locLeftTop);
locEventOffset.offset(locLeftTop.x, locLeftTop.y);
return new PointF(WXViewUtils.getWebPxByWidth(locEventOffset.x,component.getInstance().getInstanceViewPortWidth()),
WXViewUtils.getWebPxByWidth(locEventOffset.y,component.getInstance().getInstanceViewPortWidth()));
}
示例8: setSize
import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
public void setSize(int width, int height) {
if (width < 0 || height < 0 || isDestroy || !mRendered) {
return;
}
float realWidth = WXViewUtils.getWebPxByWidth(width,getInstanceViewPortWidth());
float realHeight = WXViewUtils.getWebPxByWidth(height,getInstanceViewPortWidth());
View godView = mRenderContainer;
if (godView != null) {
ViewGroup.LayoutParams layoutParams = godView.getLayoutParams();
if (layoutParams != null) {
if(godView.getWidth() != width || godView.getHeight() != height) {
layoutParams.width = width;
layoutParams.height = height;
godView.setLayoutParams(layoutParams);
}
JSONObject style = new JSONObject();
WXComponent rootComponent = mRootComp;
if(rootComponent == null){
return;
}
style.put(Constants.Name.DEFAULT_WIDTH, realWidth);
style.put(Constants.Name.DEFAULT_HEIGHT, realHeight);
updateRootComponentStyle(style);
}
}
}
示例9: getEventLocInScreenCoordinate
import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
/**
* Get event location in Screen's coordinate, e.g. root(global) coordinate.
* @param eventX {@link MotionEvent#getX()} or {@link MotionEvent#getHistoricalX(int, int)}
* @param eventY {@link MotionEvent#getX()} or {@link MotionEvent#getHistoricalX(int, int)}
* @return the eventLocation in screen's coordinate
* @see {@link #getEventLocInScreenCoordinate(MotionEvent, int, int)}
*/
@NonNull
private PointF getEventLocInScreenCoordinate(float eventX, float eventY) {
globalRect.set(0, 0, 0, 0);
globalOffset.set(0, 0);
globalEventOffset.set((int) eventX, (int) eventY);
component.getRealView().getGlobalVisibleRect(globalRect, globalOffset);
globalEventOffset.offset(globalOffset.x, globalOffset.y);
return new PointF(WXViewUtils.getWebPxByWidth(globalEventOffset.x,component.getInstance().getViewPortWidth()),
WXViewUtils.getWebPxByWidth(globalEventOffset.y,component.getInstance().getViewPortWidth()));
}
示例10: getEventLocInPageCoordinate
import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
/**
* Get event's location in Document's (Page) coordinate.
* @param eventX {@link MotionEvent#getX()} or {@link MotionEvent#getHistoricalX(int, int)}
* @param eventY {@link MotionEvent#getX()} or {@link MotionEvent#getHistoricalX(int, int)}
* @return the event location in page's coordinate.
* @see {@link #getEventLocInPageCoordinate(MotionEvent, int, int)}
*/
@NonNull
private PointF getEventLocInPageCoordinate(float eventX, float eventY) {
locEventOffset.set(eventX, eventY);
locLeftTop.set(0, 0);
component.computeVisiblePointInViewCoordinate(locLeftTop);
locEventOffset.offset(locLeftTop.x, locLeftTop.y);
return new PointF(WXViewUtils.getWebPxByWidth(locEventOffset.x,component.getInstance().getViewPortWidth()),
WXViewUtils.getWebPxByWidth(locEventOffset.y,component.getInstance().getViewPortWidth()));
}
示例11: setSize
import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
public void setSize(int width, int height) {
if (width < 0 || height < 0 || isDestroy || !mRendered) {
return;
}
float realWidth = WXViewUtils.getWebPxByWidth(width,getViewPortWidth());
float realHeight = WXViewUtils.getWebPxByWidth(height,getViewPortWidth());
View godView = mRenderContainer;
if (godView != null) {
ViewGroup.LayoutParams layoutParams = godView.getLayoutParams();
if (layoutParams != null) {
if(godView.getWidth() != width || godView.getHeight() != height) {
layoutParams.width = width;
layoutParams.height = height;
godView.setLayoutParams(layoutParams);
}
JSONObject style = new JSONObject();
WXComponent rootComponent = mRootComp;
if(rootComponent == null){
return;
}
style.put(Constants.Name.DEFAULT_WIDTH, realWidth);
style.put(Constants.Name.DEFAULT_HEIGHT, realHeight);
updateRootComponentStyle(style);
}
}
}
示例12: getWebPxValue
import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
@NonNull
private float getWebPxValue(int value,int viewport) {
return WXViewUtils.getWebPxByWidth(value, viewport);
}