update
This commit is contained in:
parent
d95df4b1a8
commit
43362d3800
@ -173,7 +173,7 @@ public class MainActivity extends AbsOTOActivity {
|
||||
isHome = true;
|
||||
}
|
||||
if (data.getChat() == 0) {
|
||||
isMan = IMLoginManager.get(mContext).getUserInfo().getSex() == 1;
|
||||
isMan = UserManager.getUserBean().getUser().getSex() == 1;
|
||||
}
|
||||
if (!isHome && data.getChat() != 0) {
|
||||
isShow = false;
|
||||
@ -237,7 +237,7 @@ public class MainActivity extends AbsOTOActivity {
|
||||
OTONetManager.getInstance(mContext).getBaseInfos(false, new com.yunbao.common.http.base.HttpCallback<com.shayu.onetoone.bean.UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(com.shayu.onetoone.bean.UserBean data) {
|
||||
UserManager.saveUserBean(data);
|
||||
UserManager.saveUserBean(mContext,data);
|
||||
if (data.getStatus() == 0) {
|
||||
RouteManager.forwardCompleteActivity();
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import android.webkit.WebViewClient;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
@ -82,7 +83,7 @@ public class WebViewActivity extends AbsOTOActivity {
|
||||
return;
|
||||
}
|
||||
if (!url.contains("token")&&url.startsWith("http")) {
|
||||
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
|
||||
IMLoginModel userInfo = UserManager.getUserBean().getUser();
|
||||
url += "&uid=" + userInfo.getId() + "&token=" + userInfo.getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0");
|
||||
}
|
||||
Log.i("WebView",url);
|
||||
|
@ -19,6 +19,7 @@ import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
@ -77,7 +78,7 @@ public class DynamicFragment extends BaseFragment {
|
||||
super.onReceivedHttpError(view, request, errorResponse);
|
||||
}
|
||||
});
|
||||
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
|
||||
IMLoginModel userInfo = UserManager.getUserBean().getUser();
|
||||
String url = CommonAppConfig.HOST + "/h5/shequ/index.html#/h5/shequ?stack-key-1=698c5f85%20&uid="
|
||||
+ userInfo.getId() + "&token=" + userInfo.getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0");
|
||||
Log.i("Web", url);
|
||||
|
@ -28,6 +28,7 @@ import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.manager.SendMessageManager;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
@ -132,7 +133,7 @@ public class FriendsFragment extends BaseFragment {
|
||||
|
||||
private void initMateConfig() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getMessageConsumeConfig(IMLoginManager.get(mContext).getUserInfo().getId() + "", new HttpCallback<MessageConsumeConfigBean>() {
|
||||
.getMessageConsumeConfig(UserManager.getUserBean().getUser().getId() + "", new HttpCallback<MessageConsumeConfigBean>() {
|
||||
@Override
|
||||
public void onSuccess(MessageConsumeConfigBean data) {
|
||||
configBean = data;
|
||||
|
@ -24,6 +24,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.PermissionUtils;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lzf.easyfloat.EasyFloat;
|
||||
@ -48,6 +49,7 @@ import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.manager.SendMessageManager;
|
||||
import com.shayu.onetoone.utils.MsgCheckUtils;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.shayu.onetoone.view.MsgInputPanelForAudio;
|
||||
import com.shayu.onetoone.view.MsgInputPanelForGift;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
@ -85,10 +87,12 @@ import io.rong.imkit.model.UiMessage;
|
||||
import io.rong.imkit.picture.PictureSelector;
|
||||
import io.rong.imkit.picture.config.PictureMimeType;
|
||||
import io.rong.imkit.picture.entity.LocalMedia;
|
||||
import io.rong.imkit.userinfo.RongUserInfoManager;
|
||||
import io.rong.imlib.IRongCallback;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.imlib.model.UserInfo;
|
||||
import io.rong.message.ImageMessage;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
@ -164,6 +168,7 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
public void onError(int status, String msg) {
|
||||
super.onError(status, msg);
|
||||
if (status == OnSendMessageListener.STATUS_NOT_PRICE) {
|
||||
|
||||
MsgCheckUtils.checkPrice(mContext, targetId, new OnItemClickListener<MessageConsumeConfigBean>() {
|
||||
@Override
|
||||
public void onItemClick(MessageConsumeConfigBean bean, int position) {
|
||||
@ -635,8 +640,8 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
} else {
|
||||
sex.setImageResource(R.mipmap.ic_message_tab_woman);
|
||||
}
|
||||
System.out.println("同性別:" + data.getUser().getSex() + "|" + IMLoginManager.get(mContext).getUserInfo().getSex());
|
||||
if (data.getUser().getSex() == IMLoginManager.get(mContext).getUserInfo().getSex()) {
|
||||
System.out.println("同性別:" + data.getUser().getSex() + "|" + UserManager.getUserBean().getUser().getSex());
|
||||
if (data.getUser().getSex() == UserManager.getUserBean().getUser().getSex()) {
|
||||
call.setVisibility(View.GONE);
|
||||
video.setVisibility(View.GONE);
|
||||
}
|
||||
@ -658,6 +663,9 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
video.setImageResource(R.mipmap.ic_msg_video_lock);
|
||||
call.setTag("true");
|
||||
}
|
||||
UserInfo info = new UserInfo(data.getUser().getId() + "", data.getUser().getUserNicename(), Uri.parse(data.getUser().getAvatar()));
|
||||
info.setExtra(JSONObject.toJSONString(data));
|
||||
RongUserInfoManager.getInstance().refreshUserInfoCache(info);
|
||||
/* AppManager.runDebugCode(() -> {
|
||||
call.setTag(null);
|
||||
call.setImageResource(R.mipmap.ic_msg_call);
|
||||
|
@ -59,6 +59,7 @@ public class MsgFriendFragment extends BaseFragment implements BaseAdapter.OnIte
|
||||
SmartRefreshLayout mRefreshLayout;
|
||||
MsgMessageRecyclerViewAdapter mAdapter;
|
||||
List<BaseUiConversation> list;
|
||||
List<HomeItemBean> itemBeans;
|
||||
private int page = 1;
|
||||
private static final String TAG = MsgFriendFragment.class.getName();
|
||||
|
||||
@ -98,7 +99,6 @@ public class MsgFriendFragment extends BaseFragment implements BaseAdapter.OnIte
|
||||
mList.setLayoutManager(layoutManager);
|
||||
mList.setAdapter(this.mAdapter);
|
||||
initRefreshView();
|
||||
initData();
|
||||
|
||||
}
|
||||
|
||||
@ -114,6 +114,7 @@ public class MsgFriendFragment extends BaseFragment implements BaseAdapter.OnIte
|
||||
});
|
||||
this.mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
initData();
|
||||
}
|
||||
});
|
||||
@ -145,7 +146,6 @@ public class MsgFriendFragment extends BaseFragment implements BaseAdapter.OnIte
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getFriends(page, new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
@ -153,6 +153,7 @@ public class MsgFriendFragment extends BaseFragment implements BaseAdapter.OnIte
|
||||
if (page == 1) {
|
||||
list.clear();
|
||||
}
|
||||
itemBeans=data;
|
||||
if (data.isEmpty()) {
|
||||
mAdapter.setDataCollection(list);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
@ -160,9 +161,7 @@ public class MsgFriendFragment extends BaseFragment implements BaseAdapter.OnIte
|
||||
mRefreshLayout.finishLoadMore();
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
getNewData(data.get(i), i == data.size() - 1);
|
||||
}
|
||||
getNewData(data);
|
||||
|
||||
}
|
||||
|
||||
@ -171,37 +170,42 @@ public class MsgFriendFragment extends BaseFragment implements BaseAdapter.OnIte
|
||||
|
||||
}
|
||||
|
||||
public synchronized void getNewData(HomeItemBean item, boolean over) {
|
||||
RongIMClient.getInstance().getConversation(Conversation.ConversationType.PRIVATE, item.getId() + "", new RongIMClient.ResultCallback<Conversation>() {
|
||||
@Override
|
||||
public void onSuccess(Conversation conversation) {
|
||||
if(conversation==null){
|
||||
conversation=new Conversation();
|
||||
}
|
||||
SingleConversation singleConversation = new SingleConversation(mContext, conversation);
|
||||
if (StringUtil.isEmpty(singleConversation.mConversationContent.toString())) {
|
||||
singleConversation.mConversationContent = new SpannableString("你们什么都没聊");
|
||||
}
|
||||
list.add(singleConversation);
|
||||
if (over) {
|
||||
mAdapter.setDataCollection(list);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
mRefreshLayout.finishRefresh();
|
||||
mRefreshLayout.finishLoadMore();
|
||||
page++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getNewData(List<HomeItemBean> data) {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
HomeItemBean item = data.get(i);
|
||||
boolean over = i == data.size() - 1;
|
||||
RongIMClient.getInstance().getConversation(Conversation.ConversationType.PRIVATE, item.getId() + "", new RongIMClient.ResultCallback<Conversation>() {
|
||||
@Override
|
||||
public void onSuccess(Conversation conversation) {
|
||||
if (conversation == null) {
|
||||
conversation = new Conversation();
|
||||
}
|
||||
SingleConversation singleConversation = new SingleConversation(mContext, conversation);
|
||||
if (StringUtil.isEmpty(singleConversation.mConversationContent.toString())) {
|
||||
singleConversation.mConversationContent = new SpannableString("你们什么都没聊");
|
||||
}
|
||||
list.add(singleConversation);
|
||||
if (over) {
|
||||
mAdapter.setDataCollection(list);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
mRefreshLayout.finishRefresh();
|
||||
mRefreshLayout.finishLoadMore();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(View view, ViewHolder holder, int position) {
|
||||
if (position >= 0 && position < this.mAdapter.getData().size()) {
|
||||
@ -232,8 +236,9 @@ public class MsgFriendFragment extends BaseFragment implements BaseAdapter.OnIte
|
||||
@Subscribe
|
||||
public void event(MessageMsgBusEvent event) {
|
||||
if (event.getType() == MessageMsgBusEvent.TYPE_UPDATE_POINT) {
|
||||
page = 1;
|
||||
initData();
|
||||
/* page = 1;
|
||||
initData();*/
|
||||
getNewData(itemBeans);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ import com.shayu.onetoone.bean.JoinAnchorBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.twitter.sdk.android.core.Callback;
|
||||
import com.twitter.sdk.android.core.DefaultLogger;
|
||||
import com.twitter.sdk.android.core.Result;
|
||||
@ -612,6 +613,7 @@ public class EntryActivity extends AbsOTOActivity {
|
||||
.getBaseInfos(true,new HttpCallback<UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserBean data) {
|
||||
UserManager.saveUserBean(mContext,data);
|
||||
if (mFirstLogin) {
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY) {
|
||||
RouteManager.forwardMainActivity();
|
||||
|
@ -335,8 +335,8 @@ public class CallAudioActivity extends AbsOTOActivity implements View.OnClickLis
|
||||
}).show();
|
||||
if (toPay) {
|
||||
Log.e(TAG, "调起支付界面");
|
||||
RouteManager.forwardWebViewActivity(null, "https://www.baidu.com");
|
||||
// RouteManager.forwardWebViewActivity(null, HtmlUrlUtils.getPayUrl(mContext,false,HtmlUrlUtils.URL_PAY_COIN));
|
||||
// RouteManager.forwardWebViewActivity(null, "https://www.baidu.com");
|
||||
RouteManager.forwardWebViewActivity(null, HtmlUrlUtils.getPayUrl(mContext,false,HtmlUrlUtils.URL_PAY_COIN));
|
||||
}
|
||||
if (toChatView) {
|
||||
ConversationUtils.startConversation(mContext, targetId);
|
||||
|
@ -11,6 +11,7 @@ import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.login.EntryActivity;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.utils.HtmlUrlUtils;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
@ -51,7 +52,7 @@ public class SettingActivity extends AbsActivity {
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.set_up));
|
||||
IMLoginModel model = IMLoginManager.get(mContext).getUserInfo();
|
||||
IMLoginModel model = UserManager.getUserBean().getUser();
|
||||
|
||||
versionCode = findViewById(R.id.versionCode);
|
||||
cacheSize = findViewById(R.id.cacheSize);
|
||||
|
@ -15,6 +15,7 @@ public class SendConsumeBean extends BaseModel {
|
||||
private int code;
|
||||
private String msg;
|
||||
private String accostMsg;
|
||||
private String money;
|
||||
|
||||
public SendConsumeBean() {
|
||||
}
|
||||
@ -74,4 +75,8 @@ public class SendConsumeBean extends BaseModel {
|
||||
public void setProp(PropBean prop) {
|
||||
this.prop = prop;
|
||||
}
|
||||
|
||||
public String getMoney() {
|
||||
return money;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import com.shayu.onetoone.bean.SendConsumeBean;
|
||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.SendMessageManager;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.shayu.onetoone.view.MsgInputPanelForGift;
|
||||
import com.shayu.onetoone.widget.PagerConfig;
|
||||
import com.shayu.onetoone.widget.PagerGridLayoutManager;
|
||||
@ -107,7 +108,7 @@ public class GiftDialog extends AbsDialogPopupWindow {
|
||||
}
|
||||
|
||||
private void sendGift(GiftBean item) {
|
||||
MessageChatGiftContent bean = MessageChatGiftContent.obtain(JSONObject.toJSONString(item), "1", IMLoginManager.get(mContext).getUserInfo().getId() + "");
|
||||
MessageChatGiftContent bean = MessageChatGiftContent.obtain(JSONObject.toJSONString(item), "1", UserManager.getUserBean().getUser().getId() + "");
|
||||
bean.setExtra(JSONObject.toJSONString(item));
|
||||
IMCenter.getInstance().sendMessage(Message.obtain(targetId, Conversation.ConversationType.PRIVATE, bean),
|
||||
null,
|
||||
|
@ -31,6 +31,7 @@ import com.shayu.onetoone.bean.TargetUserInfoBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.bean.UserItemBean;
|
||||
import com.shayu.onetoone.network.API;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
@ -42,6 +43,7 @@ import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.MD5Util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
@ -118,6 +120,7 @@ public class OTONetManager {
|
||||
UserInfo info = new UserInfo(userInfo.getId() + "", userInfo.getUserNicename(), Uri.parse(userInfo.getAvatar()));
|
||||
info.setExtra(JSONObject.toJSONString(userInfo));
|
||||
RongUserInfoManager.getInstance().refreshUserInfoCache(info);
|
||||
UserManager.saveUserBean(mContext, liveGiftBeanResponseModel.getData().getInfo());
|
||||
callback.onSuccess(liveGiftBeanResponseModel.getData().getInfo());
|
||||
}
|
||||
}
|
||||
@ -391,7 +394,7 @@ public class OTONetManager {
|
||||
|
||||
public void updateFile(File file, HttpCallback<AvatarBean> callback) {
|
||||
MultipartBody.Part uploadFile = createUploadFile(file);
|
||||
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
|
||||
IMLoginModel userInfo = UserManager.getUserBean().getUser();
|
||||
API.get().otoApi(mContext)
|
||||
.updateFile(uploadFile, userInfo.getId() + "", userInfo.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -438,6 +441,10 @@ public class OTONetManager {
|
||||
}
|
||||
|
||||
public void getTargetUserInfoList(List<Integer> ids, HttpCallback<List<TargetUserInfoBean>> callback) {
|
||||
if (ids.isEmpty()) {
|
||||
callback.onSuccess(new ArrayList<>());
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Integer id : ids) {
|
||||
sb.append(id).append(",");
|
||||
@ -599,6 +606,45 @@ public class OTONetManager {
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
public void sendMessageBefore(String tuid,
|
||||
int type,
|
||||
String giftId,
|
||||
String msg,
|
||||
String time,
|
||||
int online,
|
||||
String method,
|
||||
HttpCallback<SendConsumeBean> callback) {
|
||||
|
||||
API.get().otoApi(mContext)
|
||||
.sendMessageBefore(tuid, type, giftId, msg, time, online, method)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(model -> {
|
||||
if (callback != null) {
|
||||
if (model.isError()) {
|
||||
JSONObject json = JSONObject.parseObject(model.getJsonSrc());
|
||||
SendConsumeBean bean = new SendConsumeBean();
|
||||
bean.setCode(json.getJSONObject("data").getInteger("code"));
|
||||
bean.setMsg(json.getJSONObject("data").getString("msg"));
|
||||
callback.onSuccess(bean);
|
||||
return;
|
||||
}
|
||||
SendConsumeBean bean = model.getData().getInfo();
|
||||
bean.setCode(model.getData().getCode());
|
||||
bean.setMsg(model.getData().getMsg());
|
||||
callback.onSuccess(bean);
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
Log.e(TAG, "accept: ", throwable);
|
||||
if (callback != null) {
|
||||
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
|
||||
}
|
||||
}
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
public void getMessageConsumeConfig(String toUid, HttpCallback<MessageConsumeConfigBean> callback) {
|
||||
|
||||
API.get().otoApi(mContext)
|
||||
@ -1166,7 +1212,7 @@ public class OTONetManager {
|
||||
|
||||
public void getFriendAppMoneySum(HttpCallback<FriendAppMoneySumModel> callback) {
|
||||
API.get().otoApi(mContext).
|
||||
getFriendAppMoneySum()
|
||||
getFriendAppMoneySum(3, 1)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<ResponseModel<FriendAppMoneySumModel>>() {
|
||||
|
@ -5,6 +5,7 @@ import com.shayu.onetoone.bean.PurseBean;
|
||||
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||
import com.shayu.onetoone.event.MoneyUpdateEvent;
|
||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
@ -127,6 +128,45 @@ public class SendMessageManager {
|
||||
}
|
||||
|
||||
private static void send(SendData sendData, OnSendMessageListener messageListener) {
|
||||
if(sendData.method.equals("before")){
|
||||
OTONetManager.getInstance(null)
|
||||
.sendMessageBefore(sendData.toUid,
|
||||
sendData.type,
|
||||
sendData.giftId,
|
||||
sendData.content,
|
||||
sendData.time,
|
||||
sendData.online,
|
||||
sendData.method,
|
||||
new HttpCallback<SendConsumeBean>() {
|
||||
@Override
|
||||
public void onSuccess(SendConsumeBean consumeBean) {
|
||||
if (consumeBean.getCode() != 0) {
|
||||
if (consumeBean.getCode() == 503 || consumeBean.getCode()==500) {
|
||||
messageListener.onError(OnSendMessageListener.STATUS_NOT_PRICE, consumeBean.getMsg(), consumeBean);
|
||||
} else {
|
||||
messageListener.onError(OnSendMessageListener.STATUS_ERROR, consumeBean.getMsg(), consumeBean);
|
||||
}
|
||||
|
||||
} else {
|
||||
String token = null;
|
||||
if (sendData.needToken) {
|
||||
token = UUID.randomUUID().toString();
|
||||
cache.put(token, sendData);
|
||||
}
|
||||
messageListener.onSuccess(token, consumeBean);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
messageListener.onError(OnSendMessageListener.STATUS_ERROR, error);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
OTONetManager.getInstance(null)
|
||||
.sendMessage(sendData.toUid,
|
||||
sendData.type,
|
||||
@ -139,6 +179,7 @@ public class SendMessageManager {
|
||||
@Override
|
||||
public void onSuccess(SendConsumeBean consumeBean) {
|
||||
if (consumeBean.getCode() != 0) {
|
||||
UserManager.saveMoney(consumeBean.getMoney());
|
||||
if (consumeBean.getCode() == 503 || consumeBean.getCode()==500) {
|
||||
messageListener.onError(OnSendMessageListener.STATUS_NOT_PRICE, consumeBean.getMsg(), consumeBean);
|
||||
} else {
|
||||
@ -179,6 +220,7 @@ public class SendMessageManager {
|
||||
new HttpCallback<SendConsumeBean>() {
|
||||
@Override
|
||||
public void onSuccess(SendConsumeBean sd) {
|
||||
UserManager.saveMoney(sd.getMoney());
|
||||
if (sd.getCode() != 0) {
|
||||
if (listener != null) {
|
||||
listener.onSuccess(sd.getMsg(), sd);
|
||||
@ -189,8 +231,7 @@ public class SendMessageManager {
|
||||
listener.onSuccess(null, sd);
|
||||
}
|
||||
}
|
||||
iniPurse(null);
|
||||
|
||||
Bus.get().post(new MoneyUpdateEvent(MoneyUpdateEvent.TYPE_UPDATE,sd.getMoney()+""));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -147,6 +147,16 @@ public interface OneToOneApi {
|
||||
@Query("online") int online,
|
||||
@Query("method") String method
|
||||
);
|
||||
@GET("/api/public/?service=Friendappmsg.sendBefore")
|
||||
Observable<ResponseModel<SendConsumeBean>> sendMessageBefore(
|
||||
@Query("tuid") String tuid,
|
||||
@Query("type") int type,
|
||||
@Query("gift_id") String giftId,
|
||||
@Query("msg") String msg,
|
||||
@Query("time") String time,
|
||||
@Query("online") int online,
|
||||
@Query("method") String method
|
||||
);
|
||||
|
||||
@GET("/api/public/?service=Friendappmsg.getConfig")
|
||||
Observable<ResponseModel<MessageConsumeConfigBean>> getMessageConsumeConfig(@Query("tuid") String toUid);
|
||||
@ -237,7 +247,8 @@ public interface OneToOneApi {
|
||||
*/
|
||||
@GET("/api/public/?service=Friendappmoney.sum")
|
||||
Observable<ResponseModel<FriendAppMoneySumModel>> getFriendAppMoneySum(
|
||||
|
||||
@Query("currency_type")int type,
|
||||
@Query("income")int income
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.GiftBean;
|
||||
import com.shayu.onetoone.bean.MessageChatGiftContent;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
@ -59,7 +60,7 @@ public class MessageChatReceiveGiftItemProvider extends BaseMessageItemProvider<
|
||||
ImgLoader.display(mContext, item.getGifticon(), holder.getView(R.id.giftIcon));
|
||||
LinearLayout holderView = holder.getView(R.id.layout_root);
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
if (messageChatGiftContent.getSendUid().equals(IMLoginManager.get(mContext).getUserInfo().getId() + "")) {
|
||||
if (messageChatGiftContent.getSendUid().equals(UserManager.getUserBean().getUser().getId() + "")) {
|
||||
params.gravity = Gravity.END;
|
||||
uiMessage.setMessageDirection(Message.MessageDirection.SEND);
|
||||
holder.setText(R.id.title, WordUtil.getNewString(R.string.gift_send_ta));
|
||||
|
@ -6,13 +6,16 @@ import android.view.View;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.FollowBean;
|
||||
import com.shayu.onetoone.bean.MessageConsumeConfigBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
|
||||
@ -23,11 +26,14 @@ public class UserManager {
|
||||
if (userBean == null) {
|
||||
userBean = JSONObject.parseObject(SpUtil.getStringValue("oto_user_info"), UserBean.class);
|
||||
}
|
||||
System.out.println("读取用户信息+"+userBean);
|
||||
return userBean;
|
||||
}
|
||||
|
||||
public static void saveUserBean(UserBean bean) {
|
||||
public static void saveUserBean(Context mContext, UserBean bean) {
|
||||
userBean = bean;
|
||||
System.out.println("保存用户信息" + JSONObject.toJSONString(bean));
|
||||
IMLoginManager.get(mContext).setupLoginUser(bean.getUser());
|
||||
SpUtil.setStringValue("oto_user_info", JSONObject.toJSONString(bean));
|
||||
}
|
||||
|
||||
@ -50,4 +56,28 @@ public class UserManager {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void saveMoney(String money) {
|
||||
if (StringUtil.isEmpty(money)) {
|
||||
return;
|
||||
}
|
||||
SpUtil.setStringValue("oto_user_money", money);
|
||||
}
|
||||
|
||||
public static void getMoney(Context mContext,String targetId, OnItemClickListener<String> listener) {
|
||||
String money = SpUtil.getStringValue("oto_user_money");
|
||||
if (StringUtil.isEmpty(money)) {
|
||||
money = null;
|
||||
}
|
||||
if (money == null) {
|
||||
MsgCheckUtils.checkPrice(null, targetId, new OnItemClickListener<MessageConsumeConfigBean>() {
|
||||
@Override
|
||||
public void onItemClick(MessageConsumeConfigBean bean, int position) {
|
||||
listener.onItemClick(bean.getPrice() + "", 0);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
listener.onItemClick(money, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.SendMessageManager;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.shayu.onetoone.widget.PagerConfig;
|
||||
import com.shayu.onetoone.widget.PagerGridLayoutManager;
|
||||
import com.shayu.onetoone.widget.PagerGridSnapHelper;
|
||||
@ -113,7 +114,7 @@ public class MsgInputPanelForGift extends AbsInputPanel {
|
||||
}
|
||||
|
||||
private void sendGift(GiftBean item) {
|
||||
MessageChatGiftContent bean = MessageChatGiftContent.obtain(JSONObject.toJSONString(item), "1", IMLoginManager.get(mContext).getUserInfo().getId() + "");
|
||||
MessageChatGiftContent bean = MessageChatGiftContent.obtain(JSONObject.toJSONString(item), "1", UserManager.getUserBean().getUser().getId() + "");
|
||||
bean.setExtra(JSONObject.toJSONString(item));
|
||||
IMCenter.getInstance().sendMessage(Message.obtain(targetId, Conversation.ConversationType.PRIVATE, bean),
|
||||
null,
|
||||
@ -160,10 +161,10 @@ public class MsgInputPanelForGift extends AbsInputPanel {
|
||||
|
||||
}
|
||||
});
|
||||
SendMessageManager.iniPurse(new OnItemClickListener<PurseBean>() {
|
||||
UserManager.getMoney(mContext, targetId, new OnItemClickListener<String>() {
|
||||
@Override
|
||||
public void onItemClick(PurseBean bean, int position) {
|
||||
money.setText(bean.getStart());
|
||||
public void onItemClick(String bean, int position) {
|
||||
money.setText(bean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user