Search in sources :

Example 6 with WifiPeopleVO

use of com.lingtuan.firefly.offline.vo.WifiPeopleVO in project SmartMesh_Android by SmartMeshFoundation.

the class FriendInfoUI method addFriendMethod.

/**
 * Add buddy method
 */
private void addFriendMethod() {
    if (Utils.isConnectNet(FriendInfoUI.this)) {
        Intent addFriend = new Intent(FriendInfoUI.this, FriendAddUI.class);
        addFriend.putExtra("localId", info.getLocalId());
        addFriend.putExtra("offlineFound", info.isOffLineFound());
        startActivity(addFriend);
        Utils.openNewActivityAnim(FriendInfoUI.this, false);
    } else {
        boolean isFound = false;
        if (appNetService != null) {
            List<WifiPeopleVO> wifiPeopleVOs = appNetService.getwifiPeopleList();
            for (int i = 0; i < wifiPeopleVOs.size(); i++) {
                if (info.getLocalId().equals(wifiPeopleVOs.get(i).getLocalId())) {
                    isFound = true;
                    break;
                }
            }
        }
        if (isFound) {
            appNetService.handleSendAddFriendCommend(info.getLocalId(), false);
            showToast(getString(R.string.offline_addffiend));
        } else {
            showToast(getString(R.string.net_unavailable));
        }
    }
}
Also used : WifiPeopleVO(com.lingtuan.firefly.offline.vo.WifiPeopleVO) Intent(android.content.Intent)

Example 7 with WifiPeopleVO

use of com.lingtuan.firefly.offline.vo.WifiPeopleVO in project SmartMesh_Android by SmartMeshFoundation.

the class ChattingManager method showFileView.

/**
 * Select the file
 */
public void showFileView() {
    boolean foundPeople = false;
    if (appNetService != null && appNetService.getwifiPeopleList() != null) {
        for (// All users need to traverse, find out the corresponding touid users
        WifiPeopleVO wifiPeopleVO : // All users need to traverse, find out the corresponding touid users
        appNetService.getwifiPeopleList()) {
            if (uid.equals(wifiPeopleVO.getLocalId())) {
                foundPeople = true;
                break;
            }
        }
    }
    if (!foundPeople) {
        MyToast.showToast(mContext, mContext.getString(R.string.offline_file_send_tip));
        return;
    }
    MySharedPrefs.writeBoolean(mContext, MySharedPrefs.FILE_USER, Constants.CHAT_SEND_FILE, true);
    Intent i = new Intent(mContext, SendFileUI.class);
    ((Activity) mContext).startActivityForResult(i, ACTION_MANY_FILE_RESULT);
    Utils.openNewActivityAnim((Activity) mContext, false);
}
Also used : WifiPeopleVO(com.lingtuan.firefly.offline.vo.WifiPeopleVO) Activity(android.app.Activity) Intent(android.content.Intent)

Example 8 with WifiPeopleVO

use of com.lingtuan.firefly.offline.vo.WifiPeopleVO in project SmartMesh_Android by SmartMeshFoundation.

the class ChattingManager method setCardInfo.

