Fix download image bug and update linphone

This commit is contained in:
Margaux Clerc 2015-10-07 14:28:35 +02:00
parent cfe67f88a4
commit cd8efc50c3
2 changed files with 29 additions and 23 deletions

View file

@ -136,27 +136,31 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
ImageView imageView = (ImageView) view.findViewById(R.id.image); ImageView imageView = (ImageView) view.findViewById(R.id.image);
String appData = message.getAppData(); String appData = message.getAppData();
if (appData == null || (!LinphoneManager.getInstance().isMessagePending(nativeMessage) && if(appData != null && !LinphoneManager.getInstance().isMessagePending(nativeMessage) &&
!nativeMessage.isOutgoing() && appData.contains(context.getString(R.string.temp_photo_name_with_date).split("%s")[0]))) { !nativeMessage.isOutgoing() && appData.contains(context.getString(R.string.temp_photo_name_with_date).split("%s")[0])){
appData = null;
}
if (appData == null ){
LinphoneManager.addListener(this); LinphoneManager.addListener(this);
download.setVisibility(View.VISIBLE); download.setVisibility(View.VISIBLE);
download.setOnClickListener(new OnClickListener() { download.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
v.setEnabled(false); v.setEnabled(false);
spinner.setVisibility(View.VISIBLE); v.setVisibility(View.GONE);
v.setVisibility(View.GONE); spinner.setVisibility(View.VISIBLE);
String filename = context.getString(R.string.temp_photo_name_with_date).replace("%s", String.valueOf(System.currentTimeMillis())); String filename = context.getString(R.string.temp_photo_name_with_date).replace("%s", String.valueOf(System.currentTimeMillis()));
File file = new File(Environment.getExternalStorageDirectory(), filename); File file = new File(Environment.getExternalStorageDirectory(), filename);
nativeMessage.setListener(LinphoneManager.getInstance()); nativeMessage.setAppData(filename);
nativeMessage.setFileTransferFilepath(file.getPath()); LinphoneManager.getInstance().addDownloadMessagePending(nativeMessage);
nativeMessage.downloadFile(); nativeMessage.setListener(LinphoneManager.getInstance());
nativeMessage.setAppData(filename); nativeMessage.setFileTransferFilepath(file.getPath());
LinphoneManager.getInstance().addDownloadMessagePending(nativeMessage); nativeMessage.downloadFile();
} }
}); });
} else { } else {
if(LinphoneManager.getInstance().isMessagePending(nativeMessage)){ if (LinphoneManager.getInstance().isMessagePending(nativeMessage)) {
LinphoneManager.addListener(this); LinphoneManager.addListener(this);
download.setEnabled(false); download.setEnabled(false);
ProgressBar spinner = (ProgressBar) view.findViewById(R.id.spinner); ProgressBar spinner = (ProgressBar) view.findViewById(R.id.spinner);
@ -165,9 +169,11 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
} else { } else {
LinphoneManager.removeListener(this); LinphoneManager.removeListener(this);
imageView.setVisibility(View.VISIBLE); imageView.setVisibility(View.VISIBLE);
download.setVisibility(View.GONE);
spinner.setVisibility(View.GONE);
loadBitmap(appData, imageView); loadBitmap(appData, imageView);
} }
} }
} else { } else {
TextView msgView = (TextView) view.findViewById(R.id.message); TextView msgView = (TextView) view.findViewById(R.id.message);
if (msgView != null) { if (msgView != null) {

@ -1 +1 @@
Subproject commit 62c627111fe5458b2a11e84117dffdc0d0c18565 Subproject commit 68829aef4d4162fc9e9dcbecc86c6380d9999e39