• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EMContactManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.easemob.chat.EMContactManager的典型用法代码示例。如果您正苦于以下问题:Java EMContactManager类的具体用法?Java EMContactManager怎么用?Java EMContactManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EMContactManager类属于com.easemob.chat包,在下文中一共展示了EMContactManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onCreate

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_black_list);

	listView = (ListView) findViewById(R.id.list);

	List<String> blacklist = null;
	try {
		//获取黑名单
		blacklist = EMContactManager.getInstance().getBlackListUsernames();
	} catch (Exception e) {
		e.printStackTrace();
	}

	// 显示黑名单列表
	if (blacklist != null) {
		Collections.sort(blacklist);
		adapter = new BlacklistAdapater(this, 1, blacklist);
		listView.setAdapter(adapter);
	}

	// 注册上下文菜单
	registerForContextMenu(listView);

}
 
开发者ID:macyuan,项目名称:TAG,代码行数:27,代码来源:BlacklistActivity.java


示例2: handleMessage

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
public void handleMessage(Message msg) {
    int what = msg.what;
    switch (what) {
        case ADD_FRIEND:
            String userid = list.get(msg.arg1).getServno();
            if(userid.equals(App.getInstance().getgUserInfo().getServno())){
                CommonUtil.showToast("不能添加自己为好友");
                return ;
            }
            try {
                EMContactManager.getInstance().addContact(list.get(msg.arg1).getServno(), "");
                CommonUtil.showToast("添加好友请求已发送");
            } catch (EaseMobException e) {
                e.printStackTrace();
            }
            break;
        default:
            break;
    }
}
 
开发者ID:tengbinlive,项目名称:info_demo,代码行数:21,代码来源:AddFriendListHeadersAdapter.java


示例3: handleMessage

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
public void handleMessage(Message msg) {
    dialogDismiss();
    switch (msg.what) {
        case OTHER_DATA:
            loadOtherData((CommonResponse) msg.obj);
            break;
        case FOLLOW_OTHER:
            followOtherData((CommonResponse) msg.obj);
            break;
        case ADD_FRIEND:
            try {
                EMContactManager.getInstance().addContact(otherid, "");
                CommonUtil.showToast("添加好友请求已发送");
            } catch (EaseMobException e) {
                e.printStackTrace();
            } break;
        default:
            break;
    }
}
 
开发者ID:tengbinlive,项目名称:info_demo,代码行数:21,代码来源:UserFansDetailsActivity.java


示例4: onCreate

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.em_activity_black_list);

	listView = (ListView) findViewById(R.id.list);

	// 从本地获取黑名单
	 List<String> blacklist = EMContactManager.getInstance().getBlackListUsernames();

	// 显示黑名单列表
	if (blacklist != null) {
		Collections.sort(blacklist);
		adapter = new BlacklistAdapater(this, 1, blacklist);
		listView.setAdapter(adapter);
	}

	// 注册上下文菜单
	registerForContextMenu(listView);

}
 
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:22,代码来源:BlacklistActivity.java


示例5: onCreate

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_black_list);

	listView = (ListView) findViewById(R.id.list);

	// 从本地获取黑名单
	 List<String> blacklist = EMContactManager.getInstance().getBlackListUsernames();

	// 显示黑名单列表
	if (blacklist != null) {
		Collections.sort(blacklist);
		adapter = new BlacklistAdapater(this, 1, blacklist);
		listView.setAdapter(adapter);
	}

	// 注册上下文菜单
	registerForContextMenu(listView);

}
 
开发者ID:chenjunqian,项目名称:here,代码行数:22,代码来源:BlacklistActivity.java


示例6: init

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
private void init() {     
		// setContactListener监听联系人的变化等
		EMContactManager.getInstance().setContactListener(new MyContactListener());
		// 注册一个监听连接状态的listener
		
		connectionListener = new MyConnectionListener();
		EMChatManager.getInstance().addConnectionListener(connectionListener);
		
		groupChangeListener = new MyGroupChangeListener();
		// 注册群聊相关的listener
        EMGroupManager.getInstance().addGroupChangeListener(groupChangeListener);

		//将主页侧边栏的新消息提示View设为GONE
		if (MainActivity.getInstance()!=null){
			MenuLeftFragment menuLeftFragment = (MenuLeftFragment) ((MainActivity)MainActivity.
					getInstance()).getFragment(IntentUtil.MENU_LEFT_FRAGMENT);
			menuLeftFragment.setNewMessageRemindView(View.GONE);
		}

		//内部测试方法,请忽略
//		registerInternalDebugReceiver();
	}
 
开发者ID:chenjunqian,项目名称:here,代码行数:23,代码来源:EMChatMainActivity.java


示例7: asyncFetchBlackListFromServer

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
static void asyncFetchBlackListFromServer(){
    HXSDKHelper.getInstance().asyncFetchBlackListFromServer(new EMValueCallBack<List<String>>(){

           @Override
           public void onSuccess(List<String> value) {
               EMContactManager.getInstance().saveBlackList(value);
               HXSDKHelper.getInstance().notifyBlackListSyncListener(true);
           }

           @Override
           public void onError(int error, String errorMsg) {
               HXSDKHelper.getInstance().notifyBlackListSyncListener(false);
           }
        
    });
}
 
开发者ID:chenjunqian,项目名称:here,代码行数:17,代码来源:EMChatMainActivity.java


示例8: init

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
private void init() {     
		// setContactListener监听联系人的变化等
		EMContactManager.getInstance().setContactListener(new MyContactListener());
		// 注册一个监听连接状态的listener
		
		connectionListener = new MyConnectionListener();
		EMChatManager.getInstance().addConnectionListener(connectionListener);
		
		groupChangeListener = new MyGroupChangeListener();
		// 注册群聊相关的listener
        EMGroupManager.getInstance().addGroupChangeListener(groupChangeListener);

		//将主页侧边栏的新消息提示View设为GONE
		if (MainActivity.getInstance()!=null){
//			MenuLeftFragment menuLeftFragment = (MenuLeftFragment) ((MainActivity) MainActivity.
//					getInstance()).getFragment(IntentUtil.MENU_LEFT_FRAGMENT);
//			menuLeftFragment.setNewMessageRemindView(View.GONE);
		}

		//内部测试方法,请忽略
//		registerInternalDebugReceiver();
	}
 
开发者ID:chenjunqian,项目名称:here,代码行数:23,代码来源:EMChatMainActivity.java


示例9: onCreate

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.em_activity_black_list);

    listView = (ListView) findViewById(R.id.list);

    // 从本地获取黑名单
    List<String> blacklist = EMContactManager.getInstance().getBlackListUsernames();

    // 显示黑名单列表
    if (blacklist != null) {
        Collections.sort(blacklist);
        adapter = new BlacklistAdapater(this, 1, blacklist);
        listView.setAdapter(adapter);
    }

    // 注册上下文菜单
    registerForContextMenu(listView);

}
 
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:22,代码来源:BlacklistActivity.java


示例10: addUserToBlacklist

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
/**
 * 加入到黑名单
 * 
 * @param username
 */
