本文整理汇总了Java中com.taobao.weex.utils.WXViewUtils类的典型用法代码示例。如果您正苦于以下问题:Java WXViewUtils类的具体用法?Java WXViewUtils怎么用?Java WXViewUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WXViewUtils类属于com.taobao.weex.utils包,在下文中一共展示了WXViewUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assembleDefaultOptions
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
private WXParams assembleDefaultOptions() {
Map<String, String> config = WXEnvironment.getConfig();
WXParams wxParams = new WXParams();
wxParams.setPlatform(config.get("os"));
wxParams.setOsVersion(config.get("sysVersion"));
wxParams.setAppVersion(config.get("appVersion"));
wxParams.setWeexVersion(config.get("weexVersion"));
wxParams.setDeviceModel(config.get("sysModel"));
wxParams.setShouldInfoCollect(config.get("infoCollect"));
wxParams.setLogLevel(config.get(WXConfig.logLevel));
String appName = config.get("appName");
if (!TextUtils.isEmpty(appName)) {
wxParams.setAppName(appName);
}
wxParams.setDeviceWidth(TextUtils.isEmpty(config.get("deviceWidth")) ? String.valueOf(WXViewUtils.getScreenWidth(WXEnvironment.sApplication)) : config.get("deviceWidth"));
wxParams.setDeviceHeight(TextUtils.isEmpty(config.get("deviceHeight")) ? String.valueOf(WXViewUtils.getScreenHeight(WXEnvironment.sApplication)) : config.get("deviceHeight"));
return wxParams;
}
示例2: setBorderRadius
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
public void setBorderRadius(String key, float borderRadius) {
if (borderRadius >= 0) {
switch (key) {
case Constants.Name.BORDER_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getViewPortWidth()));
break;
case Constants.Name.BORDER_TOP_LEFT_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getViewPortWidth()));
break;
case Constants.Name.BORDER_TOP_RIGHT_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getViewPortWidth()));
break;
case Constants.Name.BORDER_BOTTOM_RIGHT_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getViewPortWidth()));
break;
case Constants.Name.BORDER_BOTTOM_LEFT_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getViewPortWidth()));
break;
}
}
}
示例3: draw
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
@Override
public void draw(Canvas canvas) {
canvas.save();
updateBorderOutline();
if (mPathForBorderOutline != null) {
int useColor = WXViewUtils.multiplyColorAlpha(mColor, mAlpha);
if ((useColor >>> 24) != 0) {
mPaint.setStyle(Paint.Style.FILL);
mPaint.setColor(useColor);
mPaint.setShader(null);
canvas.drawPath(mPathForBorderOutline, mPaint);
}
}
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
drawBorders(canvas);
mPaint.setShader(null);
canvas.restore();
}
示例4: scrollTo
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
/**
* @see com.taobao.weex.dom.WXDomStatement#scrollToDom(String, JSONObject)
*/
void scrollTo(String ref, Map<String, Object> options) {
WXComponent component = mRegistry.get(ref);
if (component == null) {
return;
}
float offsetFloat = 0;
if (options != null) {
String offset = options.get("offset") == null ? "0" : options.get("offset").toString();
if (offset != null) {
try {
offsetFloat = WXViewUtils.getRealPxByWidth(Float.parseFloat(offset),mWXSDKInstance.getViewPortWidth());
}catch (Exception e ){
WXLogUtils.e("Float parseFloat error :"+e.getMessage());
}
}
}
Scrollable scroller = component.getParentScroller();
if (scroller == null) {
return;
}
scroller.scrollTo(component,(int)offsetFloat);
}
示例5: scrollTo
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
/**
* @see com.taobao.weex.dom.WXDomStatement#scrollToDom(String, JSONObject)
*/
void scrollTo(String ref, Map<String, Object> options) {
WXComponent component = mRegistry.get(ref);
if (component == null) {
return;
}
float offsetFloat = 0;
if (options != null) {
String offset = options.get("offset") == null ? "0" : options.get("offset").toString();
if (offset != null) {
try {
offsetFloat = WXViewUtils.getRealPxByWidth(Float.parseFloat(offset));
}catch (Exception e ){
WXLogUtils.e("Float parseFloat error :"+e.getMessage());
}
}
}
Scrollable scroller = component.getParentScroller();
if (scroller == null) {
return;
}
scroller.scrollTo(component,(int)offsetFloat);
}
示例6: measure
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
@Override
protected MeasureOutput measure(int width, int height) {
MeasureOutput measureOutput = new MeasureOutput();
if (this.mOrientation == Constants.Orientation.HORIZONTAL) {
int screenW = WXViewUtils.getScreenWidth(WXEnvironment.sApplication);
int weexW = WXViewUtils.getWeexWidth(getInstanceId());
measureOutput.width = width > (weexW >= screenW ? screenW : weexW) ? FrameLayout.LayoutParams.MATCH_PARENT
: width;
measureOutput.height = height;
} else {
int screenH = WXViewUtils.getScreenHeight(WXEnvironment.sApplication);
int weexH = WXViewUtils.getWeexHeight(getInstanceId());
measureOutput.height = height > (weexH >= screenH ? screenH : weexH) ? FrameLayout.LayoutParams.MATCH_PARENT
: height;
measureOutput.width = width;
}
return measureOutput;
}
示例7: setBorderRadius
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
public void setBorderRadius(String key, float borderRadius) {
if (borderRadius >= 0) {
switch (key) {
case Constants.Name.BORDER_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, WXViewUtils.getRealSubPxByWidth(borderRadius));
break;
case Constants.Name.BORDER_TOP_LEFT_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius));
break;
case Constants.Name.BORDER_TOP_RIGHT_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius));
break;
case Constants.Name.BORDER_BOTTOM_RIGHT_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius));
break;
case Constants.Name.BORDER_BOTTOM_LEFT_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius));
break;
}
}
}
示例8: setBorderWidth
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
public void setBorderWidth(String key, float borderWidth) {
if (borderWidth >= 0) {
switch (key) {
case Constants.Name.BORDER_WIDTH:
getOrCreateBorder().setBorderWidth(Spacing.ALL, WXViewUtils.getRealSubPxByWidth(borderWidth));
break;
case Constants.Name.BORDER_TOP_WIDTH:
getOrCreateBorder().setBorderWidth(Spacing.TOP, WXViewUtils.getRealSubPxByWidth(borderWidth));
break;
case Constants.Name.BORDER_RIGHT_WIDTH:
getOrCreateBorder().setBorderWidth(Spacing.RIGHT, WXViewUtils.getRealSubPxByWidth(borderWidth));
break;
case Constants.Name.BORDER_BOTTOM_WIDTH:
getOrCreateBorder().setBorderWidth(Spacing.BOTTOM, WXViewUtils.getRealSubPxByWidth(borderWidth));
break;
case Constants.Name.BORDER_LEFT_WIDTH:
getOrCreateBorder().setBorderWidth(Spacing.LEFT, WXViewUtils.getRealSubPxByWidth(borderWidth));
break;
}
}
}
示例9: makeTitleView
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
private TextView makeTitleView(Context context, Map<String, Object> options) {
String text = getOption(options, KEY_TITLE, null);
if (text == null) {
return null;
}
TextView textView = new TextView(context);
textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
int padding = WXViewUtils.dip2px(12);
textView.setPadding(padding, padding, padding, padding);
textView.getPaint().setFakeBoldText(true);
textView.setBackgroundColor(getColor(options, KEY_TITLE_BACKGROUND_COLOR, Color.TRANSPARENT));
textView.setTextColor(getColor(options, KEY_TITLE_COLOR, Color.BLACK));
textView.setText(text);
return textView;
}
示例10: draw
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
@Override
public void draw(@NonNull Canvas canvas) {
canvas.save();
updateBorderOutline();
//Shader uses alpha as well.
mPaint.setAlpha(255);
if (mPathForBorderOutline != null) {
int useColor = WXViewUtils.multiplyColorAlpha(mColor, mAlpha);
if (mShader != null) {
mPaint.setShader(mShader);
mPaint.setStyle(Paint.Style.FILL);
canvas.drawPath(mPathForBorderOutline, mPaint);
mPaint.setShader(null);
} else if ((useColor >>> 24) != 0) {
mPaint.setColor(useColor);
mPaint.setStyle(Paint.Style.FILL);
canvas.drawPath(mPathForBorderOutline, mPaint);
mPaint.setShader(null);
}
}
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
drawBorders(canvas);
mPaint.setShader(null);
canvas.restore();
}
示例11: fireScrollEvent
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
private void fireScrollEvent(Rect contentFrame, int x, int y, int oldx, int oldy) {
Map<String, Object> event = new HashMap<>(2);
Map<String, Object> contentSize = new HashMap<>(2);
Map<String, Object> contentOffset = new HashMap<>(2);
int viewport = getInstance().getInstanceViewPortWidth();
contentSize.put(Constants.Name.WIDTH, WXViewUtils.getWebPxByWidth(contentFrame.width(), viewport));
contentSize.put(Constants.Name.HEIGHT, WXViewUtils.getWebPxByWidth(contentFrame.height(), viewport));
contentOffset.put(Constants.Name.X, -WXViewUtils.getWebPxByWidth(x, viewport));
contentOffset.put(Constants.Name.Y, -WXViewUtils.getWebPxByWidth(y, viewport));
event.put(Constants.Name.CONTENT_SIZE, contentSize);
event.put(Constants.Name.CONTENT_OFFSET, contentOffset);
fireEvent(Constants.Event.SCROLL, event);
}
示例12: scrollTo
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
@Override
public void scrollTo(WXComponent component, Map<String, Object> options) {
float offsetFloat = 0;
boolean smooth = true;
if (options != null) {
String offset = options.get(Constants.Name.OFFSET) == null ? "0" : options.get(Constants.Name.OFFSET).toString();
smooth = WXUtils.getBoolean(options.get(Constants.Name.ANIMATED), true);
if (offset != null) {
try {
offsetFloat = WXViewUtils.getRealPxByWidth(Float.parseFloat(offset), getInstance().getInstanceViewPortWidth());
}catch (Exception e ){
WXLogUtils.e("Float parseFloat error :"+e.getMessage());
}
}
}
int viewYInScroller=component.getAbsoluteY() - getAbsoluteY();
int viewXInScroller=component.getAbsoluteX() - getAbsoluteX();
scrollBy(viewXInScroller - getScrollX() + (int) offsetFloat, viewYInScroller - getScrollY() + (int) offsetFloat, smooth);
}
示例13: setBorderWidth
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
public void setBorderWidth(String key, float borderWidth) {
if (borderWidth >= 0) {
switch (key) {
case Constants.Name.BORDER_WIDTH:
getOrCreateBorder().setBorderWidth(Spacing.ALL, WXViewUtils.getRealSubPxByWidth(borderWidth,getInstance().getViewPortWidth()));
break;
case Constants.Name.BORDER_TOP_WIDTH:
getOrCreateBorder().setBorderWidth(Spacing.TOP, WXViewUtils.getRealSubPxByWidth(borderWidth,getInstance().getViewPortWidth()));
break;
case Constants.Name.BORDER_RIGHT_WIDTH:
getOrCreateBorder().setBorderWidth(Spacing.RIGHT, WXViewUtils.getRealSubPxByWidth(borderWidth,getInstance().getViewPortWidth()));
break;
case Constants.Name.BORDER_BOTTOM_WIDTH:
getOrCreateBorder().setBorderWidth(Spacing.BOTTOM, WXViewUtils.getRealSubPxByWidth(borderWidth,getInstance().getViewPortWidth()));
break;
case Constants.Name.BORDER_LEFT_WIDTH:
getOrCreateBorder().setBorderWidth(Spacing.LEFT, WXViewUtils.getRealSubPxByWidth(borderWidth,getInstance().getViewPortWidth()));
break;
}
}
}
示例14: createViewImpl
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
protected void createViewImpl() {
if (mContext != null) {
mHost = initComponentHostView(mContext);
if (mHost == null && !isVirtualComponent()) {
//compatible
initView();
}
if(mHost != null){
mHost.setId(WXViewUtils.generateViewId());
ComponentObserver observer;
if ((observer = getInstance().getComponentObserver()) != null) {
observer.onViewCreated(this, mHost);
}
}
onHostViewInitialized(mHost);
}else{
WXLogUtils.e("createViewImpl","Context is null");
}
}
示例15: setBorderRadius
import com.taobao.weex.utils.WXViewUtils; //导入依赖的package包/类
public void setBorderRadius(String key, float borderRadius) {
if (borderRadius >= 0) {
switch (key) {
case Constants.Name.BORDER_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getInstanceViewPortWidth()));
break;
case Constants.Name.BORDER_TOP_LEFT_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getInstanceViewPortWidth()));
break;
case Constants.Name.BORDER_TOP_RIGHT_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getInstanceViewPortWidth()));
break;
case Constants.Name.BORDER_BOTTOM_RIGHT_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getInstanceViewPortWidth()));
break;
case Constants.Name.BORDER_BOTTOM_LEFT_RADIUS:
getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getInstanceViewPortWidth()));
break;
}
}
}