use of com.bilibili.magicasakura.widgets.Tintable 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);
}
}
}
}
use of com.bilibili.magicasakura.widgets.Tintable 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);
}
}
}
}
Aggregations