On ViewTreeObserver.OnPreDrawListener.onPreDraw getContext() doesn't return an Activity but a ContextThemeWrapper. Activity extends ContextThemeWrapper. In my app I use only one activity and then handle fragments through back stack.
At line 194 View decor = ((Activity) getContext()).getWindow().getDecorView(); an exception is being thrown java.lang.ClassCastException: android.support.v7.view.ContextThemeWrapper cannot be cast to android.app.Activity.
It seems more appropriate to replace it with this View decor = ((Activity) ((ContextThemeWrapper) getContext()).getBaseContext()).getWindow().getDecorView();
On ViewTreeObserver.OnPreDrawListener.onPreDraw
getContext()
doesn't return an Activity but a ContextThemeWrapper. Activity extends ContextThemeWrapper. In my app I use only one activity and then handle fragments through back stack.At line 194
View decor = ((Activity) getContext()).getWindow().getDecorView();
an exception is being thrown java.lang.ClassCastException: android.support.v7.view.ContextThemeWrapper cannot be cast to android.app.Activity.It seems more appropriate to replace it with this
View decor = ((Activity) ((ContextThemeWrapper) getContext()).getBaseContext()).getWindow().getDecorView();