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

能不能简单介绍一下代码结构 #693

Open
4 of 5 tasks
reloops opened this issue Jan 24, 2025 · 5 comments
Open
4 of 5 tasks

能不能简单介绍一下代码结构 #693

reloops opened this issue Jan 24, 2025 · 5 comments
Labels
enhancement New feature or request

Comments

@reloops
Copy link

reloops commented Jan 24, 2025

Acknowledgements / 确认事项

  • I have updated to the latest version of the app / 已经更新到最新版
  • I have tried the FAQ / 试过FAQ了. FAQ
  • I have searched the existing issues and this is new ticket NOT a duplicate or related to another issue / 搜索过其他issue,确实不是重复问题
  • I will fill out the title and the information in this template / 填好标题和内容

What feature should be added? / 需要加上什么功能

如题,看代码有点无从下手的感觉,git clone下来不太像是一般的android项目

Official support / 官方支持情况

  • Is this feature supported by the official pixiv app? / 官方App是否支持

Is this feature supported by any other third-party pixiv app? / 第三方App是否支持

No response

Any other information can be help? / 其它信息

No response

@reloops reloops added the enhancement New feature or request label Jan 24, 2025
@SoxiaLiSA
Copy link
Contributor

你想加什么功能

@SoxiaLiSA
Copy link
Contributor

SoxiaLiSA commented Jan 26, 2025

package ceui.lisa.xxxxxx; 这个包里面的是2019年的初版代码,也是老的UI所用的代码,多个页面就是 多个activity。

package ceui.pixiv.xxxxxx; 这个包里面的,是最新的代码,以后会在这里面加功能,这也是V5.0最新的UI所用的代码,
这是单activity + navigation 多 fragment的结构,所有的fragment都继承自 PixivFragment

package ceui.loxia.xxxxxx; 这个包是从老代码迁移到新代码的buffer,最终会被挪到 ”package ceui.pixiv.xxxxxx“ 里面。

所以代码的重点应该是在 package ceui.pixiv.xxxxxx 里面。

比如我要实现一个”用户创建的作品“ 列表,代码是:

class UserCreatedIllustsFragment : PixivFragment(R.layout.fragment_pixiv_list) {

private val binding by viewBinding(FragmentPixivListBinding::bind)
private val args by navArgs<UserCreatedIllustsFragmentArgs>()
private val viewModel by pixivListViewModel {
    DataSource(
        dataFetcher = { Client.appApi.getUserCreatedIllusts(args.userId, args.objectType) },
        itemMapper = { illust -> listOf(IllustCardHolder(illust)) }
    )
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    setUpRefreshState(binding, viewModel)
}

}

主要的数据请求和分页逻辑都在 DataSource 里面,
itemMapper 是把加载好的 proto 数据变成 UI 上认识的 recycleview viewholder

@huajideshutiao
Copy link

有一说一,挺乱的,比如相当多的界面都是在ceui.lisa.activities.TemplateActivity通过intent的dataType的值判断应该怎么渲染

@huajideshutiao
Copy link

package ceui.pixiv.xxxxxx; 这个包里面的,是最新的代码,以后会在这里面加功能,这也是V5.0最新的UI所用的代码, 这是单activity + navigation 多 fragment的结构,所有的fragment都继承自 PixivFragment

原来都5.0了吗

@SoxiaLiSA
Copy link
Contributor

SoxiaLiSA commented Jan 27, 2025

有一说一,挺乱的,比如相当多的界面都是在ceui.lisa.activities.TemplateActivity通过intent的dataType的值判断应该怎么渲染

TemplateActivity 这个是属于package ceui.lisa.xxxxxx; 这个包里面的,会被删掉。
TemplateActivity 中的所有 fragment 都会变成 navigation 的 destination,会出现在 package ceui.pixiv.xxxxxx; 包里面 ,V5 只有一个 HomeActivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants