当前位置: 首页>>代码示例>>Java>>正文


Java EMMessage.setMessageStatusCallback方法代码示例

本文整理汇总了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);
}
 
开发者ID:turoDog,项目名称:KTalk,代码行数:43,代码来源:EaseShowVideoActivity.java

示例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);
}
 
开发者ID:turoDog,项目名称:KTalk,代码行数:51,代码来源:EaseShowNormalFileActivity.java

示例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);
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:51,代码来源:EaseShowNormalFileActivity.java


注:本文中的com.hyphenate.chat.EMMessage.setMessageStatusCallback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。