Goal:
I want to draw / write / draw bitmaps from pdf and save them together so that I can send them email.
Details:
I have several Pdf
files containing 5-20
pages each, right now I am extracting bitmap images from pdfs
and loading them into fragments in ViewPager
, where I can transfer through them and write / draw or whatever I want. To save / restore the current state of the bitmap, I use onSaveInstanceState
. That way, I can get the last stage of the bitmap while you switch back and forth.
Something like that:
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable("Bitmap", bitmap); }
Problem:
The user clicks the send email button, and I should be able to save all the images no matter what page it is on, i.e. he edited pages 5 to 10 and now he is on page 10 and press the submit button, I have to get all the edited images.
Problem 2:
As I said, the number of images is about 5-20, saving the state in onSaveInstanceState
works fine, but it continues to increase the application memory in ram, and the application drops in the 10th image, where the application size goes to 150Mbs
.
But saving the image as a package in onSaveInstanceState
also necessary, as it helps speed up the loading of images when the user bounces back.
So, I was thinking, is there a way to create a custom class package where we can write an image to disk, say, 5 scroll pages and clear the memory and read it from disk to memory when the user scrolls back? does that sound reasonable?
What I tried:
As raster images are loaded into separate fragments, I tried to save bitmaps to external storage in OnDestroy
, but since saving raster images to disk is not a small task, it takes time, although I use AsyncTask
but when a user quickly AsyncTask
over a bit between fragments, saving raster images in OnDestroy
does not seem to be a convenient way.
Thatβs why I ask the question, so maybe you better understand the situation and can help me achieve this in a more convenient way.
So what are you doing, how can I deal with this situation?
Note:
If you have problems understanding the situation and need more information, leave me a comment and I will update the question.
thanks