Search in sources :

Example 1 with LoadContentViewId

use of com.andframe.annotation.pager.load.LoadContentViewId in project AndFrameWorks by scwang90.

the class AfLoadHelper method findContentView.

// <editor-fold desc="初始化布局">
public View findContentView() {
    Class<?> stop = mPager instanceof Activity ? AfLoadActivity.class : AfLoadFragment.class;
    LoadContentViewId id = AfReflecter.getAnnotation(mPager.getClass(), stop, LoadContentViewId.class);
    if (id != null) {
        return mPager.findViewById(id.value());
    }
    LoadContentViewId$ id$ = AfReflecter.getAnnotation(mPager.getClass(), stop, LoadContentViewId$.class);
    if (id$ != null) {
        Context context = AfApp.get();
        if (context != null) {
            int idv = context.getResources().getIdentifier(id$.value(), "id", context.getPackageName());
            if (idv > 0) {
                return mPager.findViewById(idv);
            }
        }
    }
    LoadContentViewType type = AfReflecter.getAnnotation(mPager.getClass(), stop, LoadContentViewType.class);
    if (type != null) {
        return AfApp.get().newViewQuery(mPager).$(type.value()).view();
    }
    Queue<View> views = new LinkedBlockingQueue<>(Collections.singletonList(mPager.getView()));
    do {
        View view = views.poll();
        if (view != null) {
            if (view instanceof AbsListView || view instanceof RecyclerView || view instanceof ScrollView || view instanceof WebView || view instanceof NestedScrollView || view instanceof ViewPager) {
                return view;
            } else if (view instanceof ViewGroup) {
                ViewGroup group = (ViewGroup) view;
                for (int j = 0; j < group.getChildCount(); j++) {
                    views.add(group.getChildAt(j));
                }
            }
        }
    } while (!views.isEmpty());
    return null;
}
Also used : Context(android.content.Context) LoadContentViewId$(com.andframe.annotation.pager.load.idname.LoadContentViewId$) ViewGroup(android.view.ViewGroup) AfLoadActivity(com.andframe.activity.AfLoadActivity) Activity(android.app.Activity) AbsListView(android.widget.AbsListView) LoadContentViewType(com.andframe.annotation.pager.load.LoadContentViewType) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) View(android.view.View) NestedScrollView(android.support.v4.widget.NestedScrollView) WebView(android.webkit.WebView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) ViewPager(android.support.v4.view.ViewPager) LoadContentViewId(com.andframe.annotation.pager.load.LoadContentViewId) NestedScrollView(android.support.v4.widget.NestedScrollView) ScrollView(android.widget.ScrollView) RecyclerView(android.support.v7.widget.RecyclerView) WebView(android.webkit.WebView) NestedScrollView(android.support.v4.widget.NestedScrollView)

Aggregations

Activity (android.app.Activity)1 Context (android.content.Context)1 ViewPager (android.support.v4.view.ViewPager)1 NestedScrollView (android.support.v4.widget.NestedScrollView)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 WebView (android.webkit.WebView)1 AbsListView (android.widget.AbsListView)1 ScrollView (android.widget.ScrollView)1 AfLoadActivity (com.andframe.activity.AfLoadActivity)1 LoadContentViewId (com.andframe.annotation.pager.load.LoadContentViewId)1 LoadContentViewType (com.andframe.annotation.pager.load.LoadContentViewType)1 LoadContentViewId$ (com.andframe.annotation.pager.load.idname.LoadContentViewId$)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1