Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.51 KB | None | 0 0
  1. public class ImageAdapter extends BaseAdapter {
  2. private Context context;
  3. List<ImageUpload> imageUploads;
  4. int resource;
  5.  
  6. public ImageAdapter(Context context, List<ImageUpload> imageUploads, int resource) {
  7. this.context = context;
  8. this.imageUploads = imageUploads;
  9. this.resource = resource;
  10. }
  11.  
  12. public View getView(int position, View convertView, ViewGroup parent) {
  13.  
  14. LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  15. View gridView;
  16. if (convertView == null) {
  17. gridView = new View(context);
  18. if (imageUploads.get(position).getOutputMetadata().getFilename().equals("null")) {
  19. gridView = inflater.inflate(R.layout.item_upload_default, null);
  20. ImageView imageView = (ImageView) gridView.findViewById(R.id.iv_upload);
  21. imageView.setImageResource(resource);
  22.  
  23. } else {
  24. gridView = inflater.inflate(R.layout.item_upload, null);
  25. ImageView imageView = (ImageView) gridView.findViewById(R.id.iv_upload);
  26. final ProgressWheel progress = (ProgressWheel) gridView.findViewById(R.id.loader_photo);
  27. ImageUpload mobile = imageUploads.get(position);
  28. if (imageUploads.get(position).isLoadImage())
  29. Picasso.with(context)
  30. .load(StringUtil.URLADS_THUMBLER_RESIZE + 150 + "x" + 150 + "/" + StringUtil.URLADS_THUMBLER_IMAGE + mobile.getOutputMetadata().getFilename())
  31. .into(imageView, new Callback() {
  32. @Override
  33. public void onSuccess() {
  34. progress.setVisibility(View.GONE);
  35. }
  36.  
  37. @Override
  38. public void onError() {
  39.  
  40. }
  41. });
  42. else {
  43. File f = new File(imageUploads.get(position).getPath());
  44. Picasso.with(context)
  45. .load(f)
  46. .into(imageView);
  47. }
  48. }
  49. } else {
  50. // holder = (ViewHolder ) row.getTag();
  51. gridView = (View) convertView;
  52. ImageView imageView = (ImageView) gridView.findViewById(R.id.iv_upload);
  53. final ProgressWheel progress = (ProgressWheel) gridView.findViewById(R.id.loader_photo);
  54. if (imageUploads.get(position).getOutputMetadata().getFilename().equals("null")) {
  55. imageView.setImageResource(resource);
  56. } else {
  57. ImageUpload mobile = imageUploads.get(position);
  58. // Picasso.with(context).load("https://i.simpalsmedia.com/999.md/BoardImages/900x900/"+mobile.getOutputMetadata().getFilename());
  59. if (imageUploads.get(position).isLoadImage())
  60. Picasso.with(context)
  61. .load(StringUtil.URLADS_THUMBLER_RESIZE + 150 + "x" + 150 + "/" + StringUtil.URLADS_THUMBLER_IMAGE + mobile.getOutputMetadata().getFilename())
  62. .into(imageView, new Callback() {
  63. @Override
  64. public void onSuccess() {
  65. progress.setVisibility(View.GONE);
  66. }
  67.  
  68. @Override
  69. public void onError() {
  70.  
  71. }
  72. });
  73. else {
  74. File f = new File(imageUploads.get(position).getPath());
  75. Picasso.with(context)
  76. .load(f)
  77. .into(imageView);
  78. }
  79. }
  80.  
  81. <ImageView
  82. android:id="@+id/iv_upload"
  83. android:layout_width="@dimen/_80sdp"
  84. android:layout_height="@dimen/_80sdp"
  85. android:src="@drawable/disable_info" />
  86.  
  87. <ImageView
  88. android:id="@+id/photo_close_btn"
  89. android:layout_width="@dimen/_15sdp"
  90. android:layout_height="@dimen/_15sdp"
  91. android:src="@drawable/close_btn" />
  92.  
  93.  
  94. <com.site.views.ProgressWheel
  95. android:id="@+id/loader_photo"
  96. android:layout_width="@dimen/size_progress_small"
  97. android:layout_height="@dimen/size_progress_small"
  98. android:layout_centerHorizontal="true"
  99. android:layout_centerVertical="true"
  100. custom:matProg_barColor="@color/progress_bar"
  101. custom:matProg_progressIndeterminate="true" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement