- Bitmap bmp = BitmapFactory.decodeFile(mFile.getStoragePath(), options);\r
-\r
- if (bmp != null) {\r
- int width = options.outWidth;\r
- int height = options.outHeight;\r
- int scale = 1;\r
- boolean recycle = false;\r
- if (width >= 2048 || height >= 2048) {\r
- scale = (int) (Math.ceil(Math.max(height, width)/2048.));\r
- options.inSampleSize = scale;\r
- recycle = true;\r
- }\r
- Display display = getActivity().getWindowManager().getDefaultDisplay();\r
- Point size = new Point();\r
- int screenwidth;\r
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {\r
- display.getSize(size);\r
- screenwidth = size.x;\r
- } else {\r
- screenwidth = display.getWidth();\r
- }\r
-\r
- Log.e("ASD", "W " + width + " SW " + screenwidth);\r
-\r
- if (width > screenwidth) {\r
- scale = (int) (Math.ceil(Math.max(height, width)/screenwidth));\r
- options.inSampleSize = scale;\r
- recycle = true;\r
- }\r
- \r
-\r
- if (recycle) bmp.recycle();\r
- bmp = BitmapFactory.decodeFile(mFile.getStoragePath(), options);\r
- \r
- }\r
- if (bmp != null) {\r
- preview.setImageBitmap(bmp);\r
- }\r
- }\r
- } catch (OutOfMemoryError e) {\r
- preview.setVisibility(View.INVISIBLE);\r
- Log.e(TAG, "Out of memory occured for file with size " + mFile.getFileLength());\r
- \r
- } catch (NoSuchFieldError e) {\r
- preview.setVisibility(View.INVISIBLE);\r
- Log.e(TAG, "Error from access to unexisting field despite protection " + mFile.getFileLength());\r
- \r
- } catch (Throwable t) {\r
- preview.setVisibility(View.INVISIBLE);\r
- Log.e(TAG, "Unexpected error while creating image preview " + mFile.getFileLength(), t);\r
+ // configure UI for depending upon local state of the file\r
+ if (FileDownloader.isDownloading(mAccount, mFile.getRemotePath()) || FileUploader.isUploading(mAccount, mFile.getRemotePath())) {\r
+ setButtonsForTransferring();\r
+ \r
+ } else if (mFile.isDown()) {\r
+ // Update preview\r
+ if (mFile.getMimetype().startsWith("image/")) {\r
+ BitmapLoader bl = new BitmapLoader();\r
+ bl.execute(new String[]{mFile.getStoragePath()});\r