1

I use this example to generate pdf file from recyclerview. I call the getScreenshotFromRecyclerView function inside doInBackground of an AsyncTask and the bitmap is generated successfully.

The problem is if I added a CircularProgressIndicator inside recyclelerview's listitem, it throws AndroidRuntimeException.

     Caused by: android.util.AndroidRuntimeException: Animators may only be run on Looper threads
    at android.animation.ValueAnimator.end(ValueAnimator.java:1204)
    at com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange.endAnimatorsWithoutCallbacks(DrawableWithAnimatedVisibilityChange.java:322)

It is because this line in getScreenshotFromRecyclerView:

RecyclerView.ViewHolder holder = adapter.createViewHolder(view, adapter.getItemViewType(i));

Which cause LayoutInflater to createView, in thread which isn't UI thread.

I don't want to display the CircularProgressIndicator in the pdf (bitmap). Although I set its visibility to invisible/gone but it doesn't help. How to bypass the CircularProgressIndicator when creating the bitmap?

   <com.google.android.material.progressindicator.CircularProgressIndicator
                android:id="@+id/progressBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:indeterminate="false"
                android:visibility="invisible"
                app:indicatorSize="120dp"
                app:trackThickness="14dp" />

   

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.