Search in sources :

Example 11 with PageBean

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);
}
Also used : PageBean(vip.kuaifan.weiui.extend.bean.PageBean)

Example 12 with PageBean

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);
}
Also used : PageBean(vip.kuaifan.weiui.extend.bean.PageBean)

Example 13 with PageBean

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);
                        }
                    }
                }
            });
        }
    });
}
Also used : Context(android.content.Context) PageActivity(vip.kuaifan.weiui.PageActivity) HashMap(java.util.HashMap) RequestOptions(vip.kuaifan.weiui.extend.integration.glide.request.RequestOptions) ViewGroup(android.view.ViewGroup) PageActivity(vip.kuaifan.weiui.PageActivity) Activity(android.app.Activity) ImageView(android.widget.ImageView) View(android.view.View) JSCallback(com.taobao.weex.bridge.JSCallback) Bitmap(android.graphics.Bitmap) PageBean(vip.kuaifan.weiui.extend.bean.PageBean) FrameLayout(android.widget.FrameLayout) Animation(android.view.animation.Animation) JSONObject(com.alibaba.fastjson.JSONObject) ImageView(android.widget.ImageView) HashMap(java.util.HashMap) Map(java.util.Map)

Example 14 with PageBean

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);
}
Also used : PageBean(vip.kuaifan.weiui.extend.bean.PageBean) JSONObject(com.alibaba.fastjson.JSONObject) JSMethod(com.taobao.weex.annotation.JSMethod)

Aggregations

PageBean (vip.kuaifan.weiui.extend.bean.PageBean)14 PageActivity (vip.kuaifan.weiui.PageActivity)6 JSONObject (com.alibaba.fastjson.JSONObject)5 Activity (android.app.Activity)4 JSMethod (com.taobao.weex.annotation.JSMethod)3 View (android.view.View)2 Animation (android.view.animation.Animation)2 JSCallback (com.taobao.weex.bridge.JSCallback)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Context (android.content.Context)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 Point (android.graphics.Point)1 RequiresApi (android.support.annotation.RequiresApi)1 ViewGroup (android.view.ViewGroup)1 AnimationSet (android.view.animation.AnimationSet)1 ScaleAnimation (android.view.animation.ScaleAnimation)1 FrameLayout (android.widget.FrameLayout)1