Android development Tips (2)

Source: Internet
Author: User

Android development Tips (2)

1. Dagger2 development sequence

Module-> Component-> Application
FirstModule)Create a class instance to be provided, and then add the moduleComponent)And provide the class to be injected, and add the componentApplication)And provides interfaces.

// Module @ Modulepublic class TestAppModule {private final Context mContext; public TestAppModule (Context context) {mContext = context. getApplicationContext () ;}// Provides class instances @ brief users @ Provides public Context provideAppContext () {return mContext ;}@ Provides public WeatherApiClient provideWeatherApiClient () {return new MockWeatherApiClient ();}} // Component @ appsent @ Component (modules = TestAppModule. class) // registration module public interface TestAppComponent extends AppComponent {void inject (MainActivityTest);} // application public class TestWeatherApplication extends WeatherApplication {private TestAppComponent mTestAppComponent; @ Override public void onCreate () {super. onCreate (); mTestAppComponent = DaggerTestAppComponent. builder (). testAppModule (new TestAppModule (this )). build () ;}// provide the component @ Override public TestAppComponent getAppComponent () {return mTestAppComponent ;}}
2. JRebel

You can refresh some project modifications without compiling the Android debugging tool. However, the function has been replaced by Android Studio 2.0 and will be released later.

3. Data Binding)

DataBinding separates data from pages and is more in line with the object-oriented programming mode.
Layout settings

<code class="hljs haskell">    <data>        <variable name="weatherData" type="clwang.chunyu.me.wcl_espresso_dagger_demo.data.WeatherData">    </variable></data>            <textview android:id="@+id/temperature" android:layout_centerinparent="true" android:layout_height="wrap_content" android:layout_marginbottom="@dimen/margin_large" android:layout_margintop="@dimen/margin_xlarge" android:layout_width="wrap_content" android:text="@{weatherData.temperatureCelsius}" android:textappearance="@style/TextAppearance.AppCompat.Display3" tools:text="10°"></textview></code>

Logical settings

Private ActivityMainBinding mBinding; // page binding class mBinding = DataBindingUtil. setContentView (this, R. layout. activity_main); // bind the page to mBinding. weatherLayout. setVisibility (View. VISIBLE); // use IdmBinding. setWeatherData (weatherData); // bind data
4. ClassyShark

The SDK for viewing Apk information is very powerful and does not require any decompilation steps. Its main functions are as follows:
(1) dex details in MultiDex.
(2) Use NativeLibrary details.
(3) Class details.
(4) Quantity statistics.

5. CocoaPod Installation

Upgrading the Mac system may cause the Pod command to disappear and you need to reinstall the Pod.

sudo gem install -n /usr/local/bin cocoapods
6. LaunchMode

LaunchMode includes four modes,
(1) standard, standard mode, restart and recreate example, default.
(2) singleTop: Stack top reuse mode. It is located at the top of the stack and cannot be created during startup. onNewIntent is called.
(3) singleTask, in the stack reuse mode, is not created and onNewIntent is called.
(4) singleInstance, in single-instance mode, is located in a single task stack and reused.

OK, That's all! Enjoy It

Related Article

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.