check object instance of before calling detachScreen (#344)

Fixes #343 

This change filters out non ScreenFragment instances when iterating through the list of installed fragments. The reason why other fragments can be added to the manager is that some libraries (e.g. glide) use fragment manager to store screen local data and attach to the screen lifecycle.
This commit is contained in:
Grzegorz Mandziak
2020-02-19 14:30:58 +00:00
committed by GitHub
parent 0e00f49e69
commit e50b7eae72

View File

@@ -252,7 +252,9 @@ public class ScreenContainer<T extends ScreenFragment> extends ViewGroup {
if (!orphaned.isEmpty()) {
Object[] orphanedAry = orphaned.toArray();
for (int i = 0; i < orphanedAry.length; i++) {
detachScreen((ScreenFragment) orphanedAry[i]);
if (orphanedAry[i] instanceof ScreenFragment) {
detachScreen((ScreenFragment) orphanedAry[i]);
}
}
}