use of vip.kuaifan.weiui.extend.bean.PageBean in project weiui by kuaifan.
the class PageActivity method startPermission.
/**
*************************************************************************************************
*/
/**
*************************************************************************************************
*/
/**
*************************************************************************************************
*/
/**
* 申请权限专用
* @param context
*/
public static void startPermission(final Context context) {
PageBean mBean = new PageBean();
mBean.setPageType("permission");
weiuiPage.openWin(context, mBean);
}
use of vip.kuaifan.weiui.extend.bean.PageBean in project weiui by kuaifan.
the class PageActivity method startTransparentPage.
/**
* 透明页面专用专用
* @param context
* @param callback
*/
public static void startTransparentPage(Context context, JSCallback callback) {
PageBean mBean = new PageBean();
mBean.setPageType("transparentPage");
mBean.setCallback(callback);
weiuiPage.openWin(context, mBean);
}
use of vip.kuaifan.weiui.extend.bean.PageBean in project weiui by kuaifan.
the class weiuiAdDialog method create.
/**
************************************************************************************************
*/
/**
************************************************************************************************
*/
/**
************************************************************************************************
*/
public static void create(WXSDKInstance mWXSDKInstance, JSONObject json, JSCallback callback) {
if (mWXSDKInstance == null || json == null) {
return;
}
String imgUrl = weiuiParse.parseStr(json.getString("imgUrl"), json.getString("img"));
if (imgUrl == null || imgUrl.isEmpty()) {
return;
}
Context mContext = mWXSDKInstance.getContext();
if (mContext == null) {
return;
}
String dialogName = weiuiParse.parseStr(json.getString("dialogName"), weiuiCommon.randomString(8));
int dialogWidth = weiuiParse.parseInt(json.getString("width"));
int dialogHeight = weiuiParse.parseInt(json.getString("height"));
boolean showClose = weiuiParse.parseBool(json.getString("showClose"), true);
boolean backClose = weiuiParse.parseBool(json.getString("backClose"), true);
//
if (callback != null) {
Map<String, Object> newData = new HashMap<>();
newData.put("status", "load");
newData.put("dialogName", dialogName);
newData.put("imgUrl", imgUrl);
callback.invokeAndKeepAlive(newData);
}
Glide.with(mContext).asBitmap().load(imgUrl).apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL)).into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
PageActivity.startTransparentPage(mContext, new JSCallback() {
@Override
public void invoke(Object data) {
if (callback != null) {
callback.invoke(data);
}
}
@Override
public void invokeAndKeepAlive(Object data) {
Map<String, Object> retData = weiuiMap.objectToMap(data);
String pageName = weiuiParse.parseStr(retData.get("pageName"));
String status = weiuiParse.parseStr(retData.get("status"));
PageBean mBean = weiuiPage.getPageBean(pageName);
if (mBean == null) {
return;
}
if (status.equals("create")) {
Activity mActivity = (Activity) mBean.getContext();
Animation mAnimation = AnimationUtils.loadAnimation(mActivity, R.anim.in_to_down);
//
View tmpView = LayoutInflater.from(mActivity).inflate(R.layout.dialog_ad, null);
ImageView tmpImage = tmpView.findViewById(R.id.v_activity_picture);
ImageView tmpClose = tmpView.findViewById(R.id.v_activity_close);
ViewGroup fullBox = tmpView.findViewById(R.id.float_full_box);
//
if (callback != null) {
tmpImage.setOnClickListener(view -> {
Map<String, Object> newData = (Map<String, Object>) data;
newData.put("status", "click");
newData.put("dialogName", dialogName);
newData.put("imgUrl", imgUrl);
callback.invokeAndKeepAlive(newData);
});
}
if (showClose) {
tmpClose.setVisibility(View.VISIBLE);
tmpClose.setOnClickListener(view -> close(dialogName));
}
if (mActivity instanceof PageActivity) {
((PageActivity) mActivity).setOnBackPressed(() -> !backClose || close(dialogName));
}
//
DialogBean tmpBean = new DialogBean();
tmpBean.setDialogName(dialogName);
tmpBean.setImgUrl(imgUrl);
tmpBean.setPageName(mBean.getPageName());
tmpBean.setContext(mBean.getContext());
tmpBean.setView(tmpView);
mAdDialogList.add(tmpBean);
//
ViewGroup.LayoutParams params = tmpImage.getLayoutParams();
if (dialogWidth > 0 && dialogHeight > 0) {
params.width = weiuiScreenUtils.weexPx2dp(mWXSDKInstance, dialogWidth);
params.height = weiuiScreenUtils.weexPx2dp(mWXSDKInstance, dialogHeight);
} else if (dialogWidth > 0) {
params.width = weiuiScreenUtils.weexPx2dp(mWXSDKInstance, dialogWidth);
params.height = (int) weiuiCommon.scaleHeight(params.width, resource.getWidth(), resource.getHeight());
} else if (dialogHeight > 0) {
params.height = weiuiScreenUtils.weexPx2dp(mWXSDKInstance, dialogHeight);
params.width = (int) weiuiCommon.scaleWidth(params.height, resource.getWidth(), resource.getHeight());
} else {
params.width = (int) (ScreenUtils.getScreenWidth() * 0.75);
params.height = (int) weiuiCommon.scaleHeight(params.width, resource.getWidth(), resource.getHeight());
}
tmpImage.setLayoutParams(params);
tmpImage.setImageBitmap(resource);
fullBox.startAnimation(mAnimation);
//
if (callback != null) {
Map<String, Object> newData = (Map<String, Object>) data;
newData.put("status", "show");
newData.put("dialogName", dialogName);
newData.put("imgUrl", imgUrl);
callback.invokeAndKeepAlive(newData);
}
//
((FrameLayout) mActivity.findViewById(R.id.v_body)).addView(tmpView);
}
if (callback != null) {
if (data instanceof Map) {
Map<String, Object> newData = (Map<String, Object>) data;
newData.put("dialogName", dialogName);
newData.put("imgUrl", imgUrl);
callback.invokeAndKeepAlive(newData);
} else {
callback.invokeAndKeepAlive(data);
}
}
}
});
}
});
}
use of vip.kuaifan.weiui.extend.bean.PageBean in project weiui by kuaifan.
the class weiuiModule method openPage.
/**
************************************************************************************************
*/
/**
************************************************************************************************
*/
/**
************************************************************************************************
*/
/**
* 打开页面 或 打开网页(内置浏览器)
* @param object
* @param callback
*/
@JSMethod
public void openPage(String object, JSCallback callback) {
JSONObject json = weiuiJson.parseObject(object);
if (json.size() == 0) {
json.put("url", object);
}
if (json.getString("url") == null || json.getString("url").isEmpty()) {
return;
}
PageBean mBean = new PageBean();
// 网址
mBean.setUrl(weiuiPage.rewriteUrl(mWXSDKInstance.getContext(), json.getString("url")));
// 名称(默认:随机生成)
if (json.getString("pageName") != null) {
mBean.setPageName(json.getString("pageName"));
}
// 类型(默认:weex)
if (json.getString("pageType") != null) {
mBean.setPageType(json.getString("pageType"));
}
// 缓存(默认:0)
if (json.getString("cache") != null) {
mBean.setCache(json.getIntValue("cache"));
}
// 是否显示等待(默认:true)
if (json.getBoolean("loading") != null) {
mBean.setLoading(json.getBoolean("loading"));
}
// 是否支持滑动返回(默认:true)
if (json.getBoolean("swipeBack") != null) {
mBean.setSwipeBack(json.getBoolean("swipeBack"));
}
// 状态栏样式(可选,等于fullscreen|immersion时statusBarType、statusBarAlpha无效)
if (json.getString("statusBarType") != null) {
mBean.setStatusBarType(json.getString("statusBarType"));
}
// 状态栏颜色值(默认:#3EB4FF)
if (json.getString("statusBarColor") != null) {
mBean.setStatusBarColor(json.getString("statusBarColor"));
}
// 状态栏透明度(默认:0)
if (json.getInteger("statusBarAlpha") != null) {
mBean.setStatusBarAlpha(json.getInteger("statusBarAlpha"));
}
// 页面背景颜色(默认:#f4f8f9)
if (json.getString("backgroundColor") != null) {
mBean.setBackgroundColor(json.getString("backgroundColor"));
}
// 返回键关闭(默认:true)
if (json.getBoolean("backPressedClose") != null) {
mBean.setBackPressedClose(json.getBoolean("backPressedClose"));
}
// JS回调事件
if (callback != null) {
mBean.setCallback(callback);
}
weiuiPage.openWin(mWXSDKInstance.getContext(), mBean);
}
Aggregations