This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DataBindingUtil.inflate(inflater, R.layout.fragment_layout, container, false, bindingComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DataBindingUtil.setContentView(this, R.layout.activity_layout, bindingComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyApplication extends DaggerApplication { | |
@Override | |
protected AndroidInjector<? extends DaggerApplication> applicationInjector() { | |
AppComponent appComponent = DaggerAppComponent.create(); | |
BindingComponent bindingComponent = DaggerBindingComponent.builder() | |
.appComponent(appComponent) | |
.build(); | |
DataBindingUtil.setDefaultComponent(bindingComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class DaggerBindingComponent implements BindingComponent { | |
private Provider<ImageBindingAdapter> provideImageBindingAdapterProvider; | |
@Override | |
public ImageBindingAdapter getImageBindingAdapter() { | |
return provideImageBindingAdapterProvider.get(); | |
} | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
@Component(modules = {AppModule.class, AndroidSupportInjectionModule.class, ...}) | |
public interface AppComponent extends AndroidInjector<MyApplication> { | |
Picasso picasso(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@DataBinding | |
@Component(dependencies = AppComponent.class, modules = BindingModule.class) | |
public interface BindingComponent extends DataBindingComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
public class BindingModule { | |
@Provides @DataBinding ImageBindingAdapter provideImageBindingAdapter(Picasso picasso) { | |
return new ImageBindingAdapter(picasso); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface DataBindingComponent { | |
ImageBindingAdapter getImageBindingAdapter(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ImageBindingAdapter { | |
private final Picasso picasso; | |
public ImageBindingAdapter(Picasso picasso) { | |
this.picasso = picasso; | |
} | |
@BindingAdapter("android:src") | |
public void loadImage(ImageView view, String url) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@BindingAdapter("android:src") | |
public static void loadImage(ImageView view, String url) { | |
Picasso.get().load(url).fit().into(view); | |
} |
NewerOlder