Back to project page haavi.
The source code is released under:
MIT License
If you think the Android project haavi listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package rx.android; //from w w w .j a v a 2 s. c om import android.view.View; import android.widget.ArrayAdapter; import android.widget.TextView; import rx.Observable; import rx.util.functions.Action1; import java.util.List; public final class Properties { // no instances of helper class private Properties() { } /** * Updates the <em>enabled</em> property of a view for each event received. */ public static EnabledProperty enabledFrom(View view) { return new EnabledProperty(view); } /** * Updates the <em>text</em> property of a view for each event received. */ public static TextProperty textFrom(TextView view) { return new TextProperty(view); } /** * Clear, update and notify changes of dataset for {@code ArrayAdapter}. */ public static <T> ArrayAdapterProperty<T> dataSetFrom(ArrayAdapter<T> adapter) { return new ArrayAdapterProperty<T>(adapter); } public static class EnabledProperty implements Action1<Boolean> { private final View view; private EnabledProperty(View view) { this.view = view; } public void set(Observable<Boolean> observable) { observable.subscribe(this); } @Override public void call(Boolean enabled) { view.setEnabled(enabled); } } public static class TextProperty implements Action1<String> { private final TextView view; private TextProperty(TextView view) { this.view = view; } public void set(Observable<String> observable) { observable.subscribe(this); } @Override public void call(String text) { view.setText(text); } } public static class ArrayAdapterProperty<T> implements Action1<List<T>> { private final ArrayAdapter<T> adapter; ArrayAdapterProperty(ArrayAdapter<T> adapter) { this.adapter = adapter; } public void set(Observable<List<T>> observable) { observable.subscribe(this); } @Override public void call(List<T> items) { adapter.clear(); for (T item : items) { adapter.add(item); } adapter.notifyDataSetChanged(); } } }