Android Development Tips (2)

Source: Internet
Author: User

Welcome to follow my GitHub and follow my csdn.

I'll introduce some interesting little points about Android. Previous article.

1. Dagger2 Development Sequence

Application, Component, Module
The module first creates an instance of the class that needs to be provided, followed by adding the module to the component (Component) and providing the classes that need to be injected, and finally adding the component to the application (application) and provides the interface.

//Module@Module Public  class testappmodule {    Private FinalContext Mcontext; Public Testappmodule(Context context)    {mcontext = Context.getapplicationcontext (); }//Provide class instances    @AppScope    @Provides     PublicContextProvideappcontext() {returnMcontext; }@Provides     PublicWeatherapiclientprovideweatherapiclient() {return NewMockweatherapiclient (); }}//Components@AppScope@Component(modules = Testappmodule.class)//Brochure Module Public  interface testappcomponent extends AppComponent {    voidInject (mainactivitytest test);}//Application Public  class testweatherapplication extends weatherapplication {    PrivateTestappcomponent mtestappcomponent;@Override  Public void onCreate() {Super. OnCreate (); Mtestappcomponent = Daggertestappcomponent.builder (). Testappmodule (NewTestappmodule ( This). build (); }//Supply Components    @Override     PublicTestappcomponentgetappcomponent() {returnMtestappcomponent; }}
2. JRebel

Android Debugging tools, without compiling, you can refresh some project changes. Just feature has been replaced by Android Studio 2.0, waiting for 2.0 official release.

3. Data binding (DataBinding)

DataBinding implements the separation of data from the page, more in line with the object-oriented programming model.
Layout settings

< Data><variable name="Weatherdata"             Type= "Clwang.chunyu.me.wcl_espresso_dagger_demo." data. weatherdata"/></ Data><TextViewAndroid:id="@+id/temperature"Android:layout_width="Wrap_content"android:layout_height="Wrap_content"Android:layout_centerinparent="true"Android:layout_marginbottom="@dimen/margin_large"android:layout_margintop="@dimen/margin_xlarge"android:text="@{weatherdata.temperaturecelsius}"Android:textappearance="@style/textappearance.appcompat.display3"tools:text="10°"/>

Logical Settings

private// 页面绑定类mBinding = DataBindingUtil.setContentView(this// 绑定页面// 使用Id// 绑定数据
4. Classyshark

The software to view the APK information is very powerful, eliminating the steps to decompile, the main features:
(1) Specific information about Dex in Multidex.
(2) Use nativelibrary specific information.
(3) The specific information of the class.
(4) Quantity statistics.

5. Cocoapod Installation

Upgrading your Mac system may cause POD commands to disappear and you need to install the pod again.

-n /usr/local/bin cocoapods
6. Launchmode

The Launchmode consists of four modes,
(1) Standard, Normal mode, start again create Demo sample, default.
(2) Singletop, stack top multiplexing mode, located at the top of the stack, boot will not be created, call onnewintent.
(3) Singletask, stack in the reuse mode, the presence will not be created, call onnewintent.
(4) SingleInstance, single-instance mode, separate in a task stack, reuse.

7. Standard font for TextView

Style

style="@style/textappearance.appcompat.display4" style="@style/textappearance.appcompat.display3" style="@style/textappearance.appcompat.display2" style="@style/textappearance.appcompat.display1" style="@style/textappearance.appcompat.headline" style="@style/textappearance.appcompat.title" style="@style/textappearance.appcompat.subhead" style="@style/textappearance.appcompat.body2" style="@style/textappearance.appcompat.body1" style="@style/textappearance.appcompat.caption" style="@style/textappearance.appcompat.button" 

Show

8. Generate DBHelper scripts on your own initiative


Install JINJA2.

install Jinja2

Setting up data

CLASS RepoString IdString NameString DescriptionString OwnerENDCLASS

Download the code base. Generate code.

python sql_lite_helper.-f-n-p me.-a clwang
9. Serialization parameters of the Gson

In some cases, the JSON name differs from the variable and needs to be specified.

@SerializedName("avatar_url"private String avatarUrl;
Proguard Reserve Library

The most concise way is to keep all of them. Remove the warning dontwarn, and keep the keepclass.

# 在线更新-dontwarn clwang.chunyu.me.**-keep class clwang.chunyu.me.**{*;}

OK, that ' s all! Enjoy it!

Android Development Tips (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.