- // Decode image in background.
- @Override
- protected Bitmap doInBackground(OCFile... params) {
- Bitmap thumbnail = null;
-
- try {
- if (mAccount != null) {
- AccountManager accountMgr = AccountManager.get(MainApp.getAppContext());
-
- mServerVersion = accountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION);
- OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount, MainApp.getAppContext());
- mClient = OwnCloudClientManagerFactory.getDefaultSingleton().
- getClientFor(ocAccount, MainApp.getAppContext());
- }
-
- mFile = params[0];
- final String imageKey = String.valueOf(mFile.getRemoteId());
-
- // Check disk cache in background thread
- thumbnail = getBitmapFromDiskCache(imageKey);
-
- // Not found in disk cache
- if (thumbnail == null || mFile.needsUpdateThumbnail()) {
- // Converts dp to pixel
- Resources r = MainApp.getAppContext().getResources();
-
- int px = (int) Math.round(r.getDimension(R.dimen.file_icon_size));
-
- if (mFile.isDown()){
- Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(
- mFile.getStoragePath(), px, px);
-
- if (bitmap != null) {
- thumbnail = ThumbnailUtils.extractThumbnail(bitmap, px, px);
-
- // Rotate image, obeying exif tag
- thumbnail = BitmapUtils.rotateImage(thumbnail, mFile.getStoragePath());
-
- // Add thumbnail to cache
- addBitmapToCache(imageKey, thumbnail);
+ /**
+ * Converts size of file icon from dp to pixel
+ * @return int
+ */
+ private int getThumbnailDimension(){
+ // Converts dp to pixel
+ Resources r = MainApp.getAppContext().getResources();
+ return Math.round(r.getDimension(R.dimen.file_icon_size_grid));
+ }