In the rapid development of the Internet today, programmers really a little rotten street, recently frequently hear friends are working, and to do development, to training institutions and then come out for a long time to find a job. A variety of cross-professional, post-work transition. The competition in the Internet industry is becoming more and more fierce today, efficient and rapid development, a solid foundation is the key to win. Today, I would like to recommend some Android developers to develop plug-ins and some of the skills of development, just some personal insights, I hope to help you.

Specification of code

Code specification for the long-term development of a programmer is quite important, android code specification and Java are basically the same, here recommend Alibaba Java development manual, Ali is still constantly updated and improved, thanks to Ali for the industry to do a great contribution, this small step, a great impact. If everyone follows this specification, are you still scratching your head about what the code block is and what the iteration of the project is when you take on someone else’s project?

Android efficient development tools recommended

Android Studio automatically generates the layout code plug-in LayoutCreator

Many of you are familiar with JakeWharton’s Butterknife, androidAnnotations, and Dagger 2 dependency injection, but is it really good to use them? In fact, it is very performance, here to butterKnife source analysis

ButterKnife. The bind process

Look at the source code

static void bind(@NonNull Object target, @NonNull Object source, @NonNull Finder finder) { Class<? > targetClass = target.getClass(); try { ViewBinder<Object> viewBinder = findViewBinderForClass(targetClass); viewBinder.bind(finder, target,source); } catch (Exception e) {// omit Exception}}Copy the code

Let’s look at another method

private static ViewBinder<Object> findViewBinderForClass(Class<? > cls) throws IllegalAccessException, InstantiationException { ViewBinder<Object> viewBinder = BINDERS.get(cls); // Find the cache firstif(viewBinder ! = null) {returnviewBinder; } String clsName = cls.getName();if (clsName.startsWith("android.") || clsName.startsWith("java.")) {
   returnNOP_VIEW_BINDER; } try {// Find the name of the Activity class plus"$$ViewBinder"Class, instantiate, and return Class<? > viewBindingClass = Class.forName(clsName +"$$ViewBinder"); //noinspection unchecked viewBinder = (ViewBinder<Object>) viewBindingClass.newInstance(); } catch (ClassNotFoundException e) {viewBinder = findViewBinderForClass(cls.getSuperClass); } // cache viewBinder binders. put(CLS, viewBinder);return viewBinder;
}Copy the code

Looking through the source code ButterKnife has had a performance impact, as well as introducing more classes and methods and increasing the size of the installation package. However, the improvement in development efficiency is also noticeable, especially with the use of the AS plug-in. It’s up to you as the developer to decide which ones to choose. Several other injected third-party libraries are similar, so LayoutCreator is recommended here to avoid writing findViewById without affecting performance

  • The installation

    Method 1: Download the JAR package from the project and import it from the local disk

    Method 2: Download and install LayoutCreator from the Plugin center of Android Studio

Use the screenshot

image

Android Code Generator quickly generates corresponding activities, fragments, Adapter, and menus based on the layout file.

With the LayoutCreator widget above, plus this widget, you can probably save a lot of coding time, don’t you feel that you finally have time to have a girlfriend?! Good luck finding a girlfriend for those of you who don’t have one…

  • The installation

    Method 1: Download the JAR package from the project and import it from the local disk

    Preferences/Settings->Plugins->Browse Repositories… Then type Android Code Generator in the search box.

Use the screenshot

image

The plugin GsonFormat quickly implements Javabeans

Are you still writing arguments one by one to return strings in JSONObject format? GsonFormat A string in JSONObject format that automatically generates entity-class parameters. Write entity class in the future is a matter of seconds!!

  • The installation

    Method 1: Download the gsonformat. jar package and import it from the local disk

    Android Studio File->Settings.. – > Plugins – > Browse repositores.. Search for GsonFormat, install the plug-in, and restart Android Studio

Use the screenshot

gsonFormat.gif

Other plug-ins

There are two installation methods. You can refer to the preceding installation methods

SelectorChapek

The designer has given us all these resources, is it too much of a hassle to write a selector for every button? This plugin is designed to solve this problem. All you have to do is tell the designers to follow the rules and name it.

LeakCanary

Highly recommended, to help you in the development phase of the convenient detection of memory leaks, easier to use.

Genymotion

Strong enough to be known to all

Android Parcelable code generator

Insert code that implements the Parcelable interface into the class.

Android Material Design Icon Generator

Import the Material Design icon into the program.

Android Drawable Importer

This is a very powerful image import plugin. It imports Android icon and Material icon Drawable, batch import Drawable, multi-source import Drawable (that is, import a picture of various DPI images)

Android Studio has many plugins, choose some commonly used, don’t install too many plugins oh, if you want what function of the plug-in can leave a message, I recommend you

Common Open Source libraries

Android is open source, so also born a batch of a batch of open source big bull, and then these big bull wrote a great open source library, let us work more simple today, here to introduce some commonly used open source library

Network request

Okhttp: fast-Android-networking; okHttputils; NoHttp

Retrofit is a very sophisticated web request based on OKHTTP

Now the mainstream is these two, and Volley, Xutil and so on will not be introduced

Data parsing

gson

fastjson

Pictures to load

glide

fresco

picasso

The database

greenDAO

ormlite

LitePal

realm-java

Refresh the controls

Refer to Refresh load control

Event bus

In fact, it is not recommended to use the event bus personally, because the code logic is not clear, and the later iteration maintenance is troublesome; Observer specific, observer may cause interface bloat

EventBus

Rounded corners

CircleImageView

The chart

MPAndroidChart

SmallChart

WilliamChart

hellocharts-android

ImageVie gesture operation

PhotoView

PinchImageView

Photo picker

TakePhoto

PhotoPicker

MultiImageSelector

The loading frame

AVLoadingIndicatorView

Android-SpinKit

LoadingDrawable

LoadingView

Custom dialog box

sweet-alert-dialog

dialogplus

MaterialDialog

material-dialogs

Media player

  • video

JieCaoVideoPlayer

ExoPlayer

PLDroidPlayer

GSYVideoPlayer

  • audio

android-UniversalMusicPlayer

Timber

  • live

SmarterStreaming

Other recommended

RxJava

RxAndroid

AndroidSwipeLayout others hate a variety of imitation ios what effect programmers can write to play with no problem. Imitation of iOS left and right sliding effect

Circular -progress-button Button with progress display, make operation more cool

ToggleButton state switch Button, similar to iOS, with View implementation

AndPermission Permission management

AndroidUtilCode Large collection of utility classes

Code writing tips

XML layout

  • Matters needing attention

    • Avoid yellow warning

    • Don’t use outdated methods

    • Include the use of

    • The use of the merge

    • The use of viewstub

    • Avoid deep nesting of layouts; Simple linearLayout, complex layout Relativelayout; Some effects consider whether the custom view can be achieved, do not use view overlay

    • Style is used to reduce the amount of code

    • Proper use of weight

    • Margain and padding are used in a reasonable comparison

    • Use of the latest layout method ConstaintLayout

    • Avoid unnecessary rendering by using third-party tools

Java code

  • Matters needing attention

    • In order to improve UE, it is necessary to consider cache, data storage optimization, algorithm optimization, JNI, logic optimization, and requirements optimization (optimization will be described in detail later).

    • Code results clear, multi-method, avoid a method to execute many lines of code

    • Avoid warnings; Do more exception handling; Judge the condition to consider

Resource management

  • Matters needing attention

    • Lint in AndroidStudio removes useless resources

    • Caution Caution When deleting resources imported by a third party (typical: a union)

Focus on: more coding, look at the bottom, know what it is, know why

Personal blog