Search in sources :

Example 1 with WrapperListAdapter

use of android.widget.WrapperListAdapter in project HoloEverywhere by Prototik.

the class FastScroller method getSectionsFromIndexer.

void getSectionsFromIndexer() {
    ListAdapter adapter = mList.getAdapter();
    mSectionIndexer = null;
    if (adapter instanceof HeaderViewListAdapter) {
        mListOffset = ((HeaderViewListAdapter) adapter).getHeadersCount();
    }
    if (adapter instanceof ListAdapterWrapper) {
        adapter = ((ListAdapterWrapper) adapter).getWrappedAdapter();
    }
    if (adapter instanceof WrapperListAdapter) {
        adapter = ((WrapperListAdapter) adapter).getWrappedAdapter();
    }
    if (adapter instanceof ExpandableListConnector) {
        ExpandableListAdapter expAdapter = ((ExpandableListConnector) adapter).getAdapter();
        if (expAdapter instanceof SectionIndexer) {
            mSectionIndexer = (SectionIndexer) expAdapter;
            mListAdapter = adapter;
            mSections = mSectionIndexer.getSections();
        }
    } else {
        if (adapter instanceof SectionIndexer) {
            mSectionIndexer = (SectionIndexer) adapter;
            mSections = mSectionIndexer.getSections();
            if (mSections == null) {
                mSections = new String[] { " " };
            }
        } else {
            mSections = new String[] { " " };
        }
    }
    mListAdapter = adapter;
}
Also used : ExpandableListAdapter(android.widget.ExpandableListAdapter) SectionIndexer(android.widget.SectionIndexer) ExpandableListAdapter(android.widget.ExpandableListAdapter) ListAdapter(android.widget.ListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter)

Example 2 with WrapperListAdapter

use of android.widget.WrapperListAdapter in project MagicaSakura by Bilibili.

the class ThemeUtils method refreshView.

private static void refreshView(View view, ExtraRefreshable extraRefreshable) {
    if (view == null)
        return;
    view.destroyDrawingCache();
    if (view instanceof Tintable) {
        ((Tintable) view).tint();
        if (view instanceof ViewGroup) {
            for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
                refreshView(((ViewGroup) view).getChildAt(i), extraRefreshable);
            }
        }
    } else {
        if (extraRefreshable != null) {
            extraRefreshable.refreshSpecificView(view);
        }
        if (view instanceof AbsListView) {
            try {
                if (sRecyclerBin == null) {
                    sRecyclerBin = AbsListView.class.getDeclaredField("mRecycler");
                    sRecyclerBin.setAccessible(true);
                }
                if (sListViewClearMethod == null) {
                    sListViewClearMethod = Class.forName("android.widget.AbsListView$RecycleBin").getDeclaredMethod("clear");
                    sListViewClearMethod.setAccessible(true);
                }
                sListViewClearMethod.invoke(sRecyclerBin.get(view));
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
            ListAdapter adapter = ((AbsListView) view).getAdapter();
            while (adapter instanceof WrapperListAdapter) {
                adapter = ((WrapperListAdapter) adapter).getWrappedAdapter();
            }
            if (adapter instanceof BaseAdapter) {
                ((BaseAdapter) adapter).notifyDataSetChanged();
            }
        }
        if (view instanceof RecyclerView) {
            try {
                if (sRecycler == null) {
                    sRecycler = RecyclerView.class.getDeclaredField("mRecycler");
                    sRecycler.setAccessible(true);
                }
                if (sRecycleViewClearMethod == null) {
                    sRecycleViewClearMethod = Class.forName("android.support.v7.widget.RecyclerView$Recycler").getDeclaredMethod("clear");
                    sRecycleViewClearMethod.setAccessible(true);
                }
                sRecycleViewClearMethod.invoke(sRecycler.get(view));
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            ((RecyclerView) view).getRecycledViewPool().clear();
            ((RecyclerView) view).invalidateItemDecorations();
        }
        if (view instanceof ViewGroup) {
            for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
                refreshView(((ViewGroup) view).getChildAt(i), extraRefreshable);
            }
        }
    }
}
Also used : Tintable(com.bilibili.magicasakura.widgets.Tintable) ViewGroup(android.view.ViewGroup) AbsListView(android.widget.AbsListView) SuppressLint(android.annotation.SuppressLint) InvocationTargetException(java.lang.reflect.InvocationTargetException) RecyclerView(android.support.v7.widget.RecyclerView) BaseAdapter(android.widget.BaseAdapter) ListAdapter(android.widget.ListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter)