private void addUserToBlacklist(String username) {
	try {
		EMContactManager.getInstance().addUserToBlackList(username, true);
		Toast.makeText(getApplicationContext(), "移入黑名单成功", 0).show();
	} catch (EaseMobException e) {
		e.printStackTrace();
		Toast.makeText(getApplicationContext(), "移入黑名单失败", 0).show();
	}
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:15,代码来源:ChatActivity.java


示例11: deleteContact

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
/**
 * 删除联系人
 * 
 * @param toDeleteUser
 */
public void deleteContact(final User tobeDeleteUser) {
	final ProgressDialog pd = new ProgressDialog(getActivity());
	pd.setMessage("正在删除...");
	pd.setCanceledOnTouchOutside(false);
	pd.show();
	new Thread(new Runnable() {
		public void run() {
			try {
				EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
				// 删除db和内存中此用户的数据
				UserDao dao = new UserDao(getActivity());
				dao.deleteContact(tobeDeleteUser.getUsername());
				DemoApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
				getActivity().runOnUiThread(new Runnable() {
					public void run() {
						pd.dismiss();
						adapter.remove(tobeDeleteUser);
						adapter.notifyDataSetChanged();

					}
				});
			} catch (final Exception e) {
				getActivity().runOnUiThread(new Runnable() {
					public void run() {
						pd.dismiss();
						Toast.makeText(getActivity(), "删除失败: " + e.getMessage(), 1).show();
					}
				});

			}

		}
	}).start();

}
 
开发者ID:macyuan,项目名称:TAG,代码行数:41,代码来源:ContactlistFragment.java


示例12: moveToBlacklist

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
/**
 * 把user移入到黑名单
 */
private void moveToBlacklist(final String username){
	final ProgressDialog pd = new ProgressDialog(getActivity());
	pd.setMessage("正在移入黑名单...");
	pd.setCanceledOnTouchOutside(false);
	pd.show();
	new Thread(new Runnable() {
		public void run() {
			try {
				//加入到黑名单
				EMContactManager.getInstance().addUserToBlackList(username,true);
				getActivity().runOnUiThread(new Runnable() {
					public void run() {
						pd.dismiss();
						Toast.makeText(getActivity(), "移入黑名单成功", 0).show();
					}
				});
			} catch (EaseMobException e) {
				e.printStackTrace();
				getActivity().runOnUiThread(new Runnable() {
					public void run() {
						pd.dismiss();
						Toast.makeText(getActivity(), "移入黑名单失败", 0).show();
					}
				});
			}
		}
	}).start();
	
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:33,代码来源:ContactlistFragment.java


示例13: removeOutBlacklist

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
/**
 * 移出黑民单
 * 
 * @param tobeRemoveUser
 */
void removeOutBlacklist(final String tobeRemoveUser) {
	try {
		// 移出黑民单
		EMContactManager.getInstance().deleteUserFromBlackList(tobeRemoveUser);
		adapter.remove(tobeRemoveUser);
	} catch (EaseMobException e) {
		e.printStackTrace();
		runOnUiThread(new Runnable() {
			public void run() {
				Toast.makeText(getApplicationContext(), "移出失败", 0).show();
			}
		});
	}
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:20,代码来源:BlacklistActivity.java


示例14: moveToBlacklist

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
/**
 * 把user移入到黑名单
 */
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 {
                //加入到黑名单
                EMContactManager.getInstance().addUserToBlackList(username,false);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2, 0).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, 0).show();
                    }
                });
            }
        }
    }).start();
    
}
 
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:37,代码来源:EaseContactListFragment.java


示例15: getView

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.item_mayknow, parent, false);
        holder = new ViewHolder();
        holder.head = (SelectableRoundedImageView) convertView.findViewById(R.id.head);
        holder.name_tv = (TextView) convertView.findViewById(R.id.name_tv);
        holder.add_tv = (TextView) convertView.findViewById(R.id.add_tv);
        holder.add_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    EMContactManager.getInstance().addContact(list.get(position).getServno(), "");
                    CommonUtil.showToast("添加好友请求已发送");
                } catch (EaseMobException e) {

                }
            }
        });
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    ImageLoader.getInstance().displayImage(list.get(position).getUphoto(), holder.head);
    holder.name_tv.setText(list.get(position).getUalias());
    return convertView;
}
 
开发者ID:tengbinlive,项目名称:info_demo,代码行数:29,代码来源:MayKnowAdapter.java


示例16: registerGroupAndContactListener

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
/**
 * 注册群组和联系人监听,由于logout的时候会被sdk清除掉,再次登录的时候需要再注册一下
 */
public void registerGroupAndContactListener(){
    if(!isGroupAndContactListenerRegisted){
        //注册群组变动监听
        EMGroupManager.getInstance().addGroupChangeListener(new MyGroupChangeListener());
        //注册联系人变动监听
        EMContactManager.getInstance().setContactListener(new MyContactListener());
        isGroupAndContactListenerRegisted = true;
    }
    
}
 
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:14,代码来源:DemoHelper.java


示例17: removeOutBlacklist

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
/**
 * 移出黑民单
 * 
 * @param tobeRemoveUser
 */
void removeOutBlacklist(final String tobeRemoveUser) {
    final ProgressDialog pd = new ProgressDialog(this);
    pd.setMessage(getString(R.string.be_removing));
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
           public void run() {
               try {
                   // 移出黑民单
                   EMContactManager.getInstance().deleteUserFromBlackList(tobeRemoveUser);
                   runOnUiThread(new Runnable() {
                       public void run() {
                           pd.dismiss();
                           adapter.remove(tobeRemoveUser);
                       }
                   });
               } catch (EaseMobException e) {
                   e.printStackTrace();
                   runOnUiThread(new Runnable() {
                       public void run() {
                           pd.dismiss();
                           Toast.makeText(getApplicationContext(), R.string.Removed_from_the_failure, 0).show();
                       }
                   });
               }
           }
       }).start();
}
 
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:34,代码来源:BlacklistActivity.java


示例18: deleteContact

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
/**
 * 删除联系人
 * 
 * @param toDeleteUser
 */
public void deleteContact(final EaseUser tobeDeleteUser) {
	String st1 = getResources().getString(R.string.deleting);
	final String st2 = getResources().getString(R.string.Delete_failed);
	final ProgressDialog pd = new ProgressDialog(getActivity());
	pd.setMessage(st1);
	pd.setCanceledOnTouchOutside(false);
	pd.show();
	new Thread(new Runnable() {
		public void run() {
			try {
				EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
				// 删除db和内存中此用户的数据
				UserDao dao = new UserDao(getActivity());
				dao.deleteContact(tobeDeleteUser.getUsername());
				DemoHelper.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
				getActivity().runOnUiThread(new Runnable() {
					public void run() {
						pd.dismiss();
						contactList.remove(tobeDeleteUser);
						contactListLayout.refresh();

					}
				});
			} catch (final Exception e) {
				getActivity().runOnUiThread(new Runnable() {
					public void run() {
						pd.dismiss();
						Toast.makeText(getActivity(), st2 + e.getMessage(), 1).show();
					}
				});

			}

		}
	}).start();

}
 
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:43,代码来源:ContactListFragment.java


示例19: onSyncComplete

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
@Override
public void onSyncComplete(boolean success) {
    getActivity().runOnUiThread(new Runnable(){

        @Override
        public void run() {
            blackList = EMContactManager.getInstance().getBlackListUsernames();
            refresh();
        }
        
    });
}
 
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:13,代码来源:ContactListFragment.java


示例20: addUserToBlacklist

import com.easemob.chat.EMContactManager; //导入依赖的package包/类
/**
 * 加入到黑名单
 * 
 * @param username
 */
private void addUserToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(this);
       pd.setMessage(getString(R.string.Is_moved_into_blacklist));
       pd.setCanceledOnTouchOutside(false);
       pd.show();
    new Thread(new Runnable() {
           public void run() {
               try {
                   EMContactManager.getInstance().addUserToBlackList(username, false);
                   runOnUiThread(new Runnable() {
                       public void run() {
                           pd.dismiss();
                           Toast.makeText(getApplicationContext(), R.string.Move_into_blacklist_success, 0).show();
                       }
                   });
               } catch (EaseMobException e) {
                   e.printStackTrace();
                   runOnUiThread(new Runnable() {
                       public void run() {
                           pd.dismiss();
                           Toast.makeText(getApplicationContext(), R.string.Move_into_blacklist_failure, 0).show();
                       }
                   });
               }
           }
       }).start();
}
 
开发者ID:Owater,项目名称:school_shop,代码行数:33,代码来源:ChatActivity.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Attributes类代码示例发布时间:2022-05-23
下一篇:
Java NGCCRuntimeEx类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap