0

I have a working app presently, but I don't like the implementation for my Recyclers.
My goal is to know when a Recycler and Adapter is ready to be called without throwing a nullpointer, illegalstate, etc... This can happen if I try to swap data sets too soon.

My research led me to using the ViewTreeObserver draw listeners, but I am hoping that there is a better solution that I missed. Something similar to MediaPlayer.setOnPreparedListener would be nice.

Presently using:

    Recycler.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { 
    @Override public boolean onPreDraw() { 
        // code to signal readiness 
return true; 
        } });

Is there a better way to accomplish this?

Jason P.
  • 1
  • 1

0 Answers0