Search in sources :

Example 16 with WXComponentProp

use of com.taobao.weex.ui.component.WXComponentProp in project WeexErosFramework by bmfe.

the class BMCalendar method setMinDate.

@WXComponentProp(name = "minimumDate")
public void setMinDate(String minDate) {
    if (TextUtils.isEmpty(minDate))
        return;
    this.mMinDate = minDate;
    if (mBuilder != null) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(getDate(mMinDate));
        mBuilder.setMinimumDate(calendar);
        if (!TextUtils.isEmpty(mMaxDate)) {
            Calendar maxCalendar = Calendar.getInstance();
            maxCalendar.setTime(getDate(mMaxDate));
            mBuilder.setMaximumDate(maxCalendar);
            mBuilder.commit();
        }
    }
}
Also used : Calendar(java.util.Calendar) WXComponentProp(com.taobao.weex.ui.component.WXComponentProp)

Example 17 with WXComponentProp

use of com.taobao.weex.ui.component.WXComponentProp in project WeexErosFramework by bmfe.

the class HookTextarea method setTintColor.

// benmu.org
@WXComponentProp(name = HookConstants.NAME.TINTCOLOR)
public void setTintColor(String tintColor) {
    if (TextUtils.isEmpty(tintColor))
        return;
    try {
        EditText editText = getHostView();
        Field cursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
        cursorDrawableRes.setAccessible(true);
        int drawableId = cursorDrawableRes.getInt(editText);
        Field mEditor = TextView.class.getDeclaredField("mEditor");
        mEditor.setAccessible(true);
        Object editor = mEditor.get(editText);
        Class<?> clazz = editor.getClass();
        Field mCursorDrawable = clazz.getDeclaredField("mCursorDrawable");
        mCursorDrawable.setAccessible(true);
        Drawable[] drawables = new Drawable[1];
        drawables[0] = editText.getContext().getResources().getDrawable(drawableId);
        drawables[0].setColorFilter(WXResourceUtils.getColor(tintColor), PorterDuff.Mode.SRC_IN);
        mCursorDrawable.set(editor, drawables);
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : EditText(android.widget.EditText) Field(java.lang.reflect.Field) Drawable(android.graphics.drawable.Drawable) WXDomObject(com.taobao.weex.dom.WXDomObject) WXComponentProp(com.taobao.weex.ui.component.WXComponentProp)

Example 18 with WXComponentProp

use of com.taobao.weex.ui.component.WXComponentProp in project WeexErosFramework by bmfe.

the class HookWeb method setUrl.

@WXComponentProp(name = Constants.Name.SRC)
public void setUrl(String url) {
    if (TextUtils.isEmpty(url) || getHostView() == null) {
        return;
    }
    if (!TextUtils.isEmpty(url)) {
        Uri ul = getInstance().rewriteUri(Uri.parse(url), URIAdapter.WEB);
        if (LOCAL_SCHEME.equalsIgnoreCase(ul.getScheme())) {
            String mUrl = "file://" + localPath(ul);
            loadUrl(mUrl);
        } else {
            loadUrl(ul.toString());
        }
    }
}
Also used : Uri(android.net.Uri) WXComponentProp(com.taobao.weex.ui.component.WXComponentProp)

Example 19 with WXComponentProp

use of com.taobao.weex.ui.component.WXComponentProp in project weex-example by KalicyZhou.

the class SimpleComponentHolder method getMethods.

static Pair<Map<String, Invoker>, Map<String, Invoker>> getMethods(Class clz) {
    Map<String, Invoker> methods = new HashMap<>();
    Map<String, Invoker> mInvokers = new HashMap<>();
    Annotation[] annotations;
    Annotation anno;
    try {
        for (Method method : clz.getMethods()) {
            try {
                annotations = method.getDeclaredAnnotations();
                for (int i = 0, annotationsCount = annotations.length; i < annotationsCount; ++i) {
                    anno = annotations[i];
                    if (anno == null) {
                        continue;
                    }
                    if (anno instanceof WXComponentProp) {
                        String name = ((WXComponentProp) anno).name();
                        methods.put(name, new MethodInvoker(method, true));
                        break;
                    } else if (anno instanceof JSMethod) {
                        JSMethod methodAnno = (JSMethod) anno;
                        String name = methodAnno.alias();
                        if (JSMethod.NOT_SET.equals(name)) {
                            name = method.getName();
                        }
                        mInvokers.put(name, new MethodInvoker(method, methodAnno.uiThread()));
                        break;
                    }
                }
            } catch (ArrayIndexOutOfBoundsException | IncompatibleClassChangeError e) {
            //ignore: getDeclaredAnnotations may throw this
            }
        }
    } catch (IndexOutOfBoundsException e) {
        e.printStackTrace();
    //ignore: getMethods may throw this
    }
    return new Pair<>(methods, mInvokers);
}
Also used : HashMap(java.util.HashMap) JSMethod(com.taobao.weex.annotation.JSMethod) Method(java.lang.reflect.Method) JSMethod(com.taobao.weex.annotation.JSMethod) Annotation(java.lang.annotation.Annotation) MethodInvoker(com.taobao.weex.bridge.MethodInvoker) Invoker(com.taobao.weex.bridge.Invoker) WXComponentProp(com.taobao.weex.ui.component.WXComponentProp) MethodInvoker(com.taobao.weex.bridge.MethodInvoker) Pair(android.util.Pair)

Example 20 with WXComponentProp

use of com.taobao.weex.ui.component.WXComponentProp in project WeexErosFramework by bmfe.

the class BMCalendar method setMaxDate.

@WXComponentProp(name = "maximumDate")
public void setMaxDate(String maxDate) {
    if (TextUtils.isEmpty(maxDate))
        return;
    this.mMaxDate = maxDate;
    if (mBuilder != null) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(getDate(mMaxDate));
        mBuilder.setMaximumDate(calendar);
        if (!TextUtils.isEmpty(mMinDate)) {
            Calendar minCalendar = Calendar.getInstance();
            minCalendar.setTime(getDate(mMinDate));
            mBuilder.setMinimumDate(minCalendar);
            mBuilder.commit();
        }
    }
}
Also used : Calendar(java.util.Calendar) WXComponentProp(com.taobao.weex.ui.component.WXComponentProp)

Aggregations

WXComponentProp (com.taobao.weex.ui.component.WXComponentProp)29 WXRecyclerView (com.taobao.weex.ui.view.listview.WXRecyclerView)13 Calendar (java.util.Calendar)4 HookBounceScrollerView (com.eros.framework.extend.hook.ui.view.HookBounceScrollerView)3 Drawable (android.graphics.drawable.Drawable)2 Uri (android.net.Uri)2 SpannableString (android.text.SpannableString)2 URLSpan (android.text.style.URLSpan)2 Pair (android.util.Pair)2 EditText (android.widget.EditText)2 TextView (android.widget.TextView)2 HookWXHorizontalScrollView (com.eros.framework.extend.hook.ui.view.HookWXHorizontalScrollView)2 JSMethod (com.taobao.weex.annotation.JSMethod)2 Invoker (com.taobao.weex.bridge.Invoker)2 MethodInvoker (com.taobao.weex.bridge.MethodInvoker)2 WXDomObject (com.taobao.weex.dom.WXDomObject)2 WXHorizontalScrollView (com.taobao.weex.ui.view.WXHorizontalScrollView)2 Annotation (java.lang.annotation.Annotation)2 Field (java.lang.reflect.Field)2 Method (java.lang.reflect.Method)2