@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; }
@Override public Object getItem(int position) { return fileHandler.getFiles().get(position); }
@Override public long getItemId(int position) { return fileHandler.getFiles().get(position).hashCode(); }
@Override public int getCount() { return fileHandler.getFiles().size(); }