本文整理汇总了Java中com.hyphenate.chat.EMMessage.setMessageStatusCallback方法的典型用法代码示例。如果您正苦于以下问题:Java EMMessage.setMessageStatusCallback方法的具体用法?Java EMMessage.setMessageStatusCallback怎么用?Java EMMessage.setMessageStatusCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hyphenate.chat.EMMessage
的用法示例。
在下文中一共展示了EMMessage.setMessageStatusCallback方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: downloadVideo
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
* download video file
*/
private void downloadVideo(EMMessage message) {
message.setMessageStatusCallback(new EMCallBack() {
@Override
public void onSuccess() {
runOnUiThread(new Runnable() {
@Override
public void run() {
loadingLayout.setVisibility(View.GONE);
progressBar.setProgress(0);
showLocalVideo(localFilePath);
}
});
}
@Override
public void onProgress(final int progress,String status) {
Log.d("ease", "video progress:" + progress);
runOnUiThread(new Runnable() {
@Override
public void run() {
progressBar.setProgress(progress);
}
});
}
@Override
public void onError(int error, String msg) {
Log.e("###", "offline file transfer error:" + msg);
File file = new File(localFilePath);
if (file.exists()) {
file.delete();
}
}
});
EMClient.getInstance().chatManager().downloadAttachment(message);
}
示例2: onCreate
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ease_activity_show_file);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
final EMMessage message = getIntent().getParcelableExtra("msg");
if (!(message.getBody() instanceof EMFileMessageBody)) {
Toast.makeText(EaseShowNormalFileActivity.this, "Unsupported message body", Toast.LENGTH_SHORT).show();
finish();
return;
}
final File file = new File(((EMFileMessageBody)message.getBody()).getLocalUrl());
message.setMessageStatusCallback(new EMCallBack() {
@Override
public void onSuccess() {
runOnUiThread(new Runnable() {
public void run() {
FileUtils.openFile(file, EaseShowNormalFileActivity.this);
finish();
}
});
}
@Override
public void onError(int code, String error) {
runOnUiThread(new Runnable() {
public void run() {
if(file != null && file.exists()&&file.isFile())
file.delete();
String str4 = getResources().getString(R.string.Failed_to_download_file);
Toast.makeText(EaseShowNormalFileActivity.this, str4+message, Toast.LENGTH_SHORT).show();
finish();
}
});
}
@Override
public void onProgress(final int progress, String status) {
runOnUiThread(new Runnable() {
public void run() {
progressBar.setProgress(progress);
}
});
}
});
EMClient.getInstance().chatManager().downloadAttachment(message);
}
示例3: onCreate
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ease_activity_show_file);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
final EMMessage message = getIntent().getParcelableExtra("msg");
if (!(message.getBody() instanceof EMFileMessageBody)) {
Toast.makeText(EaseShowNormalFileActivity.this, "Unsupported message body", Toast.LENGTH_SHORT).show();
finish();
return;
}
final File file = new File(((EMFileMessageBody)message.getBody()).getLocalUrl());
message.setMessageStatusCallback(new EMCallBack() {
@Override
public void onSuccess() {
runOnUiThread(new Runnable() {
public void run() {
FileUtils.openFile(file,EaseShowNormalFileActivity.this);
finish();
}
});
}
@Override
public void onError(int code, String error) {
runOnUiThread(new Runnable() {
public void run() {
if(file != null && file.exists()&&file.isFile())
file.delete();
String str4 = getResources().getString(R.string.Failed_to_download_file);
Toast.makeText(EaseShowNormalFileActivity.this, str4+message, Toast.LENGTH_SHORT).show();
finish();
}
});
}
@Override
public void onProgress(final int progress, String status) {
runOnUiThread(new Runnable() {
public void run() {
progressBar.setProgress(progress);
}
});
}
});
EMClient.getInstance().chatManager().downloadAttachment(message);
}