mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Merge pull request #122 from domdomegg/fix-video-thumbnail
Fix video thumbnail
This commit is contained in:
commit
6a43a83601
1 changed files with 26 additions and 10 deletions
|
|
@ -1,8 +1,10 @@
|
||||||
package fr.free.nrw.commons;
|
package fr.free.nrw.commons;
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.*;
|
import android.os.AsyncTask;
|
||||||
import com.nostra13.universalimageloader.core.*;
|
import android.os.Build;
|
||||||
|
|
||||||
|
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||||
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
||||||
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
||||||
|
|
||||||
|
|
@ -13,12 +15,22 @@ import org.w3c.dom.Node;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
import javax.xml.transform.*;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.*;
|
import java.io.IOException;
|
||||||
import java.text.*;
|
import java.io.InputStream;
|
||||||
import java.util.*;
|
import java.io.StringWriter;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.TimeZone;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import javax.xml.transform.TransformerConfigurationException;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import javax.xml.transform.TransformerFactory;
|
||||||
|
import javax.xml.transform.TransformerFactoryConfigurationError;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
public static Date parseMWDate(String mwDate) {
|
public static Date parseMWDate(String mwDate) {
|
||||||
|
|
@ -131,11 +143,15 @@ public class Utils {
|
||||||
public static String makeThumbUrl(String imageUrl, String filename, int width) {
|
public static String makeThumbUrl(String imageUrl, String filename, int width) {
|
||||||
// Ugly Hack!
|
// Ugly Hack!
|
||||||
// Update: OH DEAR GOD WHAT A HORRIBLE HACK I AM SO SORRY
|
// Update: OH DEAR GOD WHAT A HORRIBLE HACK I AM SO SORRY
|
||||||
String thumbUrl = imageUrl.replaceFirst("test/", "test/thumb/").replace("commons/", "commons/thumb/") + "/" + width + "px-" + filename.replaceAll("File:", "").replaceAll(" ", "_");
|
if(imageUrl.endsWith("webm")) {
|
||||||
if(thumbUrl.endsWith("jpg") || thumbUrl.endsWith("png") || thumbUrl.endsWith("jpeg")) {
|
return imageUrl.replaceFirst("test/", "test/thumb/").replace("commons/", "commons/thumb/") + "/" + width + "px--" + filename.replaceAll("File:", "").replaceAll(" ", "_") + ".jpg";
|
||||||
return thumbUrl;
|
|
||||||
} else {
|
} else {
|
||||||
return thumbUrl + ".png";
|
String thumbUrl = imageUrl.replaceFirst("test/", "test/thumb/").replace("commons/", "commons/thumb/") + "/" + width + "px-" + filename.replaceAll("File:", "").replaceAll(" ", "_");
|
||||||
|
if(thumbUrl.endsWith("jpg") || thumbUrl.endsWith("png") || thumbUrl.endsWith("jpeg")) {
|
||||||
|
return thumbUrl;
|
||||||
|
} else {
|
||||||
|
return thumbUrl + ".png";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue