- if (bitmap != null) {\r
- thumbnail = ThumbnailUtils.extractThumbnail(bitmap, px, px);\r
-\r
- // Add thumbnail to cache\r
- addBitmapToCache(imageKey, thumbnail);\r
+ if (file.isDown()){\r
+ Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(\r
+ file.getStoragePath(), px, px);\r
+ \r
+ if (bitmap != null) {\r
+ thumbnail = ThumbnailUtils.extractThumbnail(bitmap, px, px);\r
+ \r
+ // Add thumbnail to cache\r
+ addBitmapToCache(imageKey, thumbnail);\r
+ }\r
+ \r
+ } else {\r
+ // Download thumbnail from server\r
+ // Commented out as maybe changes to client library are needed\r
+ // DefaultHttpClient httpclient = new DefaultHttpClient();\r
+ // try {\r
+ // httpclient.getCredentialsProvider().setCredentials(\r
+ // new AuthScope(mClient.getBaseUri().toString().replace("https://", ""), 443), \r
+ // new UsernamePasswordCredentials(mClient.getCredentials().getUsername(), mClient.getCredentials().getAuthToken()));\r
+ // \r
+ //\r
+ // HttpGet httpget = new HttpGet(mClient.getBaseUri() + "/ocs/v1.php/thumbnail?x=50&y=50&path=" + URLEncoder.encode(file.getRemotePath(), "UTF-8"));\r
+ // HttpResponse response = httpclient.execute(httpget);\r
+ // HttpEntity entity = response.getEntity();\r
+ // \r
+ // if (entity != null) {\r
+ // byte[] bytes = EntityUtils.toByteArray(entity);\r
+ // Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);\r
+ // thumbnail = ThumbnailUtils.extractThumbnail(bitmap, px, px);\r
+ // \r
+ // // Add thumbnail to cache\r
+ // if (thumbnail != null){\r
+ // addBitmapToCache(imageKey, thumbnail);\r
+ // }\r
+ // }\r
+ // } catch(Exception e){\r
+ // e.printStackTrace();\r
+ // }finally {\r
+ // httpclient.getConnectionManager().shutdown();\r
+ // }\r