Search in sources :

Example 1 with ContentView

use of org.xutils.view.annotation.ContentView in project xUtils3 by wyouflf.

the class ViewInjectorImpl method inject.

@Override
public void inject(Activity activity) {
    //获取Activity的ContentView的注解
    Class<?> handlerType = activity.getClass();
    try {
        ContentView contentView = findContentView(handlerType);
        if (contentView != null) {
            int viewId = contentView.value();
            if (viewId > 0) {
                Method setContentViewMethod = handlerType.getMethod("setContentView", int.class);
                setContentViewMethod.invoke(activity, viewId);
            }
        }
    } catch (Throwable ex) {
        LogUtil.e(ex.getMessage(), ex);
    }
    injectObject(activity, handlerType, new ViewFinder(activity));
}
Also used : ContentView(org.xutils.view.annotation.ContentView) Method(java.lang.reflect.Method)

Example 2 with ContentView

use of org.xutils.view.annotation.ContentView in project xUtils3 by wyouflf.

the class ViewInjectorImpl method inject.

@Override
public View inject(Object fragment, LayoutInflater inflater, ViewGroup container) {
    // inject ContentView
    View view = null;
    Class<?> handlerType = fragment.getClass();
    try {
        ContentView contentView = findContentView(handlerType);
        if (contentView != null) {
            int viewId = contentView.value();
            if (viewId > 0) {
                view = inflater.inflate(viewId, container, false);
            }
        }
    } catch (Throwable ex) {
        LogUtil.e(ex.getMessage(), ex);
    }
    // inject res & event
    injectObject(fragment, handlerType, new ViewFinder(view));
    return view;
}
Also used : ContentView(org.xutils.view.annotation.ContentView) ContentView(org.xutils.view.annotation.ContentView) View(android.view.View)

Aggregations

ContentView (org.xutils.view.annotation.ContentView)2 View (android.view.View)1 Method (java.lang.reflect.Method)1