Changes the url for media which are unknown
This commit is contained in:
parent
098da433bd
commit
01fc898c04
|
@ -271,7 +271,7 @@ public class MediaActivity extends AppCompatActivity {
|
||||||
currentAction = action;
|
currentAction = action;
|
||||||
final Attachment attachment = attachments.get(mediaPosition-1);
|
final Attachment attachment = attachments.get(mediaPosition-1);
|
||||||
String type = attachment.getType();
|
String type = attachment.getType();
|
||||||
final String url = attachment.getUrl();
|
String url = attachment.getUrl();
|
||||||
finalUrlDownload = url;
|
finalUrlDownload = url;
|
||||||
videoView.setVisibility(View.GONE);
|
videoView.setVisibility(View.GONE);
|
||||||
if( videoView.isPlaying()) {
|
if( videoView.isPlaying()) {
|
||||||
|
@ -281,13 +281,17 @@ public class MediaActivity extends AppCompatActivity {
|
||||||
preview_url = attachment.getPreview_url();
|
preview_url = attachment.getPreview_url();
|
||||||
if( type.equals("unknown")){
|
if( type.equals("unknown")){
|
||||||
preview_url = attachment.getRemote_url();
|
preview_url = attachment.getRemote_url();
|
||||||
if( preview_url.endsWith(".png") || preview_url.endsWith(".jpg")|| preview_url.endsWith(".jpeg"))
|
if( preview_url.endsWith(".png") || preview_url.endsWith(".jpg")|| preview_url.endsWith(".jpeg")) {
|
||||||
type = "image";
|
type = "image";
|
||||||
if( preview_url.endsWith(".mp4"))
|
}else if( preview_url.endsWith(".mp4")) {
|
||||||
type = "video";
|
type = "video";
|
||||||
|
}
|
||||||
|
url = attachment.getRemote_url();
|
||||||
|
attachment.setType(type);
|
||||||
}
|
}
|
||||||
switch (type){
|
switch (type){
|
||||||
case "image":
|
case "image":
|
||||||
|
final String finalUrl = url;
|
||||||
imageLoader.displayImage(url, imageView, options, new SimpleImageLoadingListener(){
|
imageLoader.displayImage(url, imageView, options, new SimpleImageLoadingListener(){
|
||||||
@Override
|
@Override
|
||||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||||
|
@ -299,7 +303,7 @@ public class MediaActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onLoadingFailed(java.lang.String imageUri, android.view.View view, FailReason failReason){
|
public void onLoadingFailed(java.lang.String imageUri, android.view.View view, FailReason failReason){
|
||||||
imageLoader.displayImage(url, imageView, options);
|
imageLoader.displayImage(finalUrl, imageView, options);
|
||||||
loader.setVisibility(View.GONE);
|
loader.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -336,6 +340,7 @@ public class MediaActivity extends AppCompatActivity {
|
||||||
client.setSSLSocketFactory(mastalabSSLSocketFactory);
|
client.setSSLSocketFactory(mastalabSSLSocketFactory);
|
||||||
client.setUserAgent(USER_AGENT);
|
client.setUserAgent(USER_AGENT);
|
||||||
client.setConnectTimeout(120000); //120s timeout
|
client.setConnectTimeout(120000); //120s timeout
|
||||||
|
final String finalUrl1 = url;
|
||||||
client.get(url, null, new FileAsyncHttpResponseHandler(MediaActivity.this) {
|
client.get(url, null, new FileAsyncHttpResponseHandler(MediaActivity.this) {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(int statusCode, Header[] headers, Throwable throwable, File file) {
|
public void onFailure(int statusCode, Header[] headers, Throwable throwable, File file) {
|
||||||
|
@ -352,7 +357,7 @@ public class MediaActivity extends AppCompatActivity {
|
||||||
public void onSuccess(int statusCode, Header[] headers, File response) {
|
public void onSuccess(int statusCode, Header[] headers, File response) {
|
||||||
File dir = getCacheDir();
|
File dir = getCacheDir();
|
||||||
File from = new File(dir, response.getName());
|
File from = new File(dir, response.getName());
|
||||||
File to = new File(dir, Helper.md5(url) + ".mp4");
|
File to = new File(dir, Helper.md5(finalUrl1) + ".mp4");
|
||||||
if (from.exists())
|
if (from.exists())
|
||||||
//noinspection ResultOfMethodCallIgnored
|
//noinspection ResultOfMethodCallIgnored
|
||||||
from.renameTo(to);
|
from.renameTo(to);
|
||||||
|
|
Loading…
Reference in New Issue