1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-25 17:27:00 +00:00

Improved view clearing

This commit is contained in:
M66B 2022-04-18 09:54:52 +02:00
parent 6206194ece
commit 3c5d41cad3

View file

@ -1275,17 +1275,27 @@ public class Helper {
static void clearViews(Object instance) {
try {
String cname = instance.getClass().getSimpleName();
for (Field field : instance.getClass().getDeclaredFields()) {
String fname = cname + ":" + field.getName();
Class<?> ftype = field.getType();
Class<?> type = (ftype.isArray() ? ftype.getComponentType() : ftype);
if (type == null) {
Log.e(fname + "=null");
continue;
}
if (View.class.isAssignableFrom(type) ||
Animator.class.isAssignableFrom(type) ||
Snackbar.class.isAssignableFrom(type) ||
SelectionTracker.class.isAssignableFrom(type) ||
SelectionTracker.SelectionPredicate.class.isAssignableFrom(type) ||
PagerAdapter.class.isAssignableFrom(type) ||
RecyclerView.Adapter.class.isAssignableFrom(type)) {
Log.i("Clearing " + instance.getClass().getSimpleName() + ":" + field.getName());
RecyclerView.Adapter.class.isAssignableFrom(type))
try {
Log.i("Clearing " + fname);
field.setAccessible(true);
@ -1307,10 +1317,12 @@ public class Helper {
}
field.set(instance, null);
} catch (Throwable ex) {
Log.e(new Throwable(fname, ex));
}
}
} catch (Throwable ex) {
Log.w(ex);
Log.e(ex);
}
}