I have RecyclerView
and, in some cases, I show another view on top of it - ProgressDialog
, AlertDialog
or DialogFragment
.
Is there some way to notify me about cases when my RecyclerView
is at front or another view is above it now?
I tried to add onFocusChangeListener()
to my RecyclerView
, but no luck.
PS. Definitely, I can in my RecyclerView
create some method isOnFront(boolean onFront)
and in all my other views call it, but maybe there is some more elegance way?
ProgressDialog
,AlertDialog
andDialogFragment
would lay their content on theWindow
, not to your activity's/fragment's view hierarchy. Which means, that as soon as either of them is shown, the focus ofWindow
is changed. Hence, you can make use ofViewTreeObserver#addOnWindowFocusChangeListener()
API: