Search in sources :

Example 6 with RequestListener

use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.

the class ChatReportReasonUI method sendReportChatMsg.

private void sendReportChatMsg() {
    if (TextUtils.isEmpty(buid)) {
        return;
    }
    if (TextUtils.equals("-1", seven) && TextUtils.equals("-1", eight) && TextUtils.equals("-1", nine) && TextUtils.equals("-1", ten) && TextUtils.equals("-1", eleven)) {
        showToast(getResources().getString(R.string.report_reason_choice));
        return;
    }
    StringBuilder sb = new StringBuilder();
    sb.append(seven);
    sb.append(",");
    sb.append(eight);
    sb.append(",");
    sb.append(nine);
    sb.append(",");
    sb.append(ten);
    sb.append(",");
    sb.append(eleven);
    sb.append(",");
    String replace0String = sb.toString().replace("-1,", "");
    type = replace0String.substring(0, replace0String.length() - 1);
    if (msgList == null) {
        showToast(getResources().getString(R.string.chat_please_choice_msg));
        return;
    }
    /**
     * Chat logs together
     */
    ChatMsg cmBuild = new ChatMsg();
    String contentString = cmBuild.parseChatMsgListToJsonString(msgList);
    if (TextUtils.isEmpty(contentString)) {
        showToast(getResources().getString(R.string.chat_please_choice_msg));
        return;
    }
    NetRequestImpl.getInstance().sendReportChatMsg(type, buid, contentString, new RequestListener() {

        @Override
        public void start() {
            if (mProgressDialog == null) {
                mProgressDialog = LoadingDialog.showDialog(ChatReportReasonUI.this, null, getString(R.string.chatting_sending_two));
            }
        }

        @Override
        public void success(JSONObject response) {
            if (mProgressDialog != null) {
                mProgressDialog.dismiss();
            }
            showToast(response.optString("msg"));
            setResult(RESULT_OK);
            Utils.exitActivityAndBackAnim(ChatReportReasonUI.this, true);
        }

        @Override
        public void error(int errorCode, String errorMsg) {
            if (mProgressDialog != null) {
                mProgressDialog.dismiss();
            }
            showToast(errorMsg);
        }
    });
}
Also used : RequestListener(com.lingtuan.firefly.listener.RequestListener) JSONObject(org.json.JSONObject) ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Example 7 with RequestListener

use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.

the class ChatAdapter method requestFavFile.

/**
 * Collect cancel collect file interface
 */
