Java 类android.databinding.ObservableField 实例源码

项目:LiteReader    文件:OneReviewContentViewModel.java   
@Override
public void onViewAttached(View view) {
    this.content = new ObservableField<>(getString(R.string.loading));
    RxTask.asyncMap(new Func1<String, String>() {
        @Override
        public String call(String s) {
            return extractContent(review.shareUrl);
        }
    }, new Action1<String>() {
        @Override
        public void call(String html) {
            content.set(html);
        }
    });

}
项目:Flubber    文件:BindingAdapters.java   
@BindingAdapter({"checked", "model"})
public static <T> void setChecked(RadioButton radioButton, final ObservableField<T> checked, final T model) {

    if (checked == null) {
        return;
    }

    radioButton.setOnCheckedChangeListener(
            (buttonView, isChecked) -> {
                if ((checked.get() == null || !checked.get().equals(model))
                        && isChecked) {

                    checked.set(model);
                }
            });

    final T checkedModel = checked.get();
    final boolean shouldBeChecked = checkedModel != null && checkedModel.equals(model);

    if (shouldBeChecked != radioButton.isChecked()) {
        radioButton.setChecked(shouldBeChecked);
    }
}
项目:ZeroKit-Android-SDK    文件:EncryptViewModel.java   
public EncryptViewModel(final Context context, FragmentManager fragmentManager) {
    pagerAdapter = new EncryptPagerAdapter(context, fragmentManager);
    pageChangeListener = new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            drawableDot1.set(context.getResources().getDrawable(position == 0 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot));
            drawableDot2.set(context.getResources().getDrawable(position == 1 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot));
            drawableDot3.set(context.getResources().getDrawable(position == 2 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot));
        }

    };

    drawableDot1 = new ObservableField<>(context.getResources().getDrawable(R.drawable.selecteditem_dot));
    drawableDot2 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot));
    drawableDot3 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot));
}
项目:RxDataBinding    文件:RxObservableFieldTest.java   
@Test @UiThreadTest public void propertyChangeEvents_String() {
  final ObservableField<String> observableField = new ObservableField<>();
  String value = "databinding";

  RecordingObserver<String> o = new RecordingObserver<>();
  RxObservableField.propertyChanges(observableField).subscribe(o);
  o.assertNoMoreEvents();

  observableField.set(value);
  assertEquals(value, o.takeNext());

  value += " is cool.";
  observableField.set(value);
  assertEquals(value, o.takeNext());

  o.dispose();

  value += " Yeah?";
  observableField.set(value);
  o.assertNoMoreEvents();
}
项目:RxDataBinding    文件:RxObservableFieldTest.java   
@Test @UiThreadTest public void propertyChangeEvents_Object() {
  final ObservableField<Object> observableField = new ObservableField<>();
  Object value;

  RecordingObserver<Object> o = new RecordingObserver<>();
  RxObservableField.propertyChanges(observableField).subscribe(o);
  o.assertNoMoreEvents();

  value = new Object();
  observableField.set(value);
  assertEquals(value, o.takeNext());

  value = new Object();
  observableField.set(value);
  assertEquals(value, o.takeNext());

  o.dispose();

  value = new Object();
  observableField.set(value);
  o.assertNoMoreEvents();
}
项目:okuki    文件:RxObservableField.java   
public static <T> Observable<T> toObservable(@NonNull final ObservableField<T> field) {

        return Observable.create(e -> {
            T initialValue = field.get();
            if (initialValue != null) {
                e.onNext(initialValue);
            }
            final OnPropertyChangedCallback callback = new OnPropertyChangedCallback() {
                @Override
                public void onPropertyChanged(android.databinding.Observable observable, int i) {
                    e.onNext(field.get());
                }
            };
            field.addOnPropertyChangedCallback(callback);
            e.setCancellable(() -> field.removeOnPropertyChangedCallback(callback));
        });
    }
项目:ZeroKit-Android-Sample    文件:EncryptViewModel.java   
public EncryptViewModel(final Context context, FragmentManager fragmentManager) {
    pagerAdapter = new EncryptPagerAdapter(context, fragmentManager);
    pageChangeListener = new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            drawableDot1.set(context.getResources().getDrawable(position == 0 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot));
            drawableDot2.set(context.getResources().getDrawable(position == 1 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot));
            drawableDot3.set(context.getResources().getDrawable(position == 2 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot));
        }

    };

    drawableDot1 = new ObservableField<>(context.getResources().getDrawable(R.drawable.selecteditem_dot));
    drawableDot2 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot));
    drawableDot3 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot));
}
项目:Architecture-Demo    文件:EditPostComponentViewModel.java   
@Inject
public EditPostComponentViewModel(Bus bus,
                                  INavigator navigator,
                                  IRepository repository,
                                  ILocalization localization) {
    super(bus);

    this.navigator = navigator;
    this.repository = repository;
    this.localization = localization;

    this.saveCommand = new Command(this::savePost);

    this.title = new ObservableField<>();
    this.summary = new ObservableField<>();
}
项目:Anago    文件:SignInActivityViewModel.java   
@Inject
public SignInActivityViewModel(BaseActivity activity, SignInUseCase signInUseCase,
                               CheckSessionUseCase checkSessionUseCase) {
    super(activity);

    this.signInUseCase = signInUseCase;
    this.checkSessionUseCase = checkSessionUseCase;

    name = new ObservableField<>();
    password = new ObservableField<>();
    buttonEnabled = new ObservableBoolean(false);

    checkSessionUseCase.run()
            .compose(bindToLifecycle().forSingle())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(authToken -> {
                Timber.v("Check session: " + authToken.token);
                Toast.makeText(getContext(), "Already signed in", Toast.LENGTH_SHORT).show();
                goToNext();
            }, Timber::e);
}
项目:android-data-binding-rxjava    文件:RxUtils.java   
public static <T> Observable<T> toObservable(@NonNull final ObservableField<T> observableField) {
    return Observable.fromEmitter(asyncEmitter -> {

        final OnPropertyChangedCallback callback = new OnPropertyChangedCallback() {
            @Override
            public void onPropertyChanged(android.databinding.Observable dataBindingObservable, int propertyId) {
                if (dataBindingObservable == observableField) {
                    asyncEmitter.onNext(observableField.get());
                }
            }
        };

        observableField.addOnPropertyChangedCallback(callback);

        asyncEmitter.setCancellation(() -> observableField.removeOnPropertyChangedCallback(callback));

    }, AsyncEmitter.BackpressureMode.LATEST);
}
项目:Cinder    文件:CinderUnitTest.java   
@Test
public void computableListElementsAreComputable() throws Exception {

    String string1 = "STRING 1";
    String string2 = "STRING 2";
    StringClass stringClass = new StringClass(string1);

    ObservableList<StringClass> strings = new ObservableArrayList<>();
    strings.add(0, stringClass);
    ObservableField<String> computedString = Cinder.computeField(()->strings.get(0).element.get(),
            Cinder.observable(strings, StringClass.class, "element")).immediate();
    assertEquals(computedString.get(), string1);

    strings.get(0).element.set(string2);
    assertEquals(computedString.get(), string2);
}
项目:Cinder    文件:CinderUnitTest.java   
@Test
public void simpleObservesObservableLists() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    StringClass stringClass1 = new StringClass(string1);
    StringClass stringClass2 = new StringClass(string2);
    ObservableArrayList<StringClass> observableList = new ObservableArrayList<>();

    ObservableField<String> observingString = new ObservableField<>("");
    Cinder.observe(
            ()->observingString.set(observableList.get(0).element.get()),
            observableList);

    observableList.add(0, stringClass1);
    assertEquals(observingString.get(), string1);

    observableList.add(0, stringClass2);
    assertEquals(observingString.get(), string2);

    observableList.remove(0);
    assertEquals(observingString.get(), string1);
}
项目:Cinder    文件:CinderUnitTest.java   
@Test
public void simpleObservesObservableMaps() throws Exception {
    String key1 = "KEY 1";
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    String stringMissing = "MISSING";
    StringClass stringClass1 = new StringClass(string1);
    StringClass stringClass2 = new StringClass(string2);
    ObservableArrayMap<String, StringClass> observableMap = new ObservableArrayMap<>();

    ObservableField<String> observingString = new ObservableField<>("");
    Cinder.observe(()->
                    observingString.set((observableMap.get(key1) != null) ?
                    observableMap.get(key1).element.get() : stringMissing),
                    observableMap);
    observableMap.put(key1, stringClass1);
    assertEquals(observingString.get(), string1);

    observableMap.put(key1, stringClass2);
    assertEquals(observingString.get(), string2);

    observableMap.remove(key1);
    assertEquals(observingString.get(), stringMissing);
}
项目:Cinder    文件:CinderComputableUnitTest.java   
@Test
public void takeTakesCorrectTimes() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    String string3 = "STRING 3";
    ObservableArrayList<String> observed = new ObservableArrayList<>();
    observed.add(string1);
    CinderComputable computing = Cinder.observable(observed).take(2).immediate();
    ObservableField<String> observing = Cinder.<String>computeField(()-> {
        return observed.get(0);
    }, computing).immediate();
    assertEquals(string1, observing.get());

    observed.add(0, string2);
    assertEquals(string2, observing.get());

    observed.add(0, string3);
    assertEquals(string2, observing.get());
}
项目:Cinder    文件:CinderComputableUnitTest.java   
@Test
public void skipSkipsCorrectTimes() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    ObservableArrayList<String> observed = new ObservableArrayList<>();
    observed.add(string1);
    CinderComputable computing = Cinder.observable(observed).skip(1);
    ObservableField<String> observing = Cinder.<String>computeField(()-> {
        return observed.size() > 0 ?  observed.get(0) : "";
    }, computing);

    observed.add(0, string1);
    assertEquals(null, observing.get());

    observed.add(0, string2);
    assertEquals(string2, observing.get());
}
项目:Cinder    文件:CinderComputableUnitTest.java   
@Test
public void takeWhileTakesWhileTrue() throws Exception {
    String badString = "BAD STRING";
    String goodString = "GOOD STRING";
    String gooderString = "GOODER STRING";
    ObservableArrayList<String> observed = new ObservableArrayList<>();
    observed.add(goodString);
    CinderComputable computing = Cinder.observable(observed).takeWhile(()->observed.get(0).startsWith("GOOD"));
    ObservableField<String> observing = Cinder.<String>computeField(()-> {
        return observed.get(0);
    }, computing).immediate();

    observed.add(0, goodString);
    assertEquals(goodString, observing.get());

    observed.add(0, badString);
    assertEquals(goodString, observing.get());

    observed.add(0, gooderString);
    assertEquals(goodString, observing.get());
}
项目:Cinder    文件:CinderComputableUnitTest.java   
@Test
public void skipWhileSkipsWhileTrue() throws Exception {
    String badString = "BAD STRING";
    String goodString = "GOOD STRING";
    String gooderString = "GOODER STRING";
    ObservableArrayList<String> observed = new ObservableArrayList<>();
    observed.add(goodString);
    CinderComputable computing = Cinder.observable(observed).takeWhile(()->observed.get(0).startsWith("GOOD"));
    ObservableField<String> observing = Cinder.<String>computeField(()-> {
        return observed.get(0);
    }, computing).immediate();

    observed.add(0, goodString);
    assertEquals(goodString, observing.get());

    observed.add(0, badString);
    assertEquals(goodString, observing.get());

    observed.add(0, gooderString);
    assertEquals(goodString, observing.get());
}
项目:Cinder    文件:CinderArrayMapUnitTest.java   
@Test
public void takeWhileTakesWhileTrue() throws Exception {
    String badString = "BAD STRING";
    String goodString = "GOOD STRING";
    String gooderString = "GOODER STRING";
    ObservableField<String> observed = new ObservableField<>("");
    ObservableArrayMap<String, String> observing = Cinder.<String, String>computeArrayMap((list)->{
        list.put(key1, observed.get());
    }, observed).takeWhile(()->observed.get().startsWith("GOOD"));

    observed.set(goodString);
    assertEquals(goodString, observing.get(key1));

    observed.set(badString);
    assertEquals(goodString, observing.get(key1));

    observed.set(gooderString);
    assertEquals(goodString, observing.get(key1));
}
项目:Cinder    文件:CinderArrayMapUnitTest.java   
@Test
public void skipWhileSkipsWhileTrue() throws Exception {
    String badString = "BAD STRING";
    String goodString = "GOOD STRING";
    String gooderString = "GOODER STRING";
    ObservableField<String> observed = new ObservableField<>("");
    ObservableArrayMap<String, String> observing = Cinder.<String, String>computeArrayMap((list)->{
        list.put(key1, observed.get());
    }, observed).skipWhile(()->observed.get().startsWith("BAD"));

    observed.set(badString);
    assertEquals(0, observing.size());

    observed.set(goodString);
    assertEquals(goodString, observing.get(key1));

    observed.set(gooderString);
    assertEquals(gooderString, observing.get(key1));
}
项目:Cinder    文件:CinderArrayListUnitTest.java   
@Test
public void takeTakesCorrectTimes() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    String string3 = "STRING 3";
    ObservableField<String> observed = new ObservableField<>(string1);
    ObservableArrayList<String> observing = Cinder.<String>computeArrayList((list)->{
        list.add(0, observed.get());
    }, observed).take(2).immediate();
    assertEquals(string1, observing.get(0));

    observed.set(string2);
    assertEquals(string2, observing.get(0));

    observed.set(string3);
    assertEquals(string2, observing.get(0));
}
项目:Cinder    文件:CinderArrayListUnitTest.java   
@Test
public void takeWhileTakesWhileTrue() throws Exception {
    String badString = "BAD STRING";
    String goodString = "GOOD STRING";
    String gooderString = "GOODER STRING";
    ObservableField<String> observed = new ObservableField<>("");
    ObservableArrayList<String> observing = Cinder.<String>computeArrayList((list)->{
        list.add(0, observed.get());
    }, observed).takeWhile(()->observed.get().startsWith("GOOD"));

    observed.set(goodString);
    assertEquals(goodString, observing.get(0));

    observed.set(badString);
    assertEquals(goodString, observing.get(0));

    observed.set(gooderString);
    assertEquals(goodString, observing.get(0));
}
项目:Cinder    文件:CinderArrayListUnitTest.java   
@Test
public void skipWhileSkipsWhileTrue() throws Exception {
    String badString = "BAD STRING";
    String goodString = "GOOD STRING";
    String gooderString = "GOODER STRING";
    ObservableField<String> observed = new ObservableField<>("");
    ObservableArrayList<String> observing = Cinder.<String>computeArrayList((list)->{
        list.add(0, observed.get());
    }, observed).takeWhile(()->observed.get().startsWith("GOOD"));

    observed.set(goodString);
    assertEquals(goodString, observing.get(0));

    observed.set(badString);
    assertEquals(goodString, observing.get(0));

    observed.set(gooderString);
    assertEquals(goodString, observing.get(0));
}
项目:Cinder    文件:CinderFieldUnitTest.java   
@Test
public void takeTakesCorrectTimes() throws Exception {
    String string1 = "123";
    String string2 = "32";
    ObservableField<String> observed = new ObservableField<>(string1);
    ObservableField<String> observing = Cinder.<String>computeField(()->
                    observed.get()
            , observed).take(2).immediate();
    assertTrue(observing.get() == string1);

    observed.set(string2);
    assertTrue(observing.get() == string2);

    observed.set(string1);
    assertTrue(observing.get() == string2);
}
项目:Cinder    文件:CinderFieldUnitTest.java   
@Test
public void skipSkipsCorrectTimes() throws Exception {
    String string1 = "123";
    String string2 = "32";
    ObservableField<String> observed = new ObservableField<>();
    ObservableField<String> observing = Cinder.<String>computeField(()->
                    observed.get()
            , observed).skip(1);

    observed.set(string1);
    assertTrue(observing.get() == null);

    observed.set(string2);
    assertTrue(observing.get() == string2);

    observed.set(string1);
    assertTrue(observing.get() == string1);
}
项目:Cinder    文件:CinderBooleanUnitTest.java   
@Test
public void takeTakesCorrectTimes() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    ObservableField<String> observed = new ObservableField<>(string1);
    ObservableBoolean observing = Cinder.computeBoolean(()->
        observed.get().equals(string1)
        , observed).take(2).immediate();
    assertTrue(observing.get());

    observed.set(string2);
    assertFalse(observing.get());

    observed.set(string1);
    assertFalse(observing.get());
}
项目:Cinder    文件:CinderBooleanUnitTest.java   
@Test
public void skipSkipsCorrectTimes() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    ObservableField<String> observed = new ObservableField<>(string1);
    ObservableBoolean observing = Cinder.computeBoolean(()->
        observed.get().equals(string1)
        , observed).skip(1);

    observed.set(string1);
    assertFalse(observing.get());

    observed.set(string2);
    assertFalse(observing.get());

    observed.set(string1);
    assertTrue(observing.get());
}
项目:devfest-2016-realm    文件:PasswordReadViewModel.java   
public PasswordReadViewModel(Navigator navigator, PasswordInteractor interactor, int id) {
  this.navigator = navigator;
  this.interactor = interactor;
  this.id = id;

  this.title = new ObservableField<>();
  this.icon = new ObservableField<>();
  this.username = new ObservableField<>();
  this.password = new ObservableField<>();
  this.displayPassword = new ObservableBoolean(false);
  this.customFields = new ObservableArrayList<>();

  realmPassword = interactor.readPassword(id);
  realmPassword.addChangeListener(this::updateView);

  updateView(realmPassword);
}
项目:ForgetAdapters    文件:PersonViewModel.java   
public PersonViewModel(IPersonViewAccess access) {

        this.access = access;
        name = new ObservableField<String>();
        surname = new ObservableField<String>();
        company = new ObservableField<String>();
    }
