title: Android listener imageview effectively drawn
body: <p>I'm creating an android app to people draw names out of a set (raffle).</p>
  
  <p>I want to create an animation where after pressing the button the app goes randomly between the names and show them (with photos) for a short time them replace for a next one and on and on (like a raffling effect)</p>
  
  <p>The effect is working pretty fine for the NAMES, the problem i got is with the images</p>
  
  <p>what i do is:</p>
  
  <pre><code> final View drawingView = LayoutInflater.from(this).inflate(R.layout.winner_inspect_layout, null);
          new AlertDialog.Builder(this).setView(drawingView).show();
  
          final AppCompatImageView ivPhoto = drawingView.findViewById(R.id.winnerPhoto);
          final AppCompatTextView txName = drawingView.findViewById(R.id.winnerName);
          final AppCompatTextView txComment = drawingView.findViewById(R.id.winnerComment);
  
  
          ivPhoto.getViewTreeObserver().addOnGlobalLayoutListener(new Puzzler(ivPhoto, txName, txComment, validTickets, 6000));
          ivPhoto.forceLayout();
  </code></pre>
  
  <p>and the <code>Puzzler</code> does:</p>
  
  <pre><code> @Override
          public void onGlobalLayout() {
              Comment ticket = this.tickets.poll();
              this.txName.setText(ticket.getId() + "");
              this.txComment.setText(ticket.getText());
  
              Picasso.get().load(ticket.getProfilePhotoUrl()).fit().into(this.ivPhoto);
  
              if (System.currentTimeMillis() - this.startTime &gt; this.maxTime || this.tickets.isEmpty()) {
                  ivPhoto.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                  annouceWinner(ivPhoto);
              }
  
          }
  </code></pre>
  
  <p>So i do watch global layout on the imageview hopping that the method will be called after the whole image has been made visible.... but what actually happens is the method is called before the image is visible... so it is possible to see the names switching each other, but the images is just possible to see 1 or 2 in the whole process...</p>
  
  <p>i made a very very short video showing the effect (plase take 15 seconds to watch)<br>
  <a href="https://youtu.be/nxykGdBwIeM" rel="nofollow noreferrer">https://youtu.be/nxykGdBwIeM</a></p>
  
  <p>how can i listen the event of the image being really displayed to the user? the actual effect with the names is what i desire, but as is possible to watch most of the photos are switched before being visible</p>