// Path: Bindroid/src/com/bindroid/utils/Action.java
// public interface Action<T> {
//   /**
//    * The method to invoke.
//    * 
//    * @param parameter
//    *          the parameter to the action.
//    */
//   void invoke(T parameter);
// }
// 
// Path: Bindroid/src/com/bindroid/utils/Function.java
// public interface Function<T> {
//   /**
//    * The function to evaluate.
//    * 
//    * @return the result of the evaluation.
//    */
//   T evaluate();
// }
// 
// Path: Bindroid/src/com/bindroid/utils/Property.java
// public class Property<T> {
//   protected Action<T> setter;
// 
//   protected Function<T> getter;
// 
//   protected Class<?> propertyType;
// 
//   protected Property() {
//   }
// 
//   /**
//    * Creates a property from a getter and setter. The type will be assumed to be {@link Object}.
//    * 
//    * @param getter
//    *          the getter for the property.
//    * @param setter
//    *          the setter for the property.
//    */
//   public Property(Function<T> getter, Action<T> setter) {
//     this(getter, setter, Object.class);
//   }
// 
//   /**
//    * Creates a property from a getter and setter.
//    * 
//    * @param getter
//    *          the getter for the property.
//    * @param setter
//    *          the setter for the property.
//    * @param type
//    *          the type of the property.
//    */
//   public Property(Function<T> getter, Action<T> setter, Class<?> type) {
//     this.getter = getter;
//     this.setter = setter;
//     this.propertyType = type;
//   }
// 
//   /**
//    * @return the getter for the property.
//    */
//   public Function<T> getGetter() {
//     return this.getter;
//   }
// 
//   /**
//    * @return the setter for the property.
//    */
//   public Action<T> getSetter() {
//     return this.setter;
//   }
// 
//   /**
//    * @return the type of the property.
//    */
//   public Class<?> getType() {
//     return this.propertyType;
//   }
// 
//   /**
//    * Invokes the getter.
//    * 
//    * @return the value returned by the getter.
//    */
//   public final T getValue() {
//     return this.getter.evaluate();
//   }
// 
//   /**
//    * Invokes the setter with the given value.
//    * 
//    * @param value
//    *          the value to pass to the setter.
//    */
//   public final void setValue(T value) {
//     this.setter.invoke(value);
//   }
// }


import java.util.concurrent.atomic.AtomicReference;
import android.os.Handler;
import android.os.Looper;
import com.bindroid.utils.Action;
import com.bindroid.utils.Function;
import com.bindroid.utils.Property;

package com.bindroid.ui;




/**
 * A property that wraps another property, delegating calls to the UI thread.
 */
public class UiProperty<T> extends Property<T> {
  private Property<T> property;

  private static final Handler UI_THREAD_HANDLER = new Handler(Looper.getMainLooper());

  /**
   * Creates a UIProperty for the given property.
   * 
   * @param property
   *          the property to wrap.
   * @return the new property, whose getters and setters will dispatch to the UI thread.
   */
  public static <T> UiProperty<T> make(Property<T> property) {
    return new UiProperty<T>(property);
  }

  private UiProperty(Property<T> property) {
    this.property = property;
    if (property.getGetter() != null) {
      this.getter = new Function<T>() {

// Path: Bindroid/src/com/bindroid/utils/Action.java
// public interface Action<T> {
//   /**
//    * The method to invoke.
//    * 
//    * @param parameter
//    *          the parameter to the action.
//    */
//   void invoke(T parameter);
// }
// 
// Path: Bindroid/src/com/bindroid/utils/Function.java
// public interface Function<T> {
//   /**
//    * The function to evaluate.
//    * 
//    * @return the result of the evaluation.
//    */
//   T evaluate();
// }
// 
// Path: Bindroid/src/com/bindroid/utils/Property.java
// public class Property<T> {
//   protected Action<T> setter;
// 
//   protected Function<T> getter;
// 
//   protected Class<?> propertyType;
// 
//   protected Property() {
//   }
// 
//   /**
//    * Creates a property from a getter and setter. The type will be assumed to be {@link Object}.
//    * 
//    * @param getter
//    *          the getter for the property.
//    * @param setter
//    *          the setter for the property.
//    */
//   public Property(Function<T> getter, Action<T> setter) {
//     this(getter, setter, Object.class);
//   }
// 
//   /**
//    * Creates a property from a getter and setter.
//    * 
//    * @param getter
//    *          the getter for the property.
//    * @param setter
//    *          the setter for the property.
//    * @param type
//    *          the type of the property.
//    */
//   public Property(Function<T> getter, Action<T> setter, Class<?> type) {
//     this.getter = getter;
//     this.setter = setter;
//     this.propertyType = type;
//   }
// 
//   /**
//    * @return the getter for the property.
//    */
//   public Function<T> getGetter() {
//     return this.getter;
//   }
// 
//   /**
//    * @return the setter for the property.
//    */
//   public Action<T> getSetter() {
//     return this.setter;
//   }
// 
//   /**
//    * @return the type of the property.
//    */
//   public Class<?> getType() {
//     return this.propertyType;
//   }
// 
//   /**
//    * Invokes the getter.
//    * 
//    * @return the value returned by the getter.
//    */
//   public final T getValue() {
//     return this.getter.evaluate();
//   }
// 
//   /**
//    * Invokes the setter with the given value.
//    * 
//    * @param value
//    *          the value to pass to the setter.
//    */
//   public final void setValue(T value) {
//     this.setter.invoke(value);
//   }
// }


// Path: Bindroid/src/com/bindroid/ui/UiProperty.java
import java.util.concurrent.atomic.AtomicReference;
import android.os.Handler;
import android.os.Looper;
import com.bindroid.utils.Action;
import com.bindroid.utils.Function;
import com.bindroid.utils.Property;

package com.bindroid.ui;




/**
 * A property that wraps another property, delegating calls to the UI thread.
 */
public class UiProperty<T> extends Property<T> {
  private Property<T> property;

  private static final Handler UI_THREAD_HANDLER = new Handler(Looper.getMainLooper());

  /**
   * Creates a UIProperty for the given property.
   * 
   * @param property
   *          the property to wrap.
   * @return the new property, whose getters and setters will dispatch to the UI thread.
   */
  public static <T> UiProperty<T> make(Property<T> property) {
    return new UiProperty<T>(property);
  }

  private UiProperty(Property<T> property) {
    this.property = property;
    if (property.getGetter() != null) {
      this.getter = new Function<T>() {

        @Override
