All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.robobinding.widget.compoundbutton.CheckedAttribute Maven / Gradle / Ivy

There is a newer version: 0.8.14
Show newest version
package org.robobinding.widget.compoundbutton;

import org.robobinding.property.ValueModel;
import org.robobinding.viewattribute.property.TwoWayPropertyViewAttribute;
import org.robobinding.widgetaddon.compoundbutton.CompoundButtonAddOn;

import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;

/**
 * 
 * @since 1.0
 * @version $Revision: 1.0 $
 * @author Robert Taylor
 * @author Cheng Wei
 */
public class CheckedAttribute implements TwoWayPropertyViewAttribute {
	@Override
	public void updateView(CompoundButton view, Boolean newValue, CompoundButtonAddOn viewAddOn) {
		view.setChecked(newValue);
	}

	@Override
	public void observeChangesOnTheView(CompoundButtonAddOn viewAddOn, final ValueModel valueModel, CompoundButton view) {
		viewAddOn.addOnCheckedChangeListener(new OnCheckedChangeListener() {
			@Override
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				valueModel.setValue(isChecked);
			}
		});
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy