コード例 #1
0
 @Override
 public View getView(final int position, View convertView, ViewGroup parent) {
   final ImageView view = new ImageView(context);
   final String path = fileHandler.getFiles().get(position).getPath();
   Bitmap bitmap = getBitmapFromMemCache(path);
   if (null == bitmap) {
     view.setVisibility(view.INVISIBLE);
     service.submit(
         new Runnable() {
           @Override
           public void run() {
             Bitmap bitmap = resizeToSmall(BitmapFactory.decodeFile(path));
             addBitmapToMemoryCache(path, bitmap);
             setBitmap(view, bitmap);
           }
         });
   } else {
     view.setImageBitmap(bitmap);
   }
   int sizeWidth = SkylightApp.getScreen().getWidth();
   sizeWidth = (sizeWidth - horizontalSpacing * 4) / 3;
   view.setLayoutParams(new GridView.LayoutParams(sizeWidth, (int) (sizeWidth / 1.5)));
   view.setScaleType(ImageView.ScaleType.CENTER_CROP);
   return view;
 }
コード例 #2
0
 @Override
 public Object getItem(int position) {
   return fileHandler.getFiles().get(position);
 }
コード例 #3
0
 @Override
 public long getItemId(int position) {
   return fileHandler.getFiles().get(position).hashCode();
 }
コード例 #4
0
 @Override
 public int getCount() {
   return fileHandler.getFiles().size();
 }