Search in sources :

Example 1 with HyphenateException

use of com.hyphenate.exceptions.HyphenateException in project SmartCampus by Vegen.

the class EaseChatFilePresenter method onBubbleClick.

@Override
public void onBubbleClick(EMMessage message) {
    EMNormalFileMessageBody fileMessageBody = (EMNormalFileMessageBody) message.getBody();
    String filePath = fileMessageBody.getLocalUrl();
    File file = new File(filePath);
    if (file.exists()) {
        // open files if it exist
        FileUtils.openFile(file, (Activity) getContext());
    } else {
        // download the file
        getContext().startActivity(new Intent(getContext(), EaseShowNormalFileActivity.class).putExtra("msg", message));
    }
    if (message.direct() == EMMessage.Direct.RECEIVE && !message.isAcked() && message.getChatType() == EMMessage.ChatType.Chat) {
        try {
            EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId());
        } catch (HyphenateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
Also used : HyphenateException(com.hyphenate.exceptions.HyphenateException) EMNormalFileMessageBody(com.hyphenate.chat.EMNormalFileMessageBody) Intent(android.content.Intent) File(java.io.File) EaseChatRowFile(com.hyphenate.easeui.widget.chatrow.EaseChatRowFile)

Example 2 with HyphenateException

use of com.hyphenate.exceptions.HyphenateException in project SmartCampus by Vegen.

the class EaseContactListFragment method moveToBlacklist.

/**
 * move user to blacklist
 */
protected void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st1 = getResources().getString(R.string.Is_moved_into_blacklist);
    final String st2 = getResources().getString(R.string.Move_into_blacklist_success);
    final String st3 = getResources().getString(R.string.Move_into_blacklist_failure);
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {

        public void run() {
            try {
                // move to blacklist
                EMClient.getInstance().contactManager().addUserToBlackList(username, false);
                getActivity().runOnUiThread(new Runnable() {

                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2, Toast.LENGTH_SHORT).show();
                        refresh();
                    }
                });
            } catch (HyphenateException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {

                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();
}
Also used : HyphenateException(com.hyphenate.exceptions.HyphenateException) ProgressDialog(android.app.ProgressDialog)

Aggregations

HyphenateException (com.hyphenate.exceptions.HyphenateException)2 ProgressDialog (android.app.ProgressDialog)1 Intent (android.content.Intent)1 EMNormalFileMessageBody (com.hyphenate.chat.EMNormalFileMessageBody)1 EaseChatRowFile (com.hyphenate.easeui.widget.chatrow.EaseChatRowFile)1 File (java.io.File)1