Android technology selection

Thermal paper REVIEW |   Click on the title to read

Under Internet winter, the programmer how to break through to enhance their own?

Front and let Android developers unemployed technology: Flutter Web first experience

The only programmers can understand, Java is black too badly!

Source: DreamWinter

www.jianshu.com/p/25cf7ce0d8d0

Technology selection is very important for the development of a project, think:

The lower limit of technical decisions, decided to taste the upper limit.

Good technology can only guarantee made out of App not bad, tastes good to the limited technology to the limit, App will be made to the next level.

Network Framework

Retrofit + RxJava + OkHttp
this seems nothing to say, it has been the mainstream, and it is very easy to use.

  • Retrofit full advantage of the flexibility annotation, configured in the form of an interface to decouple. Communication with back-up is also very convenient, directly to the api interface to copy him to become.

  • RxJava simply can not go back a great product. Java object-oriented very scientific, but multi-threaded infinite callback really terrible, very simple logic is often thrown into confusion, RxJava a good solution to this problem.

  • The advantage OkHttp I do not quite understand, I only know that nothing difficult on the network after I use it, the others have, want to be able to do.

There is a good Sample, are not familiar with the operation of RxJava students can understand the next:
HTTPS% 3A% 2F% 2Fgithub.com% 2Famitshekhariitbhu% 2FRxJava2-Android-the Samples

Hot update

A year ago (2018), when I take the heat update also considered the US group, Ali family. Now I tell you, all pass, with Tinker. As for why, under a little attention to know which items are lying to deceive the performance of which is the real star of the intention to solve the problem of maintenance.

Tinker official Wiki  https://github.com/Tencent/tinker/wiki

Why strong push Tinker? First of all, I spent time in the company and is now home with Tinker posted dozens of hot update, not out of question. Tinker difference bsdiff algorithmically generated based on very small sub-contractors, not related to the resource file, then added, mostly in less than 30k. After the patch will automatically synthesize a callback, the user is prompted to restart the App to take effect.

Use Tinker few points to note:

  • TinkerId very important, it is best displayed somewhere within the App;

  • Manifest.xml best not to change, although some changes to the generated patch can be synthesized, but are not able to succeed on all devices;

  • Tinker patch after installing the full amount of the package TinkerId, so multiple changes can be large, it is recommended not to maintain the current version is too large, but released a new full package amount based restarted. (This passage mouthful, ah, slowly understanding)

  • Do not increase when released patches versionCode, although Tinker did not limit you, but do not increase, otherwise it will be a mess. versionCode increase in the total amount released apk.

Architecture

Architecture is a topic on relatively tall, so often boast loaded to force people to talk. Despised by the students with the MVC MVP, MVVM with the look down with the MVP, with LiveModel look down on the use MVVM.
But I want to say is:

The blind pursuit of the top chain contempt, as if wearing a pair of shoes do not fit the large - inviting burden.

In addition, I personally very optimistic about MVVM, Google DataBinding it too TM card, and seriously affect the UI development efficiency, but also increase the coupling.

As MVP, I feel better Fragment easy to use, also pulled out, is also split the code, Fragment can be done more thoroughly, because the View can follow.

As LiveModel not used, do not comment. But one thing is really easy to use --Lifecycles! This stock tyranny memory leaks! The principle is very simple, that is the observer mode, monitor the page life cycle. Niubi is that Google will be integrated into the event publisher Activity and Fragment, it is very convenient to use.

In short, before the election infrastructure must understand:

  • This architecture can solve the problem?

  • This architecture will bring what issues?

  • Scalability How?

  • The average length of time will not affect development?

  • There is no impact on performance?

“九层之台,起于垒土”,多花点时间思考与参照是非常有必要的。

UI适配

其实不在这范畴,但今天在首页看到一篇蠢文,所以顺带聊聊UI。

layout选择

我一般只用这几个布局:

  • LinearLayout:线性布局,直观的上下结构或者横竖结构,用它没问题。

  • FrameLayout:层叠布局,其实就是设计师眼里的“图层”,子控件之间没啥约束的优先用它。

  • ConstraintLayout:弹性布局,非常牛叉,适合约束比较复杂的页面。比如复杂的item我常用这个布局。RelativeLayout能做的它都能做,而且它自带比例控制。用好了它你才真正知道什么叫做“减少视图层级”。

  • CoordinatorLayout:我没叫过它中文名,也找不到好的译名,但在Android 5.0 Material Design兴起时,它是绝对的主角,沉浸式及一个漂亮的头部动画都离不开它,用好它的关键是理解Behavior。

文字适配

挑一台最具代表性的大众设备,以sp为单位适配好它就好。相同sp在不同设备,其物理大小是不一样的。比如同样是默认的14sp,同样是1080p,小米的会比华为的小一点,因为小米的dp/sp会小一点。

注意:

dp并非物理尺寸,屏幕多少dp*dp是由厂商定义的。

Google这样设计的好处是手机App可以直接适配电视。(想要验证上方论述很简单:在xml中画一个200dp*200dp的黑框,然后用不同设备预览)。

另外,dp尽量不要用小数(除非值很小,需控制误差),Google设计dp就是用来适配众多设备的,而不是丝毫不差用来适配设计稿的(因为大部分设计稿基于iOS设计)。如果真的是强迫每个设备上显示物理大小需要一致,那么直接用inch就行(少部分鸡贼厂商是没有给出准确inch的),也别用什么dp了(搬倒砖)。

刘海适配

三星之前的全面屏设备算长的了,都是没有刘海的,比例是18.5:9。
所以,可以得出最简单的规则:

该规则不会漏掉市面上任何一台刘海屏手机。但是,它会把极少数非刘海屏手机识别为刘海屏:OPPO、Vivo家的较新旗舰机。如果要进一步精准的话,就把那几台特殊的设备型号统计出来,加以判断即可(其实不是太必要,因为那么长的非刘海手机被识别成刘海屏,上方留了点背景关系不大)。

版本选择

再聊聊各种版本选择,比如IDE啊,第三方库啊,Android buildVersion啊。

个人偏好:

  • 项目稳定性很重要的话,IDE尽量不要预览版(让别人去填坑吧)、各种库也是。

  • 第三方库之类的升级不要太着急,看看版本变动与issue。

  • 新开项目尽量用最新稳定版,不然以后还得适配api。

  • 现在是2019年了,Android 5.0已经发布5年了,App最低兼容到api21就行了(主要是5.0相比4.+变得太大了,过多的适配影响开发效率。实在要适配的话也只适配到api19,也就是Android4.4,占有率还是有一点的)。

  • 编译版本的话,新项目可以上Android X,我已经用了半年了,没啥问题。

更多学习和讨论,欢迎加入我们的知识星球,这里有1000+小伙伴,让你的学习不寂寞~·

看完本文有收获?请转发分享给更多人


我们的知识星球第三期开期了,已达到1100人了,能连续做三期已很不容易了,有很多老用户续期,目前续期率达到50%,说明了大家对我们的知识星球还是很认可的,欢迎大家加入尽早我们的知识星球,更多星球信息参见:

欢迎加入Java和Android架构社群

如何进阶成为Java的Android版和架构师?

说两件事

640?wx_fmt=jpeg

微信扫描或者点击上方二维码领取的Android \ Python的\ AI \的Java等高级进阶资源

更多学习资料点击下面的“阅读原文 ”获取

640?wx_fmt=gif

谢谢老板,点个好看↓

Guess you like

Origin blog.csdn.net/xJ032w2j4cCjhOW8s8/article/details/91349999