use of vip.kuaifan.weiui.extend.bean.PageBean in project weiui by kuaifan.
the class PageActivity method startScanerCode.
/**
* 扫描二维码与条形码专用
* @param context
* @param obj
* @param callback
*/
public static void startScanerCode(Context context, String obj, JSCallback callback) {
JSONObject json = weiuiJson.parseObject(obj);
if (json.size() == 0 && obj != null && obj.equals("null")) {
json.put("desc", String.valueOf(obj));
}
json.put("successClose", weiuiJson.getBoolean(json, "successClose", true));
//
PermissionUtils.permission(PermissionConstants.CAMERA).rationale(shouldRequest -> PermissionUtils.showRationaleDialog(context, shouldRequest)).callback(new PermissionUtils.FullCallback() {
@Override
public void onGranted(List<String> permissionsGranted) {
PageBean mBean = new PageBean();
mBean.setUrl(weiuiJson.getString(json, "desc", "将二维码图片对准扫描框即可自动扫描"));
mBean.setPageType("scanerCode");
mBean.setCallback(callback);
mBean.setOtherObject(json);
weiuiPage.openWin(context, mBean);
}
@Override
public void onDenied(List<String> permissionsDeniedForever, List<String> permissionsDenied) {
if (!permissionsDeniedForever.isEmpty()) {
PermissionUtils.showOpenAppSettingDialog(context);
}
}
}).request();
}
use of vip.kuaifan.weiui.extend.bean.PageBean in project weiui by kuaifan.
the class PageActivity method onCreate.
@Override
@RequiresApi(api = Build.VERSION_CODES.M)
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
mPageInfo = weiuiPage.getPageBean(intent.getStringExtra("name"));
if (mPageInfo == null) {
mPageInfo = new PageBean();
}
switch(mPageInfo.getPageType()) {
case "permission":
mPermissionInstance = PermissionUtils.getInstance();
if (mPermissionInstance.getThemeCallback() != null) {
mPermissionInstance.getThemeCallback().onActivityCreate(this);
}
break;
case "swipeCaptcha":
break;
case "scanerCode":
initSwipeBackFinish();
break;
case "transparentPage":
break;
default:
initSwipeBackFinish();
break;
}
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
if (getSupportActionBar() != null) {
getSupportActionBar().hide();
}
if (mPageInfo.getPageName() != null) {
mPageInfo.setContext(this);
weiuiPage.setPageBean(mPageInfo.getPageName(), mPageInfo);
}
switch(mPageInfo.getPageType()) {
case "permission":
if (mPermissionInstance.rationale(this)) {
finish();
return;
}
if (mPermissionInstance.getPermissionsRequest() != null) {
int size = mPermissionInstance.getPermissionsRequest().size();
requestPermissions(mPermissionInstance.getPermissionsRequest().toArray(new String[size]), 1);
}
setImmersionStatusBar();
break;
case "swipeCaptcha":
setContentView(R.layout.activity_page_swipe_captcha);
initSwipeCaptchaPageView();
break;
case "scanerCode":
setContentView(R.layout.activity_page_scaner_code);
setImmersionStatusBar();
initScanerCodePageView();
break;
case "transparentPage":
setContentView(R.layout.activity_transparent);
setImmersionStatusBar();
break;
default:
setContentView(R.layout.activity_page);
if (mPageInfo.getUrl() == null || mPageInfo.getUrl().isEmpty()) {
finish();
return;
}
initDefaultPage();
break;
}
invokeAndKeepAlive("create", null);
}
use of vip.kuaifan.weiui.extend.bean.PageBean in project weiui by kuaifan.
the class PageActivity method startSwipeCaptcha.
/**
* 滑动验证码专用
* @param context
* @param img
* @param callback
*/
public static void startSwipeCaptcha(Context context, String img, JSCallback callback) {
PageBean mBean = new PageBean();
mBean.setUrl(img);
mBean.setPageType("swipeCaptcha");
mBean.setCallback(callback);
weiuiPage.openWin(context, mBean);
}
use of vip.kuaifan.weiui.extend.bean.PageBean in project weiui by kuaifan.
the class weiuiModule method setPageBackPressed.
/**
* 拦截返回按键事件
* @param object
* @param callback 为null时取消拦截
*/
@JSMethod
public void setPageBackPressed(String object, JSCallback callback) {
JSONObject json = weiuiJson.parseObject(object);
if (json.size() == 0) {
json.put("pageName", object);
}
String pageName = json.getString("pageName");
if (pageName == null || pageName.isEmpty()) {
if (mWXSDKInstance.getContext() instanceof PageActivity) {
pageName = ((PageActivity) mWXSDKInstance.getContext()).getPageInfo().getPageName();
}
}
PageBean mPageBean = weiuiPage.getWinInfo(pageName);
if (mPageBean == null) {
return;
}
PageActivity mPageActivity = ((PageActivity) mPageBean.getContext());
if (callback == null) {
mPageActivity.setOnBackPressed(null);
} else {
mPageActivity.setOnBackPressed(() -> {
callback.invokeAndKeepAlive(null);
return true;
});
}
}
use of vip.kuaifan.weiui.extend.bean.PageBean in project weiui by kuaifan.
the class weiuiPictureModule method create.
/**
************************************************************************************************
*/
/**
************************************************************************************************
*/
/**
************************************************************************************************
*/
/**
* 打开相册
* @param object
* @param callback
*/
@JSMethod
public void create(String object, final JSCallback callback) {
final JSONObject json = weiuiJson.parseObject(object);
//
PageActivity.startTransparentPage(mWXSDKInstance.getContext(), 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;
}
switch(status) {
case "create":
List<LocalMedia> selected = new ArrayList<>();
JSONArray selectedList = weiuiJson.parseArray(json.getString("selected"));
for (int i = 0; i < selectedList.size(); i++) {
JSONObject tempJson = weiuiJson.parseObject(selectedList.get(i));
LocalMedia tempMedia = new LocalMedia();
tempMedia.setDuration(tempJson.getInteger("duration"));
tempMedia.setPath(tempJson.getString("path"));
tempMedia.setCut(tempJson.getBoolean("cut"));
tempMedia.setNum(tempJson.getInteger("num"));
tempMedia.setWidth(tempJson.getInteger("width"));
tempMedia.setHeight(tempJson.getInteger("height"));
tempMedia.setChecked(tempJson.getBoolean("checked"));
tempMedia.setMimeType(tempJson.getInteger("mimeType"));
tempMedia.setPosition(tempJson.getInteger("position"));
tempMedia.setCompressed(tempJson.getBoolean("compressed"));
tempMedia.setPictureType(tempJson.getString("pictureType"));
selected.add(tempMedia);
}
PictureSelectionModel model;
if (weiuiJson.getString(json, "type", "gallery").equals("camera")) {
model = PictureSelector.create(mBean.getActivity()).openCamera(// 全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()、音频.ofAudio()
weiuiJson.getInt(json, "gallery", PictureMimeType.ofAll()));
} else {
model = PictureSelector.create(mBean.getActivity()).openGallery(// 全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()、音频.ofAudio()
weiuiJson.getInt(json, "gallery", PictureMimeType.ofAll()));
}
// 最大选择数量 int
model.maxSelectNum(weiuiJson.getInt(json, "maxNum", 9)).minSelectNum(// 最小选择数量 int
weiuiJson.getInt(json, "minNum", 0)).imageSpanCount(// 每行显示个数 int
weiuiJson.getInt(json, "spanCount", 4)).selectionMode(// 多选 or 单选 PictureConfig.MULTIPLE or PictureConfig.SINGLE
weiuiJson.getInt(json, "mode", PictureConfig.MULTIPLE)).previewImage(// 是否可预览图片 true or false
weiuiJson.getBoolean(json, "previewImage", true)).previewVideo(// 是否可预览视频 true or false
weiuiJson.getBoolean(json, "previewVideo", true)).enablePreviewAudio(// 是否可播放音频 true or false
weiuiJson.getBoolean(json, "previewAudio", true)).isCamera(// 是否显示拍照按钮 true or false
weiuiJson.getBoolean(json, "camera", true)).imageFormat(// 拍照保存图片格式后缀,默认jpeg
weiuiJson.getString(json, "format", PictureMimeType.JPEG)).isZoomAnim(// 图片列表点击 缩放效果 默认true
weiuiJson.getBoolean(json, "zoomAnim", true)).sizeMultiplier(// glide 加载图片大小 0~1之间 如设置 .glideOverride()无效
weiuiJson.getFloat(json, "multiplier", 0.5f)).enableCrop(// 是否裁剪 true or false
weiuiJson.getBoolean(json, "crop", false)).compress(// 是否压缩 true or false
weiuiJson.getBoolean(json, "compress", false)).glideOverride(weiuiJson.getInt(json, "overrideWidth", 100), // int glide 加载宽高,越小图片列表越流畅,但会影响列表图片浏览的清晰度
weiuiJson.getInt(json, "overrideHeight", 100)).withAspectRatio(weiuiJson.getInt(json, "ratioX", 1), // int 裁剪比例 如16:9 3:2 3:4 1:1 可自定义
weiuiJson.getInt(json, "ratioY", 1)).hideBottomControls(// 是否显示uCrop工具栏,默认不显示 true or false
weiuiJson.getBoolean(json, "cropControls", false)).isGif(// 是否显示gif图片 true or false
weiuiJson.getBoolean(json, "git", false)).freeStyleCropEnabled(// 裁剪框是否可拖拽 true or false
weiuiJson.getBoolean(json, "freeCrop", false)).circleDimmedLayer(// 是否圆形裁剪 true or false
weiuiJson.getBoolean(json, "circle", false)).showCropFrame(// 是否显示裁剪矩形边框 圆形裁剪时建议设为false true or false
weiuiJson.getBoolean(json, "cropFrame", true)).showCropGrid(// 是否显示裁剪矩形网格 圆形裁剪时建议设为false true or false
weiuiJson.getBoolean(json, "cropGrid", true)).openClickSound(// 是否开启点击声音 true or false
weiuiJson.getBoolean(json, "clickSound", false)).selectionMedia(// 是否传入已选图片 List<LocalMedia> list
selected).previewEggs(// 预览图片时 是否增强左右滑动图片体验(图片滑动一半即可看到上一张是否选中) true or false
weiuiJson.getBoolean(json, "eggs", false)).cropCompressQuality(// 裁剪压缩质量 默认90 int
weiuiJson.getInt(json, "quality", 90)).minimumCompressSize(// 小于100kb的图片不压缩
weiuiJson.getInt(json, "compressSize", 100)).synOrAsy(// 同步true或异步false 压缩 默认同步
weiuiJson.getBoolean(json, "sync", true)).cropWH(weiuiJson.getInt(json, "cropWidth", 0), // 裁剪宽高比,设置如果大于图片本身宽高则无效 int
weiuiJson.getInt(json, "cropHeight", 0)).rotateEnabled(// 裁剪是否可旋转图片 true or false
weiuiJson.getBoolean(json, "rotate", true)).scaleEnabled(// 裁剪是否可放大缩小图片 true or false
weiuiJson.getBoolean(json, "scale", true)).videoQuality(// 视频录制质量 0 or 1 int
weiuiJson.getInt(json, "videoQuality", 0)).videoMaxSecond(// 显示多少秒以内的视频or音频也可适用 int
weiuiJson.getInt(json, "videoMaxSecond", 15)).videoMinSecond(// 显示多少秒以内的视频or音频也可适用 int
weiuiJson.getInt(json, "videoMinSecond", 10)).recordVideoSecond(// 视频秒数录制 默认60s int
weiuiJson.getInt(json, "recordVideoSecond", 60)).forResult(PictureConfig.CHOOSE_REQUEST);
break;
case "activityResult":
int requestCode = weiuiParse.parseInt(retData.get("requestCode"));
int resultCode = weiuiParse.parseInt(retData.get("resultCode"));
if (resultCode == RESULT_OK) {
switch(requestCode) {
case PictureConfig.CHOOSE_REQUEST:
if (callback != null) {
Map<String, Object> callData = new HashMap<>();
callData.put("status", "success");
callData.put("lists", PictureSelector.obtainMultipleResult((Intent) retData.get("resultData")));
callback.invokeAndKeepAlive(callData);
}
break;
}
}
mBean.getActivity().finish();
break;
}
if (callback != null) {
callback.invokeAndKeepAlive(data);
}
}
});
}
Aggregations