ARouter(三) RouteMeta & Postcard

先名词解释,路由信息:寻找对象的依据。

RouteMeta包含基本的路由信息,是路由信息的容器,Postcard也是,因为Postcard 继承了RouteMeta。

RouteMeta对象是在自动生成的类里面生成的,这是能包含路由信息的原因。第一篇已经讲到过。

Postcard更多的作用是:完成寻找对象前的准备,以及跳转Activity前的参数准备。

RouteMeta 

    private RouteType type;         // Type of route
    private Element rawType;        // Raw type of route
    private Class<?> destination;   // Destination
    private String path;            // Path of route
    private String group;           // Group of route
    private int priority = -1;      // The smaller the number, the higher the priority, 拦截器的优先级。
    private int extra;              // Extra data
    private Map<String, Integer> paramsType;  // Param type
    private String name;

    private Map<String, Autowired> injectConfig;  // Cache inject config.
  • paramsType, 这个已经没有用了, 已经用injcetConfig替代。可能为了适配老版本,依旧保留着。
  • injcetConfig, injcetConfig是加了@AutoWired的属性注解列表。跳转时传递的参数,在跳转目的地会赋值好。
Map<String, Autowired> injectConfig = new HashMap<>();   
     for (Element field : element.getEnclosedElements()) {      
      if (field.getKind().isField() && field.getAnnotation(Autowired.class) != null && !types.isSubtype(field.asType(), iProvider)) {                // It must be field, then it has annotation, but it not be provider.
        Autowired paramConfig = field.getAnnotation(Autowired.class);
        String injectName = StringUtils.isEmpty(paramConfig.name()) ? field.getSimpleName().toString() : paramConfig.name();
        paramsType.put(injectName, typeUtils.typeExchange(field));
        injectConfig.put(injectName, paramConfig);
    }

Postcard

    private Uri uri;
    private Object tag;             // A tag prepare for some thing wrong. 在拦截器里有用到。保存了一些错误信息
    private Bundle mBundle;         // Data to transform。用于给Activity或fragment传递参数
    private int flags = -1;         // Flags of route. 是Activity的启动模式, 比如,Intent.FLAG_ACTIVITY_NEW_TASK
    private int timeout = 300;      // Navigation timeout, TimeUnit.Second   在拦截器阻塞执行时间的最长时间。超时后,只在后面默默执行,不再卡Naviagtion().
    private IProvider provider;     // It will be set value, if this postcard was provider.
    private boolean greenChannel; //针对拦截器, 设置true后,不再执行拦截器。
    private SerializationService serializationService; //解析json的方式。实现SerializationService后,可以直接传对象,会转化成json传过去。没啥用的吧
    private String action; // Intent action, intent.setAction(action); 跳转Activity时会用到。
    private Bundle optionsCompat;    // The transition animation of activity
    private int enterAnim = -1; //activity打开的动画资源
    private int exitAnim = -1;//activity关闭的动画资源
  • 还有一个withXXXXX()方法, 都是为了封装mBundle。
  • Navigation()方法中,最后还是调用了_ARouter类的Navigation()方法。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值