thest1 / LazyList

Lazy load of images in Android
http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview/3068012#3068012
MIT License
1.2k stars 497 forks source link

Some image failed to load. #24

Closed rheza closed 11 years ago

rheza commented 11 years ago

Hi,

i just implement lazylist to my application,but it doesn't work well, some of the image not loaded to the image view, it will load if i scroll the listview to the bottom. is there any fix for this ?, or is this known issue ?

thanks

thest1 commented 11 years ago

No it's not a known issue. I can't answer out of the blue. You should just debug and figure out what's going on there. If you start my sample application does it work for you? If it does what's the difference between sample application and your application?

2012/10/24 Rheza Pahlevi notifications@github.com

Hi,

i just implement lazylist to my application,but it doesn't work well, some of the image not loaded to the image view, it will load if i scroll the listview to the bottom. is there any fix for this ?, or is this known issue ?

thanks

— Reply to this email directly or view it on GitHubhttps://github.com/thest1/LazyList/issues/24.

rheza commented 11 years ago

hmm, the example works great. is it possible if it's because the fragment activity ?, other than my adopter, all codes all exactly same with your example.

here is my adapter code,


import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import com.fedorvlasov.lazylist.*;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Bitmap.Config;
import android.graphics.PorterDuff.Mode;
import android.os.AsyncTask;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.app.Activity;

public class SocialAdaptor extends ArrayAdapter<Social> {

     private ArrayList<Social> social;
     public ImageLoader imageLoader; 
     public SocialAdaptor(Context context,
             int textViewResourceId,
             ArrayList<Social> items) {
        super(context, textViewResourceId, items);
        this.social = items;
        imageLoader=new ImageLoader(context);

     }

     @Override
     public View getView(int position, View convertView, ViewGroup parent) {

             View V = convertView;

             if(V == null) {
                 LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                 V = vi.inflate(R.layout.list_item, null);
             }

             Social o = social.get(position);

             TextView posterName = (TextView) V.findViewById(R.id.poster);
             TextView checkinStatusNew = (TextView) V.findViewById(R.id.statustext);
             TextView checkinView = (TextView) V.findViewById(R.id.checkinTime);
             ImageView profilePicView = (ImageView) V.findViewById(R.id.profilePicture);
             TextView commentCountText = (TextView) V.findViewById(R.id.commentCountText);

             commentCountText.setText(o.commentCount);

             posterName.setText(o.employeeName);
             checkinStatusNew.setText(o.activityText);

             imageLoader.DisplayImage(o.employeePicUrl, profilePicView);

             return V;          
     }

 }

Thanks

thest1 commented 11 years ago

What context do you pass to your Adapter constructor? It should be activity context not application context.

2012/10/24 Rheza Pahlevi notifications@github.com

hmm, the example works great. is it possible if it's because the fragment activity ?, other than my adopter, all codes all exactly same with your example.

here is my adapter code,

import java.io.InputStream;import java.net.MalformedURLException;import java.net.URL;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Date; import com.fedorvlasov.lazylist.*; import android.content.Context;import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.graphics.PorterDuffXfermode;import android.graphics.Rect;import android.graphics.RectF;import android.graphics.Bitmap.Config;import android.graphics.PorterDuff.Mode;import android.os.AsyncTask;import android.text.format.DateUtils;import android.util.Log;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ArrayAdapter;import android.widget.ImageView;import android.widget.RelativeLayout;import android.widget.TextView;import android.app.Activity;

public class SocialAdaptor extends ArrayAdapter {

 private ArrayList<Social> social;
 public ImageLoader imageLoader;
 public SocialAdaptor(Context context,
         int textViewResourceId,
         ArrayList<Social> items) {
    super(context, textViewResourceId, items);
    this.social = items;
    imageLoader=new ImageLoader(context);

 }

 @Override
 public View getView(int position, View convertView, ViewGroup parent) {

         View V = convertView;

         if(V == null) {
             LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
             V = vi.inflate(R.layout.list_item, null);
         }

         Social o = social.get(position);

         TextView posterName = (TextView) V.findViewById(R.id.poster);
         TextView checkinStatusNew = (TextView) V.findViewById(R.id.statustext);
         TextView checkinView = (TextView) V.findViewById(R.id.checkinTime);
         ImageView profilePicView = (ImageView) V.findViewById(R.id.profilePicture);
         TextView commentCountText = (TextView) V.findViewById(R.id.commentCountText);

         commentCountText.setText(o.commentCount);

         posterName.setText(o.employeeName);
         checkinStatusNew.setText(o.activityText);

         imageLoader.DisplayImage(o.employeePicUrl, profilePicView);

         return V;
 }

}

Thanks

— Reply to this email directly or view it on GitHubhttps://github.com/thest1/LazyList/issues/24#issuecomment-9730016.

rheza commented 11 years ago

woa, that fixed the problem. Thank you so much!