Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @BindingAdapter({"resourceState"})
- public static void setResourceState(CompoundButton view, int state) {
- boolean checked;
- checked = state != LocationState.STOPPED;
- if (view.isChecked() != checked) {
- view.setChecked(checked);
- }
- }
- @InverseBindingAdapter(attribute = "resourceState", event = "resourceStateAttrChanged")
- public static int getResourceStateAttrChanged(CompoundButton view) {
- if (view.isChecked()) {
- return LocationState.WAITING;
- } else {
- return LocationState.STOPPED;
- }
- }
- @BindingAdapter({"resourceStateAttrChanged"})
- public static void setResourceStateAttrChanged(CompoundButton view, final InverseBindingListener attrChange) {
- view.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- Context context = buttonView.getContext();
- if (isChecked) {
- Repository.getInstance().requestLocationUpdates(context);
- } else {
- Repository.getInstance().removeLocationUpdates(context);
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement