title: setImageBitmap from URL in the main thread
body: <p>Task:
  setImageBitmap from URL into recyclerview items and use PDFBox lib to get PDF file with all recyclerview items including the images in these items.</p>
  
  <p>Problem:
  converting url image to bitmap requires not working on main thread and that makes pdf file created without images set to its position (blank in image position).</p>
  
  <p>permitting working on main thread makes it possible for the app to crash or too slow.</p>
  
  <pre><code>final BitmapFactory.Options options = new BitmapFactory.Options();
  
          // down sizing image as it throws OutOfMemory Exception for larger
          // images
          options.inSampleSize = 10;
  
          Bitmap bitmap = null;
          URL url = null;
          try {
  
              StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
              StrictMode.setThreadPolicy(policy);
  
              url = new URL(imag_path);
          } catch (MalformedURLException e) {
              e.printStackTrace();
          }
          try {
              bitmap = BitmapFactory.decodeStream(url.openConnection().getInputStream());
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          return bitmap;
  </code></pre>
  
  <p>resulting PDF photo as below:</p>
  
  <p><a href="https://i.stack.imgur.com/0AXps.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0AXps.jpg" alt="enter image description here"></a></p>