Picasso Images not loading - android

This is extended from the thread:Picasso Images are not loading in Gridview Android
Now the new problem is that the Picasso is not loading the images properly. If i hardcode the image url though, then the image will display (repetitively though).
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
//Inflate the XML based
Layout
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.movies_item, parent, false);
}
//Get the ImageView
ImageView movieThumbnail = (ImageView) convertView.findViewById(R.id.movies_item_thumbnail);
//Load Image into the ImageView
Picasso.with(context).load(movies.get(position).getThumbnail()).into(movieThumbnail);
//When I hardcode the url, the image shows as shown in the screenshot below
//Picasso.with(context).load("http://image.tmdb.org/t/p/w500/nBNZadXqJSdt05SHLqgT0HuC5Gm.jpg").into(movieThumbnail);
Log.v("Populating", movies.get(position).getThumbnail());
return convertView;
}
I am completely lost. It does not throw any error too. HELP!!!!!!!!
[UPDATE]
Please refer to this link for the solution!
OkHTTP and Picasso don't run together

Well try using this
movies.get(position).getThumbnail().toString()
and make sure your URL is complete

I will give my code try this way..
Picasso.with(ctx).load(String.valueOf(images.get(position))).error(R.drawable.scorpion).into(serve_dish_iv); here variable "images" is ArrayList variable.. Try this way
Picasso.with(context).load(movies.get(position).getThumbnail()).error(R.drawable‌​.defulticon).into(movieThumbnail);
if any images are not available then default image is show.. If any issue please ask me..

Related

can't load images in Image View using glide

I'm using glide library in order to show images in Grid view, but there is noting shown in my image view. and I got an error that :
E/Glide: class com.bumptech.glide.load.engine.GlideException: Failed
to load resource
my code works correctly as I use bitmap. Here is my code:
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
Log.e("sara" , "this part takes time");
LayoutInflater inflater = getLayoutInflater();
convertView = getLayoutInflater().inflate(R.layout.gallery_gridsq, parent, false);
iv = (ImageView) convertView.findViewById(R.id.icon);
file = new File(Uri.parse(getItem(position).toString()).getPath());
Uri imageUri = Uri.fromFile(file);
Glide
.with(Gallery2.this)
.load(imageUri)
.into(iv);
return convertView;
}
Regard to Glide on Github see this issue may help you.

Icon doesn't load

Hi my icons don't load and i don't know why. They should appear in the navigation. Im very new and don't find good new resources to learn.
Everything is old. Some links would help thank u.
The GetView needs to set the image on the ImageButton in the layout. Notice that you aren't even using the items in your adapter? Instead of using a list of ImageButton why not accept the drawables, and then set the image of each ImageButton from the items? See an updated version of GetView (below) which should get you a working example of setting the image on the ImageButton in each of your buttons.
public override View GetView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if(v == null){
v = LayoutInflater.From(context).Inflate(Resource.Layout.MenuButtonLayout, parent, false);
}
var imageButton = v.FindViewById<ImageButton>(Resource.Id.myButton);
imageButton.SetImageResource(Resource.Drawable.Noten);
return v;
}

Add Condition for ArrayAdapter in Android

I'm working on Imgur API and I fetched some image links. In a gridview, i am showing all pictures but sometimes api gives ".gif" and picasso cannot load this animated pictures. I want to pass if its a gif which convertview didn't load. As you can see, I'dont want to that gray areas. Do you have any idea?
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if (null == convertView ) {
convertView = inflater.inflate(R.layout.listview_item_image, parent, false);
}
ImageView img = (ImageView) convertView.findViewById(R.id.im);
if(datas.get(position).getLink().endsWith(".jpg") ){
Picasso.with(context)
.load(datas.get(position).getLink())
.fit()
.into(img);
}else convertView.setVisibility(View.GONE);
return convertView;
}
1: []
You must remove all objects which ends with .gif from the datas ArrayList, or you must not add them in the first place, you can give a condition while adding in ArrayList
if(data.getLink().endsWith(".jpg"))
datas.add(data)

Android gridview containing NetworkImageView from volley library duplicates image on scroll

I'm using NetworkImageView for loading image from Url in my Gridview.
It works fine for the first time, but on Scroll, the grid items start duplicating at random positions.
Below is my code for GridView adapter:
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater)
context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.grid_item, null);
}
NetworkImageView imageViewBand = (NetworkImageView) convertView.findViewById(R.id.imageView_grid_item);
TextView textViewBand = (TextView) convertView.findViewById(R.id.textView_grid_item);
imageViewBand.setDefaultImageResId(R.drawable.college_default_icon_grid_view);
imageViewBand.setAdjustViewBounds(true);
imageViewBand.setImageUrl(Constants.schoolImageUrl, AppController.getInstance(context).getImageLoader());
textViewBand.setText(schoolArrayList.get(position).getSchoolName());
return convertView;
}
The text in grid item works fine, but the issue occurs only with volley image loader causing image duplicate.
Please help.
Your problem is that you are reusing the view on scroll but you are not resetting the imageViewBand image url to null before loading the new image. So what you have to do is to set image url to null before reusing it
Next time try implementing a RecyclerView with a GridLayoutManager since with a RecyclerView reusing views is done automatically

ImageView of ListView loading incorrect few second when scrolling ListView

I'm using ListView with ImageView is a element of List. I have got problem when fast scrolling my List : The system seems to be recycling views until it loads the correct position's view in my ListView, resulting in duplicated images and text for a few seconds. After that, ImageView display images correctly. I'm using Universal Image Loader library to load images.
#Override
public View getView(int position, View v, ViewGroup parent) {
final PhotoViewHolder holder;
if(v == null){
LayoutInflater li = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = li.inflate(R.layout.photo_item_horizonal_layout, parent, false);
holder = new PhotoViewHolder();
holder.imgPhoto = (ImageView)v.findViewById(R.id.imgPhotoIcon);
v.setTag(holder);
}else{
holder = (PhotoViewHolder)v.getTag();
}
//item variable is a element at position of ArrayList
ImageLoader.getInstance().displayImage(item.getImageUrl(), holder.imgPhoto);
...
}
Can anyone help me?
Thanks in advanced
Do one thing Download Aquery from This link put that .jar File in your Lib folder and change your code to this:
#Override
public View getView(int position, View v, ViewGroup parent) {
final PhotoViewHolder holder;
if(v == null){
LayoutInflater li = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = li.inflate(R.layout.photo_item_horizonal_layout, parent, false);
holder = new PhotoViewHolder();
holder.imgPhoto = (ImageView)v.findViewById(R.id.imgPhotoIcon);
v.setTag(holder);
}else{
holder = (PhotoViewHolder)v.getTag();
}
//item variable is a element at position of ArrayList
AQuery aQuery=new AQuery(v)
aQuery.id(holder.imgPhoto).image(item.getImageUrl().toString());
}
Use a placeholder image while image is loading . You can do that by UIL option:
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.placeholder)
......
.build();
This should solve your problem.
Are you changing the image of the ImageView by yourself in a later part of the code?
if you do, you should call
ImageLoader.getInstance().cancelDisplayTask(holder.imgPhoto);
so that the library knows that the link between the image and the imageview is broken

Categories

Resources