Example 3 with WrapperListAdapter

use of android.widget.WrapperListAdapter in project remusic by aa112901.

the class ThemeUtils method refreshView.

private static void refreshView(View view, ExtraRefreshable extraRefreshable) {
    if (view == null)
        return;
    view.destroyDrawingCache();
    if (view instanceof Tintable) {
        ((Tintable) view).tint();
        if (view instanceof ViewGroup) {
            for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
                refreshView(((ViewGroup) view).getChildAt(i), extraRefreshable);
            }
        }
    } else {
        if (extraRefreshable != null) {
            extraRefreshable.refreshSpecificView(view);
        }
        if (view instanceof AbsListView) {
            ListAdapter adapter = ((AbsListView) view).getAdapter();
            while (adapter instanceof WrapperListAdapter) {
                adapter = ((WrapperListAdapter) adapter).getWrappedAdapter();
            }
            if (adapter instanceof BaseAdapter) {
                ((BaseAdapter) adapter).notifyDataSetChanged();
            }
        }
        if (view instanceof RecyclerView) {
            try {
                if (mRecycler == null) {
                    mRecycler = RecyclerView.class.getDeclaredField("mRecycler");
                    mRecycler.setAccessible(true);
                }
                if (mClearMethod == null) {
                    mClearMethod = Class.forName("android.support.v7.widget.RecyclerView$Recycler").getDeclaredMethod("clear");
                    mClearMethod.setAccessible(true);
                }
                mClearMethod.invoke(mRecycler.get(view));
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            ((RecyclerView) view).getRecycledViewPool().clear();
            ((RecyclerView) view).invalidateItemDecorations();
        }
        if (view instanceof ViewGroup) {
            for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
                refreshView(((ViewGroup) view).getChildAt(i), extraRefreshable);
            }
        }
    }
}
Also used : Tintable(com.bilibili.magicasakura.widgets.Tintable) ViewGroup(android.view.ViewGroup) AbsListView(android.widget.AbsListView) InvocationTargetException(java.lang.reflect.InvocationTargetException) RecyclerView(android.support.v7.widget.RecyclerView) BaseAdapter(android.widget.BaseAdapter) ListAdapter(android.widget.ListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter)

Example 4 with WrapperListAdapter

use of android.widget.WrapperListAdapter in project ListViewAnimations by nhaarman.

the class DragAndDropHandler method setAdapterInternal.

/**
 * @throws java.lang.IllegalStateException    if the adapter does not have stable ids.
 * @throws java.lang.IllegalArgumentException if the adapter does not implement {@link com.nhaarman.listviewanimations.util.Swappable}.
 */
private void setAdapterInternal(@NonNull final ListAdapter adapter) {
    ListAdapter actualAdapter = adapter;
    if (actualAdapter instanceof WrapperListAdapter) {
        actualAdapter = ((WrapperListAdapter) actualAdapter).getWrappedAdapter();
    }
    if (!actualAdapter.hasStableIds()) {
        throw new IllegalStateException("Adapter doesn't have stable ids! Make sure your adapter has stable ids, and override hasStableIds() to return true.");
    }
    if (!(actualAdapter instanceof Swappable)) {
        throw new IllegalArgumentException("Adapter should implement Swappable!");
    }
    mAdapter = actualAdapter;
}
Also used : Swappable(com.nhaarman.listviewanimations.util.Swappable) ListAdapter(android.widget.ListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter)

Aggregations

ListAdapter (android.widget.ListAdapter)4 WrapperListAdapter (android.widget.WrapperListAdapter)4 RecyclerView (android.support.v7.widget.RecyclerView)2 ViewGroup (android.view.ViewGroup)2 AbsListView (android.widget.AbsListView)2 BaseAdapter (android.widget.BaseAdapter)2 Tintable (com.bilibili.magicasakura.widgets.Tintable)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 SuppressLint (android.annotation.SuppressLint)1 ExpandableListAdapter (android.widget.ExpandableListAdapter)1 SectionIndexer (android.widget.SectionIndexer)1 Swappable (com.nhaarman.listviewanimations.util.Swappable)1