Update UI during print screen process

Asked

Viewed 107 times

1

I have a Activity and several Fragments in it and, in a Fragment, I have a list of images.

I want it, through a floating button, to print all the images without having to change the image that appears on the screen myself.

I made the code below but it updates the screen image only after taking the pictures, so it takes repeated photos(if the list has 6 pictures it takes 2 photos of the first 3).

I would like to know how to update the list to print all the images at once.

@OnClick(R.id.fab_client_screenshot)

public void printScreen() {
Handler handler = new Handler();
handler.post(new Runnable() {
       @Override
       public void run() {
           ListView list = JListaImagens.getInstance().getList();
           list.setSelection(0);
           int j = 0;
           while (j < list.getCount()) {
               int lastPosition = list.getLastVisiblePosition();
               try {
                  for (int i = 0; i < list.getLastVisiblePosition(); i++) {
                     if (list.getChildAt(i).isEnabled()) {
                         JUtil.saveScreenShot(list.getChildAt(i), "Imagem" + j + ".png");
                         j++;
                     }
                  }
               list.setSelection(lastPosition);
               Thread.sleep(1500);
               } catch (InterruptedException e) {
                  e.printStackTrace();
               }
            }
        }
    });
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.