Search in sources :

Example 1 with PageActivity

use of vip.kuaifan.weiui.PageActivity in project weiui by kuaifan.

the class weiuiModule method reloadPage.

/**
 * 重新加载页面(刷新)
 * @param object
 */
@JSMethod
public void reloadPage(String object) {
    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) {
            ((PageActivity) mWXSDKInstance.getContext()).reload();
        }
        return;
    }
    weiuiPage.reloadWin(pageName);
}
Also used : PageActivity(vip.kuaifan.weiui.PageActivity) JSONObject(com.alibaba.fastjson.JSONObject) JSMethod(com.taobao.weex.annotation.JSMethod)

Example 2 with PageActivity

use of vip.kuaifan.weiui.PageActivity in project weiui by kuaifan.

the class weiuiModule method getPageInfo.

/**
 * 获取页面信息
 * @param object
 * @return
 */
@JSMethod(uiThread = false)
public Object getPageInfo(String object) {
    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) {
            return ((PageActivity) mWXSDKInstance.getContext()).getPageInfo().toMap();
        }
        return null;
    }
    return weiuiPage.getWinInfo(pageName).toMap();
}
Also used : PageActivity(vip.kuaifan.weiui.PageActivity) JSONObject(com.alibaba.fastjson.JSONObject) JSMethod(com.taobao.weex.annotation.JSMethod)

Example 3 with PageActivity

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

Example 4 with PageActivity

use of vip.kuaifan.weiui.PageActivity in project weiui by kuaifan.

the class weiuiPage method getWinInfo.

public static PageBean getWinInfo(String name) {
    if (name == null) {
        return null;
    }
    PageBean mBean = getPageBean(name);
    if (mBean == null) {
        return null;
    }
    Activity activity = mBean.getActivity();
    if (activity == null) {
        return null;
    }
    if (activity instanceof PageActivity) {
        return ((PageActivity) activity).getPageInfo();
    }
    return null;
}
Also used : PageActivity(vip.kuaifan.weiui.PageActivity) PageBean(vip.kuaifan.weiui.extend.bean.PageBean) PageActivity(vip.kuaifan.weiui.PageActivity) Activity(android.app.Activity)

Example 5 with PageActivity

use of vip.kuaifan.weiui.PageActivity in project weiui by kuaifan.

the class weiuiPage method reloadWin.

public static void reloadWin(String name) {
    if (name == null) {
        return;
    }
    PageBean mBean = getPageBean(name);
    if (mBean == null) {
        return;
    }
    Activity activity = mBean.getActivity();
    if (activity == null) {
        return;
    }
    if (activity instanceof PageActivity) {
        ((PageActivity) activity).reload();
    }
}
Also used : PageActivity(vip.kuaifan.weiui.PageActivity) PageBean(vip.kuaifan.weiui.extend.bean.PageBean) PageActivity(vip.kuaifan.weiui.PageActivity) Activity(android.app.Activity)

Aggregations

PageActivity (vip.kuaifan.weiui.PageActivity)8 JSONObject (com.alibaba.fastjson.JSONObject)5 PageBean (vip.kuaifan.weiui.extend.bean.PageBean)5 Activity (android.app.Activity)3 JSMethod (com.taobao.weex.annotation.JSMethod)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Context (android.content.Context)1 Bitmap (android.graphics.Bitmap)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 Animation (android.view.animation.Animation)1 FrameLayout (android.widget.FrameLayout)1 ImageView (android.widget.ImageView)1 JSCallback (com.taobao.weex.bridge.JSCallback)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 RequestOptions (vip.kuaifan.weiui.extend.integration.glide.request.RequestOptions)1