/[projects]/android/Side9/src/dk/thoerup/side9/ImageAdapter.java
ViewVC logotype

Diff of /android/Side9/src/dk/thoerup/side9/ImageAdapter.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 790 by torben, Thu Jun 3 09:11:07 2010 UTC revision 791 by torben, Thu Jun 3 09:31:00 2010 UTC
# Line 4  import java.io.File; Line 4  import java.io.File;
4  import java.util.ArrayList;  import java.util.ArrayList;
5    
6  import android.content.Context;  import android.content.Context;
 import android.content.res.TypedArray;  
7  import android.graphics.Bitmap;  import android.graphics.Bitmap;
8  import android.graphics.BitmapFactory;  import android.graphics.BitmapFactory;
9  import android.os.Environment;  import android.os.Environment;
# Line 18  public class ImageAdapter extends BaseAd Line 17  public class ImageAdapter extends BaseAd
17      //int mGalleryItemBackground;      //int mGalleryItemBackground;
18      private Context mContext;      private Context mContext;
19            
20      ArrayList<String> mBitmaps = new ArrayList<String>();      ArrayList<String> mBitmapPaths = new ArrayList<String>();
21        ArrayList<Bitmap> mBitmaps = new ArrayList<Bitmap>();
22    
23      public ImageAdapter(Context c) {      public ImageAdapter(Context c) {
24          mContext = c;          mContext = c;
# Line 27  public class ImageAdapter extends BaseAd Line 27  public class ImageAdapter extends BaseAd
27                    
28          File root = new File(path);          File root = new File(path);
29          File files[] = root.listFiles();          File files[] = root.listFiles();
30          for (File f : files) {          for (File f : files) {          
31                  mBitmaps.add(  f.getPath() );              Bitmap bmp = BitmapFactory.decodeFile( f.getPath() );
32                Bitmap scaled =  Bitmap.createScaledBitmap(bmp, bmp.getWidth()/4, bmp.getHeight()/4, true);
33                
34                    mBitmapPaths.add(  f.getPath() );
35                    mBitmaps.add(scaled);
36          }          }
           
           
37      }      }
38    
39      public int getCount() {      public int getCount() {
# Line 47  public class ImageAdapter extends BaseAd Line 49  public class ImageAdapter extends BaseAd
49      }      }
50            
51      public String getImagePath(int position) {      public String getImagePath(int position) {
52          return mBitmaps.get(position);          return mBitmapPaths.get(position);
53      }      }
54    
55      public View getView(int position, View convertView, ViewGroup parent) {      public View getView(int position, View convertView, ViewGroup parent) {
# Line 62  public class ImageAdapter extends BaseAd Line 64  public class ImageAdapter extends BaseAd
64              imageView = (ImageView) convertView;              imageView = (ImageView) convertView;
65          }          }
66    
67          Bitmap bmp = BitmapFactory.decodeFile( mBitmaps.get(position) );  
68          imageView.setImageBitmap( Bitmap.createScaledBitmap(bmp, bmp.getWidth()/3, bmp.getHeight()/3, true) );          imageView.setImageBitmap( mBitmaps.get(position) );
69          return imageView;          return imageView;
70    
71      }      }

Legend:
Removed from v.790  
changed lines
  Added in v.791

  ViewVC Help
Powered by ViewVC 1.1.20