阅读全文
  • 实现navigation

    目录

    阅读全文
  • LiveData概述

    目录

    阅读全文
  • Dagger多重绑定

    目录

    Dagger allows you to bind several objects into a collection even when the objects are bound in different modules using multibindings. Dagger assembles the collection so that application code can inject it without depending directly on the individual bindings.

    Dagger允许您将多个对象绑定到一个集合中,即使对象使用多重绑定绑定到不同模块中时也是如此。Dagger组合集合,以便应用程序代码可以注入它而不依赖于单个绑定。

    阅读全文
  • Dagger子组件

    阅读全文
  • Dagger & Android

    dagger.android

    One of the central difficulties of writing an Android application using Dagger is that many Android framework classes are instantiated by the OS itself, like Activity and Fragment, but Dagger works best if it can create all the injected objects. Instead, you have to perform members injection in a lifecycle method. This means many classes end up looking like:

    使用Dagger编写Android应用程序的主要困难之一是很多Android框架类都是由操作系统本身实例化的,例如Activity和Fragment,但是如果Dagger可以创建所有注入的对象,则Dagger的效果最好。相反,您必须在生命周期方法中执行成员注入。这意味着许多类最终看起来像:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    public class FrombulationActivity extends Activity {
    @Inject Frombulator frombulator;

    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // DO THIS FIRST. Otherwise frombulator might be null!
    ((SomeApplicationBaseType) getContext().getApplicationContext())
    .getApplicationComponent()
    .newActivityComponentBuilder()
    .activity(this)
    .build()
    .inject(this);
    // ... now you can write the exciting code
    }
    }

    注入Activity对象

    1.Install AndroidInjectionModule in your application component to ensure that all bindings necessary for these base types are available.

    1.在您的应用程序组件中安装AndroidInjectionModule以确保这些基本类型所需的所有绑定都可用。

    2.Start off by writing a @Subcomponent that implements AndroidInjector, with a @Subcomponent.Builder that extends AndroidInjector.Builder:

    2.首先编写一个实现AndroidInjector<YourActivity>@Subcomponent和一个继承AndroidInjector.Builder<YourActivity>`@Subcomponent.Builder`。

    阅读全文
  • Dagger使用指南

    目录

    The best classes in any application are the ones that do stuff: the BarcodeDecoder, the KoopaPhysicsEngine, and the AudioStreamer. These classes have dependencies; perhaps a BarcodeCameraFinder, DefaultPhysicsEngine, and an HttpStreamer.

    任何应用程序中最好的类是那些做事情的类:BarcodeDecoderKoopaPhysicsEngineAudioStreamer。 这些类具有依赖性; 也许是一个BarcodeCameraFinderDefaultPhysicsEngine和一个HttpStreamer

    To contrast, the worst classes in any application are the ones that take up space without doing much at all: the BarcodeDecoderFactory, the CameraServiceLoader, and the MutableContextWrapper. These classes are the clumsy duct tape that wires the interesting stuff together.

    相比之下,任何应用程序中最糟糕的类是那些占用空间而又没有做太多事情类:BarcodeDecoderFactory,CameraServiceLoader和MutableContextWrapper。 这些类是将有趣的东西连接在一起。

    阅读全文
  • mat

    阅读全文
  • shell学习笔记

    阅读全文