ashutiwari4

Untitled

Mar 27th, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. @Override
  2. protected Bitmap createBitmap(final int position) {
  3. Log.v(TAG, "creating item " + position);
  4.  
  5. final Bitmap bitmap = getBitmapFromURL(ImgList.get(position)
  6. .getImageUrl());
  7. bitmapMap.put(position, new WeakReference<Bitmap>(bitmap));
  8. return bitmap;
  9. }
  10.  
  11. public static Bitmap getBitmapFromURL(String Url) {
  12. try {
  13. URL url = new URL(Url);
  14. HttpURLConnection connection = (HttpURLConnection) url
  15. .openConnection();
  16. connection.setDoInput(true);
  17. connection.connect();
  18. InputStream input = connection.getInputStream();
  19. Bitmap myBitmap = BitmapFactory.decodeStream(input);
  20. System.out.println("Bitmap Decoded Here size is: "
  21. + myBitmap.getHeight());
  22. return myBitmap;
  23. } catch (IOException e) {
  24. e.printStackTrace();
  25. return null;
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment