From 6ec464ead704730a4bf34c7cce725b19c78dfff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=8C?= Date: Sun, 12 Jun 2016 00:25:04 +0800 Subject: [PATCH] add the voice send --- .../java/cn/bmob/imdemo/ui/ChatActivity.java | 634 +----------------- .../java/cn/bmob/imdemo/ui/LocActivity.java | 191 ++++++ .../java/cn/bmob/imdemo/ui/MainActivity.java | 33 +- .../imdemo/ui/fragment/ContactFragment.java | 4 +- app/src/main/res/layout/activity_chat.xml | 6 +- app/src/main/res/layout/activity_loc.xml | 46 +- app/src/main/res/layout/activity_main.xml | 35 - app/src/main/res/layout/activity_splash.xml | 1 + .../res/layout/include_chat_bottom_bar.xml | 66 +- app/src/main/res/values/colors.xml | 2 +- 10 files changed, 259 insertions(+), 759 deletions(-) diff --git a/app/src/main/java/cn/bmob/imdemo/ui/ChatActivity.java b/app/src/main/java/cn/bmob/imdemo/ui/ChatActivity.java index cd54378..9c685d2 100755 --- a/app/src/main/java/cn/bmob/imdemo/ui/ChatActivity.java +++ b/app/src/main/java/cn/bmob/imdemo/ui/ChatActivity.java @@ -1,5 +1,6 @@ package cn.bmob.imdemo.ui; +import android.app.Activity; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Bundle; @@ -63,643 +64,12 @@ import cn.bmob.v3.exception.BmobException; * @project:ChatActivity * @date :2016-01-25-18:23 */ -public class ChatActivity extends ParentWithNaviActivity implements ObseverListener,MessageListHandler{ +public class ChatActivity extends Activity { - @Bind(R.id.ll_chat) - LinearLayout ll_chat; - @Bind(R.id.sw_refresh) - SwipeRefreshLayout sw_refresh; - - @Bind(R.id.rc_view) - RecyclerView rc_view; - - @Bind(R.id.edit_msg) - EditText edit_msg; - - @Bind(R.id.btn_chat_add) - Button btn_chat_add; - @Bind(R.id.btn_chat_emo) - Button btn_chat_emo; - @Bind(R.id.btn_speak) - Button btn_speak; - @Bind(R.id.btn_chat_voice) - Button btn_chat_voice; - @Bind(R.id.btn_chat_keyboard) - Button btn_chat_keyboard; - @Bind(R.id.btn_chat_send) - Button btn_chat_send; - - @Bind(R.id.layout_more) - LinearLayout layout_more; - @Bind(R.id.layout_add) - LinearLayout layout_add; - @Bind(R.id.layout_emo) - LinearLayout layout_emo; - - // 语音有关 - @Bind(R.id.layout_record) - RelativeLayout layout_record; - @Bind(R.id.tv_voice_tips) - TextView tv_voice_tips; - @Bind(R.id.iv_record) - ImageView iv_record; - private Drawable[] drawable_Anims;// 话筒动画 - BmobRecordManager recordManager; - - ChatAdapter adapter; - protected LinearLayoutManager layoutManager; - BmobIMConversation c; - - @Override - protected String title() { - return c.getConversationTitle(); - } - - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_chat); - c= BmobIMConversation.obtain(BmobIMClient.getInstance(), (BmobIMConversation) getBundle().getSerializable("c")); - initNaviView(); - initSwipeLayout(); - initVoiceView(); - initBottomView(); - } - - private void initSwipeLayout(){ - sw_refresh.setEnabled(true); - layoutManager = new LinearLayoutManager(this); - rc_view.setLayoutManager(layoutManager); - adapter = new ChatAdapter(this,c); - rc_view.setAdapter(adapter); - ll_chat.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - ll_chat.getViewTreeObserver().removeGlobalOnLayoutListener(this); - sw_refresh.setRefreshing(true); - //自动刷新 - queryMessages(null); - } - }); - //下拉加载 - sw_refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { - @Override - public void onRefresh() { - BmobIMMessage msg = adapter.getFirstMessage(); - queryMessages(msg); - } - }); - //设置RecyclerView的点击事件 - adapter.setOnRecyclerViewListener(new OnRecyclerViewListener() { - @Override - public void onItemClick(int position) { - Logger.i(""+position); - } - - @Override - public boolean onItemLongClick(int position) { - //这里省了个懒,直接长按就删除了该消息 - c.deleteMessage(adapter.getItem(position)); - adapter.remove(position); - return true; - } - }); - } - - private void initBottomView(){ - edit_msg.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - if(event.getAction()==MotionEvent.ACTION_DOWN||event.getAction()==MotionEvent.ACTION_UP){ - scrollToBottom(); - } - return false; - } - }); - edit_msg.addTextChangedListener(new TextWatcher() { - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - scrollToBottom(); - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - if (!TextUtils.isEmpty(s)) { - btn_chat_send.setVisibility(View.VISIBLE); - btn_chat_keyboard.setVisibility(View.GONE); - btn_chat_voice.setVisibility(View.GONE); - } else { - if (btn_chat_voice.getVisibility() != View.VISIBLE) { - btn_chat_voice.setVisibility(View.VISIBLE); - btn_chat_send.setVisibility(View.GONE); - btn_chat_keyboard.setVisibility(View.GONE); - } - } - } - - @Override - public void afterTextChanged(Editable s) { - } - }); - } - - /** - * 初始化语音布局 - * @param - * @return void - */ - private void initVoiceView() { - btn_speak.setOnTouchListener(new VoiceTouchListener()); - initVoiceAnimRes(); - initRecordManager(); - } - - /** - * 初始化语音动画资源 - * @Title: initVoiceAnimRes - * @param - * @return void - */ - private void initVoiceAnimRes() { - drawable_Anims = new Drawable[] { - getResources().getDrawable(R.mipmap.chat_icon_voice2), - getResources().getDrawable(R.mipmap.chat_icon_voice3), - getResources().getDrawable(R.mipmap.chat_icon_voice4), - getResources().getDrawable(R.mipmap.chat_icon_voice5), - getResources().getDrawable(R.mipmap.chat_icon_voice6) }; - } - - private void initRecordManager(){ - // 语音相关管理器 - recordManager = BmobRecordManager.getInstance(this); - // 设置音量大小监听--在这里开发者可以自己实现:当剩余10秒情况下的给用户的提示,类似微信的语音那样 - recordManager.setOnRecordChangeListener(new OnRecordChangeListener() { - - @Override - public void onVolumnChanged(int value) { - iv_record.setImageDrawable(drawable_Anims[value]); - } - - @Override - public void onTimeChanged(int recordTime, String localPath) { - Logger.i("voice", "已录音长度:" + recordTime); - if (recordTime >= BmobRecordManager.MAX_RECORD_TIME) {// 1分钟结束,发送消息 - // 需要重置按钮 - btn_speak.setPressed(false); - btn_speak.setClickable(false); - // 取消录音框 - layout_record.setVisibility(View.INVISIBLE); - // 发送语音消息 - sendVoiceMessage(localPath, recordTime); - //是为了防止过了录音时间后,会多发一条语音出去的情况。 - new Handler().postDelayed(new Runnable() { - - @Override - public void run() { - btn_speak.setClickable(true); - } - }, 1000); - } - } - }); - } - - /** - * 长按说话 - * @author smile - * @date 2014-7-1 下午6:10:16 - */ - class VoiceTouchListener implements View.OnTouchListener { - @Override - public boolean onTouch(View v, MotionEvent event) { - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - if (!Util.checkSdCard()) { - toast("发送语音需要sdcard支持!"); - return false; - } - try { - v.setPressed(true); - layout_record.setVisibility(View.VISIBLE); - tv_voice_tips.setText(getString(R.string.voice_cancel_tips)); - // 开始录音 - recordManager.startRecording(c.getConversationId()); - } catch (Exception e) { - e.printStackTrace(); - } - return true; - case MotionEvent.ACTION_MOVE: { - if (event.getY() < 0) { - tv_voice_tips.setText(getString(R.string.voice_cancel_tips)); - tv_voice_tips.setTextColor(Color.RED); - } else { - tv_voice_tips.setText(getString(R.string.voice_up_tips)); - tv_voice_tips.setTextColor(Color.WHITE); - } - return true; - } - case MotionEvent.ACTION_UP: - v.setPressed(false); - layout_record.setVisibility(View.INVISIBLE); - try { - if (event.getY() < 0) {// 放弃录音 - recordManager.cancelRecording(); - Logger.i("voice", "放弃发送语音"); - } else { - int recordTime = recordManager.stopRecording(); - if (recordTime > 1) { - // 发送语音文件 - sendVoiceMessage(recordManager.getRecordFilePath(c.getConversationId()),recordTime); - } else {// 录音时间过短,则提示录音过短的提示 - layout_record.setVisibility(View.GONE); - showShortToast().show(); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - return true; - default: - return false; - } - } - } - - Toast toast; - - /** - * 显示录音时间过短的Toast - * @Title: showShortToast - * @return void - */ - private Toast showShortToast() { - if (toast == null) { - toast = new Toast(this); - } - View view = LayoutInflater.from(this).inflate( - R.layout.include_chat_voice_short, null); - toast.setView(view); - toast.setGravity(Gravity.CENTER, 0, 0); - toast.setDuration(Toast.LENGTH_SHORT); - return toast; - } - - @OnClick(R.id.edit_msg) - public void onEditClick(View view){ - if (layout_more.getVisibility() == View.VISIBLE) { - layout_add.setVisibility(View.GONE); - layout_emo.setVisibility(View.GONE); - layout_more.setVisibility(View.GONE); - } - } - - @OnClick(R.id.btn_chat_emo) - public void onEmoClick(View view){ - if (layout_more.getVisibility() == View.GONE) { - showEditState(true); - } else { - if (layout_add.getVisibility() == View.VISIBLE) { - layout_add.setVisibility(View.GONE); - layout_emo.setVisibility(View.VISIBLE); - } else { - layout_more.setVisibility(View.GONE); - } - } - } - - @OnClick(R.id.btn_chat_add) - public void onAddClick(View view){ - if (layout_more.getVisibility() == View.GONE) { - layout_more.setVisibility(View.VISIBLE); - layout_add.setVisibility(View.VISIBLE); - layout_emo.setVisibility(View.GONE); - hideSoftInputView(); - } else { - if (layout_emo.getVisibility() == View.VISIBLE) { - layout_emo.setVisibility(View.GONE); - layout_add.setVisibility(View.VISIBLE); - } else { - layout_more.setVisibility(View.GONE); - } - } - } - @OnClick(R.id.btn_chat_voice) - public void onVoiceClick(View view){ - edit_msg.setVisibility(View.GONE); - layout_more.setVisibility(View.GONE); - btn_chat_voice.setVisibility(View.GONE); - btn_chat_keyboard.setVisibility(View.VISIBLE); - btn_speak.setVisibility(View.VISIBLE); - hideSoftInputView(); - } - - @OnClick(R.id.btn_chat_keyboard) - public void onKeyClick(View view){ - showEditState(false); - } - - @OnClick(R.id.btn_chat_send) - public void onSendClick(View view){ - sendMessage(); - } - - @OnClick(R.id.tv_picture) - public void onPictureClick(View view){ -// sendLocalImageMessage(); -// sendOtherMessage(); - sendVideoMessage(); - } - @OnClick(R.id.tv_camera) - public void onCameraClick(View view){ - sendRemoteImageMessage(); - } - - @OnClick(R.id.tv_location) - public void onLocationClick(View view){ - sendLocationMessage(); - } - - /** - * 根据是否点击笑脸来显示文本输入框的状态 - * @param isEmo 用于区分文字和表情 - * @return void - */ - private void showEditState(boolean isEmo) { - edit_msg.setVisibility(View.VISIBLE); - btn_chat_keyboard.setVisibility(View.GONE); - btn_chat_voice.setVisibility(View.VISIBLE); - btn_speak.setVisibility(View.GONE); - edit_msg.requestFocus(); - if (isEmo) { - layout_more.setVisibility(View.VISIBLE); - layout_more.setVisibility(View.VISIBLE); - layout_emo.setVisibility(View.VISIBLE); - layout_add.setVisibility(View.GONE); - hideSoftInputView(); - } else { - layout_more.setVisibility(View.GONE); - showSoftInputView(); - } - } - - /** - * 显示软键盘 - */ - public void showSoftInputView() { - if (getWindow().getAttributes().softInputMode == WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { - if (getCurrentFocus() != null) - ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)) - .showSoftInput(edit_msg, 0); - } - } - - /** - * 发送文本消息 - */ - private void sendMessage(){ - String text=edit_msg.getText().toString(); - if(TextUtils.isEmpty(text.trim())){ - toast("请输入内容"); - return; - } - BmobIMTextMessage msg =new BmobIMTextMessage(); - msg.setContent(text); - //可设置额外信息 - Map map =new HashMap<>(); - map.put("level", "1");//随意增加信息 - msg.setExtraMap(map); - c.sendMessage(msg, listener); - } - - /** - * 直接发送远程图片地址 - */ - public void sendRemoteImageMessage(){ - BmobIMImageMessage image =new BmobIMImageMessage(); - image.setRemoteUrl("http://img.lakalaec.com/ad/57ab6dc2-43f2-4087-81e2-b5ab5681642d.jpg"); - c.sendMessage(image, listener); - } - - /** - * 发送本地图片地址 - */ - public void sendLocalImageMessage(){ - //正常情况下,需要调用系统的图库或拍照功能获取到图片的本地地址,开发者只需要将本地的文件地址传过去就可以发送文件类型的消息 - BmobIMImageMessage image =new BmobIMImageMessage("/storage/emulated/0/bimagechooser/IMG_20160302_172003.jpg"); - c.sendMessage(image, listener); -// //因此也可以使用BmobIMFileMessage来发送文件消息 -// BmobIMFileMessage file =new BmobIMFileMessage("文件地址"); -// c.sendMessage(file,listener); - } - - /** - * 发送语音消息 - * @Title: sendVoiceMessage - * @param local - * @param length - * @return void - */ - private void sendVoiceMessage(String local, int length) { - BmobIMAudioMessage audio =new BmobIMAudioMessage(local); - //可设置额外信息-开发者设置的额外信息,需要开发者自己从extra中取出来 - Map map =new HashMap<>(); - map.put("from", "优酷"); - audio.setExtraMap(map); - //设置语音文件时长:可选 -// audio.setDuration(length); - c.sendMessage(audio, listener); - } - - /** - * 发送视频文件 - */ - private void sendVideoMessage(){ - BmobIMVideoMessage video =new BmobIMVideoMessage("/storage/sdcard0/bimagechooser/11.png"); - c.sendMessage(video, listener); - } - - /** - * 发送地理位置 - */ - public void sendLocationMessage(){ - //测试数据,真实数据需要从地图SDK中获取 - - Bundle bundle = new Bundle(); - bundle.putSerializable("c", c); - startActivity(LocActivity.class , bundle, true); - - /*BmobIMLocationMessage location =new BmobIMLocationMessage("广州番禺区",23.5,112.0); - Map map =new HashMap<>(); - map.put("from", "百度地图"); - location.setExtraMap(map); - c.sendMessage(location, listener);*/ - } - - /** - * 消息发送监听器 - */ - public MessageSendListener listener =new MessageSendListener() { - - @Override - public void onProgress(int value) { - super.onProgress(value); - //文件类型的消息才有进度值 - Logger.i("onProgress:"+value); - } - - @Override - public void onStart(BmobIMMessage msg) { - super.onStart(msg); - adapter.addMessage(msg); - edit_msg.setText(""); - scrollToBottom(); - } - - @Override - public void done(BmobIMMessage msg, BmobException e) { - adapter.notifyDataSetChanged(); - edit_msg.setText(""); - scrollToBottom(); - if (e != null) { - toast(e.getMessage()); - } - } - }; - - /**首次加载,可设置msg为null,下拉刷新的时候,默认取消息表的第一个msg作为刷新的起始时间点,默认按照消息时间的降序排列 - * @param msg - */ - public void queryMessages(BmobIMMessage msg){ - c.queryMessages(msg, 10, new MessagesQueryListener() { - @Override - public void done(List list, BmobException e) { - sw_refresh.setRefreshing(false); - if (e == null) { - if (null != list && list.size() > 0) { - adapter.addMessages(list); - layoutManager.scrollToPositionWithOffset(list.size() - 1, 0); - } - } else { - toast(e.getMessage() + "(" + e.getErrorCode() + ")"); - } - } - }); - } - - private void scrollToBottom() { - layoutManager.scrollToPositionWithOffset(adapter.getItemCount() - 1, 0); - } - - @Override - public void onMessageReceive(List list) { - Logger.i("聊天页面接收到消息:" + list.size()); - //当注册页面消息监听时候,有消息(包含离线消息)到来时会回调该方法 - for (int i=0;i> map =event.getEventMap(); -// if(map!=null&&map.size()>0){ -// //只获取当前聊天对象的离线消息 -// List list = map.get(c.getConversationId()); -// if(list!=null && list.size()>0){ -// for (int i=0;i cache = BmobNotificationManager.getInstance(this).getNotificationCacheList(); - if(cache.size()>0){ - int size =cache.size(); - for(int i=0;i= BmobRecordManager.MAX_RECORD_TIME) {// 1分钟结束,发送消息 + // 需要重置按钮 + btn_speak.setPressed(false); + btn_speak.setClickable(false); + // 取消录音框 + layout_record.setVisibility(View.INVISIBLE); + // 发送语音消息 + sendVoiceMessage(localPath, recordTime); + //是为了防止过了录音时间后,会多发一条语音出去的情况。 + new Handler().postDelayed(new Runnable() { + + @Override + public void run() { + btn_speak.setClickable(true); + } + }, 1000); + } + } + }); + } + + /** + * 长按说话 + * @author smile + * @date 2014-7-1 下午6:10:16 + */ + class VoiceTouchListener implements View.OnTouchListener { + @Override + public boolean onTouch(View v, MotionEvent event) { + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: + if (!Util.checkSdCard()) { + toast("发送语音需要sdcard支持!"); + return false; + } + try { + v.setPressed(true); + layout_record.setVisibility(View.VISIBLE); + tv_voice_tips.setText(getString(R.string.voice_cancel_tips)); + // 开始录音 + recordManager.startRecording(c.getConversationId()); + } catch (Exception e) { + e.printStackTrace(); + } + return true; + case MotionEvent.ACTION_MOVE: { + if (event.getY() < 0) { + tv_voice_tips.setText(getString(R.string.voice_cancel_tips)); + tv_voice_tips.setTextColor(Color.RED); + } else { + tv_voice_tips.setText(getString(R.string.voice_up_tips)); + tv_voice_tips.setTextColor(Color.WHITE); + } + return true; + } + case MotionEvent.ACTION_UP: + v.setPressed(false); + layout_record.setVisibility(View.INVISIBLE); + try { + if (event.getY() < 0) {// 放弃录音 + recordManager.cancelRecording(); + Logger.i("voice", "放弃发送语音"); + } else { + int recordTime = recordManager.stopRecording(); + if (recordTime > 1) { + // 发送语音文件 + sendVoiceMessage(recordManager.getRecordFilePath(c.getConversationId()),recordTime); + } else {// 录音时间过短,则提示录音过短的提示 + layout_record.setVisibility(View.GONE); + showShortToast().show(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + default: + return false; + } + } + } + + Toast toast; + + /** + * 显示录音时间过短的Toast + * @Title: showShortToast + * @return void + */ + private Toast showShortToast() { + if (toast == null) { + toast = new Toast(this); + } + View view = LayoutInflater.from(this).inflate( + R.layout.include_chat_voice_short, null); + toast.setView(view); + toast.setGravity(Gravity.CENTER, 0, 0); + toast.setDuration(Toast.LENGTH_SHORT); + return toast; + } + /** + * 发送语音消息 + * @Title: sendVoiceMessage + * @param local + * @param length + * @return void + */ + private void sendVoiceMessage(String local, int length) { + BmobIMAudioMessage audio =new BmobIMAudioMessage(local); + //可设置额外信息-开发者设置的额外信息,需要开发者自己从extra中取出来 + Map map =new HashMap<>(); + map.put("from", "优酷"); + audio.setExtraMap(map); + //设置语音文件时长:可选 +// audio.setDuration(length); + c.sendMessage(audio, listener); } /** @@ -347,6 +535,9 @@ public class LocActivity extends ParentWithNaviActivity implements ObseverListen friend_loc = new LatLng(recv_loc_msg.getLatitude(), recv_loc_msg.getLongitude()); refresh_map(); } + else if ( msg.getMsgType().equals("audio")){ + + } } diff --git a/app/src/main/java/cn/bmob/imdemo/ui/MainActivity.java b/app/src/main/java/cn/bmob/imdemo/ui/MainActivity.java index 2f56a95..551f158 100755 --- a/app/src/main/java/cn/bmob/imdemo/ui/MainActivity.java +++ b/app/src/main/java/cn/bmob/imdemo/ui/MainActivity.java @@ -41,17 +41,13 @@ import cn.bmob.v3.exception.BmobException; */ public class MainActivity extends BaseActivity implements ObseverListener{ - @Bind(R.id.btn_conversation) - Button btn_conversation; + @Bind(R.id.btn_set) Button btn_set; @Bind(R.id.btn_contact) Button btn_contact; - @Bind(R.id.iv_conversation_tips) - ImageView iv_conversation_tips; - @Bind(R.id.iv_contact_tips) ImageView iv_contact_tips; @@ -95,10 +91,9 @@ public class MainActivity extends BaseActivity implements ObseverListener{ @Override protected void initView() { super.initView(); - mTabs = new Button[3]; - mTabs[0] = btn_conversation; - mTabs[1] = btn_contact; - mTabs[2] =btn_set; + mTabs = new Button[2]; + mTabs[0] = btn_contact; + mTabs[1] =btn_set; mTabs[0].setSelected(true); initTab(); } @@ -107,25 +102,21 @@ public class MainActivity extends BaseActivity implements ObseverListener{ conversationFragment = new ConversationFragment(); setFragment = new SetFragment(); contactFragment=new ContactFragment(); - fragments = new Fragment[] {conversationFragment, contactFragment,setFragment}; + fragments = new Fragment[] {contactFragment,setFragment}; getSupportFragmentManager().beginTransaction() - .add(R.id.fragment_container, conversationFragment). - add(R.id.fragment_container, contactFragment) + .add(R.id.fragment_container, contactFragment) .add(R.id.fragment_container, setFragment) - .hide(setFragment).hide(contactFragment) - .show(conversationFragment).commit(); + .hide(setFragment) + .show(contactFragment).commit(); } public void onTabSelect(View view) { switch (view.getId()) { - case R.id.btn_conversation: - index = 0; - break; case R.id.btn_contact: - index = 1; + index = 0; break; case R.id.btn_set: - index = 2; + index = 1; break; } onTabIndex(index); @@ -189,9 +180,9 @@ public class MainActivity extends BaseActivity implements ObseverListener{ private void checkRedPoint(){ int count = (int)BmobIM.getInstance().getAllUnReadCount(); if(count>0){ - iv_conversation_tips.setVisibility(View.VISIBLE); + iv_contact_tips.setVisibility(View.VISIBLE); }else{ - iv_conversation_tips.setVisibility(View.GONE); + iv_contact_tips.setVisibility(View.GONE); } //是否有好友添加的请求 if(NewFriendManager.getInstance(this).hasNewFriendInvitation()){ diff --git a/app/src/main/java/cn/bmob/imdemo/ui/fragment/ContactFragment.java b/app/src/main/java/cn/bmob/imdemo/ui/fragment/ContactFragment.java index 9f81f28..468b98e 100755 --- a/app/src/main/java/cn/bmob/imdemo/ui/fragment/ContactFragment.java +++ b/app/src/main/java/cn/bmob/imdemo/ui/fragment/ContactFragment.java @@ -27,6 +27,7 @@ import cn.bmob.imdemo.bean.User; import cn.bmob.imdemo.event.RefreshEvent; import cn.bmob.imdemo.model.UserModel; import cn.bmob.imdemo.ui.ChatActivity; +import cn.bmob.imdemo.ui.LocActivity; import cn.bmob.imdemo.ui.NewFriendActivity; import cn.bmob.imdemo.ui.SearchUserActivity; import cn.bmob.newim.BmobIM; @@ -141,7 +142,8 @@ public class ContactFragment extends ParentWithNaviFragment { BmobIMConversation c = BmobIM.getInstance().startPrivateConversation(info, null); Bundle bundle = new Bundle(); bundle.putSerializable("c", c); - startActivity(ChatActivity.class, bundle); + startActivity(LocActivity.class, bundle); + //startActivity(ChatActivity.class, bundle); } } diff --git a/app/src/main/res/layout/activity_chat.xml b/app/src/main/res/layout/activity_chat.xml index cae5253..60e66c1 100755 --- a/app/src/main/res/layout/activity_chat.xml +++ b/app/src/main/res/layout/activity_chat.xml @@ -2,12 +2,12 @@ - @@ -51,6 +51,6 @@ android:textSize="14sp" /> - +--> diff --git a/app/src/main/res/layout/activity_loc.xml b/app/src/main/res/layout/activity_loc.xml index d26123f..92636ed 100644 --- a/app/src/main/res/layout/activity_loc.xml +++ b/app/src/main/res/layout/activity_loc.xml @@ -9,10 +9,46 @@ - + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index f20f9e5..9fc307e 100755 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -11,41 +11,6 @@ android:gravity="center_vertical" android:orientation="horizontal" > - - - - -