preface
The following advice is based on my own experience and several blogs on the web
-
Control the size of each image, as they will affect the size of the APK (and interact with the UI). Here are some sites that compress images.
Known as panda compression
Smartmap is a platform for image compression and image format conversion developed by Tencent ISUX front-end team. Its functions include PNG, JPEG, GIF and other formats of image compression, as well as automatic selection of the best image format for uploading pictures. At the same time, the platform will also convert a webP format image for the user
ImageAlpha significantly reduces the file size (including alpha transparency) of 24-bit PNG files by applying lossy compression and conversion to the more efficient PNG8 + alpha format
Imageoptim lossless compression and client support (Mac client)
SquooshGoogle is an open source online service for compressing images. In addition to reducing size, it can also do simple editing, including cropping and reducing color palettes
-
If a large amount of data needs to be passed between page jumps, it is not recommended to use intents or bundles, but rather RxBus, EventBus, and LiveDataBus. LiveDataBus is highly recommended. But don’t abuse it
-
Adopt PBF (Package By Feature) to refer to Blankj’s Android development specification
-
ConstraintLayout, Include, ViewStub, Merge, and avoid nesting.
-
Choose open source libraries carefully; Don’t import a large library just for a small function
-
Use auxiliary tools to detect memory leaks, performance checks, exception reporting systems, and so on. Recommend some wheels (lots of tools, choose your own)
Bugly Tencent Bugly provides mobile developers with professional abnormal reporting and operation statistics, helping developers quickly find and solve anomalies, grasping product operation dynamics, and timely following up user feedback
BlockCanary is a non-invasive performance monitoring component for Android
LeakCanary Memory leak detection library
-
Use dependency injection decoupling!! Decouple!! Decouple!! Dagger2 on Android
-
Don’t write useless code to your Application, keep it simple, or it will slow down your Application’s initialization and startup
-
Avoid using databases unless you really need to
-
Use DialogFragment instead of Dialog, official explanation
-
Don’t use enumerations too much; they take up more memory than integers
-
Use some Android-specific data structures, such as SparseArray and Pair, for better performance
-
Use soft and weak references appropriately, official explanation
-
Use thread pools instead of creating a large number of threads; Reference: Android threads and thread pools is enough
-
Add comments appropriately!! Add comments appropriately!! Add comments appropriately!!
-
Don’t create objects or do time-consuming tasks inside View’s onDraw method
-
Don’t set objects like Context or View to static
-
Use static inner classes whenever possible to avoid potential memory leaks due to inner classes
-
A good set of development practices; Reference: Android development specification
-
Code should have a sense of hierarchy and follow a single responsibility, see: Six principles of design Pattern (1) : Single responsibility principle
That’s all I can think of at present, I’ll update it later