当前位置: 首页>>代码示例>>Java>>正文


Java NavigationCallback类代码示例

本文整理汇总了Java中com.alibaba.android.arouter.facade.callback.NavigationCallback的典型用法代码示例。如果您正苦于以下问题:Java NavigationCallback类的具体用法?Java NavigationCallback怎么用?Java NavigationCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NavigationCallback类属于com.alibaba.android.arouter.facade.callback包,在下文中一共展示了NavigationCallback类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _navigation

import com.alibaba.android.arouter.facade.callback.NavigationCallback; //导入依赖的package包/类
private Object _navigation(final Context context, final Postcard postcard, final int requestCode, final NavigationCallback callback) {
    final Context currentContext = null == context ? mContext : context;

    switch (postcard.getType()) {
        case ACTIVITY:
            // Build intent
            final Intent intent = new Intent(currentContext, postcard.getDestination());
            intent.putExtras(postcard.getExtras());

            // Set flags.
            int flags = postcard.getFlags();
            if (-1 != flags) {
                intent.setFlags(flags);
            } else if (!(currentContext instanceof Activity)) {    // Non activity, need less one flag.
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            }

            // Navigation in main looper.
            new Handler(Looper.getMainLooper()).post(new Runnable() {
                @Override
                public void run() {
                    if (requestCode > 0) {  // Need start for result
                        ActivityCompat.startActivityForResult((Activity) currentContext, intent, requestCode, postcard.getOptionsBundle());
                    } else {
                        ActivityCompat.startActivity(currentContext, intent, postcard.getOptionsBundle());
                    }

                    if ((0 != postcard.getEnterAnim() || 0 != postcard.getExitAnim()) && currentContext instanceof Activity) {    // Old version.
                        ((Activity) currentContext).overridePendingTransition(postcard.getEnterAnim(), postcard.getExitAnim());
                    }

                    if (null != callback) { // Navigation over.
                        callback.onArrival(postcard);
                    }
                }
            });

            break;
        case PROVIDER:
            return postcard.getProvider();
        case BOARDCAST:
        case CONTENT_PROVIDER:
        case FRAGMENT:
            Class fragmentMeta = postcard.getDestination();
            try {
                Object instance = fragmentMeta.getConstructor().newInstance();
                if (instance instanceof Fragment) {
                    ((Fragment) instance).setArguments(postcard.getExtras());
                } else if (instance instanceof android.support.v4.app.Fragment) {
                    ((android.support.v4.app.Fragment) instance).setArguments(postcard.getExtras());
                }

                return instance;
            } catch (Exception ex) {
                logger.error(Consts.TAG, "Fetch fragment instance error, " + TextUtils.formatStackTrace(ex.getStackTrace()));
            }
        case METHOD:
        case SERVICE:
        default:
            return null;
    }

    return null;
}
 
开发者ID:alibaba,项目名称:ARouter,代码行数:65,代码来源:_ARouter.java

示例2: navigation

import com.alibaba.android.arouter.facade.callback.NavigationCallback; //导入依赖的package包/类
/**
 * Launch the navigation.
 *
 * @param mContext    .
 * @param postcard    .
 * @param requestCode Set for startActivityForResult
 * @param callback    cb
 */
public Object navigation(Context mContext, Postcard postcard, int requestCode, NavigationCallback callback) {
    return _ARouter.getInstance().navigation(mContext, postcard, requestCode, callback);
}
 
开发者ID:alibaba,项目名称:ARouter,代码行数:12,代码来源:ARouter.java

示例3: navigation

import com.alibaba.android.arouter.facade.callback.NavigationCallback; //导入依赖的package包/类
/**
 * Navigation to the route with path in postcard.
 *
 * @param context Activity and so on.
 */
public Object navigation(Context context, NavigationCallback callback) {
    return ARouter.getInstance().navigation(context, this, -1, callback);
}
 
开发者ID:alibaba,项目名称:ARouter,代码行数:9,代码来源:Postcard.java

示例4: navigation

import com.alibaba.android.arouter.facade.callback.NavigationCallback; //导入依赖的package包/类
/**
 * Launch the navigation.
 *
 * @param mContext .
 * @param postcard .
 * @param requestCode Set for startActivityForResult
 * @param callback cb
 */
public Object navigation(Context mContext, Postcard postcard, int requestCode, NavigationCallback callback) {
    return _ARouter.getInstance().navigation(mContext, postcard, requestCode, callback);
}
 
开发者ID:CaMnter,项目名称:AndroidLife,代码行数:12,代码来源:ARouter.java


注:本文中的com.alibaba.android.arouter.facade.callback.NavigationCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。