public void setCardInfo(UserBaseVo cardVo) {
    boolean successed = true;
    if (uid.equals(Constants.APP_EVERYONE)) {
        ChatMsg msg = XmppMessageUtil.getInstance().sendCard(uid, userName, avatarUrl, cardVo.getShowName(), cardVo.getSightml(), cardVo.getThumb(), cardVo.getLocalId(), isGroup, isSend);
        if (appNetService != null) {
            WifiPeopleVO cardInfo = new WifiPeopleVO();
            cardInfo.setLocalId(cardVo.getLocalId());
            cardInfo.setUsername(cardVo.getUsername());
            cardInfo.setSightml(cardVo.getSightml());
            String path;
            if (cardVo.getThumb().startsWith("http") || cardVo.getThumb().startsWith("www")) {
                path = NextApplication.mImageLoader.getDiscCache().get(cardVo.getThumb()).getPath();
            } else {
                path = cardVo.getThumb();
            }
            cardInfo.setThumb(path);
            successed = appNetService.handleSendCard(cardInfo, true, uid, msg.getMessageId());
        }
        if (msg.getSend() == 0 && !successed) {
            msg.setSend(0);
        }
        mAdapter.addChatMsg(msg, true);
    } else if (isGroup) {
        ChatMsg msg = XmppMessageUtil.getInstance().sendCard(uid, userName, avatarUrl, cardVo.getShowName(), cardVo.getSightml(), cardVo.getThumb(), cardVo.getLocalId(), isGroup, isSend);
        mAdapter.addChatMsg(msg, true);
    } else {
        boolean foundPeople = false;
        if (appNetService != null && appNetService.getwifiPeopleList() != null) {
            for (// All users need to traverse, find out the corresponding touid users
            WifiPeopleVO vo : // All users need to traverse, find out the corresponding touid users
            appNetService.getwifiPeopleList()) {
                if (uid.equals(vo.getLocalId())) {
                    foundPeople = true;
                    break;
                }
            }
        }
        if (// With no net with no net send messages
        foundPeople) {
            WifiPeopleVO cardInfo = new WifiPeopleVO();
            cardInfo.setLocalId(cardVo.getLocalId());
            cardInfo.setUsername(cardVo.getUsername());
            cardInfo.setSightml(cardVo.getSightml());
            String path;
            if (cardVo.getThumb().startsWith("http") || cardVo.getThumb().startsWith("www")) {
                path = NextApplication.mImageLoader.getDiscCache().get(cardVo.getThumb()).getPath();
            } else {
                path = cardVo.getThumb();
            }
            cardInfo.setThumb(path);
            ChatMsg msg = new ChatMsg();
            msg.setType(6);
            msg.setThirdId(cardInfo.getLocalId());
            msg.setThirdImage(cardInfo.getThumb());
            msg.setThirdName(cardInfo.getUserName());
            msg.setCardSign(cardInfo.getSightml());
            msg.setOffLineMsg(true);
            msg.setSend(1);
            msg.setMessageId(UUID.randomUUID().toString());
            msg.setMsgTime(System.currentTimeMillis() / 1000);
            msg.setShowTime(FinalUserDataBase.getInstance().isOffLineShowTime(uid, msg.getMsgTime()));
            successed = appNetService.handleSendCard(cardInfo, false, uid, msg.getMessageId());
            if (!successed) {
                msg.setSend(0);
            }
            mAdapter.addChatMsg(msg, true);
            FinalUserDataBase.getInstance().saveChatMsg(msg, uid, userName, avatarUrl);
        } else {
            ChatMsg msg = XmppMessageUtil.getInstance().sendCard(uid, userName, avatarUrl, cardVo.getShowName(), cardVo.getSightml(), cardVo.getThumb(), cardVo.getLocalId(), isGroup, isSend);
            mAdapter.addChatMsg(msg, true);
        }
    }
    listView.setSelection(mAdapter.getCount());
}
Also used : WifiPeopleVO(com.lingtuan.firefly.offline.vo.WifiPeopleVO) ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Example 9 with WifiPeopleVO

use of com.lingtuan.firefly.offline.vo.WifiPeopleVO in project SmartMesh_Android by SmartMeshFoundation.

the class ChattingManager method sendImgMethod.

/**
 * Sending pictures method
 * @param picturePath Image path
 */
private void sendImgMethod(String picturePath) {
    float density = mContext.getResources().getDisplayMetrics().density;
    // mContext.getResources().getDisplayMetrics().widthPixels;
    int screenWidth = Constants.MAX_IMAGE_WIDTH;
    // mContext.getResources().getDisplayMetrics().heightPixels;
    int screenHeight = Constants.MAX_IMAGE_HEIGHT;
    int width = (int) (120 * density);
    Bitmap bmp = BitmapUtils.getimage(picturePath, width, width, 10);
    Bitmap bmpUpload = BitmapUtils.getimage(picturePath, screenWidth, screenHeight, Constants.MAX_KB);
    BitmapUtils.saveBitmap2SD(bmp, 10, false);
    String uploadPath = BitmapUtils.saveBitmap2SD(bmpUpload, screenWidth, true).getPath();
    String url = uploadPath;
    boolean successed = true;
    if (uid.equals(Constants.APP_EVERYONE)) {
        ChatMsg msg = createImageChatMsg(uid, url, userName, avatarUrl, BitmapUtils.BitmapToBase64String(bmp), isGroup, isSend);
        if (appNetService != null) {
            successed = appNetService.handleSendPicutre(url, true, uid, msg.getMessageId());
        }
        if (msg.getSend() == 0 && !successed) {
            msg.setSend(0);
        }
        mAdapter.addChatMsg(msg, true);
    } else if (uid.equals(Constants.APP_MESH)) {
        // send mesh picture
        ChatMsg msg = createImageChatMsg(uid, url, userName, avatarUrl, BitmapUtils.BitmapToBase64String(bmp), isGroup, isSend);
        mAdapter.addChatMsg(msg, true);
    } else if (isGroup) {
        ChatMsg msg = createImageChatMsg(uid, url, userName, avatarUrl, BitmapUtils.BitmapToBase64String(bmp), isGroup, isSend);
        mAdapter.addChatMsg(msg, true);
    } else {
        boolean foundPeople = false;
        if (appNetService != null && appNetService.getwifiPeopleList() != null) {
            for (// All users need to traverse, find out the corresponding touid users
            WifiPeopleVO vo : // All users need to traverse, find out the corresponding touid users
            appNetService.getwifiPeopleList()) {
                if (uid.equals(vo.getLocalId())) {
                    foundPeople = true;
                    break;
                }
            }
        }
        if (// With no net with no net send messages
        foundPeople) {
            ChatMsg msg = new ChatMsg();
            msg.setType(1);
            msg.setContent(url);
            msg.setLocalUrl(url);
            msg.setCover(BitmapUtils.BitmapToBase64String(bmp));
            msg.parseUserBaseVo(NextApplication.myInfo.getUserBaseVo());
            msg.setChatId(uid);
            msg.setOffLineMsg(true);
            msg.setSend(1);
            msg.setMessageId(UUID.randomUUID().toString());
            msg.setMsgTime(System.currentTimeMillis() / 1000);
            msg.setShowTime(FinalUserDataBase.getInstance().isOffLineShowTime(uid, msg.getMsgTime()));
            successed = appNetService.handleSendPicutre(url, false, uid, msg.getMessageId());
            if (!successed) {
                msg.setSend(0);
            }
            mAdapter.addChatMsg(msg, true);
            FinalUserDataBase.getInstance().saveChatMsg(msg, uid, userName, avatarUrl);
        } else {
            ChatMsg msg = createImageChatMsg(uid, url, userName, avatarUrl, BitmapUtils.BitmapToBase64String(bmp), isGroup, isSend);
            mAdapter.addChatMsg(msg, true);
        }
    }
    listView.setSelection(mAdapter.getCount());
    if (bmp != null && !bmp.isRecycled()) {
        bmp.recycle();
    }
    if (bmpUpload != null && !bmpUpload.isRecycled()) {
        bmpUpload.recycle();
    }
}
Also used : Bitmap(android.graphics.Bitmap) WifiPeopleVO(com.lingtuan.firefly.offline.vo.WifiPeopleVO) ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Example 10 with WifiPeopleVO

use of com.lingtuan.firefly.offline.vo.WifiPeopleVO in project SmartMesh_Android by SmartMeshFoundation.

the class ChattingUI method sentTextMethod.

/**
 * Send text
 */
