Search in sources :

Example 1 with ChatAdapter

use of com.lingtuan.firefly.chat.adapter.ChatAdapter in project SmartMesh_Android by SmartMeshFoundation.

the class ChatHistoryUI method initData.

@Override
protected void initData() {
    swipeLayout.setColorSchemeResources(R.color.black);
    setTitle(getResources().getString(R.string.report_chat_title));
    mRightBtn.setText(getResources().getString(R.string.submit));
    mRightBtn.setVisibility(View.VISIBLE);
    ChattingManager.getInstance(this).destory();
    chattingManager = ChattingManager.getInstance(this);
    List<ChatMsg> mList = FinalUserDataBase.getInstance().getChatMsgListByChatId(buid, 0, 20);
    mAdapter = new ChatAdapter(mList, this, null, listView);
    chattingManager.setUserInfo(userName, avatarUrl, buid, mAdapter, listView);
    mAdapter.addSelectedList(selectedList, true);
    listView.setAdapter(mAdapter);
    listView.setSelection(mList.size());
}
Also used : ChatAdapter(com.lingtuan.firefly.chat.adapter.ChatAdapter) ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Example 2 with ChatAdapter

use of com.lingtuan.firefly.chat.adapter.ChatAdapter in project SmartMesh_Android by SmartMeshFoundation.

the class ChattingUI method initData.

@Override
protected void initData() {
    if (uid.equals(Constants.APP_EVERYONE)) {
        setTitle(getString(R.string.everyone));
        chattingSet.setVisibility(View.GONE);
        mMeshPhoto.setVisibility(View.GONE);
    } else if (uid.equals(Constants.APP_MESH)) {
        setTitle(getString(R.string.wifimesh));
        chattingSet.setImageResource(R.drawable.icon_friend_info);
        chattingSet.setVisibility(View.VISIBLE);
        mMeshPhoto.setVisibility(View.VISIBLE);
    } else {
        setTitle(userName);
        chattingSet.setImageResource(R.drawable.icon_friend_info);
        chattingSet.setVisibility(View.VISIBLE);
        mMeshPhoto.setVisibility(View.GONE);
    }
    if (uid.equals(Constants.APP_EVERYONE) || isGroup) {
        mFile.setVisibility(View.GONE);
    } else if (uid.equals(Constants.APP_MESH)) {
        chattingBottomRela.setVisibility(View.GONE);
    } else {
        mFile.setVisibility(View.VISIBLE);
    }
    swipeLayout.setColorSchemeResources(R.color.black);
    // Remove notification bar
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.cancelAll();
    ChattingManager.getInstance(this).destory();
    chattingManager = ChattingManager.getInstance(this);
    if (NextApplication.myInfo != null) {
        int openSmartMesh = MySharedPrefs.readInt1(NextApplication.mContext, MySharedPrefs.FILE_USER, MySharedPrefs.KEY_NO_NETWORK_COMMUNICATION + NextApplication.myInfo.getLocalId());
        if (openSmartMesh == 1) {
            bindService(new Intent(this, AppNetService.class), serviceConn, BIND_AUTO_CREATE);
        }
    }
    // message broadcast distribution
    IntentFilter filter = new IntentFilter(XmppAction.ACTION_MESSAGE_LISTENER);
    // message list broadcast distribution
    filter.addAction(XmppAction.ACTION_OFFLINE_MESSAGE_LIST_LISTENER);
    // message update broadcast distribution
    filter.addAction(XmppAction.ACTION_MESSAGE_UPDATE_LISTENER);
    // message update kick
    filter.addAction(XmppAction.ACTION_MESSAGE_GROUP_KICK_LISTENER);
    // message sending pictures percentage
    filter.addAction(XmppAction.ACTION_MESSAGE_IMAGE_PERCENT);
    // More pictures to send
    filter.addAction(Constants.ACTION_CHATTING_FRIEND_NOTE);
    // More pictures to send
    filter.addAction(XmppAction.ACTION_ENTER_EVERYONE_LISTENER);
    // chat
    filter.addAction(Constants.MSG_REPORT_SEND_MSG_RESULT);
    filter.addAction(Constants.MSG_REPORT_SEND_MSG_PROGRESS);
    filter.addAction(Constants.MSG_REPORT_START_RECV_FILE);
    filter.addAction(Constants.MSG_REPORT_CANCEL_SEND_FILE);
    filter.addAction(Constants.MSG_REPORT_CANCEL_RECV_FILE);
    msgReceiverListener = new MsgReceiverListener();
    registerReceiver(msgReceiverListener, filter);
    // Choose picture sends the message
    IntentFilter filterVideo = new IntentFilter(Constants.ACTION_CHATTING_PHOTO_LIST);
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, filterVideo);
    XmppMessageUtil.getInstance().setGroupDismiss(isDismissGroup);
    XmppMessageUtil.getInstance().setGroupKick(isKickGroup);
    chattingManager.setGroup(isGroup);
    chattingManager.setSend(!(isDismissGroup || isKickGroup));
    chattingManager.setmInputContent(mInputContent);
    List<ChatMsg> mList = FinalUserDataBase.getInstance().getChatMsgListByChatId(uid, 0, 20);
    for (int i = 0; i < mList.size(); i++) {
        ChatMsg vo = mList.get(i);
        if (vo.getType() == 1010 && vo.getUnread() == 1) {
            vo.setUnread(0);
            FinalUserDataBase.getInstance().updateChatMsgUrneadBymessageId(vo.getMessageId());
        }
    }
    unreadStartIndex = (mList.size() - unread) > 0 ? (mList.size() - unread) : 0;
    if (unread > mList.size()) {
        unreadOffset = unread - mList.size();
    }
    if (unread > 0) {
        showunreadNum();
    }
    for (ChatMsg msg : mList) {
        if (// Is sending images, voice, video because of the need to upload, is if it is sent every time into the state, send again
        msg.getSend() == 2) {
            if (// The picture
            msg.getType() == 1) {
                XmppMessageUtil.getInstance().reSend(3, msg);
            } else if (// voice
            msg.getType() == 2) {
                XmppMessageUtil.getInstance().reSend(11, msg);
            }
        }
    }
    mAdapter = new ChatAdapter(mList, this, this, listView);
    int source = 1;
    String sourcid = uid;
    if (isGroup) {
        source = 2;
        sourcid = uid.replace("group-", "");
    }
    mAdapter.setChatType(source, sourcid);
    mAdapter.setInputEditText(mInputContent, chattingManager);
    mAdapter.setGroup(isGroup);
    mAdapter.setKickDismiss(isKickGroup, isDismissGroup);
    chattingManager.setUserInfo(userName, avatarUrl, uid, mAdapter, listView);
    listView.setAdapter(mAdapter);
    listView.setSelection(mList.size());
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            finishTempActivity();
        }
    }, 100);
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            if (isDismissGroup || isKickGroup) {
                showToast(isDismissGroup ? getString(R.string.discuss_group_dismiss) : getString(R.string.discuss_group_kick));
            }
        }
    }, 500);
}
Also used : IntentFilter(android.content.IntentFilter) NotificationManager(android.app.NotificationManager) AppNetService(com.lingtuan.firefly.offline.AppNetService) Handler(android.os.Handler) Intent(android.content.Intent) ChatMsg(com.lingtuan.firefly.vo.ChatMsg) ChatAdapter(com.lingtuan.firefly.chat.adapter.ChatAdapter)

Aggregations

ChatAdapter (com.lingtuan.firefly.chat.adapter.ChatAdapter)2 ChatMsg (com.lingtuan.firefly.vo.ChatMsg)2 NotificationManager (android.app.NotificationManager)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Handler (android.os.Handler)1 AppNetService (com.lingtuan.firefly.offline.AppNetService)1