binder

Simple annotation based model to view binding library

Лицензия

Лицензия

Группа

Группа

com.kendamasoft
Идентификатор

Идентификатор

binder
Последняя версия

Последняя версия

0.9.7
Дата

Дата

Тип

Тип

aar
Описание

Описание

binder
Simple annotation based model to view binding library
Ссылка на сайт

Ссылка на сайт

https://github.com/stariy95/android-binder
Система контроля версий

Система контроля версий

https://github.com/stariy95/android-binder

Скачать binder

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.kendamasoft/binder/ -->
<dependency>
    <groupId>com.kendamasoft</groupId>
    <artifactId>binder</artifactId>
    <version>0.9.7</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.kendamasoft/binder/
implementation 'com.kendamasoft:binder:0.9.7'
// https://jarcasting.com/artifacts/com.kendamasoft/binder/
implementation ("com.kendamasoft:binder:0.9.7")
'com.kendamasoft:binder:aar:0.9.7'
<dependency org="com.kendamasoft" name="binder" rev="0.9.7">
  <artifact name="binder" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.kendamasoft', module='binder', version='0.9.7')
)
libraryDependencies += "com.kendamasoft" % "binder" % "0.9.7"
[com.kendamasoft/binder "0.9.7"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

Android Binder

This project is a simple annotation based model to view binder.

Installation

Add as a dependency to your build.gradle:

dependencies {
    compile 'com.kendamasoft.binder:0.9.7'
}

Simple Injection

class MyActivity extends Activity {
    @Inject(R.id.textView)
    TextView text;
    
    @Inject({R.id.icon1, R.id.icon2, R.id.icon3})
    List<ImageView> icons;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.activity_test);
        Binder.register(this);
        
        text.setText("Hello World");
    }
    
    @Override
    protected void onDestroy() {
        super.onDestroy();
        Binder.unregister(this);
    }
}

Binding and callbacks

class MyModel extends Observable {

    @Bind(R.id.editText)
    String text = "World!";
    
    @Bind(R.id.textView)
    String description = "Hello";
    
    @Inject(R.id.button)
    private Button button;
    
    public void setText(String text) {
        this.text = text;
        notifyFieldChange("text");
    }
    
    public void setDescription(String description) {
        this.description = description;
        notifyFieldChange("description");
    }
    
    @Callback(R.id.checkBox)
    public void setEnabled(boolean enabled) {
        button.setEnabled(enabled);
    }
}

class MyActivity extends Activity {
    @Model
    MyModel model;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.activity_test);
        Binder.register(this);
        
        model.setEnabled(false);
    }
    
    @OnClick(R.id.button)
    void onTestButtonClick() {
        model.setDescription("Hello World!");
    }
    
}

List View Helper

class TestListModelHelper extends ViewHolderHelper<TestListModel> {                 
    @Inject(R.id.textViewName)
    TextView nameView;

    @Inject(R.id.textViewDescription)     
    TextView descriptionView;
 
    @Override
    public void applyView(TestListModel model, View rootView) {
        nameView.setText(model.name);
        descriptionView.setText(model.description);
    }
}  

class MyActivity extends Activity {
    
    List<TestListModelHelper> listModel = new ArrayList<>();
    
    @Inject(R.id.listView)
    ListView listView;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.activity_test);
        Binder.register(this);
        
        ...
        
        listView.setAdapter(new ListViewAdapter<>(this, R.layout.list_item_test, TestListBinder.class, listModel));
    }
}

Unregister

Call Binder.unregister(...) to clean everything up. Good place for this call is onDestroy() methods.

Версии библиотеки

Версия
0.9.7
0.9.6
0.9.5
0.9.4
0.9.1