Readhub https://readhub.cn 是一个专注于科技新闻实时分享的网站, 从一开始发布到现在一直都是我获取信息的重要渠道, 目前只有网页端和小程序可用, 一次偶然的灵感让我决定自己做一个客户端.
第一步: 抓包
想要获取数据, 首先要知道获取数据的 API, 在没有任何官方文档的前提下, 只有抓包能够解决这个问题.
工具: Fidder 4 https://www.telerik.com/download/fiddler
使用方法: Fiddler - 超好用的 http 抓包工具使用介绍 http://www.hangge.com/blog/cache/detail_1697.html
抓包结果:
- public static final String HOST = "https://api.readhub.me/";
- // 热门话题列表
- @GET("topic")
- Observable<DataListBean<TopicBean>> getTopicList(
- @Query("lastCursor") Long lastCursor,
- @Query("pageSize") int pageSize
- );
- // 其它模块新闻 type
- public static final String TYPE_NEWS = "news";// 科技动态
- public static final String TYPE_TECHNEWS = "technews";// 开发者资讯
- public static final String TYPE_BLOCKCHAIN = "blockchain";// 区块链快讯
- public static final String TYPE_JOBS = "jobs";// 招聘详情
- // 其他模块新闻列表
- @GET("{type}")
- Observable<DataListBean<NewsBean>> getNewsList(
- @Path("type") @Constants.Type String type,
- @Query("lastCursor") Long lastCursor,
- @Query("pageSize") int pageSize
- );
- // 即使查看
- @GET("topic/instantview")
- Observable<InstantReadBean> getTopicInstantRead(@Query("topicId") String topicId);
- // 话题详情
- @GET("topic/{topic_id}")
- Observable<TopicDetailBean> getTopicDetail(@Path("topic_id") String topicId);
- // 相关话题
- @GET("topic/related")
- Observable<List<RelevantTopicBean>> getRelateTopic(@Query("entityId") String topicId,
- @Query("eventType") int eventType,
- @Query("order") long order,
- @Query("t") long timeStamp);
- // 最新消息
- @GET("topic/newCount")
- Observable<NewTopicCountBean> getNewTopicCount(@Query("latestCursor") Long lastCursor);
第二步: 开发
特点
采用 Google Material Design 风格
采用 MVP + dagger 2 架构进行解耦
网络请求使用 Retrofit + RxJava
本地数据库采用 Room + RxJava
主题切换, 支持夜间模式
集成 Tinker 并支持应用内更新
侧滑返回
支持 CustomTabs
新话题悬浮提示
使用矢量图减少安装包体积
项目预览 -- 夜间模式
起始页 | 主菜单 | 首页 |
---|---|---|
即时查看 | 话题详情 | 文章网页 |
---|---|---|
本地搜索 | 设置 | 关于 |
---|---|---|
项目预览 -- 蓝色主题 (默认)
起始页 | 主菜单 | 首页 |
---|---|---|
即时查看 | 话题详情 | 文章网页 |
---|---|---|
本地搜索 | 设置 | 关于 |
---|---|---|
使用到的第三方开源库
项目名称 | 简介 |
---|---|
https://github.com/ReactiveX/RxJava | 一个专注于异步编程与控制可观察数据(或者事件)流的 API |
https://github.com/ReactiveX/RxAndroid | 在 Android 中使用 RxJava |
Retrofit https://github.com/square/retrofit | HTTP 请求工具库 |
ButterKnife https://github.com/JakeWharton/butterknife | 强大的注解框架,提供视图和事件绑定 |
Dagger https://github.com/google/dagger | 依赖注入框架 |
https://github.com/YoKeyword/Fragmentation | 强大的 Fragment 管理库 |
https://github.com/cachapa/ExpandableLayout | 支持展开和收缩子 View 的 Layout |
https://github.com/hongyangAndroid/FlowLayout | Android 流式布局,支持单选、多选等,适合用于产品标签等 |
https://github.com/square/leakcanary | 使用于 Android 和 Java 和内存泄漏检查工具 |
https://github.com/Justson/AgentWeb | Android webView 框架 |
支持添加头部和尾部的 RecyclerView | |
用于调试 Android SQLite 和 Shared preferences 的库 | |
Bugly https://bugly.qq.com/v2/ | 帮助开发者快速发现并解决异常,同时掌握产品运营动态,及时跟进用户反馈 |
Tinker https://github.com/Tencent/tinker | Android 热修复解决方案,支持 dex,library 和资源更新且不用重新安装 app |
https://github.com/Meituan-Dianping/walle | Android Signature V2 Scheme 签名下的新一代渠道包打包神器 |
使用到的工具 / 网站
网站名称 | 简介 |
---|---|
Iconfont http://www.iconfont.cn/ | 阿里巴巴矢量图标库,提供了本项目中的大部分矢量图 |
https://www.aconvert.com/cn/image/resize/ | 在线调整图片大小(PNG, JPG 和 GIF) |
https://convertio.co/zh/png-converter/ | 在线图像文件转换器,支持 SVG 转换成 PNG |
http://www.logoko.com.cn/design | 在线 logo 设计 |
图帮主 http://www.tubangzhu.com/ | 在线平面设计 |
https://shields.io/ | metadata 图标设计 |
https://compresspng.com/zh/ | 在线压缩 PNG 图像 |
感谢
- https://github.com/BryantPang/ReadHub
- https://github.com/TakWolf/Readhub-Android
- https://github.com/JsonChao/Awesome-WanAndroid
- https://github.com/iMeiji/Toutiao
第三步: 申请各大应用市场的开发者账号
要上架到应用市场, 必须要申请相应平台的开发者账号, 目前国内主流的应用市场开发者账号申请地址如下:
Google Play (注册需要绑定一个可用于境外支付的信用卡, 费用是 29 美刀)
豌豆荚, PP 助手, YunOS 应用商店等 http://open.uc.cn/ (首先需要实名认证, 然后需要申请 App 的软件著作权或者上传一份开发者声明, 本 App 因为该平台不允许个人上架新闻类应用被拒绝...)
腾讯应用宝 http://op.open.qq.com/appregv2/ (实名认证 + 软件著作权)
酷安市场 https://developer.coolapk.com/ (之所以叫酷安, 是因为他们只接受比较库的应用, 再次被拒绝...)
小米应用市场 https://dev.mi.com/console/app/phone.html (实名认证 + ...)
第四步: 打包发布
多渠道打包工具: 强烈推荐多渠道打包神器 -- https://github.com/Meituan-Dianping/walle
用法: Walle 多渠道打包 & Tinker 热修复 https://www.jianshu.com/p/0ba717f7385f
总结
一个 App 从构思到上架, 还是需要花不少精力和时间的, 如果没有充足的业余时间, 即使功能简单的 App 也是不容易做好的. 如果能在这个过程中感受到亲自打磨产品的激情和乐趣, 那将会对产品质量产生无尽的力量, 希望每个开发者都能做出自己心仪的 App!
来源: https://juejin.im/post/5c81ce3ae51d4539b639b32e