List of usage examples for android.content IntentFilter setPriority
public final void setPriority(int priority)
From source file:com.hx.hxchat.activity.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???//from ww w . j a v a2 s. com chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); toChatUserNick = getIntent().getStringExtra("userName"); /* userId10000??????????? */ if (getIntent().getStringExtra("userId").equals("10000")) { rl_bottom.setVisibility(View.GONE); } // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,false); } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.rl_setting).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); findViewById(R.id.container_video_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); group = EMGroupManager.getInstance().getGroup(toChatUsername); if (group != null) ((TextView) findViewById(R.id.name)).setText(group.getGroupName()); else ((TextView) findViewById(R.id.name)).setText(toChatUsername); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnreadMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(9); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:com.xuejian.client.lxp.module.toolbox.im.ChatActivity.java
private void setUpView() { activityInstance = this; titleHeaderBar.enableBackKey(true);// www. j a v a2 s . c om findViewById(R.id.ly_title_bar_left).setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(ChatActivity.this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivityWithNoAnim(intent); overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right); } }); iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ??? chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); toChatUser = AccountManager.getInstance().getContactList(mContext).get(toChatUsername); if (toChatUser == null) { finish(); } titleHeaderBar.getTitleTextView().setText(toChatUser.getNick()); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,false); } else { // ? toChatUsername = getIntent().getStringExtra("groupId"); titleHeaderBar.setRightViewImageRes(R.drawable.ic_more); group = EMGroupManager.getInstance().getGroup(toChatUsername); if (group != null) { titleHeaderBar.getTitleTextView().setText(group.getGroupName()); } Fragment fragment = new GroupDetailFragment(); Bundle args = new Bundle(); args.putString("groupId", toChatUsername); fragment.setArguments(args); // FragmentActivity??Fragment FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.menu_frame, fragment).commit(); titleHeaderBar.setRightOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Intent intent = new Intent(mContext,GroupDetailsActivity.class); // intent.putExtra("groupId",toChatUsername); // startActivity(intent); //END?gravity.right ?? START?left ?? if (drawerLayout.isDrawerVisible(GravityCompat.END)) { drawerLayout.closeDrawer(GravityCompat.END);// } else { drawerLayout.openDrawer(GravityCompat.END);// } } }); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnsetMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.GONE); expressionContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // cmd?BroadcastReceiver IntentFilter cmdIntentFilter = new IntentFilter(EMChatManager.getInstance().getCmdMessageBroadcastAction()); cmdIntentFilter.setPriority(3); mContext.registerReceiver(cmdMessageReceiver, cmdIntentFilter); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:com.liangxun.university.huanxin.chat.activity.ChatActivity.java
public void setUpView2() { conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0/*from w w w. ja v a2 s . c o m*/ conversation.resetUnreadMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType, toChatUser, getMyApp().getImageLoader()); adapter.setOnClickContentItemListener(this); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:cn.kangeqiu.kq.activity.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); roomId = getIntent().getStringExtra("roomId"); // ???// w w w .ja v a 2 s . c o m chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? findViewById(R.id.container_dadu).setVisibility(View.GONE); findViewById(R.id.container_jingcai).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("userId"); String nickname = getIntent().getStringExtra("nickname"); ((TextView) findViewById(R.id.name)).setText(nickname); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,false); } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); findViewById(R.id.container_video_call).setVisibility(View.GONE); findViewById(R.id.container_file).setVisibility(View.GONE); // findViewById(R.id.container_photo).setVisibility(View.GONE); findViewById(R.id.container_location).setVisibility(View.GONE); findViewById(R.id.container_video).setVisibility(View.GONE); findViewById(R.id.score_lay).setVisibility(View.VISIBLE); toChatUsername = getIntent().getStringExtra("groupId"); group = EMGroupManager.getInstance().getGroup(toChatUsername); ((TextView) findViewById(R.id.name)).setText(group.getGroupName()); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); doPullDate("2061", new MCHttpCallBack() { @Override public void onSuccess(MCHttpResp resp) { super.onSuccess(resp); try { String resultCode = resp.getJson().getString("result_code"); if (resultCode.equals("0")) { match = resp.getJson().getJSONObject("match"); loader.LoadImage( resp.getJson().getJSONObject("match").getJSONObject("team1").getString("icon"), team_icon1); loader.LoadImage( resp.getJson().getJSONObject("match").getJSONObject("team2").getString("icon"), team_icon2); score_textView.setText( resp.getJson().getJSONObject("match").getJSONObject("team1").getString("score") + ":" + resp.getJson().getJSONObject("match").getJSONObject("team2") .getString("score")); String stateStr = ""; String stateJson = resp.getJson().getJSONObject("match").getString("state"); if (stateJson.equals("0")) { stateStr = ""; } else if (stateJson.equals("1")) { stateStr = ""; } else if (stateJson.equals("2")) { stateStr = "?"; } tv_state.setText(stateStr); // private CircleImageView team_icon1, team_icon2; // private TextView tv_state, score_textView; } else { Toast.makeText(getApplicationContext(), resp.getJson().getString("message"), Toast.LENGTH_SHORT).show(); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void onError(MCHttpResp resp) { super.onError(resp); } }); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnreadMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:com.liangxun.yuejiula.huanxin.chat.activity.ChatActivity.java
public void setUpView2() { conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0//www. j a v a 2 s. c om conversation.resetUnreadMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType, toChatUser, getMyApp().getImageLoader()); adapter.setOnClickContentItemListener(this); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ???T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:com.wemolian.app.wml.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???//w w w . j a v a 2s.c o m chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); // type=getIntent().getIntExtra("type", 0); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra(LocalDBKey.CONTACTS_COLUMN_NAME_HXID); String toChatUserCName = getIntent().getStringExtra(LocalDBKey.CONTACTS_COLUMN_NAME_USERCNAME); ((TextView) findViewById(R.id.name)).setText(toChatUserCName); toUserCName = getIntent().getStringExtra(LocalDBKey.CONTACTS_COLUMN_NAME_USERCNAME); toUserImgName = getIntent().getStringExtra(LocalDBKey.CONTACTS_COLUMN_NAME_IMGNAME); } else { findViewById(R.id.container_voice_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupHxId"); groupId = getIntent().getStringExtra("groupId"); groupName = getIntent().getStringExtra("groupName"); ((TextView) findViewById(R.id.name)).setText(groupName); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnreadMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType); // // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } iv_setting = (ImageView) this.findViewById(R.id.iv_setting); iv_setting_group = (ImageView) this.findViewById(R.id.iv_setting_group); if (chatType == CHATTYPE_SINGLE) { iv_setting.setVisibility(View.VISIBLE); iv_setting_group.setVisibility(View.GONE); iv_setting.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub startActivity( new Intent(ChatActivity.this, ChatSingleSettingActivity.class).putExtra("userId", toChatUsername)); } }); } else { iv_setting.setVisibility(View.GONE); iv_setting_group.setVisibility(View.VISIBLE); iv_setting_group.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivityForResult((new Intent(ChatActivity.this, ChatRoomSettingActivity.class) .putExtra("groupHxId", toChatUsername).putExtra("groupId", groupId) .putExtra("groupName", groupName)), REQUEST_CODE_GROUP_DETAIL); } }); } }
From source file:com.parttime.IM.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); btnMore.setOnClickListener(this); nameVeiw = (TextView) findViewById(R.id.name); memberNum = (TextView) findViewById(R.id.number); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???/* w w w .j a v a 2s . co m*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); //chatBottomBarHelper = new ChatBottomBarHelper(this); if (toChatUsername != null && !"".equals(toChatUsername)) { if (ApplicationConstants.JZDR.equals(toChatUsername)) { sp.saveSharedPreferences(ApplicationConstants.JZDR + "realname", "?"); } else if (ApplicationConstants.CAIWU.equals(toChatUsername)) { sp.saveSharedPreferences(ApplicationConstants.CAIWU + "realname", "?"); } else if (ApplicationConstants.DINGYUE.equals(toChatUsername)) { sp.saveSharedPreferences(ApplicationConstants.DINGYUE + "realname", "?"); } else if (ApplicationConstants.KEFU.equals(toChatUsername)) { sp.saveSharedPreferences(ApplicationConstants.KEFU + "realname", "??"); chatBottomBarHelper = new ChatBottomBarHelper(this); } else if (ApplicationConstants.TONGZHI.equals(toChatUsername)) { sp.saveSharedPreferences(ApplicationConstants.TONGZHI + "realname", ""); } } // ?? // ???,??? String chatName = sp.loadStringSharedPreference(toChatUsername + "realname", ""); if (!"".equals(chatName)) { nameVeiw.setText(chatName); } else { getNick(toChatUsername, nameVeiw); } } else { // ? findViewById(R.id.container_right2_image).setVisibility(View.VISIBLE); findViewById(R.id.container_group_notice).setVisibility(View.VISIBLE); findViewById(R.id.container_contact_detail).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); group = EMGroupManager.getInstance().getGroup(toChatUsername); new Thread(new Runnable() { @Override public void run() { try { EMGroup returnGroup = EMGroupManager.getInstance().getGroupFromServer(toChatUsername); // ? EMGroupManager.getInstance().createOrUpdateLocalGroup(returnGroup); if (group != null) { setGroupChatTitle(); } } catch (Exception ignore) { } } }).start(); if (group != null) { setGroupChatTitle(); } // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnreadMsgCount(); // 2015-4-7? // ************************************************************** // ?db?conversationgetChatOptions().getNumberOfMessagesLoaded // ??? final List<EMMessage> msgs = conversation.getAllMessages(); int msgCount = msgs != null ? msgs.size() : 0; if (msgCount < conversation.getAllMsgCount() && msgCount < pagesize) { String msgId = null; if (msgs != null && msgs.size() > 0) { msgId = msgs.get(0).getMsgId(); } if (chatType == CHATTYPE_SINGLE) { conversation.loadMoreMsgFromDB(msgId, pagesize); } else { conversation.loadMoreGroupMsgFromDB(msgId, pagesize); } } // ************************************************************** adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); // ==================?================== listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EMConversation conversation = adapter.getEMConversationItem(); String username = conversation.getUserName(); if (username.equals(ApplicationControl.getInstance().getUserName())) Toast.makeText(ChatActivity.this, "", Toast.LENGTH_SHORT).show(); else { // Intent intent = new Intent(ChatActivity.this, UserInfo.class); // startActivity(intent); } } }); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); moreGone(); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:com.hanyu.desheng.activity.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???//from www . j a v a 2 s . co m chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); String username = getIntent().getStringExtra("username"); if (username != null) { if (username.length() < 7) { ((TextView) findViewById(R.id.name)).setText(username); } else { ((TextView) findViewById(R.id.name)).setText(username.substring(0, 7) + "..."); } } else { Gson gson = new Gson(); List<String> userList = new ArrayList<String>(); userList.add(toChatUsername); final String uns = gson.toJson(userList); new HttpTask<Void, Void, String>(ChatActivity.this) { // private AlertDialog errorDialog; @Override protected String doInBackground(Void... params) { return EngineManager.getUserEngine().toGetHxUser(uns); } @Override protected void onPostExecute(String result) { if (result != null) { LogUtils.e(getClass(), "result:" + result); ChatBean chatBean = GsonUtils.json2Bean(result, ChatBean.class); if (chatBean != null && chatBean.code == 0) { String username = chatBean.data.info_list.get(0).miname; if (username.length() < 7) { ((TextView) findViewById(R.id.name)).setText(username); } else { ((TextView) findViewById(R.id.name)).setText(username.substring(0, 7) + "..."); } } else { } } } @Override protected void onPreExecute() { } }.executeProxy(); } // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,false); } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); findViewById(R.id.container_video_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); ISCANCHAT = GroupDao.getGroup(toChatUsername, ExampleApplication.getInstance().getUserName()); if (!ISCANCHAT) { CountDown cd = new CountDown(5000, 1000); cd.start(); } group = EMGroupManager.getInstance().getGroup(toChatUsername); new Thread() { public void run() { try { String checkUserChat = EngineManager.getUserEngine().checkUserChat( ExampleApplication.getInstance().getUserName(), getIntent().getStringExtra("groupId")); JSONObject jsonObject = new JSONObject(checkUserChat); JSONObject jsonObject2 = jsonObject.getJSONObject("data"); String isSilence = jsonObject2.getString("is_silence"); if (isSilence.equals("1")) { runOnUiThread(new Runnable() { @Override public void run() { // ? mEditTextContent.setHint("?"); mEditTextContent.setEnabled(false); buttonPressToSpeak.setEnabled(false); } }); } } catch (Exception e) { e.printStackTrace(); } }; }.start(); // ? registerBandListener(); if (group != null) { if (group.getGroupName().length() < 7) { ((TextView) findViewById(R.id.name)) .setText(group.getGroupName() + "(" + group.getAffiliationsCount() + ")"); } else { ((TextView) findViewById(R.id.name)).setText( group.getGroupName().substring(0, 7) + "...(" + group.getAffiliationsCount() + ")"); } } else ((TextView) findViewById(R.id.name)).setText(toChatUsername); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnreadMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); //EMChatManager.getInstance().getChatOptions().setShowNotificationInBackgroud(false); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:com.ieeton.agency.activity.ChatActivity.java
private void setUpView() { activityInstance = this; Intent intent = getIntent();/*from www . j a v a 2s .c om*/ if (intent == null) { return; } mChatUser = (ChatUser) intent.getExtras().getSerializable(EXTRA_USERINFO); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ??? chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = intent.getStringExtra(EXTRA_USERID); String nick = ""; if (mChatUser != null) { nick = mChatUser.getName(); } else if (!TextUtils.isEmpty(Utils.getNickCache(this, toChatUsername))) { nick = Utils.getNickCache(this, toChatUsername); } else { nick = getString(R.string.default_nick); } if (toChatUsername.equals(NetEngine.getFeedbackId())) { mTitleName.setText(getString(R.string.xiaomishu)); } else { mTitleName.setText(nick); } } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); group = EMGroupManager.getInstance().getGroup(toChatUsername); mTitleName.setText(group.getGroupName()); } if (mChatUser == null) { new FetchInfoTask().execute(MODE_HUANXIN); } else { if (ChatUser.USER_DOCTOR.equals(mChatUser.getType())) { new FetchInfoTask().execute(MODE_DOCTOR); } else if (ChatUser.USER_PATIENT.equals(mChatUser.getType())) { new FetchInfoTask().execute(MODE_PATIENT); } } if (toChatUsername.equals(NetEngine.getFeedbackId())) { mBtnCall.setVisibility(View.VISIBLE); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnsetMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType, new MessageAdapter.HeaderClickListener() { @Override public void click(int id) { if (id == CLICK_LEFT) { if (mUser == null) { return; } //? if (mUser.getUserType() == UserInfo.ACCOUNT_DOCTOR) { return; } Intent intent = new Intent(ChatActivity.this, PatientProfileActivity.class); intent.putExtra(PatientProfileActivity.EXTRA_USERID, toChatUsername); startActivity(intent); } else { Intent intent = new Intent(ChatActivity.this, MainActivity.class); intent.putExtra(MainActivity.INPUT_INDEX, MainActivity.INPUT_SETTING); startActivity(intent); } } }); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); //iv_emoticons_normal.setVisibility(View.VISIBLE); //iv_emoticons_checked.setVisibility(View.INVISIBLE); expressionContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); if (toChatUsername.equals(NetEngine.getFeedbackId()) && conversation.getMsgCount() <= 0) { //??? boolean notificationOn = EMChatManager.getInstance().getChatOptions().getNotificationEnable(); boolean soundOn = EMChatManager.getInstance().getChatOptions().getNoticedBySound(); boolean vibrateOn = EMChatManager.getInstance().getChatOptions().getNoticedByVibrate(); if (notificationOn && soundOn) { mSoundID = initSoundPool(); mSoundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() { @Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { playSound(); } }); } if (notificationOn && vibrateOn) { mVibrator = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE); playVibrator(); } EMMessage message = EMMessage.createSendMessage(EMMessage.Type.TXT); String msgID = message.getMsgId(); message.setMsgId("ieeton" + msgID); String content = getString(R.string.mishu_begin_conversation); TextMessageBody txtBody = new TextMessageBody(content); message.addBody(txtBody); message.setFrom(toChatUsername); message.setTo(DemoApplication.getInstance().getUserName()); message.direct = EMMessage.Direct.RECEIVE; conversation.addMessage(message); EMChatManager.getInstance().saveMessage(message); adapter.refresh(); } // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:com.fullteem.yueba.app.ui.ChatActivity.java
private void setUpView() { // popwindow// w w w .j a v a2 s. c o m menuTexts = getResources().getStringArray(R.array.msgmenu); activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ??? chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? // ?? Map<String, User> users = appContext.getContactList(); toChatUsername = getIntent().getStringExtra("userId");// bug bill.// should be// imServerId if (null == toChatUsername) { return; } userNickName = getIntent().getStringExtra("nickname"); getUserTokenByAccount(toChatUsername); ImageUrl = getIntent().getStringExtra("imgurl"); List<String> blackList = EMContactManager.getInstance().getBlackListUsernames(); for (String key : users.keySet()) { // ?????? if (null != toChatUsername && toChatUsername.equalsIgnoreCase(key)// debug to be // null! && !blackList.contains(key)) { menuTexts = getResources().getStringArray(R.array.msgmenu_friend); } } ((TextView) findViewById(R.id.name)).setText(userNickName); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,false); } else { // ? // findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); System.out.println("toChatUsername" + toChatUsername); group = EMGroupManager.getInstance().getGroup(toChatUsername); menuTexts = getResources().getStringArray(R.array.msgmenu_group); if (group == null) { ((TextView) findViewById(R.id.name)).setText(""); } else { ((TextView) findViewById(R.id.name)).setText(group.getGroupName()); } // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnsetMsgCount(); adapter = new MessageAdapter(this, toChatUsername, ImageUrl, chatType); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }