Android Open Source - GreenGear Operation






From Project

Back to project page GreenGear.

License

The source code is released under:

MIT License

If you think the Android project GreenGear listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.bradleycurran.viewquery;
//from  ww w  .  j  a v  a2  s.c  o m
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.TextView;

abstract class Operation<T extends View> {

    private static final String TAG = Operation.class.getSimpleName();
    private Class<T>            mClass;

    Operation(Class<T> cls) {
        mClass = cls;
    }

    void run(View view) {
        T t = get(view, mClass);

        if (t != null) {
            execute(t);
        }
    }

    abstract void execute(T view);

    static abstract class ViewOperation extends Operation<View> {
        public ViewOperation() {
            super(View.class);
        }
    }

    static abstract class ImageOperation extends Operation<ImageView> {
        public ImageOperation() {
            super(ImageView.class);
        }
    }

    static abstract class TextOperation extends Operation<TextView> {
        public TextOperation() {
            super(TextView.class);
        }
    }

    @SuppressWarnings("rawtypes")
    static abstract class AdapterOperation extends Operation<AdapterView> {
        AdapterOperation() {
            super(AdapterView.class);
        }
    }

    static <T extends View> T get(View view, Class<T> cls) {
        if (view == null) {
            Log.e(TAG, "View is null, cannot perform " + cls.getSimpleName());
            return null;
        }

        if (!cls.isInstance(view)) {
            Log.e(TAG, "View is not a " + cls.getSimpleName());
            return null;
        }

        return cls.cast(view);
    }
}




Java Source Code List

com.bradleycurran.droidprefs.DroidPrefs.java
com.bradleycurran.greengear.model.KeyValue.java
com.bradleycurran.greengear.util.AssetUtil.java
com.bradleycurran.greengear.util.Log.java
com.bradleycurran.greengear.util.ViewUtil.java
com.bradleycurran.velocadapter.ArrayVelocAdapter.java
com.bradleycurran.velocadapter.VelocAdapter.java
com.bradleycurran.velocadapter.ViewBinder.java
com.bradleycurran.viewquery.Operation.java
com.bradleycurran.viewquery.ViewQuery.java
com.bradleycurran.viewquery.animation.hc.BounceTouchListener.java