private void sentTextMethod() {
    final String content = mInputContent.getText().toString().trim();
    String atIds = chattingManager.getSbAtGroupSelectIds();
    Editable mEditable = mInputContent.getText();
    boolean isAtAll = chattingManager.isAtAll(mEditable.toString());
    boolean successed = true;
    if (uid.equals(Constants.APP_EVERYONE)) {
        ChatMsg msg = XmppMessageUtil.getInstance().sendText(uid, content, isAtAll, atIds, userName, avatarUrl, isGroup, !(isDismissGroup || isKickGroup));
        if (appNetService != null) {
            successed = appNetService.handleSendString(content, true, "", msg.getMessageId());
        }
        if (msg.getSend() == 0 && !successed) {
            msg.setSend(0);
        }
        mAdapter.addChatMsg(msg, true);
    } else if (uid.equals(Constants.APP_MESH)) {
        // send mesh text
        ChatMsg msg = XmppMessageUtil.getInstance().sendText(uid, content, isAtAll, atIds, userName, avatarUrl, isGroup, !(isDismissGroup || isKickGroup));
        mAdapter.addChatMsg(msg, true);
    } else if (isGroup) {
        ChatMsg msg = XmppMessageUtil.getInstance().sendText(uid, content, isAtAll, atIds, userName, avatarUrl, isGroup, !(isDismissGroup || isKickGroup));
        mAdapter.addChatMsg(msg, true);
    } else {
        boolean foundPeople = false;
        if (appNetService != null && appNetService.getwifiPeopleList() != null) {
            for (// All users need to traverse, find out the corresponding touid users
            WifiPeopleVO vo : // All users need to traverse, find out the corresponding touid users
            appNetService.getwifiPeopleList()) {
                if (uid.equals(vo.getLocalId())) {
                    foundPeople = true;
                    break;
                }
            }
        }
        if (// With no net with no net send messages
        foundPeople) {
            ChatMsg msg = new ChatMsg();
            msg.parseUserBaseVo(NextApplication.myInfo.getUserBaseVo());
            msg.setChatId(uid);
            msg.setType(0);
            msg.setSend(1);
            msg.setMsgTime(System.currentTimeMillis() / 1000);
            msg.setShowTime(FinalUserDataBase.getInstance().isOffLineShowTime(uid, msg.getMsgTime()));
            msg.setContent(content);
            msg.setOffLineMsg(true);
            msg.setMessageId(UUID.randomUUID().toString());
            if (appNetService != null) {
                successed = appNetService.handleSendString(content, false, uid, msg.getMessageId());
            }
            if (!successed) {
                msg.setSend(0);
            }
            mAdapter.addChatMsg(msg, true);
            File recvFile = new File(SDCardCtrl.getOfflinePath() + File.separator + uid + ".jpg");
            String imageAvatar = "file://" + recvFile.getAbsolutePath();
            FinalUserDataBase.getInstance().saveChatMsg(msg, uid, isGroup ? "offline" : userName, imageAvatar);
        } else {
            ChatMsg msg = XmppMessageUtil.getInstance().sendText(uid, content, isAtAll, atIds, userName, avatarUrl, isGroup, !(isDismissGroup || isKickGroup));
            mAdapter.addChatMsg(msg, true);
        }
    }
    mInputContent.setText("");
    listView.setSelection(mAdapter.getCount() - 1);
}
Also used : WifiPeopleVO(com.lingtuan.firefly.offline.vo.WifiPeopleVO) Editable(android.text.Editable) File(java.io.File) ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Aggregations

WifiPeopleVO (com.lingtuan.firefly.offline.vo.WifiPeopleVO)11 ChatMsg (com.lingtuan.firefly.vo.ChatMsg)5 UserBaseVo (com.lingtuan.firefly.vo.UserBaseVo)3 Intent (android.content.Intent)2 Bitmap (android.graphics.Bitmap)2 Activity (android.app.Activity)1 Cursor (android.database.Cursor)1 Editable (android.text.Editable)1 File (java.io.File)1