欢迎Follow我的GitHub, 关注我的CSDN.
我会介绍关于Android的一些有趣的小知识点. 上一篇.

1. Dagger2的开发顺序
Module -> Component -> Application
首先模块(Module)创建需要提供的类实例, 其次把模块添加到组件(Component)中并提供需要注入的类, 最后把组件添加到应用(Application)中并提供接口.
// 模块@Modulepublic class TestAppModule { private final Context mContext; public TestAppModule(Context context) { mContext = context.getApplicationContext(); } // 提供类实例 @AppScope @Provides public Context provideAppContext() { return mContext; } @Provides public WeatherApiClient provideWeatherApiClient() { return new MockWeatherApiClient(); }}// 组件@AppScope@Component(modules = TestAppModule.class) // 注册模块public interface TestAppComponent extends AppComponent { void inject(MainActivityTest test);}// 应用public class TestWeatherApplication extends WeatherApplication { private TestAppComponent mTestAppComponent; @Override public void onCreate() { super.onCreate(); mTestAppComponent = DaggerTestAppComponent.builder() .testAppModule(new TestAppModule(this)) .build(); } // 提供组件 @Override public TestAppComponent getAppComponent() { return mTestAppComponent; }}2. JRebel
Android调试工具, 不用编译, 就可以刷新一些项目修改. 不过功能已经被Android Studio 2.0 代替, 等待2.0正式发版.
3. 数据绑定(DataBinding)
DataBinding实现数据与页面的分离, 更符合面向对象的编程模式.
布局设置
<data> <variable name="weatherData" type="clwang.chunyu.me.wcl_espresso_dagger_demo.data.WeatherData"/> </data> <TextView android: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°"/>逻辑设置
private ActivityMainBinding mBinding; // 页面绑定类mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main); // 绑定页面mBinding.weatherLayout.setVisibility(View.VISIBLE); // 使用IdmBinding.setWeatherData(weatherData); // 绑定数据4. ClassyShark
查看Apk信息的软件, 功能非常强大, 省去反编译的步骤, 主要功能:
(1) 在MultiDex中dex的详细信息.
(2) 使用NativeLibrary的详细信息.
(3) 类的详细信息.
(4) 数量统计.
5. CocoaPod安装
升级Mac系统, 可能会导致Pod命令消失, 需要重新安装Pod.
sudo gem install -n /usr/local/bin cocoapods6. LaunchMode
LaunchMode包含四种模式,
(1) standard, 标准模式, 启动重新创建示例, 默认.
(2) singleTop, 栈顶复用模式, 位于栈顶, 启动不会被创建, 调用onNewIntent.
(3) singleTask, 栈内复用模式, 存在不会被创建, 调用onNewIntent.
(4) singleInstance, 单实例模式, 单独位于一个任务栈内, 复用.
OK, That’s all! Enjoy It