Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

withStringArrayList传参接收不到... #4

Closed
fuxuanyang11 opened this issue Apr 12, 2023 · 4 comments
Closed

withStringArrayList传参接收不到... #4

fuxuanyang11 opened this issue Apr 12, 2023 · 4 comments

Comments

@fuxuanyang11
Copy link

image
获取到的数据是空的

@JailedBird
Copy link
Owner

JailedBird commented Apr 12, 2023

问题稍微有点模糊,麻烦根据下面几个步骤确认下:
0、发一下跳转部分的代码
1、检查build文件下生成的对应代码, 根据经验判断有没问题(也可以发出来)
2、查看注入点是否忘记调用ARouter.getInstance().inject(this); 注入
3、更换mUrls模块的注解处理器为原生注解处理器, 然后看是否存在问题
4、将mUrls替换为MutableList, 看是否存在问题

@JailedBird
Copy link
Owner

JailedBird commented Apr 12, 2023

貌似确实会出问题, 代码生成中区分了11中数据类型,8种基础类型Parcelable和Serializable, Object类(走Json解析方案,包括ArrayList等), 因此需要使用withObject传递参数
Arouter使用withObject传参需要自定义序列化工具:

参考:https://github.com/alibaba/ARouter#iv-advanced-usage

// If you need to pass a custom object, Create a new class(Not the custom object class),implement the SerializationService, And use the @Route annotation annotation, E.g:
@Route(path = "/yourservicegroupname/json")
public class JsonServiceImpl implements SerializationService {
    @Override
    public void init(Context context) {

    }

    @Override
    public <T> T json2Object(String text, Class<T> clazz) {
        return JSON.parseObject(text, clazz);
    }

    @Override
    public String object2Json(Object instance) {
        return JSON.toJSONString(instance);
    }
}

另外, 如果使用json方式完成对象解析, 如果字段内容为空可能会导致崩溃, 我会立即修复这个问题

@JailedBird
Copy link
Owner

image 获取到的数据是空的

请去README更新最新版本(xxx-1.0.2), 按照withObject传递参数即可, 可以去参考app模块的跳转传参示例😘

@fuxuanyang11
Copy link
Author

好的。 谢谢大佬

@JailedBird JailedBird pinned this issue Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants