X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/689199a0b54471c4c0311b50197e247bc1d145ec..e9bf119fa40ab59e44e712fc4e0bf49478683fb8:/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java?ds=inline diff --git a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index e3144a4e..68910a28 100644 --- a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -55,6 +55,7 @@ import com.owncloud.android.lib.resources.status.OwnCloudVersion; import com.owncloud.android.ui.adapter.DiskLruImageCache; import com.owncloud.android.utils.BitmapUtils; import com.owncloud.android.utils.DisplayUtils; +import com.owncloud.android.utils.FileStorageUtils; /** * Manager for concurrent access to thumbnails cache. @@ -181,17 +182,16 @@ public class ThumbnailsCacheManager { if (mFile instanceof OCFile) { thumbnail = doOCFileInBackground(); - if (((OCFile) mFile).isVideo()){ + if (((OCFile) mFile).isVideo() && thumbnail != null){ thumbnail = addVideoOverlay(thumbnail); } } else if (mFile instanceof File) { thumbnail = doFileInBackground(); String url = ((File) mFile).getAbsolutePath(); - FileNameMap fileNameMap = URLConnection.getFileNameMap(); - String mMimeType = fileNameMap.getContentTypeFor("file://" + url); + String mMimeType = FileStorageUtils.getMimeTypeFromName(url); - if (mMimeType != null && mMimeType.startsWith("video/")){ + if (mMimeType != null && mMimeType.startsWith("video/") && thumbnail != null){ thumbnail = addVideoOverlay(thumbnail); } //} else { do nothing @@ -383,8 +383,8 @@ public class ThumbnailsCacheManager { R.drawable.view_play); Bitmap resizedPlayButton = Bitmap.createScaledBitmap(playButton, - (int) (thumbnail.getWidth() * 0.6), - (int) (thumbnail.getHeight() * 0.6), true); + (int) (thumbnail.getWidth() * 0.3), + (int) (thumbnail.getHeight() * 0.3), true); Bitmap resultBitmap = Bitmap.createBitmap(thumbnail.getWidth(), thumbnail.getHeight(), @@ -400,8 +400,12 @@ public class ThumbnailsCacheManager { int x3 = 0; int y3 = 0; - double ym = ( ((Math.pow(x3,2) - Math.pow(x1,2) + Math.pow(y3,2) - Math.pow(y1,2)) * (x2 - x1)) - (Math.pow(x2,2) - Math.pow(x1,2) + Math.pow(y2,2) - Math.pow(y1,2)) * (x3 - x1) ) / (2 * ( ((y3 - y1) * (x2 - x1)) - ((y2 - y1) * (x3 - x1)) )); - double xm = ( (Math.pow(x2,2) - Math.pow(x1,2)) + (Math.pow(y2,2) - Math.pow(y1,2)) - (2*ym*(y2 - y1)) ) / (2*(x2 - x1)); + double ym = ( ((Math.pow(x3,2) - Math.pow(x1,2) + Math.pow(y3,2) - Math.pow(y1,2)) * + (x2 - x1)) - (Math.pow(x2,2) - Math.pow(x1,2) + Math.pow(y2,2) - + Math.pow(y1,2)) * (x3 - x1) ) / (2 * ( ((y3 - y1) * (x2 - x1)) - + ((y2 - y1) * (x3 - x1)) )); + double xm = ( (Math.pow(x2,2) - Math.pow(x1,2)) + (Math.pow(y2,2) - Math.pow(y1,2)) - + (2*ym*(y2 - y1)) ) / (2*(x2 - x1)); // offset to top left double ox = - xm; @@ -413,8 +417,8 @@ public class ThumbnailsCacheManager { Paint p = new Paint(); p.setAlpha(230); - c.drawBitmap(resizedPlayButton, (float) ((thumbnail.getWidth() / 2) - ox), - (float) ((thumbnail.getHeight() / 2) + ym), p); + c.drawBitmap(resizedPlayButton, (float) ((thumbnail.getWidth() / 2) + ox), + (float) ((thumbnail.getHeight() / 2) - ym), p); return resultBitmap; }