Example usage for android.util Property Property

List of usage examples for android.util Property Property

Introduction

In this page you can find the example usage for android.util Property Property.

Prototype

public Property(Class<V> type, String name) 

Source Link

Document

A constructor that takes an identifying name and #getType() type for the property.

Usage

From source file:com.bachhuberdesign.deckbuildergwent.util.AnimUtils.java

/**
 * The animation framework has an optimization for <code>Properties</code> of type
 * <code>int</code> but it was only made public in API24, so wrap the impl in our own type
 * and conditionally create the appropriate type, delegating the implementation.
 *//*from w ww . j a v a2 s.  c  o  m*/
public static <T> Property<T, Integer> createIntProperty(final IntProp<T> impl) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        return new IntProperty<T>(impl.name) {
            @Override
            public Integer get(T object) {
                return impl.get(object);
            }

            @Override
            public void setValue(T object, int value) {
                impl.set(object, value);
            }
        };
    } else {
        return new Property<T, Integer>(Integer.class, impl.name) {
            @Override
            public Integer get(T object) {
                return impl.get(object);
            }

            @Override
            public void set(T object, Integer value) {
                impl.set(object, value);
            }
        };
    }
}

From source file:com.bachhuberdesign.deckbuildergwent.util.AnimUtils.java

/**
 * The animation framework has an optimization for <code>Properties</code> of type
 * <code>float</code> but it was only made public in API24, so wrap the impl in our own type
 * and conditionally create the appropriate type, delegating the implementation.
 *///from   w  w w.  j a  v  a  2 s.  com
public static <T> Property<T, Float> createFloatProperty(final FloatProp<T> impl) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        return new FloatProperty<T>(impl.name) {
            @Override
            public Float get(T object) {
                return impl.get(object);
            }

            @Override
            public void setValue(T object, float value) {
                impl.set(object, value);
            }
        };
    } else {
        return new Property<T, Float>(Float.class, impl.name) {
            @Override
            public Float get(T object) {
                return impl.get(object);
            }

            @Override
            public void set(T object, Float value) {
                impl.set(object, value);
            }
        };
    }
}

From source file:org.chromium.chrome.browser.toolbar.ToolbarPhone.java

private Property<TextView, Integer> buildUrlScrollProperty(final View containerView,
        final boolean isContainerRtl) {
    // If the RTL-ness of the container view changes during an animation, the scroll values
    // become invalid.  If that happens, snap to the ending position and no longer update.
    return new Property<TextView, Integer>(Integer.class, "scrollX") {
        private boolean mRtlStateInvalid;

        @Override//from w w w  . ja v a  2s  .c  om
        public Integer get(TextView view) {
            return view.getScrollX();
        }

        @Override
        public void set(TextView view, Integer scrollX) {
            if (mRtlStateInvalid)
                return;
            boolean rtl = ApiCompatibilityUtils.isLayoutRtl(containerView);
            if (rtl != isContainerRtl) {
                mRtlStateInvalid = true;
                if (!rtl || mUrlBar.getLayout() != null) {
                    scrollX = 0;
                    if (rtl) {
                        scrollX = (int) view.getLayout().getPrimaryHorizontal(0);
                        scrollX -= view.getWidth();
                    }
                }
            }
            view.setScrollX(scrollX);
        }
    };
}