项目:Flubber    文件:RadioRVAdapter.java   
public RadioRVAdapter(Context context) {
    this.context = context;
    checked.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable observable, int i) {
            if (selectedListener != null) {
                final ObservableField observableField = (ObservableField) observable;
                selectedListener.onElementSelected((RadioElementModel) observableField.get());
            }
        }
    });
}
项目:android-mvvm-architecture    文件:BlogItemViewModel.java   
public BlogItemViewModel(BlogResponse.Blog blog, BlogItemViewModelListener listener) {
    this.mBlog = blog;
    this.mListener = listener;
    imageUrl = new ObservableField<>(mBlog.getCoverImgUrl());
    title = new ObservableField<>(mBlog.getTitle());
    author = new ObservableField<>(mBlog.getAuthor());
    date = new ObservableField<>(mBlog.getDate());
    content = new ObservableField<>(mBlog.getDescription());
}
项目:Mvvm    文件:RecyclerViewModel.java   
public RecyclerViewModel(int itemVariableId, @LayoutRes int itemLayoutResId, MvvmAdapter<T> adapter, OnItemClickListener<T> listener, int listenerVariableId) {
    this.items = new ObservableArrayList<>();
    this.adapter = null == adapter ? new MvvmAdapter<T>() : adapter;
    this.listener = listener;
    this.bindingItem = BindingItem.<T>of(itemVariableId, itemLayoutResId);
    if (null != listener) {
        this.bindingItem.bindExtra(listenerVariableId, listener);
    }
    this.itemDecoration = new ObservableField<>();
    this.layoutManager = new ObservableField<>();
}
项目:AndroidToolbox    文件:Utils.java   
/**
 * Converts DataBinding's ObservableField  to RxJava2's Observable
 * see https://habrahabr.ru/post/328512/
 * @param observableField
 * @param <T>
 * @return Observable (RxJava2)
 */
public static <T> Observable<T> toObservable(@NonNull final ObservableField<T> observableField) {

    return Observable.fromPublisher(asyncEmitter -> {
        final android.databinding.Observable.OnPropertyChangedCallback callback = new android.databinding.Observable.OnPropertyChangedCallback() {
            @Override
            public void onPropertyChanged(android.databinding.Observable dataBindingObservable, int propertyId) {
                if (dataBindingObservable == observableField) {
                    asyncEmitter.onNext(observableField.get());
                }
            }
        };
        observableField.addOnPropertyChangedCallback(callback);
    });
}
项目:ZeroKit-Android-SDK    文件:DecryptViewModel.java   
@Inject
public DecryptViewModel(Zerokit zerokit) {
    this.zerokit = zerokit;

    this.inProgressDecrypt = new ObservableField<>(false);
    this.textEncrypted = new ObservableField<>();
    this.textDecrypted = new ObservableField<>();
    this.clickListenerDecrypt = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            decrypt(textEncrypted.get());
        }
    };
}
项目:ZeroKit-Android-SDK    文件:ShareTresorViewModel.java   
@Inject
public ShareTresorViewModel(Zerokit zerokit, AdminApi adminApi, final EventBus eventBus) {
    this.zerokit = zerokit;
    this.adminApi = adminApi;

    this.inProgress = new ObservableField<>(false);
    this.userId = new ObservableField<>();
    this.textSummary = new ObservableField<>();
    this.sharedWithUserId = new ObservableField<>("");
    this.clickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            shareTresor(tresorId, userId.get());
        }
    };
    errorResponseHandlerSdk = new Action<ResponseZerokitError>() {
        @Override
        public void call(ResponseZerokitError errorResponse) {
            inProgress.set(false);
            eventBus.post(new ShowMessageMessage(errorResponse.toString()));
        }
    };
    errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() {
        @Override
        public void call(ResponseAdminApiError errorResponse) {
            inProgress.set(false);
            eventBus.post(new ShowMessageMessage(errorResponse.toString()));
        }
    };
}
项目:ZeroKit-Android-SDK    文件:EncryptTextViewModel.java   
@Inject
public EncryptTextViewModel(Zerokit zerokit, final EventBus eventBus) {
    this.zerokit = zerokit;

    this.inProgressEncrypt = new ObservableField<>(false);
    this.inProgressDecrypt = new ObservableField<>(false);
    this.encryptClicked = new ObservableField<>(false);
    this.textOriginal = new ObservableField<>();
    this.textEncrypted = new ObservableField<>();
    this.textSummary = new ObservableField<>();
    this.textDecrypted = new ObservableField<>();
    this.clickListenerEncrypt = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            encryptClicked.set(true);
            encrypt(tresorId, textOriginal.get());
        }
    };
    this.clickListenerDecrypt = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            decrypt(textEncrypted.get());
        }
    };
    this.clickListenerCopy = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            eventBus.post(new CopyEncryptedTextMessage(textEncrypted.get()));
        }
    };
}
项目:ZeroKit-Android-SDK    文件:CreateTresorViewModel.java   
@Inject
public CreateTresorViewModel(final Zerokit zerokit, final AdminApi adminApi, final EventBus eventBus) {
    this.zerokit = zerokit;
    this.adminApi = adminApi;
    this.eventBus = eventBus;


    this.inProgress = new ObservableField<>(false);
    this.tresorId = new ObservableField<>("");
    this.clickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            createTresor();
            inProgress.set(true);
        }
    };

    errorResponseHandlerSdk = new Action<ResponseZerokitError>() {
        @Override
        public void call(ResponseZerokitError errorResponse) {
            inProgress.set(false);
            eventBus.post(new ShowMessageMessage(errorResponse.toString()));
        }
    };
    errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() {
        @Override
        public void call(ResponseAdminApiError errorResponse) {
            inProgress.set(false);
            eventBus.post(new ShowMessageMessage(errorResponse.toString()));
        }
    };
}
项目:RxDataBinding    文件:RxObservableField.java   
/**
 * Create an observable of property change events on {@code observableField}.
 * <p>
 * <em>Warning:</em> The created observable keeps a strong reference to {@code observableField}.
 * Unsubscribe to free this reference.
 */
@CheckResult @NonNull //
public static <T> Observable<? extends T> propertyChanges(
    @NonNull ObservableField<T> observableField) {
  checkNotNull(observableField, "observableField == null");
  return new ObservableFieldObservable<>(observableField);
}
项目:RxDataBinding    文件:ObservableFieldObservable.java   
Listener(final ObservableField<T> observableField, final Observer<? super T> observer) {
  this.observableField = observableField;
  this.onPropertyChangedCallback =
      new android.databinding.Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(android.databinding.Observable observable,
            int ignoredPropertyId) {
          if (!isDisposed()) {
            ObservableField<T> observableField = convert(observable);
            observer.onNext(observableField.get());
          }
        }
      };
}
项目:DereHelper    文件:SongListVM.java   
static void loadData(BaseActivity mContext, String search, String orderType, ObservableField<List<Song>> target){
    if (TextUtils.isEmpty(orderType)){
        orderType = "a.start_date DESC";
    }
    String sql = String.format(sql_raw, search, orderType);
    try {
        Observable<List<Song>> songList = Observable.just(DBHelper.with(mContext, DBHelper.DB_NAME_master)
                .getBeanListByRaw(sql, Song.class));
        songList.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(target::set);
    }catch (Exception e){
        e.printStackTrace();
    }
}
项目:ZeroKit-Android-Sample    文件:DecryptViewModel.java   
@Inject
public DecryptViewModel(Zerokit zerokit) {
    this.zerokit = zerokit;

    this.inProgressDecrypt = new ObservableField<>(false);
    this.textEncrypted = new ObservableField<>();
    this.textDecrypted = new ObservableField<>();
    this.clickListenerDecrypt = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            decrypt(textEncrypted.get());
        }
    };
}