Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public View getView(int position, View convertView, ViewGroup parent) {
- ImageView iv;
- final Document document = getItem(position);
- final int currentColumnCount = Utils.getInteger(R.integer.grid_column_count);
- if (convertView == null) {
- iv = new ImageView(App.getContext());
- iv.setAdjustViewBounds(true);
- } else {
- iv = (ImageView)convertView;
- }
- float margin = Utils.dp2px(Utils.getDimension(R.dimen.common_padding_small))*(currentColumnCount-1);
- int ivWidth = (int) ((Utils.getDisplayXY()[0]-margin) / currentColumnCount);
- float thumbRatio = (float) document.getHeight() / (float)document.getWidth();
- int ivHeight = (int)( ivWidth * thumbRatio);
- if (ivHeight >= parent.getHeight() ){ //TODO remove after GridView lib new release
- ivHeight = parent.getHeight() - (int)Utils.getDimension(R.dimen.common_padding_large);
- }
- iv.setLayoutParams(new ViewGroup.LayoutParams(ivWidth,ivHeight));
- ImageLoader.getInstance().displayImage(document.getPath_thumbnail(), iv);
- return iv;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement