// Path: decor/src/main/java/com/mounacheikhna/decor/AttrsDecorator.java
// public abstract class AttrsDecorator<T extends View> implements Decorator {
// 
//     TypedArray values;
// 
//     @Override
//     public void apply(View view, View parent, String name, Context context, AttributeSet attributeSet) {
//         if (!clazz().isAssignableFrom(view.getClass())) {
//             return;
//         }
// 
//         values = obtainAttributes(context, attributeSet);
//         if(values == null || values.length() == 0) return;
// 
//         try {
//             for (int i = 0; i < values.length(); i++) {
//                 TypedValue buf = new TypedValue();
//                 if (values.hasValue(i) && values.getValue(i, buf)) {
//                     apply((T) view, values);
//                     break;
//                 }
//             }
//         } finally {
//             values.recycle();
//         }
//     }
// 
//     TypedArray obtainAttributes(Context context, AttributeSet attributeSet) {
//         //TODO: instead of always passing 0 here for defStyleAttr : make it accept theme setted attribute
//         return context.getTheme().obtainStyledAttributes(attributeSet, styleable(), defStyleAttr(), 0);
//     }
// 
//     protected abstract int[] styleable();
// 
//     protected int defStyleAttr() {
//         return 0;
//     }
// 
//     /**
//      * The class for the given viewtype. Please be kind and just return the right class here :)
//      *
//      * @return The class/typetoken for T
//      */
//     protected abstract Class<T> clazz();
// 
//     /**
//      * This method will be called if a View of type T was inflated and it had one of the attributes
//      * specified by {@link AttrsDecorator#styleable()} set.
//      * @param view  The view object that is being decorated.
//      * @param typedArray A {@link TypedArray} for attributes.
//      *
//      */
//     protected abstract void apply(T view, TypedArray typedArray);
// 
// }


import android.app.Activity;
import android.view.View;
import com.mounacheikhna.decor.AttrsDecorator;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
package com.mounacheikhna.decorators;





/**
 * Created by cheikhna on 02/04/2015.
 */
public abstract class OnActionBaseDecorator extends AttrsDecorator<View> {

    protected Activity mContainerActivity;

    public OnActionBaseDecorator(Activity activity) {
        mContainerActivity = activity;
    }

    @Override
    protected Class<View> clazz() {
        return View.class;
    }

    protected boolean onAction(String methodName) {
        Method mHandler = null;
        try {
            if(mContainerActivity != null) {
                mHandler = mContainerActivity.getClass().getMethod(methodName);
            }
        } catch (NoSuchMethodException e) {
// Path: decor/src/main/java/com/mounacheikhna/decor/AttrsDecorator.java
// public abstract class AttrsDecorator<T extends View> implements Decorator {
// 
//     TypedArray values;
// 
//     @Override
//     public void apply(View view, View parent, String name, Context context, AttributeSet attributeSet) {
//         if (!clazz().isAssignableFrom(view.getClass())) {
//             return;
//         }
// 
//         values = obtainAttributes(context, attributeSet);
//         if(values == null || values.length() == 0) return;
// 
//         try {
//             for (int i = 0; i < values.length(); i++) {
//                 TypedValue buf = new TypedValue();
//                 if (values.hasValue(i) && values.getValue(i, buf)) {
//                     apply((T) view, values);
//                     break;
//                 }
//             }
//         } finally {
//             values.recycle();
//         }
//     }
// 
//     TypedArray obtainAttributes(Context context, AttributeSet attributeSet) {
//         //TODO: instead of always passing 0 here for defStyleAttr : make it accept theme setted attribute
//         return context.getTheme().obtainStyledAttributes(attributeSet, styleable(), defStyleAttr(), 0);
//     }
// 
//     protected abstract int[] styleable();
// 
//     protected int defStyleAttr() {
//         return 0;
//     }
// 
//     /**
//      * The class for the given viewtype. Please be kind and just return the right class here :)
//      *
//      * @return The class/typetoken for T
//      */
//     protected abstract Class<T> clazz();
// 
//     /**
//      * This method will be called if a View of type T was inflated and it had one of the attributes
//      * specified by {@link AttrsDecorator#styleable()} set.
//      * @param view  The view object that is being decorated.
//      * @param typedArray A {@link TypedArray} for attributes.
//      *
//      */
//     protected abstract void apply(T view, TypedArray typedArray);
// 
// }


// Path: decorators/src/main/java/com/mounacheikhna/decorators/OnActionBaseDecorator.java
import android.app.Activity;
import android.view.View;
import com.mounacheikhna.decor.AttrsDecorator;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

package com.mounacheikhna.decorators;





/**
 * Created by cheikhna on 02/04/2015.
 */
public abstract class OnActionBaseDecorator extends AttrsDecorator<View> {

    protected Activity mContainerActivity;

    public OnActionBaseDecorator(Activity activity) {
        mContainerActivity = activity;
    }

    @Override
    protected Class<View> clazz() {
        return View.class;
    }

    protected boolean onAction(String methodName) {
        Method mHandler = null;
        try {
            if(mContainerActivity != null) {
                mHandler = mContainerActivity.getClass().getMethod(methodName);
            }
        } catch (NoSuchMethodException e) {
            e.printStackTrace();