private void requestFavFile(final ChatMsg msg) {
    if (mProgressDialog != null) {
        mProgressDialog.dismiss();
        mProgressDialog = null;
    }
    mProgressDialog = LoadingDialog.showDialog(mContext, null, null);
    mProgressDialog.setCancelable(false);
    NetRequestImpl.getInstance().fileCollect(msg.getThirdId(), msg.getCreateTime(), msg.getContent(), msg.getDatingSOSId(), new RequestListener() {

        @Override
        public void start() {
        }

        @Override
        public void success(JSONObject response) {
            if (mProgressDialog != null) {
                mProgressDialog.dismiss();
                mProgressDialog = null;
            }
            if (msg.getDatingSOSId() == 1) {
                MyToast.showToast(mContext, mContext.getString(R.string.chat_cancel_collection_failed));
                msg.setDatingSOSId(0);
                FinalUserDataBase.getInstance().updateChatMsgCollectState(msg.getMessageId(), 0);
            } else {
                MyToast.showToast(mContext, mContext.getString(R.string.chat_collection_failed));
                msg.setDatingSOSId(1);
                FinalUserDataBase.getInstance().updateChatMsgCollectState(msg.getMessageId(), 1);
            }
            if (// collection
            msg.getDatingSOSId() == 1) {
                if (// Upload successfully, or download successful collection, keep the path, so as to collect the list into the don't have to download
                msg.getInviteType() == 2 || msg.getInviteType() == 7) {
                    JSONObject json = new JSONObject();
                    try {
                        json.put("state", msg.getInviteType());
                        json.put("localurl", msg.getLocalUrl());
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    MySharedPrefs.write(mContext, MySharedPrefs.KEY_FIREFLY_FILEPATH, msg.getThirdId(), json.toString());
                }
            }
        }

        @Override
        public void error(int errorCode, String errorMsg) {
            if (mProgressDialog != null) {
                mProgressDialog.dismiss();
                mProgressDialog = null;
            }
            MyToast.showToast(mContext, errorMsg);
        }
    });
}
Also used : RequestListener(com.lingtuan.firefly.listener.RequestListener) JSONObject(org.json.JSONObject) JSONException(org.json.JSONException)

Example 8 with RequestListener

use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.

the class DiscussGroupJoinUI method joinDiscussGroup.

private void joinDiscussGroup() {
    if (TextUtils.isEmpty(cid)) {
        return;
    }
    if (data.size() <= 0) {
        return;
    }
    if (mProgressDialog != null) {
        mProgressDialog.dismiss();
        mProgressDialog = null;
    }
    mProgressDialog = LoadingDialog.showDialog(this, null, null);
    mProgressDialog.setCancelable(false);
    NetRequestImpl.getInstance().joinDiscussGroup(cid, new RequestListener() {

        @Override
        public void start() {
        }

        @Override
        public void success(JSONObject response) {
            if (mProgressDialog != null) {
                mProgressDialog.dismiss();
                mProgressDialog = null;
                Utils.gotoGroupChat(DiscussGroupJoinUI.this, false, groupName, cid, data);
            }
        }

        @Override
        public void error(int errorCode, String errorMsg) {
            if (mProgressDialog != null) {
                mProgressDialog.dismiss();
                mProgressDialog = null;
            }
            showToast(errorMsg);
            if (errorCode == 1240922) {
                Utils.gotoGroupChat(DiscussGroupJoinUI.this, true, groupName, cid, data);
            }
        }
    });
}
Also used : RequestListener(com.lingtuan.firefly.listener.RequestListener) JSONObject(org.json.JSONObject)

Example 9 with RequestListener

use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.

the class DiscussGroupSettingUI method addMembersRequest.

private void addMembersRequest(final ArrayList<UserBaseVo> continueList) {
    if (continueList.size() <= 0) {
        return;
    }
    if (mProgressDialog != null) {
        mProgressDialog.dismiss();
        mProgressDialog = null;
    }
    mProgressDialog = LoadingDialog.showDialog(this, null, null);
    mProgressDialog.setCancelable(false);
    StringBuffer touids = new StringBuffer();
    final StringBuffer tonames = new StringBuffer();
    for (int i = 0; i < continueList.size(); i++) {
        if (i == continueList.size() - 1) {
            touids.append(continueList.get(i).getLocalId());
            tonames.append(continueList.get(i).getShowName());
        } else {
            touids.append(continueList.get(i).getLocalId() + ",");
            tonames.append(continueList.get(i).getShowName() + ",");
        }
    }
    NetRequestImpl.getInstance().addDiscussMembers(touids.toString(), cid, new RequestListener() {

        @Override
        public void start() {
        }

        @Override
        public void success(JSONObject response) {
            if (mProgressDialog != null) {
                mProgressDialog.dismiss();
                mProgressDialog = null;
            }
            showToast(response.optString("msg"));
            for (int m = 0; m < continueList.size(); m++) {
                if (isAdmin) {
                    data.add(continueList.get(m));
                    showdata.add(showdata.size() - 2, continueList.get(m));
                } else {
                    data.add(continueList.get(m));
                    showdata.add(showdata.size() - 1, continueList.get(m));
                }
            }
            inviteOthersChatMsg(tonames.toString());
            resetlist();
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    adapter.notifyDataSetChanged();
                }
            }, 100);
        }

        @Override
        public void error(int errorCode, String errorMsg) {
            if (mProgressDialog != null) {
                mProgressDialog.dismiss();
                mProgressDialog = null;
            }
            showToast(errorMsg);
        }
    });
}
Also used : RequestListener(com.lingtuan.firefly.listener.RequestListener) JSONObject(org.json.JSONObject) Handler(android.os.Handler)

Example 10 with RequestListener

use of com.lingtuan.firefly.listener.RequestListener in project SmartMesh_Android by SmartMeshFoundation.

the class DiscussGroupSettingUI method renameDicsuss.

private void renameDicsuss(final String name) {
    if (mProgressDialog != null) {
        mProgressDialog.dismiss();
        mProgressDialog = null;
    }
    mProgressDialog = LoadingDialog.showDialog(this, null, null);
    mProgressDialog.setCancelable(false);
    NetRequestImpl.getInstance().renameDicsuss(name, cid, new RequestListener() {

        @Override
        public void start() {
        }

        @Override
        public void success(JSONObject response) {
            nameEdit.setText(name);
            showToast(response.optString("msg"));
            if (mProgressDialog != null) {
                mProgressDialog.dismiss();
                mProgressDialog = null;
            }
            reNameChatMsg(name);
        }

        @Override
        public void error(int errorCode, String errorMsg) {
            if (mProgressDialog != null) {
                mProgressDialog.dismiss();
                mProgressDialog = null;
            }
            showToast(errorMsg);
        }
    });
}
Also used : RequestListener(com.lingtuan.firefly.listener.RequestListener) JSONObject(org.json.JSONObject)

Aggregations

RequestListener (com.lingtuan.firefly.listener.RequestListener)32 JSONObject (org.json.JSONObject)32 SuppressLint (android.annotation.SuppressLint)7 Intent (android.content.Intent)6 JSONArray (org.json.JSONArray)5 UserBaseVo (com.lingtuan.firefly.vo.UserBaseVo)4 UserInfoVo (com.lingtuan.firefly.vo.UserInfoVo)4 JSONException (org.json.JSONException)4 TokenVo (com.lingtuan.firefly.wallet.vo.TokenVo)3 Handler (android.os.Handler)2 RegistUI (com.lingtuan.firefly.login.RegistUI)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Bundle (android.os.Bundle)1 NewContactVO (com.lingtuan.firefly.contact.vo.NewContactVO)1 ContactItemComparator (com.lingtuan.firefly.custom.contact.ContactItemComparator)1 ChatMsg (com.lingtuan.firefly.vo.ChatMsg)1