|
|
@@ -20,6 +20,9 @@ import android.util.Log;
|
|
|
import android.view.KeyEvent;
|
|
|
import android.view.Menu;
|
|
|
import android.view.MenuItem;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
@@ -98,6 +101,7 @@ public class MucChatActivity extends ActionBackActivity
|
|
|
|
|
|
}
|
|
|
};
|
|
|
+ private LinearLayout botton_ll;
|
|
|
private CoreService mService;
|
|
|
private boolean mHasSend = false;// 有没有发送过消息,发送过需要更新界面
|
|
|
private FastVolley mFastVolley;
|
|
|
@@ -110,7 +114,8 @@ public class MucChatActivity extends ActionBackActivity
|
|
|
private Friend mFriend;
|
|
|
private ChatMessage instantMessage;
|
|
|
private String instantFilePath;// 转发文件传过来的path
|
|
|
-
|
|
|
+ private ImageView tv_none;
|
|
|
+ private ImageView tv_delete;
|
|
|
private String[] noticeFriendList;
|
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@@ -162,21 +167,32 @@ public class MucChatActivity extends ActionBackActivity
|
|
|
@Override
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
Log.d("wang", "接收到广播");
|
|
|
- if (mChatContentView != null) {
|
|
|
- int position = intent.getIntExtra(Constants.CHAT_REMOVE_MESSAGE_POSITION, 10000);
|
|
|
- if (position == 10000) {
|
|
|
- return;
|
|
|
+ if (intent.getIntExtra(Constants.CHAT_REMOVE_MESSAGE_FALG, 10000) == 1) {//当广播为删除一个信息时候
|
|
|
+ if (mChatContentView != null) {
|
|
|
+ int position = intent.getIntExtra(Constants.CHAT_REMOVE_MESSAGE_POSITION, 10000);
|
|
|
+ if (position == 10000) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ChatMessage message = mChatMessages.get(position);
|
|
|
+ boolean isSuccess = ChatMessageDao.getInstance().deleteSingleChatMessage(mLoginUserId, mFriend.getUserId(), message);
|
|
|
+ if (isSuccess) {
|
|
|
+
|
|
|
+ mChatMessages.remove(position);
|
|
|
+ mChatContentView.notifyDataSetInvalidated(true);
|
|
|
+ MsgBroadcast.broadcastMsgUiUpdate(mContext);
|
|
|
+ } else {
|
|
|
+ Toast.makeText(mContext, "删除失败", Toast.LENGTH_SHORT).show();
|
|
|
+ }
|
|
|
}
|
|
|
- ChatMessage message = mChatMessages.get(position);
|
|
|
- boolean isSuccess = ChatMessageDao.getInstance().deleteSingleChatMessage(mLoginUserId, mFriend.getUserId(), message);
|
|
|
- if (isSuccess) {
|
|
|
-
|
|
|
- mChatMessages.remove(position);
|
|
|
- mChatContentView.notifyDataSetInvalidated(true);
|
|
|
- MsgBroadcast.broadcastMsgUiUpdate(mContext);
|
|
|
- } else {
|
|
|
- Toast.makeText(mContext, "删除失败", Toast.LENGTH_SHORT).show();
|
|
|
+ } else {//当广播为删除一个信息时候
|
|
|
+ Log.i("gongpengming", "点击更多时候接受到广播");
|
|
|
+ if (botton_ll != null) {
|
|
|
+ botton_ll.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ if (mChatBottomView != null) {
|
|
|
+ mChatBottomView.setVisibility(View.GONE);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -227,6 +243,8 @@ public class MucChatActivity extends ActionBackActivity
|
|
|
mChatContentView = (ChatContentView) findViewById(R.id.chat_content_view);
|
|
|
mChatContentView.setToUserId(mUseId);
|
|
|
mChatContentView.setData(mChatMessages);
|
|
|
+ tv_delete = (ImageView) findViewById(R.id.tv_delete);
|
|
|
+ tv_none = (ImageView) findViewById(R.id.tv_none);
|
|
|
mChatContentView.setMessageEventListener(this);
|
|
|
mChatContentView.setRoomNickName(mFriend.getRoomMyNickName());
|
|
|
mChatContentView.setRefreshListener(new PullDownListView.RefreshingListener() {
|
|
|
@@ -235,9 +253,52 @@ public class MucChatActivity extends ActionBackActivity
|
|
|
loadDatas(false);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+ botton_ll = (LinearLayout) findViewById(R.id.botton_ll);
|
|
|
mChatBottomView = (ChatBottomView) findViewById(R.id.chat_bottom_view);
|
|
|
mChatBottomView.setChatBottomListener(this);
|
|
|
+ tv_none.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ if (botton_ll != null) {
|
|
|
+ botton_ll.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ if (mChatBottomView != null) {
|
|
|
+ mChatBottomView.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ mChatContentView.setShowCB(false);
|
|
|
+ mChatContentView.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ tv_delete.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ //TODO 确定删除选择聊天记录
|
|
|
+ if (botton_ll != null) {
|
|
|
+ botton_ll.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ if (mChatBottomView != null) {
|
|
|
+ mChatBottomView.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ //点击删除记录时候
|
|
|
+ onDeleteMore();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ private void onDeleteMore() {
|
|
|
+ List<Integer> ints = mChatContentView.getInts();
|
|
|
+ ArrayList<ChatMessage> messages = new ArrayList<>();
|
|
|
+ for (int i = 0; i < ints.size(); i++) {
|
|
|
+ Log.i("gongpengming", "当前i=" + i);
|
|
|
+ messages.add(mChatMessages.get(ints.get(i)));
|
|
|
+ }
|
|
|
+ boolean isSuccess = ChatMessageDao.getInstance().deleteSingleChatMessage(mLoginUserId, mFriend.getUserId(), messages);
|
|
|
+ if (isSuccess) {
|
|
|
+ mChatMessages.removeAll(messages);
|
|
|
+ mChatContentView.notifyDataSetInvalidated(true);
|
|
|
+ MsgBroadcast.broadcastMsgUiUpdate(mContext);
|
|
|
+// mChatContentView.notifyDataSetChanged();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void updateUi(String roomName) {
|