Search in sources :

Example 1 with RouterModel

use of com.benmu.framework.model.RouterModel in project WeexErosFramework by bmfe.

the class DefaultRouterAdapter method open.

public boolean open(Context context, String params, JSCallback jsCallback) {
    ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
    RouterModel routerModel = parseManager.parseObject(params, RouterModel.class);
    if (jsCallback != null) {
        routerModel.backCallback = (SimpleJSCallback) jsCallback;
    }
    return !(routerModel == null || !(context instanceof Activity)) && performStartActivity((Activity) context, routerModel, Constant.BMPAGE_CATEGORY);
}
Also used : RouterModel(com.benmu.framework.model.RouterModel) AbstractWeexActivity(com.benmu.framework.activity.AbstractWeexActivity) Activity(android.app.Activity) ParseManager(com.benmu.framework.manager.impl.ParseManager)

Example 2 with RouterModel

use of com.benmu.framework.model.RouterModel in project WeexErosFramework by bmfe.

the class DefaultRouterAdapter method back.

public boolean back(Context context, String params) {
    ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
    RouterModel routerModel = parseManager.parseObject(params, RouterModel.class);
    int backLength = routerModel.length;
    if (backLength >= RouterTracker.length()) {
        RouterTracker.clearActivitySurplus(1);
    } else {
        for (int i = 0; i < backLength; i++) {
            RouterTracker.popActivity();
        }
    }
    Object backParams = routerModel.params;
    if (backParams instanceof Map) {
        if (((Map) backParams).size() > 0) {
            Activity activity = RouterTracker.peekActivity();
            if (activity instanceof AbstractWeexActivity) {
                // 设置back参数
                ((AbstractWeexActivity) activity).setRouterParam(routerModel);
            }
        }
    }
    return true;
}
Also used : RouterModel(com.benmu.framework.model.RouterModel) AbstractWeexActivity(com.benmu.framework.activity.AbstractWeexActivity) Activity(android.app.Activity) AbstractWeexActivity(com.benmu.framework.activity.AbstractWeexActivity) ParseManager(com.benmu.framework.manager.impl.ParseManager) Map(java.util.Map)

Example 3 with RouterModel

use of com.benmu.framework.model.RouterModel in project WeexErosFramework by bmfe.

the class DefaultRouterAdapter method toWebView.

public void toWebView(Context context, String params) {
    if (TextUtils.isEmpty(params))
        return;
    ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
    WebViewParamBean webViewParamBean = parseManager.parseObject(params, WebViewParamBean.class);
    String title = webViewParamBean.getTitle();
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addCategory(Constant.BMWEBVIEW_CATEGORY);
    String type = webViewParamBean.getType() == null ? Constant.ACTIVITIES_ANIMATION.ANIMATION_PUSH : webViewParamBean.getType();
    RouterModel routerModel = new RouterModel(null, type, null, title, webViewParamBean.isNavShow(), null);
    intent.putExtra(Constant.ROUTERPARAMS, routerModel);
    intent.putExtra(Constant.WEBVIEW_PARAMS, webViewParamBean);
    if (context instanceof Activity) {
        Activity activity = (Activity) context;
        activity.startActivity(intent);
        if (Constant.ACTIVITIES_ANIMATION.ANIMATION_PUSH.equals(routerModel.type)) {
            activity.overridePendingTransition(R.anim.right_in, R.anim.view_stay);
        } else if (Constant.ACTIVITIES_ANIMATION.ANIMATION_PRESENT.equals(routerModel.type)) {
            activity.overridePendingTransition(R.anim.bottom_in, R.anim.view_stay);
        } else if (Constant.ACTIVITIES_ANIMATION.ANIMATION_TRANSLATION.equals(routerModel.type)) {
            activity.overridePendingTransition(R.anim.left_in, R.anim.view_stay);
        } else {
            activity.overridePendingTransition(R.anim.right_in, R.anim.view_stay);
        }
    }
}
Also used : RouterModel(com.benmu.framework.model.RouterModel) AbstractWeexActivity(com.benmu.framework.activity.AbstractWeexActivity) Activity(android.app.Activity) Intent(android.content.Intent) ParseManager(com.benmu.framework.manager.impl.ParseManager) WebViewParamBean(com.benmu.framework.model.WebViewParamBean)

Example 4 with RouterModel

use of com.benmu.framework.model.RouterModel in project WeexErosFramework by bmfe.

the class EventSetHomePage method setHomePage.

@SuppressWarnings("WrongConstant")
public void setHomePage(Context context, String params) {
    StorageManager storageManager = ManagerFactory.getManagerService(StorageManager.class);
    storageManager.setData(context, Constant.SP.SP_HOMEPAGE_URL, params);
    String homePage = BMWXEnvironment.mPlatformConfig.getPage().getHomePage(context);
    RouterModel router = new RouterModel(homePage, Constant.ACTIVITIES_ANIMATION.ANIMATION_PUSH, null, null, false, null);
    Intent intent = performStartActivity(router, Constant.BMPAGE_CATEGORY);
    context.startActivity(intent);
// PendingIntent restartIntent = PendingIntent.getActivity(
// context.getApplicationContext(), 0, intent, Intent.FLAG_ACTIVITY_CLEAR_TASK);
// AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100,
// restartIntent);
}
Also used : RouterModel(com.benmu.framework.model.RouterModel) StorageManager(com.benmu.framework.manager.StorageManager) Intent(android.content.Intent)

Example 5 with RouterModel

use of com.benmu.framework.model.RouterModel in project WeexErosFramework by bmfe.

the class EventGetBackParams method getBackParams.

public void getBackParams(Context context, JSCallback jscallback) {
    RouterManager routerManager = ManagerFactory.getManagerService(RouterManager.class);
    RouterModel routerModel = routerManager.getParams(context);
    if (routerModel != null && jscallback != null) {
        jscallback.invoke(routerModel.params);
    }
}
Also used : RouterManager(com.benmu.framework.manager.impl.RouterManager) RouterModel(com.benmu.framework.model.RouterModel)

Aggregations

RouterModel (com.benmu.framework.model.RouterModel)7 Activity (android.app.Activity)3 AbstractWeexActivity (com.benmu.framework.activity.AbstractWeexActivity)3 ParseManager (com.benmu.framework.manager.impl.ParseManager)3 Intent (android.content.Intent)2 RouterManager (com.benmu.framework.manager.impl.RouterManager)2 StorageManager (com.benmu.framework.manager.StorageManager)1 WebViewParamBean (com.benmu.framework.model.WebViewParamBean)1 Map (java.util.Map)1