The most beautiful application - from the perspective of an Android R&D engineer [the most beautiful time]

Editor's recommendation: Rare Earth Nuggets , this is an application for technology developers, you can get the latest and best technical dry goods on Nuggets, not only Android knowledge, front-end, back-end, but also products and design. , don't miss it if you want to become a full stack engineer!

@author ASCE1885's  Github  short book  Weibo  CSDN

Recently I discovered a website like the most beautiful app . It regularly recommends some interesting apps. As a developer, every time I see a great app, I will analyze it from the perspective of implementation, thinking about how to implement it myself? Therefore, this series of articles aims to interpret some interesting apps from the perspective of technical selection and architecture.
The most beautiful time is an anniversary app produced by the most beautiful application team. It is used to record and share those important days. Let's start with this first!

Open source library used

1.  Open source logging library JakeWharton's Timber

Timber is a logging function library open sourced by star programmer JakeWharton . It is based on the Android Log class and provides a concise and extensible API.

The logging behavior is abstracted into a tree one by one, such as a tree that prints logs to Logcat, a tree that prints logs to files, etc. If we want to use a certain type of tree, we first need to create an instance and call The Timer.plant function will plant it, and then you can use it at will.

2.  Lightweight ORM framework ActiveAndroid

ActiveAndroid is one of several common ORM frameworks (in addition, the more famous open source solutions are GreenDAO and ORMLite ), which can greatly simplify the use of the database, manage the database in an object-oriented way, and say goodbye to handwritten SQL History. Each database table can be mapped to a class, and developers only need to use functions like save() or delete().

Reference documentation:
Official documentation

3.  JSON parsing library GSON

GSON is a function library produced by Google, which can deserialize JSON strings into corresponding Java objects, or conversely serialize Java objects into corresponding JSON strings. It saves developers the trouble of manually parsing JSON fields one by one through JSONObject and JSONArray, reduces the possibility of errors, and enhances the quality of the code.

Reference Documentation:
Official User Guide
Third Party User Guide

4.  Click on the ripple effect control RippleView

This control is implemented on Android 2.3 and above platforms and is compatible with the View click ripple effect introduced by the Android L platform.

68747470733a2f2f7261772e6769746875622e636f6d2f73697269736361632f526970706c65566965772f6d61737465722f53637265656e732f53637265656e2e676966.gif

5.  Modern HTTP function library OkHttp

OkHttp is an efficient HTTP client with the following features:

  • Support HTTP/2 and SPDY, all requests to the same host share the same socket

  • Use connection pooling to reduce latency of requests when SPDY is unavailable

  • Transparent GZIP compression reduces downloaded data size

  • Cache responses to avoid repeated network requests

OkHttp在网络性能很差的情况下能够很好的工作,它能够避免常见的网络连接问题。如果你的HTTP服务由多个IP地址,OkHttp在第一次连接失败时,会尝试其他可选的地址。这对于IPv4+IPv6以及托管在冗余数据中心的服务来说是必要的。OkHttp使用现代的TLS特性(SNI, ALPN)初始化HTTP连接,但握手失败时,会降级使用TSL1.0尝试初始化连接。

更详细的使用方法参见文档

6. 滚轮选择器控件android-wheel

android-wheel是Android平台上使用广泛的滚轮选择器,可用于实现日期时间选择器,省市区三级选择菜单等等。在最美时光这个app里面是作为日期时间选择器使用,效果如下所示:

blob.png

7. 现代的I/O操作函数库okio

okio作为java.io和java.nio的补充,是由square公司开发的一个函数库,使得开发者可以更方便的访问,存储和处理数据。一开始是作为okhttp的一个组件存在的,当然我们也可以单独使用它。

8. 类型安全的REST客户端Retrofit

