List of usage examples for android.content Context CLIPBOARD_SERVICE
String CLIPBOARD_SERVICE
To view the source code for android.content Context CLIPBOARD_SERVICE.
Click Source Link
From source file:com.xuejian.client.lxp.module.toolbox.im.ChatActivity.java
private void setUpView() { activityInstance = this; titleHeaderBar.enableBackKey(true);/*from www . ja v a 2 s . c o m*/ 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.hzx.luoyechat.activity.ChatActivity.java
private void setUpView() { 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 w w w. j a v a2 s.co m*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); Map<String, RobotUser> robotMap = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getRobotList(); if (robotMap != null && robotMap.containsKey(toChatUsername)) { isRobot = true; String nick = robotMap.get(toChatUsername).getNick(); setmyTitle(TextUtils.isEmpty(nick) ? toChatUsername : nick); } else { User user = UserUtils.getUserInfo(toChatUsername); if (user != null) { setToolbarTitle(user.getNick()); } else { setToolbarTitle(toChatUsername); } } } 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"); if (chatType == CHATTYPE_GROUP) { onGroupViewCreation(); } else { onChatRoomViewCreation(); } } // for chatroom type, we only init conversation and create view adapter on success if (chatType != CHATTYPE_CHATROOM) { onConversationInit(); onListViewCreation(); // 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:de.baumann.hhsmoodle.fragmentsMain.FragmentBrowser.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.action_help: helper_main.switchToActivity(getActivity(), FragmentBrowser_Help.class, false); return true; case R.id.action_bookmark: helper_main.switchToActivity(getActivity(), Popup_bookmarks.class, false); return true; case R.id.action_saveBookmark: final Bookmarks_DbAdapter db = new Bookmarks_DbAdapter(getActivity()); db.open();/*from ww w .java 2 s . co m*/ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View dialogView = View.inflate(getActivity(), R.layout.dialog_edit_title, null); final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title); edit_title.setHint(R.string.bookmark_edit_title); edit_title.setText(mWebView.getTitle()); builder.setView(dialogView); builder.setTitle(R.string.bookmark_edit_title); builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); final AlertDialog dialog2 = builder.create(); // Display the custom alert dialog on interface dialog2.show(); helper_main.showKeyboard(getActivity(), edit_title); dialog2.getButton(android.app.AlertDialog.BUTTON_POSITIVE) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Do stuff, possibly set wantToCloseDialog to true then... String inputTag = edit_title.getText().toString().trim(); if (db.isExist(mWebView.getUrl())) { Snackbar.make(edit_title, getString(R.string.toast_newTitle), Snackbar.LENGTH_LONG) .show(); } else { db.insert(inputTag, mWebView.getUrl(), "04", "", createDate()); dialog2.dismiss(); Snackbar.make(mWebView, R.string.bookmark_added, Snackbar.LENGTH_LONG).show(); } } }); return true; case R.id.menu_share_screenshot: screenshot(); if (shareFile.exists()) { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("image/png"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, mWebView.getTitle()); sharingIntent.putExtra(Intent.EXTRA_TEXT, mWebView.getUrl()); Uri bmpUri = Uri.fromFile(shareFile); sharingIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); startActivity(Intent.createChooser(sharingIntent, (getString(R.string.app_share_screenshot)))); } return true; case R.id.menu_save_screenshot: screenshot(); return true; case R.id.menu_share_link: Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, mWebView.getTitle()); sharingIntent.putExtra(Intent.EXTRA_TEXT, mWebView.getUrl()); startActivity(Intent.createChooser(sharingIntent, (getString(R.string.app_share_link)))); return true; case R.id.menu_share_link_browser: String url = mWebView.getUrl(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); getActivity().startActivity(intent); return true; case R.id.menu_share_link_copy: String url2 = mWebView.getUrl(); ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip(ClipData.newPlainText("text", url2)); Snackbar.make(mWebView, R.string.context_linkCopy_toast, Snackbar.LENGTH_LONG).show(); return true; } return false; }
From source file:eu.funceptionapps.convertitall.ui.ConverterInterface.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else {/*from ww w.java 2s.com*/ mDrawerLayout.openDrawer(mDrawerList); } } switch (item.getItemId()) { case R.id.homeAsUp: return true; case R.id.menu_item_copy: EditText edResult = (EditText) findViewById(R.id.ed_unitOut); ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(edResult.getText().toString()); Toast.makeText(this, getResources().getString(R.string.toast_copy_to_clipboard), Toast.LENGTH_SHORT) .show(); break; case R.id.menu_item_favorite: makeFavoriteDialog(); break; case R.id.menu_item_update_currencies: makeUpdateDialog(); break; case R.id.menu_item_settings: Intent intent = new Intent(this, SettingsInterface.class); startActivityForResult(intent, settingsRequestCode); break; case R.id.menu_item_share: if (mShareActionProvider != null) { sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, sharingMsg); sendIntent.setType("text/plain"); mShareActionProvider.setShareIntent(sendIntent); } break; case R.id.menu_item_feedback: Intent feedback = new Intent(); feedback.setAction(Intent.ACTION_SEND); String gmail = getResources().getString(R.string.gmail); String[] recipients = new String[] { gmail, "", }; feedback.putExtra(Intent.EXTRA_EMAIL, recipients); feedback.putExtra(Intent.EXTRA_SUBJECT, "Feedback"); feedback.setType("message/rfc822"); startActivity(feedback); break; } return true; }
From source file:org.ulteo.ovd.AndRdpActivity.java
@Override @TargetApi(Build.VERSION_CODES.HONEYCOMB) protected void onDestroy() { smHandler.unlistenSm();/* w w w. j av a2 s . c o m*/ smHandler.stopStatusPoll(); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(1); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); clipboard.removePrimaryClipChangedListener(clipChangedListener); } super.onDestroy(); }
From source file:com.parttime.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 w w w . jav a2s . c om*/ // chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); // if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); ((TextView) findViewById(R.id.name)).setText(toChatUsername); // 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"); // group = EMGroupManager.getInstance().getGroup(toChatUsername); // ((TextView) findViewById(R.id.name)).setText(group.getGroupName()); // // 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(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); // 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.example.administrator.bazipaipan.chat.huanxin.activity.ChatActivity.java
private void setUpView() { 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 w w w. j av a2 s. co m*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); // Map<String, RobotUser> robotMap = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getRobotList(); if (robotMap != null && robotMap.containsKey(toChatUsername)) { isRobot = true; String nick = robotMap.get(toChatUsername).getNick(); if (!TextUtils.isEmpty(nick)) { ((TextView) findViewById(R.id.name)).setText(nick); } else { ((TextView) findViewById(R.id.name)).setText(toChatUsername); } } else { // UserUtils.setUserNick(toChatUsername, (TextView) findViewById(R.id.name)); } } else { // ? ?groupid ?? 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"); if (chatType == CHATTYPE_GROUP) { onGroupViewCreation(); } else { onChatRoomViewCreation(); } } // for chatroom type, we only init conversation and create view adapter on success if (chatType != CHATTYPE_CHATROOM) { onConversationInit(); onListViewCreation(); // 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.eason.marker.emchat.chatuidemo.activity.ChatActivity.java
private void setUpView() { 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 ww .ja v a2s. c om chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); Map<String, RobotUser> robotMap = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getRobotList(); if (robotMap != null && robotMap.containsKey(toChatUsername)) { isRobot = true; String nick = robotMap.get(toChatUsername).getNick(); if (!TextUtils.isEmpty(nick)) { ((TextView) findViewById(R.id.name)).setText(nick); } else { ((TextView) findViewById(R.id.name)).setText(toChatUsername); } } else { HttpResponseHandler getUserByUsernameHandler = new HttpResponseHandler() { @Override public void getResult() { if (this.resultVO.getStatus() == ErroCode.ERROR_CODE_CORRECT) { User user = (User) this.result; UserUtils.setUserNick(user.getNickname(), (TextView) findViewById(R.id.name)); } } }; HttpRequest.getUserByUserId(toChatUsername, getUserByUsernameHandler); } } 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"); // // if(chatType == CHATTYPE_GROUP){ // onGroupViewCreation(); // }else{ // onChatRoomViewCreation(); // } } // for chatroom type, we only init conversation and create view adapter on success if (chatType != CHATTYPE_CHATROOM) { onConversationInit(); onListViewCreation(); // 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); } } //????ViewGONE if (MainActivity.getInstance() != null) { MenuLeftFragment menuLeftFragment = (MenuLeftFragment) ((MainActivity) MainActivity.getInstance()) .getFragment(IntentUtil.MENU_LEFT_FRAGMENT); menuLeftFragment.setNewMessageRemindView(View.GONE); } }
From source file:com.grass.caishi.cc.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"); // ???// ww w . j a v a2 s . c o m chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); if (toChatUsername.equals("admin")) { ((TextView) findViewById(R.id.name)).setText(""); } else { UserDao userdao = new UserDao(this); User user = userdao.getUser(toChatUsername, false); usernick = getIntent().getStringExtra("nickname"); userlogo = getIntent().getStringExtra("headurl"); if (user == null || CommonUtils.isNullOrEmpty(user.getNick())) { ((TextView) findViewById(R.id.name)).setText(""); } else { ((TextView) findViewById(R.id.name)).setText(user.getNick()); } } } else if (chatType == 0) { // ? toChatUsername = getIntent().getStringExtra("userId"); ((TextView) findViewById(R.id.name)).setText("?"); } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); group = EMGroupManager.getInstance().getGroup(toChatUsername); ((TextView) findViewById(R.id.name)).setText(group.getGroupName()); } 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.INVISIBLE); expressionContainer.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); // ????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.app.khclub.base.easeim.activity.ChatActivity.java
private void setUpView() { 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 ww.j a v a 2 s.com*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); Map<String, RobotUser> robotMap = ((KHHXSDKHelper) HXSDKHelper.getInstance()).getRobotList(); if (robotMap != null && robotMap.containsKey(toChatUsername)) { isRobot = true; String nick = robotMap.get(toChatUsername).getNick(); if (!TextUtils.isEmpty(nick)) { ((TextView) findViewById(R.id.name)).setText(nick); } else { ((TextView) findViewById(R.id.name)).setText(toChatUsername); } } else { UserUtils.setUserNick(toChatUsername, (TextView) findViewById(R.id.name)); } //? if (toChatUsername.equals(KHConst.KH_ROBOT)) { ((TextView) findViewById(R.id.name)) .setText(getString(R.string.personal_official_business_manager)); } } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_resume).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"); if (chatType == CHATTYPE_GROUP) { onGroupViewCreation(); } else { onChatRoomViewCreation(); } } // for chatroom type, we only init conversation and create view adapter on success if (chatType != CHATTYPE_CHATROOM) { onConversationInit(); onListViewCreation(); // 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); } } //???? if (getIntent().hasExtra(ShareContactsActivity.INTENT_CARD_KEY)) { sendText("###card" + getIntent().getStringExtra(ShareContactsActivity.INTENT_CARD_KEY) + "card###"); } }