Is it possible for a view to track when it is visible and when it is no longer visible on the screen? The keyword here is track as opposed to “check”. In effect I am looking for something that behaves like onShowingOnScreen
and onStopShowingOnScreen
.
For some background, my view is nested quite a bit: Activity => ViewPager => Fragment => RecyclerView.Adapter => CatViewHolder => myView
.
If you care: For the sake of this question, let’s assume this particular CatViewHolder is used only once while some other DogViewHolder is what gets reused multiple time.
Also, if the view cannot do this, can the ViewHolder do it? (It's effectively the same result).
update
For completeness, imagine I have to attach a slab to the window when the myView
is visible and detach that slab from the window the moment myView
stops being visible. ( I use slab so as not to use the word View again).