Retrofit是将REST API转换成Java接口的一个开源函数库,它要求服务器API接口遵循REST规范。它基于注解使得代码变得很简洁,Retrofit默认情况下使用GSON作为JSON解析器,使用OkHttp实现网络请求,三者通常配合使用,当然我们也可以将这两者替换成其他解析函数库。

参考文档:
Retrofit官方文档
快速Android开发系列网络篇之Retrofit
Retrofit – Java(Android) 的REST 接口封装类库
再谈RESTAPI最佳实践
使用Android API最佳实践
深入剖析Android网络开发库-part1: OkHttp, Volley and Gson

9. 下拉刷新组件Android-PullToRefresh

Android平台上广泛使用的下拉刷新组件,Github上star五千多,目前不再维护。支持的下拉刷新控件有:

  • ListView

  • ExpandableListView

  • GridView

  • WebView

  • ScrollView

  • HorizontalScrollView

  • ViewPager

10. 图片异步加载缓存函数库Android-Universal-Image-Loader

这个函数库简称UIL,是一个功能强大灵活且高度可自定义的用于加载,缓存和显示图片的开源函数库,它提供一系列配置选项,并能很好的控制图片加载和缓存的过程。

主要特性有:

  • 同步或者异步的多线程图片加载

  • 高度可自定义:线程池,下载器,解码器,内存和磁盘缓存,图片显示选项等等

  • 每张图片的显示支持多种自定义选项:默认存根图片,缓存切换,解码选项,Bitmap处理和显示等

  • 图片可缓存在内存或者磁盘(设备的文件系统或者SD卡)上

  • 可实时监听图片加载流程,包括下载进度。

参考文档:
Android-Universal-Image-Loader 图片异步加载类库的使用(超详细配置)
Android 开源框架Universal-Image-Loader完全解析
Android Universal Image Loader 源码分析

使用的第三方SDK

1. 小米推送(MiPush)

小米推送(MiPush)是小米公司为开发者提供的消息推送服务,通过在云端和客户端之间建立一条稳定、可靠的长连接,为开发者提供向客户端应用推送实时消息的服务,帮助开发者有效地拉动用户活跃。

2. 友盟统计分析SDK

友盟统计分析平台是国内最大的移动应用统计分析平台。我们帮助移动应用开发商统计和分析流量来源、内容使用、用户属性和行为数据,以便开发商利用数据进行产品、运营、推广策略的决策。

3. 友盟用户反馈SDK

友盟用户反馈SDK两行代码实现开发者和用户轻松高效沟通。收集用户建议,了解用户需求,解决用户问题,全在应用之内。

4. 新浪微博SDK

微博 Android 平台 SDK 为第三方应用提供了简单易用的微博API调用服务,使第三方客户端无需了解复杂的验证机制即可进行授权登陆,并提供微博分享功能,可直接通过微博官方客户端分享微博。

分析与总结

最美时光app用到的底层函数库基本上遵循Android开发者必知的5个开源库这篇文章介绍的函数库进行搭建。技术选型中规中矩,都是一些成熟稳定且常见的函数库,避免了开发人员流动造成的代码熟悉成本,团队新成员能够较快上手,而且也避免了开源库隐藏的bug可能造成的版本delay,因为越是成熟的开源库社区越成熟,bug也越少,就算出现新的bug,也能很快得到解决。

对于规模较小的团队,我们建议技术选型时尽量选择成熟的框架,特别是对初创公司。当公司和团队发展到一定阶段后,可以适时的引入新技术或者新框架,激活团队成员的技术敏感度。在大公司中,一般存在基础架构组这样一个团队,他们服务于全公司各个产品线,为其提供基础能力建设。当然对于团队成员整体技术水平都很高的团队来说,就算是初创公司,也有很多抛弃成熟稳定的技术或框架,转而选择新崛起的技术或者框架,因为往往新技术或框架相比成熟的技术或者框架而言更优,虽然可能存在更多的隐藏bug。说到底,技术选型是公司规模和团队素质的一个综合选择。

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326721229&siteId=291194637