Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ImageAdapter extends BaseAdapter {
- private Context context;
- List<ImageUpload> imageUploads;
- int resource;
- public ImageAdapter(Context context, List<ImageUpload> imageUploads, int resource) {
- this.context = context;
- this.imageUploads = imageUploads;
- this.resource = resource;
- }
- public View getView(int position, View convertView, ViewGroup parent) {
- LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View gridView;
- if (convertView == null) {
- gridView = new View(context);
- if (imageUploads.get(position).getOutputMetadata().getFilename().equals("null")) {
- gridView = inflater.inflate(R.layout.item_upload_default, null);
- ImageView imageView = (ImageView) gridView.findViewById(R.id.iv_upload);
- imageView.setImageResource(resource);
- } else {
- gridView = inflater.inflate(R.layout.item_upload, null);
- ImageView imageView = (ImageView) gridView.findViewById(R.id.iv_upload);
- final ProgressWheel progress = (ProgressWheel) gridView.findViewById(R.id.loader_photo);
- ImageUpload mobile = imageUploads.get(position);
- if (imageUploads.get(position).isLoadImage())
- Picasso.with(context)
- .load(StringUtil.URLADS_THUMBLER_RESIZE + 150 + "x" + 150 + "/" + StringUtil.URLADS_THUMBLER_IMAGE + mobile.getOutputMetadata().getFilename())
- .into(imageView, new Callback() {
- @Override
- public void onSuccess() {
- progress.setVisibility(View.GONE);
- }
- @Override
- public void onError() {
- }
- });
- else {
- File f = new File(imageUploads.get(position).getPath());
- Picasso.with(context)
- .load(f)
- .into(imageView);
- }
- }
- } else {
- // holder = (ViewHolder ) row.getTag();
- gridView = (View) convertView;
- ImageView imageView = (ImageView) gridView.findViewById(R.id.iv_upload);
- final ProgressWheel progress = (ProgressWheel) gridView.findViewById(R.id.loader_photo);
- if (imageUploads.get(position).getOutputMetadata().getFilename().equals("null")) {
- imageView.setImageResource(resource);
- } else {
- ImageUpload mobile = imageUploads.get(position);
- // Picasso.with(context).load("https://i.simpalsmedia.com/999.md/BoardImages/900x900/"+mobile.getOutputMetadata().getFilename());
- if (imageUploads.get(position).isLoadImage())
- Picasso.with(context)
- .load(StringUtil.URLADS_THUMBLER_RESIZE + 150 + "x" + 150 + "/" + StringUtil.URLADS_THUMBLER_IMAGE + mobile.getOutputMetadata().getFilename())
- .into(imageView, new Callback() {
- @Override
- public void onSuccess() {
- progress.setVisibility(View.GONE);
- }
- @Override
- public void onError() {
- }
- });
- else {
- File f = new File(imageUploads.get(position).getPath());
- Picasso.with(context)
- .load(f)
- .into(imageView);
- }
- }
- <ImageView
- android:id="@+id/iv_upload"
- android:layout_width="@dimen/_80sdp"
- android:layout_height="@dimen/_80sdp"
- android:src="@drawable/disable_info" />
- <ImageView
- android:id="@+id/photo_close_btn"
- android:layout_width="@dimen/_15sdp"
- android:layout_height="@dimen/_15sdp"
- android:src="@drawable/close_btn" />
- <com.site.views.ProgressWheel
- android:id="@+id/loader_photo"
- android:layout_width="@dimen/size_progress_small"
- android:layout_height="@dimen/size_progress_small"
- android:layout_centerHorizontal="true"
- android:layout_centerVertical="true"
- custom:matProg_barColor="@color/progress_bar"
- custom:matProg_progressIndeterminate="true" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement