update
@ -159,6 +159,9 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activity.message.CallAudioActivity"
|
android:name=".activity.message.CallAudioActivity"
|
||||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||||
|
<activity
|
||||||
|
android:name=".activity.MatchingActivity"
|
||||||
|
android:windowSoftInputMode="stateHidden|adjustResize"/>
|
||||||
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.shayu.onetoone.activity;
|
package com.shayu.onetoone.activity;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@ -19,14 +20,19 @@ import com.shayu.onetoone.activity.fragments.FriendsFragment;
|
|||||||
import com.shayu.onetoone.activity.fragments.MessageFragment;
|
import com.shayu.onetoone.activity.fragments.MessageFragment;
|
||||||
import com.shayu.onetoone.activity.fragments.MyFragment;
|
import com.shayu.onetoone.activity.fragments.MyFragment;
|
||||||
import com.shayu.onetoone.bean.JoinAnchorBean;
|
import com.shayu.onetoone.bean.JoinAnchorBean;
|
||||||
|
import com.shayu.onetoone.bean.MatchingItemSizeBean;
|
||||||
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
||||||
|
import com.shayu.onetoone.dialog.FirstTipsDialog;
|
||||||
|
import com.shayu.onetoone.dialog.TipsDialog;
|
||||||
import com.shayu.onetoone.event.MessageMsgBusEvent;
|
import com.shayu.onetoone.event.MessageMsgBusEvent;
|
||||||
|
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||||
import com.shayu.onetoone.manager.CallClientManager;
|
import com.shayu.onetoone.manager.CallClientManager;
|
||||||
import com.shayu.onetoone.manager.OTONetManager;
|
import com.shayu.onetoone.manager.OTONetManager;
|
||||||
import com.shayu.onetoone.manager.RouteManager;
|
import com.shayu.onetoone.manager.RouteManager;
|
||||||
import com.yunbao.common.CommonAppConfig;
|
import com.yunbao.common.CommonAppConfig;
|
||||||
import com.yunbao.common.bean.IMLoginModel;
|
import com.yunbao.common.bean.IMLoginModel;
|
||||||
import com.yunbao.common.http.base.HttpCallback;
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
import com.yunbao.common.manager.IMLoginManager;
|
import com.yunbao.common.manager.IMLoginManager;
|
||||||
import com.yunbao.common.manager.NoviceInstructorManager;
|
import com.yunbao.common.manager.NoviceInstructorManager;
|
||||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||||
@ -116,6 +122,49 @@ public class MainActivity extends AbsOTOActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
CallClientManager.getManager();
|
CallClientManager.getManager();
|
||||||
|
//initFirstLoginTips();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initFirstLoginTips() {
|
||||||
|
|
||||||
|
OTONetManager.getInstance(mContext)
|
||||||
|
.getMatchingNum(new HttpCallback<MatchingItemSizeBean>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(MatchingItemSizeBean data) {
|
||||||
|
boolean isHome = false;
|
||||||
|
boolean isMan = false;
|
||||||
|
boolean isShow = true;
|
||||||
|
if (data.getLogin() == 0) {
|
||||||
|
isHome = true;
|
||||||
|
} else if (data.getChat() == 0) {
|
||||||
|
isMan = IMLoginManager.get(mContext).getUserInfo().getSex() == 1;
|
||||||
|
} else {
|
||||||
|
isShow = false;
|
||||||
|
}
|
||||||
|
if (isShow) {
|
||||||
|
new FirstTipsDialog(mContext)
|
||||||
|
.setHome(isMan)
|
||||||
|
.setMan(isHome)
|
||||||
|
.setOnItemClickListener(new OnItemClickListener<FirstTipsDialog>() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(FirstTipsDialog dialog, int position) {
|
||||||
|
if (position == 0) {
|
||||||
|
ToastUtil.show("灵魂速配");
|
||||||
|
} else {
|
||||||
|
viewPager.setCurrentItem(2);
|
||||||
|
}
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.showDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,206 @@
|
|||||||
|
package com.shayu.onetoone.activity;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.makeramen.roundedimageview.RoundedImageView;
|
||||||
|
import com.shayu.onetoone.R;
|
||||||
|
import com.shayu.onetoone.activity.message.ChatActivity;
|
||||||
|
import com.shayu.onetoone.bean.MatchingInfoBean;
|
||||||
|
import com.shayu.onetoone.bean.MatchingInfoUserBean;
|
||||||
|
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||||
|
import com.shayu.onetoone.bean.UserBean;
|
||||||
|
import com.shayu.onetoone.dialog.TipsDialog;
|
||||||
|
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||||
|
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.ConversationUtils;
|
||||||
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
@Route(path = RouteManager.ACTIVITY_MATCHING)
|
||||||
|
public class MatchingActivity extends AbsOTOActivity {
|
||||||
|
private Task task;
|
||||||
|
private Handler handler;
|
||||||
|
private RoundedImageView user1, user2, user3, user4, user5;
|
||||||
|
private TextView num;
|
||||||
|
private ImageView back;
|
||||||
|
List<RoundedImageView> imageViewList = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLayoutId() {
|
||||||
|
return R.layout.activity_matching;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void main(Bundle savedInstanceState) {
|
||||||
|
handler = new Handler(Looper.getMainLooper());
|
||||||
|
if (initView()) {
|
||||||
|
task = new Task();
|
||||||
|
new Timer().schedule(task, 10000, 10000);
|
||||||
|
}
|
||||||
|
initData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (task != null) {
|
||||||
|
task.cancel();
|
||||||
|
task = null;
|
||||||
|
}
|
||||||
|
handler = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean initView() {
|
||||||
|
user1 = findViewById(R.id.user1);
|
||||||
|
user2 = findViewById(R.id.user2);
|
||||||
|
user3 = findViewById(R.id.user3);
|
||||||
|
user4 = findViewById(R.id.user4);
|
||||||
|
user5 = findViewById(R.id.user5);
|
||||||
|
num = findViewById(R.id.num);
|
||||||
|
back = findViewById(R.id.back);
|
||||||
|
imageViewList.add(user1);
|
||||||
|
imageViewList.add(user2);
|
||||||
|
imageViewList.add(user3);
|
||||||
|
imageViewList.add(user4);
|
||||||
|
imageViewList.add(user5);
|
||||||
|
back.setOnClickListener(v -> {
|
||||||
|
new TipsDialog(mContext)
|
||||||
|
.setTitle("確定要退出靈魂速配嗎?")
|
||||||
|
.setApplyText("繼續匹配")
|
||||||
|
.setCancelText("徹底離開")
|
||||||
|
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onCancel(Dialog dialog) {
|
||||||
|
super.onCancel(dialog);
|
||||||
|
task.cancel();
|
||||||
|
task = null;
|
||||||
|
MatchingActivity.this.finish();
|
||||||
|
}
|
||||||
|
}).showDialog();
|
||||||
|
});
|
||||||
|
Bundle bundle = getIntent().getBundleExtra("bundle");
|
||||||
|
if (bundle != null) {
|
||||||
|
String data = bundle.getString("data");
|
||||||
|
bundle.putInt("type",ChatActivity.CALL_CHAT_TYPE_MATCH);
|
||||||
|
if (data != null) {
|
||||||
|
SendConsumeBean bean = JSONObject.parseObject(data, SendConsumeBean.class);
|
||||||
|
if (bean != null) {
|
||||||
|
ToastUtil.show("有结果直接进");
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
ConversationUtils.startConversation(mContext, bean.getMateUser().getUser().getId() + "", bundle);
|
||||||
|
MatchingActivity.this.finish();
|
||||||
|
}, 5000);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initData() {
|
||||||
|
OTONetManager.getInstance(mContext)
|
||||||
|
.getMatchingInfo(new HttpCallback<MatchingInfoBean>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(MatchingInfoBean data) {
|
||||||
|
List<MatchingInfoUserBean> list = data.getList();
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
ImgLoader.display(mContext, list.get(i).getAvatar(), imageViewList.get(i));
|
||||||
|
}
|
||||||
|
num.setText(data.getPeople() + "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void call() {
|
||||||
|
handler.post(() -> ToastUtil.show("匹配"));
|
||||||
|
SendMessageManager.matching(new OnSendMessageListener() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String token, SendConsumeBean bean) {
|
||||||
|
super.onSuccess(token, bean);
|
||||||
|
task.cancel();
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putInt("type",ChatActivity.CALL_CHAT_TYPE_MATCH);
|
||||||
|
bundle.putString("data", JSONObject.toJSONString(bean));
|
||||||
|
ConversationUtils.startConversation(mContext, bean.getMateUser().getUser().getId() + "", bundle);
|
||||||
|
MatchingActivity.this.finish();
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(int status, String msg, SendConsumeBean bean) {
|
||||||
|
super.onError(status, msg, bean);
|
||||||
|
if (bean.getCode() == 503) {
|
||||||
|
handler.post(() -> ToastUtil.show("没人,继续"));
|
||||||
|
}else if(status==OnSendMessageListener.STATUS_NOT_PRICE){
|
||||||
|
task.cancel();
|
||||||
|
handler.post(() -> ToastUtil.show("价格不足"));
|
||||||
|
MatchingActivity.this.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Task extends TimerTask {
|
||||||
|
final int MAX = 5;
|
||||||
|
int index = MAX;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (index != 0) {
|
||||||
|
call();
|
||||||
|
} else {
|
||||||
|
handler.post(() -> {
|
||||||
|
new TipsDialog(mContext)
|
||||||
|
.setTitle("当前等待时间较长,建议您 先去观看动态哦,稍后再来哦~")
|
||||||
|
.setApplyText("去看动态")
|
||||||
|
.setCancelText("繼續匹配")
|
||||||
|
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onCancel(Dialog dialog) {
|
||||||
|
super.onCancel(dialog);
|
||||||
|
index = MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onApply(Dialog dialog) {
|
||||||
|
super.onApply(dialog);
|
||||||
|
task.cancel();
|
||||||
|
task = null;
|
||||||
|
MatchingActivity.this.finish();
|
||||||
|
}
|
||||||
|
}).showDialog();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean cancel() {
|
||||||
|
handler.post(() -> ToastUtil.show("取消"));
|
||||||
|
return super.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,11 +7,16 @@ import android.view.ViewGroup;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.shayu.onetoone.R;
|
import com.shayu.onetoone.R;
|
||||||
import com.shayu.onetoone.activity.fragments.BaseFragment;
|
import com.shayu.onetoone.activity.fragments.BaseFragment;
|
||||||
import com.shayu.onetoone.adapter.HomeRecommendListAdapter;
|
import com.shayu.onetoone.adapter.HomeRecommendListAdapter;
|
||||||
import com.shayu.onetoone.bean.HomeItemBean;
|
import com.shayu.onetoone.bean.HomeItemBean;
|
||||||
|
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||||
|
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||||
import com.shayu.onetoone.manager.OTONetManager;
|
import com.shayu.onetoone.manager.OTONetManager;
|
||||||
|
import com.shayu.onetoone.manager.RouteManager;
|
||||||
|
import com.shayu.onetoone.manager.SendMessageManager;
|
||||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
||||||
import com.yunbao.common.http.base.HttpCallback;
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
|
|
||||||
@ -31,12 +36,14 @@ public class RecommendFragment extends BaseFragment {
|
|||||||
private int page = 1;
|
private int page = 1;
|
||||||
private boolean isScreen;
|
private boolean isScreen;
|
||||||
Bundle screen;
|
Bundle screen;
|
||||||
|
View matching;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initView(View itemView) {
|
public void initView(View itemView) {
|
||||||
recyclerView = itemView.findViewById(R.id.recyclerView);
|
recyclerView = itemView.findViewById(R.id.recyclerView);
|
||||||
mRefreshLayout = itemView.findViewById(R.id.swipeRefreshLayout);
|
mRefreshLayout = itemView.findViewById(R.id.swipeRefreshLayout);
|
||||||
top = itemView.findViewById(R.id.btn_top_list);
|
top = itemView.findViewById(R.id.btn_top_list);
|
||||||
|
matching=itemView.findViewById(R.id.matching);
|
||||||
adapter = new HomeRecommendListAdapter(getContext());
|
adapter = new HomeRecommendListAdapter(getContext());
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
mRefreshLayout.setNestedScrollingEnabled(false);
|
mRefreshLayout.setNestedScrollingEnabled(false);
|
||||||
@ -57,6 +64,24 @@ public class RecommendFragment extends BaseFragment {
|
|||||||
top.setOnClickListener(view -> {
|
top.setOnClickListener(view -> {
|
||||||
recyclerView.scrollToPosition(0);
|
recyclerView.scrollToPosition(0);
|
||||||
});
|
});
|
||||||
|
matching.setOnClickListener(v -> {
|
||||||
|
SendMessageManager.matching(new OnSendMessageListener() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String token, SendConsumeBean bean) {
|
||||||
|
super.onSuccess(token, bean);
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("data", JSONObject.toJSONString(bean));
|
||||||
|
RouteManager.forwardActivity(RouteManager.ACTIVITY_MATCHING,bundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(int status, String msg, SendConsumeBean bean) {
|
||||||
|
super.onError(status, msg, bean);
|
||||||
|
RouteManager.forwardActivity(RouteManager.ACTIVITY_MATCHING);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
screen = getActivity().getIntent().getBundleExtra("screen");
|
screen = getActivity().getIntent().getBundleExtra("screen");
|
||||||
if (screen != null) {
|
if (screen != null) {
|
||||||
if (!isScreen) {
|
if (!isScreen) {
|
||||||
|
@ -12,7 +12,6 @@ import android.util.Log;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -22,18 +21,18 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.lxj.xpopup.XPopup;
|
import com.lxj.xpopup.XPopup;
|
||||||
import com.lxj.xpopup.interfaces.OnSelectListener;
|
|
||||||
import com.makeramen.roundedimageview.RoundedImageView;
|
import com.makeramen.roundedimageview.RoundedImageView;
|
||||||
import com.shayu.onetoone.R;
|
import com.shayu.onetoone.R;
|
||||||
import com.shayu.onetoone.adapter.MsgChatMessageListAdapter;
|
import com.shayu.onetoone.adapter.MsgChatMessageListAdapter;
|
||||||
import com.shayu.onetoone.bean.FollowBean;
|
import com.shayu.onetoone.bean.FollowBean;
|
||||||
import com.shayu.onetoone.bean.MessageChatAuthContent;
|
import com.shayu.onetoone.bean.MessageChatAuthContent;
|
||||||
import com.shayu.onetoone.bean.MessageChatTipsContent;
|
import com.shayu.onetoone.bean.MessageChatTipsContent;
|
||||||
|
import com.shayu.onetoone.bean.MessageConsumeConfigBean;
|
||||||
|
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||||
import com.shayu.onetoone.bean.UserBean;
|
import com.shayu.onetoone.bean.UserBean;
|
||||||
import com.shayu.onetoone.dialog.BottomListDialog;
|
import com.shayu.onetoone.dialog.BottomListDialog;
|
||||||
import com.shayu.onetoone.dialog.MsgChatClickDialog;
|
import com.shayu.onetoone.dialog.MsgChatClickDialog;
|
||||||
import com.shayu.onetoone.dialog.TipsDialog;
|
import com.shayu.onetoone.dialog.TipsDialog;
|
||||||
import com.shayu.onetoone.listener.OnCallStatusListener;
|
|
||||||
import com.shayu.onetoone.listener.OnDialogClickListener;
|
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||||
import com.shayu.onetoone.manager.CallClientManager;
|
import com.shayu.onetoone.manager.CallClientManager;
|
||||||
@ -47,7 +46,6 @@ import com.yunbao.common.glide.ImgLoader;
|
|||||||
import com.yunbao.common.http.base.HttpCallback;
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
import com.yunbao.common.utils.DpUtil;
|
|
||||||
import com.yunbao.common.utils.ProcessImageUtil;
|
import com.yunbao.common.utils.ProcessImageUtil;
|
||||||
import com.yunbao.common.utils.SpUtil;
|
import com.yunbao.common.utils.SpUtil;
|
||||||
import com.yunbao.common.utils.StringUtil;
|
import com.yunbao.common.utils.StringUtil;
|
||||||
@ -59,18 +57,12 @@ import java.lang.reflect.Field;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.rong.calllib.RongCallCommon;
|
|
||||||
import io.rong.imkit.IMCenter;
|
import io.rong.imkit.IMCenter;
|
||||||
import io.rong.imkit.config.RongConfigCenter;
|
import io.rong.imkit.config.RongConfigCenter;
|
||||||
import io.rong.imkit.conversation.MessageListAdapter;
|
import io.rong.imkit.conversation.MessageListAdapter;
|
||||||
import io.rong.imkit.conversation.extension.component.plugin.IPluginModule;
|
|
||||||
import io.rong.imkit.conversation.extension.component.plugin.ImagePlugin;
|
|
||||||
import io.rong.imkit.manager.SendImageManager;
|
|
||||||
import io.rong.imkit.model.UiMessage;
|
import io.rong.imkit.model.UiMessage;
|
||||||
import io.rong.imkit.picture.PictureSelectionModel;
|
|
||||||
import io.rong.imkit.picture.PictureSelector;
|
import io.rong.imkit.picture.PictureSelector;
|
||||||
import io.rong.imkit.picture.config.PictureMimeType;
|
import io.rong.imkit.picture.config.PictureMimeType;
|
||||||
import io.rong.imkit.picture.entity.LocalMedia;
|
import io.rong.imkit.picture.entity.LocalMedia;
|
||||||
@ -105,6 +97,7 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
|||||||
|
|
||||||
private String token;
|
private String token;
|
||||||
private static final String TAG = "聊天界面";
|
private static final String TAG = "聊天界面";
|
||||||
|
private MessageConsumeConfigBean configBean;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
@ -112,6 +105,7 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
|||||||
targetId = getActivity().getIntent().getStringExtra("targetId");
|
targetId = getActivity().getIntent().getStringExtra("targetId");
|
||||||
initBtn();
|
initBtn();
|
||||||
initChat();
|
initChat();
|
||||||
|
initPriceBean();
|
||||||
cameraUtil = new ProcessImageUtil(getActivity(), "com.shayu.onetoone.fileprovider");
|
cameraUtil = new ProcessImageUtil(getActivity(), "com.shayu.onetoone.fileprovider");
|
||||||
|
|
||||||
mRongExtension.setVisibility(View.VISIBLE);
|
mRongExtension.setVisibility(View.VISIBLE);
|
||||||
@ -124,8 +118,8 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
|||||||
}
|
}
|
||||||
SendMessageManager.sendMessageForText(targetId, mEditText.getText().toString(), new OnSendMessageListener() {
|
SendMessageManager.sendMessageForText(targetId, mEditText.getText().toString(), new OnSendMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String token) {
|
public void onSuccess(String token,SendConsumeBean bean) {
|
||||||
super.onSuccess(token);
|
super.onSuccess(token,bean);
|
||||||
ChatMessageFragment.this.token = token;
|
ChatMessageFragment.this.token = token;
|
||||||
sendText();
|
sendText();
|
||||||
|
|
||||||
@ -214,19 +208,40 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
|||||||
video.setOnClickListener(v -> {
|
video.setOnClickListener(v -> {
|
||||||
checkAuth(new OnSendMessageListener() {
|
checkAuth(new OnSendMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String token) {
|
public void onSuccess(String token, SendConsumeBean bean) {
|
||||||
super.onSuccess(token);
|
super.onSuccess(token,bean);
|
||||||
new BottomListDialog(mContext).setSelect(new OnItemClickListener<String>() {
|
new BottomListDialog(mContext).setSelect(new OnItemClickListener<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(String bean, int position) {
|
public void onItemClick(String bean, int position) {
|
||||||
Bundle bundle = new Bundle();
|
CallClientManager.getManager().checkMoney(targetId, true, new OnSendMessageListener() {
|
||||||
bundle.putString("model", CallClientManager.VIDEO_CALL);
|
@Override
|
||||||
bundle.putString("targetId", targetId);
|
public void onSuccess(String token, SendConsumeBean bean) {
|
||||||
bundle.putString("callId", targetId);
|
super.onSuccess(token, bean);
|
||||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_CALL_VIDEO, bundle);
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("model", CallClientManager.VIDEO_CALL);
|
||||||
|
bundle.putString("targetId", targetId);
|
||||||
|
bundle.putString("callId", targetId);
|
||||||
|
RouteManager.forwardActivity(RouteManager.ACTIVITY_CALL_VIDEO, bundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(int status, String msg) {
|
||||||
|
super.onError(status, msg);
|
||||||
|
new TipsDialog(mContext)
|
||||||
|
.setTitle("餘額不足")
|
||||||
|
.setContent("與TA視頻聊天每分鐘續消耗"+configBean.getVideoPrice()
|
||||||
|
+"鑽石,您可通過充值獲取更多鑽石,以便繼續聊天")
|
||||||
|
.setCancelText("離開")
|
||||||
|
.setApplyText("去充值")
|
||||||
|
.showDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}).setStrings(Collections.singletonList("发起视频通话\n100钻/分钟"))
|
}).setStrings(Collections.singletonList("发起视频通话\n"+configBean.getVideoPrice()+"钻/分钟"))
|
||||||
.showDialog();
|
.showDialog();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -239,18 +254,37 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
|||||||
call.setOnClickListener(v -> {
|
call.setOnClickListener(v -> {
|
||||||
checkAuth(new OnSendMessageListener() {
|
checkAuth(new OnSendMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String token) {
|
public void onSuccess(String token,SendConsumeBean bean) {
|
||||||
super.onSuccess(token);
|
super.onSuccess(token,bean);
|
||||||
new BottomListDialog(mContext).setSelect(new OnItemClickListener<String>() {
|
new BottomListDialog(mContext).setSelect(new OnItemClickListener<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(String bean, int position) {
|
public void onItemClick(String bean, int position) {
|
||||||
Bundle bundle = new Bundle();
|
CallClientManager.getManager().checkMoney(targetId, false, new OnSendMessageListener() {
|
||||||
bundle.putString("model", CallClientManager.AUDIO_CALL);
|
@Override
|
||||||
bundle.putString("targetId", targetId);
|
public void onSuccess(String token, SendConsumeBean bean) {
|
||||||
bundle.putString("callId", targetId);
|
super.onSuccess(token, bean);
|
||||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_CALL_AUDIO, bundle);
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("model", CallClientManager.AUDIO_CALL);
|
||||||
|
bundle.putString("targetId", targetId);
|
||||||
|
bundle.putString("callId", targetId);
|
||||||
|
RouteManager.forwardActivity(RouteManager.ACTIVITY_CALL_AUDIO, bundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(int status, String msg) {
|
||||||
|
super.onError(status, msg);
|
||||||
|
new TipsDialog(mContext)
|
||||||
|
.setTitle("餘額不足")
|
||||||
|
.setContent("與TA语音聊天每分鐘續消耗"+configBean.getMp3Price()
|
||||||
|
+"鑽石,您可通過充值獲取更多鑽石,以便繼續聊天")
|
||||||
|
.setCancelText("離開")
|
||||||
|
.setApplyText("去充值")
|
||||||
|
.showDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}).setStrings(Collections.singletonList("发起语音通话\n200钻/分钟"))
|
}).setStrings(Collections.singletonList("发起语音通话\n"+configBean.getMp3Price()+"钻/分钟"))
|
||||||
.showDialog();
|
.showDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,8 +305,8 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
|||||||
|
|
||||||
SendMessageManager.sendMessageForText(targetId, "图片信息", new OnSendMessageListener() {
|
SendMessageManager.sendMessageForText(targetId, "图片信息", new OnSendMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String token) {
|
public void onSuccess(String token,SendConsumeBean bean) {
|
||||||
super.onSuccess(token);
|
super.onSuccess(token,bean);
|
||||||
ChatMessageFragment.this.token = token;
|
ChatMessageFragment.this.token = token;
|
||||||
if (isCamera) {
|
if (isCamera) {
|
||||||
cameraUtil.getImageByCamera(false);
|
cameraUtil.getImageByCamera(false);
|
||||||
@ -312,7 +346,7 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
|||||||
if (data.getInfo().getName_auth() == 1) {
|
if (data.getInfo().getName_auth() == 1) {
|
||||||
listener.onError(0, "");
|
listener.onError(0, "");
|
||||||
} else {
|
} else {
|
||||||
listener.onSuccess("");
|
listener.onSuccess("",null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,8 +401,8 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String token) {
|
public void onSuccess(String token,SendConsumeBean bean) {
|
||||||
super.onSuccess(token);
|
super.onSuccess(token,bean);
|
||||||
mEditText.setText("");
|
mEditText.setText("");
|
||||||
if (!SpUtil.getInstance().isExists("chat_msg_safe_tip_" + targetId)) {
|
if (!SpUtil.getInstance().isExists("chat_msg_safe_tip_" + targetId)) {
|
||||||
SpUtil.getInstance().setBooleanValue("chat_msg_safe_tip_" + targetId, true);
|
SpUtil.getInstance().setBooleanValue("chat_msg_safe_tip_" + targetId, true);
|
||||||
@ -632,4 +666,18 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void initPriceBean(){
|
||||||
|
OTONetManager.getInstance(mContext)
|
||||||
|
.getMessageConsumeConfig(targetId, new HttpCallback<MessageConsumeConfigBean>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(MessageConsumeConfigBean data) {
|
||||||
|
configBean=data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||||
|
import com.lxj.xpopup.XPopup;
|
||||||
|
import com.lxj.xpopup.core.BasePopupView;
|
||||||
import com.lzf.easyfloat.EasyFloat;
|
import com.lzf.easyfloat.EasyFloat;
|
||||||
import com.lzf.easyfloat.enums.ShowPattern;
|
import com.lzf.easyfloat.enums.ShowPattern;
|
||||||
import com.lzf.easyfloat.interfaces.OnFloatCallbacks;
|
import com.lzf.easyfloat.interfaces.OnFloatCallbacks;
|
||||||
@ -21,6 +23,7 @@ import com.shayu.onetoone.activity.AbsOTOActivity;
|
|||||||
import com.shayu.onetoone.bean.FollowBean;
|
import com.shayu.onetoone.bean.FollowBean;
|
||||||
import com.shayu.onetoone.bean.UserBean;
|
import com.shayu.onetoone.bean.UserBean;
|
||||||
import com.shayu.onetoone.dialog.GiftDialog;
|
import com.shayu.onetoone.dialog.GiftDialog;
|
||||||
|
import com.shayu.onetoone.dialog.TipsTextDialog;
|
||||||
import com.shayu.onetoone.listener.OnCallStatusListener;
|
import com.shayu.onetoone.listener.OnCallStatusListener;
|
||||||
import com.shayu.onetoone.manager.CallClientManager;
|
import com.shayu.onetoone.manager.CallClientManager;
|
||||||
import com.shayu.onetoone.manager.OTONetManager;
|
import com.shayu.onetoone.manager.OTONetManager;
|
||||||
@ -28,6 +31,7 @@ import com.shayu.onetoone.manager.RouteManager;
|
|||||||
import com.shayu.onetoone.utils.ConversationUtils;
|
import com.shayu.onetoone.utils.ConversationUtils;
|
||||||
import com.yunbao.common.glide.ImgLoader;
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
import com.yunbao.common.http.base.HttpCallback;
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
import com.yunbao.common.utils.DpUtil;
|
import com.yunbao.common.utils.DpUtil;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
@ -267,6 +271,42 @@ public class CallAudioActivity extends AbsOTOActivity implements View.OnClickLis
|
|||||||
super.onTime(time);
|
super.onTime(time);
|
||||||
callTime.setText("通话时长:" + time);
|
callTime.setText("通话时长:" + time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private BasePopupView tipsView = null;
|
||||||
|
private TipsTextDialog tipsDialog;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTimeWarning(long msg) {
|
||||||
|
super.onTimeWarning(msg);
|
||||||
|
if (tipsView == null) {
|
||||||
|
createShow(msg);
|
||||||
|
} else {
|
||||||
|
tipsDialog.updateTips("通话将在" + msg + "秒后断\n开,请及时充值");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void createShow(long msg) {
|
||||||
|
tipsDialog = new TipsTextDialog(mContext)
|
||||||
|
.setTips("通话将在" + msg + "秒后断\n开,请及时充值")
|
||||||
|
.setOnItemClickListener(new OnItemClickListener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(String bean, int position) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tipsView = new XPopup.Builder(mContext)
|
||||||
|
.atView(money)
|
||||||
|
.hasShadowBg(false)
|
||||||
|
.isDestroyOnDismiss(true)
|
||||||
|
.isTouchThrough(true)
|
||||||
|
.isClickThrough(true)
|
||||||
|
.dismissOnBackPressed(false)
|
||||||
|
.dismissOnTouchOutside(false)
|
||||||
|
.asCustom(tipsDialog)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class WindowCallStatusListener extends OnCallStatusListener {
|
private static class WindowCallStatusListener extends OnCallStatusListener {
|
||||||
|
@ -23,6 +23,8 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||||
|
import com.lxj.xpopup.XPopup;
|
||||||
|
import com.lxj.xpopup.core.BasePopupView;
|
||||||
import com.lzf.easyfloat.EasyFloat;
|
import com.lzf.easyfloat.EasyFloat;
|
||||||
import com.lzf.easyfloat.enums.ShowPattern;
|
import com.lzf.easyfloat.enums.ShowPattern;
|
||||||
import com.lzf.easyfloat.interfaces.OnFloatCallbacks;
|
import com.lzf.easyfloat.interfaces.OnFloatCallbacks;
|
||||||
@ -32,6 +34,8 @@ import com.shayu.onetoone.activity.AbsOTOActivity;
|
|||||||
import com.shayu.onetoone.bean.FollowBean;
|
import com.shayu.onetoone.bean.FollowBean;
|
||||||
import com.shayu.onetoone.bean.UserBean;
|
import com.shayu.onetoone.bean.UserBean;
|
||||||
import com.shayu.onetoone.dialog.GiftDialog;
|
import com.shayu.onetoone.dialog.GiftDialog;
|
||||||
|
import com.shayu.onetoone.dialog.MsgChatClickDialog;
|
||||||
|
import com.shayu.onetoone.dialog.TipsTextDialog;
|
||||||
import com.shayu.onetoone.listener.OnCallStatusListener;
|
import com.shayu.onetoone.listener.OnCallStatusListener;
|
||||||
import com.shayu.onetoone.manager.CallClientManager;
|
import com.shayu.onetoone.manager.CallClientManager;
|
||||||
import com.shayu.onetoone.manager.OTONetManager;
|
import com.shayu.onetoone.manager.OTONetManager;
|
||||||
@ -39,11 +43,13 @@ import com.shayu.onetoone.manager.RouteManager;
|
|||||||
import com.shayu.onetoone.utils.ConversationUtils;
|
import com.shayu.onetoone.utils.ConversationUtils;
|
||||||
import com.yunbao.common.glide.ImgLoader;
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
import com.yunbao.common.http.base.HttpCallback;
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
import com.yunbao.common.utils.DpUtil;
|
import com.yunbao.common.utils.DpUtil;
|
||||||
import com.yunbao.common.utils.StringUtil;
|
import com.yunbao.common.utils.StringUtil;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import io.rong.calllib.CallUserProfile;
|
import io.rong.calllib.CallUserProfile;
|
||||||
@ -320,7 +326,8 @@ public class CallVideoActivity extends AbsOTOActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private void follow(){
|
|
||||||
|
private void follow() {
|
||||||
OTONetManager.getInstance(mContext)
|
OTONetManager.getInstance(mContext)
|
||||||
.follow(targetId, new HttpCallback<FollowBean>() {
|
.follow(targetId, new HttpCallback<FollowBean>() {
|
||||||
@Override
|
@Override
|
||||||
@ -335,6 +342,7 @@ public class CallVideoActivity extends AbsOTOActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private final View.OnClickListener onClickListener = new View.OnClickListener() {
|
private final View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -358,7 +366,7 @@ public class CallVideoActivity extends AbsOTOActivity {
|
|||||||
showWindow(false);
|
showWindow(false);
|
||||||
} else if (id == R.id.message) {
|
} else if (id == R.id.message) {
|
||||||
showWindow(true);
|
showWindow(true);
|
||||||
}else if(id == R.id.follow){
|
} else if (id == R.id.follow) {
|
||||||
follow();
|
follow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -407,10 +415,45 @@ public class CallVideoActivity extends AbsOTOActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onTime(String time) {
|
public void onTime(String time) {
|
||||||
super.onTime(time);
|
super.onTime(time);
|
||||||
if(callTime!=null){
|
if (callTime != null) {
|
||||||
callTime.setText("通话时长:"+time);
|
callTime.setText("通话时长:" + time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BasePopupView tipsView = null;
|
||||||
|
private TipsTextDialog tipsDialog;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTimeWarning(long msg) {
|
||||||
|
super.onTimeWarning(msg);
|
||||||
|
if (tipsView == null) {
|
||||||
|
createShow(msg);
|
||||||
|
} else {
|
||||||
|
tipsDialog.updateTips("通话将在" + msg + "秒后断\n开,请及时充值");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void createShow(long msg) {
|
||||||
|
tipsDialog = new TipsTextDialog(mContext)
|
||||||
|
.setTips("通话将在" + msg + "秒后断\n开,请及时充值")
|
||||||
|
.setOnItemClickListener(new OnItemClickListener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(String bean, int position) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tipsView = new XPopup.Builder(mContext)
|
||||||
|
.atView(money)
|
||||||
|
.hasShadowBg(false)
|
||||||
|
.isTouchThrough(true)
|
||||||
|
.isDestroyOnDismiss(true)
|
||||||
|
.isClickThrough(true)
|
||||||
|
.dismissOnBackPressed(false)
|
||||||
|
.dismissOnTouchOutside(false)
|
||||||
|
.asCustom(tipsDialog)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class WindowCallStatusListener extends OnCallStatusListener {
|
private static class WindowCallStatusListener extends OnCallStatusListener {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.shayu.onetoone.activity.message;
|
package com.shayu.onetoone.activity.message;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@ -18,9 +19,13 @@ import com.shayu.onetoone.activity.fragments.message.ChatMessageFragment;
|
|||||||
import com.shayu.onetoone.activity.fragments.message.MessageInteractiveFragment;
|
import com.shayu.onetoone.activity.fragments.message.MessageInteractiveFragment;
|
||||||
import com.shayu.onetoone.activity.fragments.message.MessageNoticeFragment;
|
import com.shayu.onetoone.activity.fragments.message.MessageNoticeFragment;
|
||||||
import com.shayu.onetoone.activity.fragments.message.SystemMessageFragment;
|
import com.shayu.onetoone.activity.fragments.message.SystemMessageFragment;
|
||||||
|
import com.shayu.onetoone.bean.MessageChatTipsContent;
|
||||||
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
||||||
|
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||||
import com.shayu.onetoone.bean.SystemMessageBean;
|
import com.shayu.onetoone.bean.SystemMessageBean;
|
||||||
import com.shayu.onetoone.bean.UserBean;
|
import com.shayu.onetoone.bean.UserBean;
|
||||||
|
import com.shayu.onetoone.dialog.TipsDialog;
|
||||||
|
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||||
import com.shayu.onetoone.manager.OTONetManager;
|
import com.shayu.onetoone.manager.OTONetManager;
|
||||||
import com.shayu.onetoone.manager.RouteManager;
|
import com.shayu.onetoone.manager.RouteManager;
|
||||||
import com.yunbao.common.glide.ImgLoader;
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
@ -29,14 +34,20 @@ import com.yunbao.common.utils.RouteUtil;
|
|||||||
import com.yunbao.common.utils.SpUtil;
|
import com.yunbao.common.utils.SpUtil;
|
||||||
import com.yunbao.common.utils.StringUtil;
|
import com.yunbao.common.utils.StringUtil;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import io.rong.imkit.conversation.ConversationFragment;
|
import io.rong.imkit.conversation.ConversationFragment;
|
||||||
|
import io.rong.imlib.model.Conversation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 聊天界面
|
* 聊天界面
|
||||||
*/
|
*/
|
||||||
@Route(path = RouteManager.ACTIVITY_MSG_CHAT)
|
@Route(path = RouteManager.ACTIVITY_MSG_CHAT)
|
||||||
public class ChatActivity extends AbsOTOActivity {
|
public class ChatActivity extends AbsOTOActivity {
|
||||||
|
public final static int CALL_CHAT_TYPE_CHAT_UP = 0;//搭讪
|
||||||
|
public final static int CALL_CHAT_TYPE_GIFT = 1;//打开【首次匹配弹窗】
|
||||||
|
public final static int CALL_CHAT_TYPE_MATCH = 2;//匹配
|
||||||
|
String targetId;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -53,18 +64,77 @@ public class ChatActivity extends AbsOTOActivity {
|
|||||||
} else if (type == 1) {
|
} else if (type == 1) {
|
||||||
conversationFragment = new MessageNoticeFragment(getIntent().getStringExtra("data"));
|
conversationFragment = new MessageNoticeFragment(getIntent().getStringExtra("data"));
|
||||||
} else if (type == 2) {
|
} else if (type == 2) {
|
||||||
conversationFragment=new MessageInteractiveFragment(getIntent().getStringExtra("data"));
|
conversationFragment = new MessageInteractiveFragment(getIntent().getStringExtra("data"));
|
||||||
} else {
|
} else {
|
||||||
conversationFragment = new ChatMessageFragment();
|
conversationFragment = new ChatMessageFragment();
|
||||||
|
targetId = getIntent().getStringExtra("targetId");
|
||||||
}
|
}
|
||||||
FragmentManager manager = getSupportFragmentManager();
|
FragmentManager manager = getSupportFragmentManager();
|
||||||
FragmentTransaction transaction = manager.beginTransaction();
|
FragmentTransaction transaction = manager.beginTransaction();
|
||||||
transaction.replace(R.id.container, conversationFragment);
|
transaction.replace(R.id.container, conversationFragment);
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
|
|
||||||
|
Bundle bundle = getIntent().getExtras();
|
||||||
|
if (bundle != null) {
|
||||||
|
int bundleInt = bundle.getInt("type", -1);
|
||||||
|
if (bundleInt == CALL_CHAT_TYPE_GIFT) {
|
||||||
|
String data = bundle.getString("data");
|
||||||
|
if (data != null) {
|
||||||
|
SendConsumeBean bean = JSONObject.parseObject(data, SendConsumeBean.class);
|
||||||
|
if (bean.getProp().getId() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ImageView imageView = new ImageView(this);
|
||||||
|
|
||||||
|
new TipsDialog(mContext)
|
||||||
|
.setTitle("首次匹配成功奖励")
|
||||||
|
.setContent("恭喜获得" + bean.getProp().getCnTitle() + "*" + bean.getProp().getNum())
|
||||||
|
.setContentView(imageView)
|
||||||
|
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onCreateView(View itemView) {
|
||||||
|
super.onCreateView(itemView);
|
||||||
|
ImgLoader.display(ChatActivity.this, bean.getProp().getIcon(), (ImageView) itemView);
|
||||||
|
}
|
||||||
|
}).showDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
initChatUpData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initChatUpData() {//反正进来就获取又没有提示信息,有的话就发送,没有就不管,抛异常=发过了
|
||||||
|
OTONetManager.getInstance(mContext)
|
||||||
|
.getChatTips(targetId, new HttpCallback<JSONObject>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(JSONObject data) {
|
||||||
|
try {
|
||||||
|
String tips1 = data.getJSONObject("data").getJSONObject("info").getJSONObject("0").getString("cn");
|
||||||
|
String tips2 = data.getJSONObject("data").getJSONObject("info").getJSONObject("1").getString("cn");
|
||||||
|
String tips3 = data.getJSONObject("data").getJSONObject("info").getJSONObject("2").getString("cn");
|
||||||
|
if (!StringUtil.isEmpty(tips1)) {
|
||||||
|
MessageChatTipsContent.sendMessage(Conversation.ConversationType.PRIVATE, targetId, MessageChatTipsContent.obtain(tips1), null);
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(tips2)) {
|
||||||
|
MessageChatTipsContent.sendMessage(Conversation.ConversationType.PRIVATE, targetId, MessageChatTipsContent.obtain(tips2), null);
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(tips3)) {
|
||||||
|
MessageChatTipsContent.sendMessage(Conversation.ConversationType.PRIVATE, targetId, MessageChatTipsContent.obtain(tips3), null);
|
||||||
|
}
|
||||||
|
OTONetManager.getInstance(mContext)
|
||||||
|
.updateChatTips(targetId, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
//调用过了,不管
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.shayu.onetoone.adapter;
|
package com.shayu.onetoone.adapter;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -11,12 +13,20 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.makeramen.roundedimageview.RoundedImageView;
|
import com.makeramen.roundedimageview.RoundedImageView;
|
||||||
import com.shayu.onetoone.R;
|
import com.shayu.onetoone.R;
|
||||||
|
import com.shayu.onetoone.activity.message.ChatActivity;
|
||||||
import com.shayu.onetoone.bean.HomeItemBean;
|
import com.shayu.onetoone.bean.HomeItemBean;
|
||||||
|
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||||
|
import com.shayu.onetoone.dialog.TipsDialog;
|
||||||
|
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||||
|
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||||
|
import com.shayu.onetoone.manager.SendMessageManager;
|
||||||
import com.shayu.onetoone.utils.ConversationUtils;
|
import com.shayu.onetoone.utils.ConversationUtils;
|
||||||
import com.yunbao.common.glide.ImgLoader;
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
import com.yunbao.common.utils.StringUtil;
|
import com.yunbao.common.utils.StringUtil;
|
||||||
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -79,30 +89,57 @@ public class HomeRecommendListAdapter extends RecyclerView.Adapter<HomeRecommend
|
|||||||
auth = itemView.findViewById(R.id.auth);
|
auth = itemView.findViewById(R.id.auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setData(HomeItemBean bean, int position) {
|
private void setData(HomeItemBean itemBean, int position) {
|
||||||
star.setText(bean.getStar() + "·" + bean.getStar_name());
|
star.setText(itemBean.getStar() + "·" + itemBean.getStar_name());
|
||||||
sign.setText(bean.getSignature());
|
sign.setText(itemBean.getSignature());
|
||||||
userName.setText(bean.getUser_nicename());
|
userName.setText(itemBean.getUser_nicename());
|
||||||
if (WordUtil.isNewZh()) {
|
if (WordUtil.isNewZh()) {
|
||||||
addTag(bean.getCn_label());
|
addTag(itemBean.getCn_label());
|
||||||
} else {
|
} else {
|
||||||
addTag(bean.getEn_label());
|
addTag(itemBean.getEn_label());
|
||||||
}
|
}
|
||||||
if (bean.getSex() == 1) {
|
if (itemBean.getSex() == 1) {
|
||||||
sex.setImageResource(R.mipmap.ic_message_tab_man);
|
sex.setImageResource(R.mipmap.ic_message_tab_man);
|
||||||
} else {
|
} else {
|
||||||
sex.setImageResource(R.mipmap.ic_message_tab_woman);
|
sex.setImageResource(R.mipmap.ic_message_tab_woman);
|
||||||
}
|
}
|
||||||
if (bean.getName_auth() == 1) {
|
if (itemBean.getName_auth() == 1) {
|
||||||
auth.setVisibility(View.VISIBLE);
|
auth.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
auth.setVisibility(View.GONE);
|
auth.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
ImgLoader.display(mContext, bean.getAvatar(), avatar);
|
ImgLoader.display(mContext, itemBean.getAvatar(), avatar);
|
||||||
chat.setOnClickListener(new View.OnClickListener() {
|
chat.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
ConversationUtils.startConversation(mContext, bean.getId() + "");
|
SendMessageManager.chatUp(itemBean.getId() + "", new OnSendMessageListener() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String token, SendConsumeBean bean) {
|
||||||
|
super.onSuccess(token, bean);
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putInt("type", ChatActivity.CALL_CHAT_TYPE_CHAT_UP);
|
||||||
|
bundle.putString("data", JSONObject.toJSONString(bean));
|
||||||
|
ConversationUtils.startConversation(mContext, itemBean.getId() + "", bundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(int status, String msg, SendConsumeBean bean) {
|
||||||
|
super.onError(status, msg, bean);
|
||||||
|
if (status == OnSendMessageListener.STATUS_NOT_PRICE) {
|
||||||
|
new TipsDialog(mContext)
|
||||||
|
.setTitle("余额不足,请充值后再进行尝试吧~")
|
||||||
|
.setApplyText("前往充值")
|
||||||
|
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onApply(Dialog dialog) {
|
||||||
|
super.onApply(dialog);
|
||||||
|
ToastUtil.show("跳充值页面");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.showDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.shayu.onetoone.bean;
|
||||||
|
|
||||||
|
import com.yunbao.common.bean.BaseModel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MatchingInfoBean extends BaseModel {
|
||||||
|
List<MatchingInfoUserBean> list;
|
||||||
|
long people;
|
||||||
|
|
||||||
|
public MatchingInfoBean() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MatchingInfoUserBean> getList() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setList(List<MatchingInfoUserBean> list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getPeople() {
|
||||||
|
return people;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPeople(long people) {
|
||||||
|
this.people = people;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,371 @@
|
|||||||
|
package com.shayu.onetoone.bean;
|
||||||
|
|
||||||
|
import com.yunbao.common.bean.BaseModel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MatchingInfoUserBean extends BaseModel {
|
||||||
|
private String id;
|
||||||
|
private List<String> cnLabel;
|
||||||
|
private List<String> enLabel;
|
||||||
|
private int firstMate;
|
||||||
|
private long createTime;
|
||||||
|
private long updateTime;
|
||||||
|
private int sex;
|
||||||
|
private int bY;
|
||||||
|
private int bYm;
|
||||||
|
private int bYmd;
|
||||||
|
private int nameAuth;
|
||||||
|
private long nameAuthTime;
|
||||||
|
private String authFront;
|
||||||
|
private String authBack;
|
||||||
|
private String authRemark;
|
||||||
|
private int sageAuth;
|
||||||
|
private long sageAuthTime;
|
||||||
|
private int isHot;
|
||||||
|
private String vodiePrice;
|
||||||
|
private String price;
|
||||||
|
private int star;
|
||||||
|
private String area;
|
||||||
|
private int isHello;
|
||||||
|
private int online;
|
||||||
|
private String mp3Price;
|
||||||
|
private int setStatus;
|
||||||
|
private int isLogin;
|
||||||
|
private int isChat;
|
||||||
|
private String userNicename;
|
||||||
|
private String avatar;
|
||||||
|
private String avatarThumb;
|
||||||
|
private String birthday;
|
||||||
|
private String signature;
|
||||||
|
private int isAttention;
|
||||||
|
private int isStatis;
|
||||||
|
private int level;
|
||||||
|
private int levelIcon;
|
||||||
|
private String starName;
|
||||||
|
private int isAccost;
|
||||||
|
private int age;
|
||||||
|
|
||||||
|
public MatchingInfoUserBean() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getCnLabel() {
|
||||||
|
return cnLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCnLabel(List<String> cnLabel) {
|
||||||
|
this.cnLabel = cnLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getEnLabel() {
|
||||||
|
return enLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnLabel(List<String> enLabel) {
|
||||||
|
this.enLabel = enLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFirstMate() {
|
||||||
|
return firstMate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstMate(int firstMate) {
|
||||||
|
this.firstMate = firstMate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(long createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(long updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSex() {
|
||||||
|
return sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSex(int sex) {
|
||||||
|
this.sex = sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getbY() {
|
||||||
|
return bY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setbY(int bY) {
|
||||||
|
this.bY = bY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getbYm() {
|
||||||
|
return bYm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setbYm(int bYm) {
|
||||||
|
this.bYm = bYm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getbYmd() {
|
||||||
|
return bYmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setbYmd(int bYmd) {
|
||||||
|
this.bYmd = bYmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNameAuth() {
|
||||||
|
return nameAuth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNameAuth(int nameAuth) {
|
||||||
|
this.nameAuth = nameAuth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getNameAuthTime() {
|
||||||
|
return nameAuthTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNameAuthTime(long nameAuthTime) {
|
||||||
|
this.nameAuthTime = nameAuthTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthFront() {
|
||||||
|
return authFront;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthFront(String authFront) {
|
||||||
|
this.authFront = authFront;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthBack() {
|
||||||
|
return authBack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthBack(String authBack) {
|
||||||
|
this.authBack = authBack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthRemark() {
|
||||||
|
return authRemark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthRemark(String authRemark) {
|
||||||
|
this.authRemark = authRemark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSageAuth() {
|
||||||
|
return sageAuth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSageAuth(int sageAuth) {
|
||||||
|
this.sageAuth = sageAuth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSageAuthTime() {
|
||||||
|
return sageAuthTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSageAuthTime(long sageAuthTime) {
|
||||||
|
this.sageAuthTime = sageAuthTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIsHot() {
|
||||||
|
return isHot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsHot(int isHot) {
|
||||||
|
this.isHot = isHot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVodiePrice() {
|
||||||
|
return vodiePrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVodiePrice(String vodiePrice) {
|
||||||
|
this.vodiePrice = vodiePrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrice(String price) {
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStar() {
|
||||||
|
return star;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStar(int star) {
|
||||||
|
this.star = star;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getArea() {
|
||||||
|
return area;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArea(String area) {
|
||||||
|
this.area = area;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIsHello() {
|
||||||
|
return isHello;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsHello(int isHello) {
|
||||||
|
this.isHello = isHello;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOnline() {
|
||||||
|
return online;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnline(int online) {
|
||||||
|
this.online = online;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMp3Price() {
|
||||||
|
return mp3Price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMp3Price(String mp3Price) {
|
||||||
|
this.mp3Price = mp3Price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSetStatus() {
|
||||||
|
return setStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSetStatus(int setStatus) {
|
||||||
|
this.setStatus = setStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIsLogin() {
|
||||||
|
return isLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsLogin(int isLogin) {
|
||||||
|
this.isLogin = isLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIsChat() {
|
||||||
|
return isChat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsChat(int isChat) {
|
||||||
|
this.isChat = isChat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserNicename() {
|
||||||
|
return userNicename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserNicename(String userNicename) {
|
||||||
|
this.userNicename = userNicename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatar() {
|
||||||
|
return avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvatar(String avatar) {
|
||||||
|
this.avatar = avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatarThumb() {
|
||||||
|
return avatarThumb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvatarThumb(String avatarThumb) {
|
||||||
|
this.avatarThumb = avatarThumb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBirthday() {
|
||||||
|
return birthday;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBirthday(String birthday) {
|
||||||
|
this.birthday = birthday;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSignature() {
|
||||||
|
return signature;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignature(String signature) {
|
||||||
|
this.signature = signature;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIsAttention() {
|
||||||
|
return isAttention;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsAttention(int isAttention) {
|
||||||
|
this.isAttention = isAttention;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIsStatis() {
|
||||||
|
return isStatis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsStatis(int isStatis) {
|
||||||
|
this.isStatis = isStatis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevel() {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLevel(int level) {
|
||||||
|
this.level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevelIcon() {
|
||||||
|
return levelIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLevelIcon(int levelIcon) {
|
||||||
|
this.levelIcon = levelIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStarName() {
|
||||||
|
return starName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStarName(String starName) {
|
||||||
|
this.starName = starName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIsAccost() {
|
||||||
|
return isAccost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsAccost(int isAccost) {
|
||||||
|
this.isAccost = isAccost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAge() {
|
||||||
|
return age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAge(int age) {
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.shayu.onetoone.bean;
|
||||||
|
|
||||||
|
public class MatchingItemSizeBean {
|
||||||
|
private int num;
|
||||||
|
private int login;
|
||||||
|
private int chat;
|
||||||
|
|
||||||
|
public MatchingItemSizeBean() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNum() {
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNum(int num) {
|
||||||
|
this.num = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLogin() {
|
||||||
|
return login;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogin(int login) {
|
||||||
|
this.login = login;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getChat() {
|
||||||
|
return chat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChat(int chat) {
|
||||||
|
this.chat = chat;
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ import android.os.Parcelable;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
|
||||||
|
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -13,15 +14,39 @@ import org.json.JSONObject;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
import io.rong.common.ParcelUtils;
|
import io.rong.common.ParcelUtils;
|
||||||
|
import io.rong.imkit.IMCenter;
|
||||||
import io.rong.imlib.MessageTag;
|
import io.rong.imlib.MessageTag;
|
||||||
|
import io.rong.imlib.RongIMClient;
|
||||||
|
import io.rong.imlib.model.Conversation;
|
||||||
|
import io.rong.imlib.model.Message;
|
||||||
import io.rong.imlib.model.MessageContent;
|
import io.rong.imlib.model.MessageContent;
|
||||||
|
|
||||||
@MessageTag(value = "MessageChatTipsContent", flag = MessageTag.ISPERSISTED)
|
@MessageTag(value = "MessageChatTipsContent", flag = MessageTag.ISPERSISTED)
|
||||||
public class MessageChatTipsContent extends MessageContent implements Parcelable {
|
public class MessageChatTipsContent extends MessageContent implements Parcelable {
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
|
public static void sendMessage(Conversation.ConversationType type, String targetId, MessageChatTipsContent tipsContent, OnSendMessageListener listener) {
|
||||||
|
IMCenter.getInstance().insertOutgoingMessage(type, targetId, Message.SentStatus.SENT, tipsContent, System.currentTimeMillis(), new RongIMClient.ResultCallback<Message>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Message message) {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onSuccess(null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(RongIMClient.ErrorCode e) {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onError(e.code, e.msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private MessageChatTipsContent() {
|
private MessageChatTipsContent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageChatTipsContent(byte[] data) {
|
public MessageChatTipsContent(byte[] data) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
@ -66,6 +91,7 @@ public class MessageChatTipsContent extends MessageContent implements Parcelable
|
|||||||
setExtra(ParcelUtils.readFromParcel(in));
|
setExtra(ParcelUtils.readFromParcel(in));
|
||||||
setContent(ParcelUtils.readFromParcel(in));
|
setContent(ParcelUtils.readFromParcel(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 快速构建消息对象方法
|
// 快速构建消息对象方法
|
||||||
public static MessageChatTipsContent obtain(String content) {
|
public static MessageChatTipsContent obtain(String content) {
|
||||||
MessageChatTipsContent msg = new MessageChatTipsContent();
|
MessageChatTipsContent msg = new MessageChatTipsContent();
|
||||||
|
108
OneToOne/src/main/java/com/shayu/onetoone/bean/PropBean.java
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
package com.shayu.onetoone.bean;
|
||||||
|
|
||||||
|
import com.yunbao.common.bean.BaseModel;
|
||||||
|
|
||||||
|
public class PropBean extends BaseModel {
|
||||||
|
int id;
|
||||||
|
String cnTitle;
|
||||||
|
String enTitle;
|
||||||
|
String icon;
|
||||||
|
int status;
|
||||||
|
int type;
|
||||||
|
long createTime;
|
||||||
|
long updateTime;
|
||||||
|
String callback;
|
||||||
|
long exTime;
|
||||||
|
int num;
|
||||||
|
|
||||||
|
public PropBean() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCnTitle() {
|
||||||
|
return cnTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCnTitle(String cnTitle) {
|
||||||
|
this.cnTitle = cnTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEnTitle() {
|
||||||
|
return enTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnTitle(String enTitle) {
|
||||||
|
this.enTitle = enTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIcon() {
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIcon(String icon) {
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(int status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(long createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(long updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCallback() {
|
||||||
|
return callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCallback(String callback) {
|
||||||
|
this.callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getExTime() {
|
||||||
|
return exTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExTime(long exTime) {
|
||||||
|
this.exTime = exTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNum() {
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNum(int num) {
|
||||||
|
this.num = num;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
package com.shayu.onetoone.bean;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.yunbao.common.bean.BaseModel;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class SendConsumeBean extends BaseModel {
|
||||||
|
private PropBean prop;
|
||||||
|
private UserBean mateUser;
|
||||||
|
@SerializedName("vodie_time")
|
||||||
|
private long videoTime;
|
||||||
|
private long mp3Time;
|
||||||
|
private int code;
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
public SendConsumeBean() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserBean getMateUser() {
|
||||||
|
return mateUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMateUser(UserBean mateUser) {
|
||||||
|
this.mateUser = mateUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getVideoTime() {
|
||||||
|
return videoTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoTime(long videoTime) {
|
||||||
|
this.videoTime = videoTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMp3Time() {
|
||||||
|
return mp3Time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMp3Time(long mp3Time) {
|
||||||
|
this.mp3Time = mp3Time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsg(String msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropBean getProp() {
|
||||||
|
return prop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProp(PropBean prop) {
|
||||||
|
this.prop = prop;
|
||||||
|
}
|
||||||
|
}
|
126
OneToOne/src/main/java/com/shayu/onetoone/bean/UserItemBean.java
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
package com.shayu.onetoone.bean;
|
||||||
|
|
||||||
|
import com.yunbao.common.bean.BaseModel;
|
||||||
|
|
||||||
|
public class UserItemBean extends BaseModel {
|
||||||
|
private int id;
|
||||||
|
private int uid;
|
||||||
|
private int prop_id;
|
||||||
|
private String cn_title;
|
||||||
|
private String en_title;
|
||||||
|
private String icon;
|
||||||
|
private int status;
|
||||||
|
private int type;
|
||||||
|
private long create_time;
|
||||||
|
private long update_time;
|
||||||
|
private String callback;
|
||||||
|
private long ex_time;
|
||||||
|
private long use_time;
|
||||||
|
|
||||||
|
public UserItemBean() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUid() {
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUid(int uid) {
|
||||||
|
this.uid = uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProp_id() {
|
||||||
|
return prop_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProp_id(int prop_id) {
|
||||||
|
this.prop_id = prop_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCn_title() {
|
||||||
|
return cn_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCn_title(String cn_title) {
|
||||||
|
this.cn_title = cn_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEn_title() {
|
||||||
|
return en_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEn_title(String en_title) {
|
||||||
|
this.en_title = en_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIcon() {
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIcon(String icon) {
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(int status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCreate_time() {
|
||||||
|
return create_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreate_time(long create_time) {
|
||||||
|
this.create_time = create_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getUpdate_time() {
|
||||||
|
return update_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdate_time(long update_time) {
|
||||||
|
this.update_time = update_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCallback() {
|
||||||
|
return callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCallback(String callback) {
|
||||||
|
this.callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getEx_time() {
|
||||||
|
return ex_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEx_time(long ex_time) {
|
||||||
|
this.ex_time = ex_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getUse_time() {
|
||||||
|
return use_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUse_time(long use_time) {
|
||||||
|
this.use_time = use_time;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
package com.shayu.onetoone.dialog;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.lxj.xpopup.XPopup;
|
||||||
|
import com.shayu.onetoone.R;
|
||||||
|
import com.yunbao.common.dialog.AbsFullDialogPopupWindow;
|
||||||
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
|
|
||||||
|
public class FirstTipsDialog extends AbsFullDialogPopupWindow {
|
||||||
|
ImageView image;
|
||||||
|
boolean isHome = true;
|
||||||
|
boolean isMan = false;
|
||||||
|
private OnItemClickListener<FirstTipsDialog> onItemClickListener;
|
||||||
|
|
||||||
|
public FirstTipsDialog(@NonNull Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FirstTipsDialog setHome(boolean home) {
|
||||||
|
isHome = home;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FirstTipsDialog setMan(boolean man) {
|
||||||
|
isMan = man;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FirstTipsDialog setOnItemClickListener(OnItemClickListener<FirstTipsDialog> onItemClickListener) {
|
||||||
|
this.onItemClickListener = onItemClickListener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildDialog(XPopup.Builder builder) {
|
||||||
|
builder.hasShadowBg(false);
|
||||||
|
builder.dismissOnBackPressed(false);
|
||||||
|
builder.dismissOnTouchOutside(false);
|
||||||
|
builder.customAnimator(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int bindLayoutId() {
|
||||||
|
return R.layout.activity_full_image;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setModel() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dismiss() {
|
||||||
|
image.setAlpha(0f);
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onShow() {
|
||||||
|
super.onShow();
|
||||||
|
if (isHome) {
|
||||||
|
image.setImageResource(R.mipmap.bg_firstlogin_tips);
|
||||||
|
} else if (isMan) {
|
||||||
|
image.setImageResource(R.mipmap.bg_firstlogin_tips_man);
|
||||||
|
} else {
|
||||||
|
image.setImageResource(R.mipmap.bg_firstlogin_tips_woman);
|
||||||
|
}
|
||||||
|
image.setOnClickListener(v -> {
|
||||||
|
|
||||||
|
if (isHome) {
|
||||||
|
onItemClickListener.onItemClick(this, 0);
|
||||||
|
} else {
|
||||||
|
onItemClickListener.onItemClick(this, 1);
|
||||||
|
}
|
||||||
|
setModel();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
image = findViewById(R.id.image);
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,7 @@ import com.shayu.onetoone.adapter.GiftListAdapter;
|
|||||||
import com.shayu.onetoone.bean.GiftBean;
|
import com.shayu.onetoone.bean.GiftBean;
|
||||||
import com.shayu.onetoone.bean.MessageChatGiftContent;
|
import com.shayu.onetoone.bean.MessageChatGiftContent;
|
||||||
import com.shayu.onetoone.bean.PurseBean;
|
import com.shayu.onetoone.bean.PurseBean;
|
||||||
|
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||||
import com.shayu.onetoone.manager.OTONetManager;
|
import com.shayu.onetoone.manager.OTONetManager;
|
||||||
import com.shayu.onetoone.manager.SendMessageManager;
|
import com.shayu.onetoone.manager.SendMessageManager;
|
||||||
@ -90,8 +91,8 @@ public class GiftDialog extends AbsDialogPopupWindow {
|
|||||||
sendBtn.setOnClickListener(v -> {
|
sendBtn.setOnClickListener(v -> {
|
||||||
SendMessageManager.sendMessageForGift(targetId, mAdapter.getItem().getId() + "", new OnSendMessageListener() {
|
SendMessageManager.sendMessageForGift(targetId, mAdapter.getItem().getId() + "", new OnSendMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String token) {
|
public void onSuccess(String token, SendConsumeBean bean) {
|
||||||
super.onSuccess(token);
|
super.onSuccess(token,bean);
|
||||||
GiftDialog.this.token = token;
|
GiftDialog.this.token = token;
|
||||||
sendGift(mAdapter.getItem());
|
sendGift(mAdapter.getItem());
|
||||||
|
|
||||||
|
@ -92,8 +92,14 @@ public class TipsDialog extends AbsDialogCenterPopupWindow {
|
|||||||
onDialogClickListener.onCreateView(contentView);
|
onDialogClickListener.onCreateView(contentView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mCancel.setText(cancelText);
|
if (!StringUtil.isEmpty(cancelText)) {
|
||||||
mApply.setText(applyText);
|
mCancel.setText(cancelText);
|
||||||
|
} else {
|
||||||
|
mCancel.setVisibility(GONE);
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(applyText)) {
|
||||||
|
mApply.setText(applyText);
|
||||||
|
}
|
||||||
mCancel.setOnClickListener(v -> {
|
mCancel.setOnClickListener(v -> {
|
||||||
if (onDialogClickListener != null) {
|
if (onDialogClickListener != null) {
|
||||||
onDialogClickListener.onCancel(dialog);
|
onDialogClickListener.onCancel(dialog);
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
package com.shayu.onetoone.dialog;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.lxj.xpopup.core.AttachPopupView;
|
||||||
|
import com.lxj.xpopup.core.BubbleAttachPopupView;
|
||||||
|
import com.shayu.onetoone.R;
|
||||||
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频/语音页面余额不足提示
|
||||||
|
*/
|
||||||
|
public class TipsTextDialog extends BubbleAttachPopupView implements View.OnClickListener {
|
||||||
|
TextView tipsView;
|
||||||
|
String tips;
|
||||||
|
OnItemClickListener<String> onItemClickListener;
|
||||||
|
|
||||||
|
public TipsTextDialog(@NonNull Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TipsTextDialog setTips(String tips) {
|
||||||
|
this.tips = tips;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TipsTextDialog setOnItemClickListener(OnItemClickListener<String> onItemClickListener) {
|
||||||
|
this.onItemClickListener = onItemClickListener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getImplLayoutId() {
|
||||||
|
return R.layout.dialog_msg_tips;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isShowUpToTarget() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
isShowUp = true;
|
||||||
|
tipsView = findViewById(R.id.tips);
|
||||||
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
||||||
|
params.gravity = Gravity.CENTER;
|
||||||
|
tipsView.setText(tips);
|
||||||
|
tipsView.setTextColor(Color.WHITE);
|
||||||
|
tipsView.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick(((TextView) v).getText().toString(), (Integer) v.getTag());
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTips(String s) {
|
||||||
|
tipsView.setText(s);
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,9 @@ public abstract class OnCallStatusListener {
|
|||||||
public abstract void onCallEnd();
|
public abstract void onCallEnd();
|
||||||
|
|
||||||
public abstract void onStartFirstFrame();
|
public abstract void onStartFirstFrame();
|
||||||
public void onTime(String time){
|
public void onTime(String time){}
|
||||||
|
public void onErrorNotPrice(String msg){}
|
||||||
|
|
||||||
|
public void onTimeWarning(long warningTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
package com.shayu.onetoone.listener;
|
package com.shayu.onetoone.listener;
|
||||||
|
|
||||||
|
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||||
|
|
||||||
public abstract class OnSendMessageListener {
|
public abstract class OnSendMessageListener {
|
||||||
public static final int STATUS_NOT_PRICE = 0;//金额不够
|
public static final int STATUS_NOT_PRICE = 0;//金额不够
|
||||||
public static final int STATUS_ERROR = 1;//接口错误
|
public static final int STATUS_ERROR = 1;//接口错误
|
||||||
|
|
||||||
|
|
||||||
public void onSuccess(String token) {
|
public void onSuccess(String token, SendConsumeBean bean) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onError(int status, String msg) {
|
public void onError(int status, String msg) {
|
||||||
}
|
}
|
||||||
|
public void onError(int status, String msg, SendConsumeBean bean){
|
||||||
|
onError(status, msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,11 @@ import android.text.TextUtils;
|
|||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
|
|
||||||
import com.blankj.utilcode.util.PermissionUtils;
|
import com.blankj.utilcode.util.PermissionUtils;
|
||||||
|
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||||
import com.shayu.onetoone.listener.OnCallStatusListener;
|
import com.shayu.onetoone.listener.OnCallStatusListener;
|
||||||
|
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||||
|
import com.yunbao.common.CommonAppContext;
|
||||||
|
import com.yunbao.common.utils.StringUtil;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -75,11 +79,19 @@ public class CallClientManager {
|
|||||||
listeners.remove(statusListener);
|
listeners.remove(statusListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startTimer() {
|
public void checkMoney(String targetId, boolean video, OnSendMessageListener listener) {
|
||||||
|
if (video) {
|
||||||
|
SendMessageManager.checkVideoMessage(targetId, "1", listener);
|
||||||
|
} else {
|
||||||
|
SendMessageManager.checkAudioMessage(targetId, "1", listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startTimer(String targetId) {
|
||||||
if (timeTask != null) {
|
if (timeTask != null) {
|
||||||
timeTask.cancel();
|
timeTask.cancel();
|
||||||
}
|
}
|
||||||
timeTask = new CallTimeTask();
|
timeTask = new CallTimeTask(targetId);
|
||||||
new Timer().schedule(timeTask, 0, 1000);
|
new Timer().schedule(timeTask, 0, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +118,7 @@ public class CallClientManager {
|
|||||||
listener.onCallStart(userId, remoteVideo);
|
listener.onCallStart(userId, remoteVideo);
|
||||||
}
|
}
|
||||||
ToastUtil.show("连接成功");
|
ToastUtil.show("连接成功");
|
||||||
startTimer();
|
startTimer(targetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -145,7 +157,7 @@ public class CallClientManager {
|
|||||||
listener.onCallStart(userId, remoteVideo);
|
listener.onCallStart(userId, remoteVideo);
|
||||||
}
|
}
|
||||||
ToastUtil.show("连接成功");
|
ToastUtil.show("连接成功");
|
||||||
startTimer();
|
startTimer(targetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -182,7 +194,7 @@ public class CallClientManager {
|
|||||||
for (OnCallStatusListener listener : listeners) {
|
for (OnCallStatusListener listener : listeners) {
|
||||||
listener.onCallStart(userId, remoteVideo);
|
listener.onCallStart(userId, remoteVideo);
|
||||||
}
|
}
|
||||||
startTimer();
|
startTimer(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -224,6 +236,30 @@ public class CallClientManager {
|
|||||||
private class CallTimeTask extends TimerTask {
|
private class CallTimeTask extends TimerTask {
|
||||||
Handler handler = new Handler(Looper.getMainLooper());
|
Handler handler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
|
private String targetId;
|
||||||
|
private boolean isCallVideo = false;
|
||||||
|
long warningTime;
|
||||||
|
long activeTime;
|
||||||
|
|
||||||
|
public CallTimeTask(String targetId) {
|
||||||
|
this.targetId = targetId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean cancel() {
|
||||||
|
long time = getTime(activeTime);
|
||||||
|
time = time % 10;
|
||||||
|
if (time == 0) {
|
||||||
|
time = 10;
|
||||||
|
}
|
||||||
|
if (isCallVideo) {
|
||||||
|
SendMessageManager.pingVideoMessage(targetId, time + "", new SendMessageListener());
|
||||||
|
} else {
|
||||||
|
SendMessageManager.pingAudioMessage(targetId, time + "", new SendMessageListener());
|
||||||
|
}
|
||||||
|
return super.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
RongCallSession callSession = RongCallClient.getInstance().getCallSession();
|
RongCallSession callSession = RongCallClient.getInstance().getCallSession();
|
||||||
@ -232,7 +268,10 @@ public class CallClientManager {
|
|||||||
timeTask = null;
|
timeTask = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long time = getTime(callSession.getActiveTime());
|
isCallVideo = callSession.getMediaType() == RongCallCommon.CallMediaType.VIDEO;
|
||||||
|
activeTime = callSession.getActiveTime();
|
||||||
|
long time = getTime(activeTime);
|
||||||
|
checkTime(time);
|
||||||
String extra;
|
String extra;
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
if (time >= 3600) {
|
if (time >= 3600) {
|
||||||
@ -249,11 +288,57 @@ public class CallClientManager {
|
|||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
for (OnCallStatusListener listener : listeners) {
|
for (OnCallStatusListener listener : listeners) {
|
||||||
listener.onTime(extra);
|
listener.onTime(extra);
|
||||||
|
listener.onTimeWarning(warningTime--);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkTime(long time) {
|
||||||
|
if (StringUtil.isEmpty(targetId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
time = time % 10;
|
||||||
|
if (time == 0) {
|
||||||
|
time = 10;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isCallVideo) {
|
||||||
|
SendMessageManager.pingVideoMessage(targetId, time + "", new SendMessageListener());
|
||||||
|
} else {
|
||||||
|
SendMessageManager.pingAudioMessage(targetId, time + "", new SendMessageListener());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SendMessageListener extends OnSendMessageListener {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String token, SendConsumeBean bean) {
|
||||||
|
super.onSuccess(token, bean);
|
||||||
|
|
||||||
|
if (isCallVideo) {
|
||||||
|
warningTime = bean.getVideoTime();
|
||||||
|
} else {
|
||||||
|
warningTime = bean.getMp3Time();
|
||||||
|
}
|
||||||
|
if (warningTime <= 60) {
|
||||||
|
for (OnCallStatusListener listener : listeners) {
|
||||||
|
listener.onTimeWarning(warningTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(int status, String msg) {
|
||||||
|
super.onError(status, msg);
|
||||||
|
if (status == OnSendMessageListener.STATUS_NOT_PRICE) {
|
||||||
|
for (OnCallStatusListener listener : listeners) {
|
||||||
|
listener.onErrorNotPrice(msg);
|
||||||
|
}
|
||||||
|
endCall();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,12 +520,12 @@ public class CallClientManager {
|
|||||||
* 如果对端调用{@link RongCallClient#startCall(int, boolean, Conversation.ConversationType, String, List, List, RongCallCommon.CallMediaType, String, StartCameraCallback)} 或
|
* 如果对端调用{@link RongCallClient#startCall(int, boolean, Conversation.ConversationType, String, List, List, RongCallCommon.CallMediaType, String, StartCameraCallback)} 或
|
||||||
* {@link RongCallClient#acceptCall(String, int, boolean, StartCameraCallback)}开始的音视频通话,则可以使用如下设置改变对端视频流的镜像显示:<br />
|
* {@link RongCallClient#acceptCall(String, int, boolean, StartCameraCallback)}开始的音视频通话,则可以使用如下设置改变对端视频流的镜像显示:<br />
|
||||||
* <pre class="prettyprint">
|
* <pre class="prettyprint">
|
||||||
* public void onRemoteUserJoined(String userId, RongCallCommon.CallMediaType mediaType, int userType, SurfaceView remoteVideo) {
|
* public void onRemoteUserJoined(String userId, RongCallCommon.CallMediaType mediaType, int userType, SurfaceView remoteVideo) {
|
||||||
* if (null != remoteVideo) {
|
* if (null != remoteVideo) {
|
||||||
* ((RongRTCVideoView) remoteVideo).setMirror( boolean);//观看对方视频流是否镜像处理
|
* ((RongRTCVideoView) remoteVideo).setMirror( boolean);//观看对方视频流是否镜像处理
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onRemoteUserJoined(String userId, RongCallCommon.CallMediaType mediaType, int userType, SurfaceView remoteVideo) {
|
public void onRemoteUserJoined(String userId, RongCallCommon.CallMediaType mediaType, int userType, SurfaceView remoteVideo) {
|
||||||
|
@ -17,12 +17,16 @@ import com.shayu.onetoone.bean.HomeItemBean;
|
|||||||
import com.shayu.onetoone.bean.HomeRankBean;
|
import com.shayu.onetoone.bean.HomeRankBean;
|
||||||
import com.shayu.onetoone.bean.JoinAnchorBean;
|
import com.shayu.onetoone.bean.JoinAnchorBean;
|
||||||
import com.shayu.onetoone.bean.LabelBean;
|
import com.shayu.onetoone.bean.LabelBean;
|
||||||
|
import com.shayu.onetoone.bean.MatchingInfoBean;
|
||||||
|
import com.shayu.onetoone.bean.MatchingItemSizeBean;
|
||||||
import com.shayu.onetoone.bean.MessageConsumeConfigBean;
|
import com.shayu.onetoone.bean.MessageConsumeConfigBean;
|
||||||
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
||||||
import com.shayu.onetoone.bean.PurseBean;
|
import com.shayu.onetoone.bean.PurseBean;
|
||||||
|
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||||
import com.shayu.onetoone.bean.SystemMessageBean;
|
import com.shayu.onetoone.bean.SystemMessageBean;
|
||||||
import com.shayu.onetoone.bean.TargetUserInfoBean;
|
import com.shayu.onetoone.bean.TargetUserInfoBean;
|
||||||
import com.shayu.onetoone.bean.UserBean;
|
import com.shayu.onetoone.bean.UserBean;
|
||||||
|
import com.shayu.onetoone.bean.UserItemBean;
|
||||||
import com.shayu.onetoone.network.API;
|
import com.shayu.onetoone.network.API;
|
||||||
import com.yunbao.common.CommonAppConfig;
|
import com.yunbao.common.CommonAppConfig;
|
||||||
import com.yunbao.common.bean.BaseModel;
|
import com.yunbao.common.bean.BaseModel;
|
||||||
@ -38,6 +42,8 @@ import java.io.File;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.Disposable;
|
||||||
|
import io.reactivex.functions.Action;
|
||||||
import io.reactivex.functions.Consumer;
|
import io.reactivex.functions.Consumer;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import io.rong.imkit.userinfo.RongUserInfoManager;
|
import io.rong.imkit.userinfo.RongUserInfoManager;
|
||||||
@ -539,14 +545,14 @@ public class OTONetManager {
|
|||||||
}).isDisposed();
|
}).isDisposed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(int tuid,
|
public void sendMessage(String tuid,
|
||||||
int type,
|
int type,
|
||||||
String giftId,
|
String giftId,
|
||||||
String msg,
|
String msg,
|
||||||
String time,
|
String time,
|
||||||
int online,
|
int online,
|
||||||
String method,
|
String method,
|
||||||
HttpCallback<HttpCallbackModel> callback) {
|
HttpCallback<SendConsumeBean> callback) {
|
||||||
|
|
||||||
API.get().otoApi(mContext)
|
API.get().otoApi(mContext)
|
||||||
.sendMessage(tuid, type, giftId, msg, time, online, method)
|
.sendMessage(tuid, type, giftId, msg, time, online, method)
|
||||||
@ -554,7 +560,18 @@ public class OTONetManager {
|
|||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(model -> {
|
.subscribe(model -> {
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onSuccess(new HttpCallbackModel(model.getData().getCode(), model.getData().getMsg()));
|
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>() {
|
}, new Consumer<Throwable>() {
|
||||||
@Override
|
@Override
|
||||||
@ -819,7 +836,110 @@ public class OTONetManager {
|
|||||||
}).isDisposed();
|
}).isDisposed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getUserItems(String page, HttpCallback<List<UserItemBean>> callback) {
|
||||||
|
API.get().otoApi(mContext)
|
||||||
|
.getUserItems(page)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(model -> {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(model.getData().getInfo());
|
||||||
|
}
|
||||||
|
}, 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 getMatchingNum(HttpCallback<MatchingItemSizeBean> callback) {
|
||||||
|
API.get().otoApi(mContext)
|
||||||
|
.getMatchingNum()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(model -> {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(model.getData().getInfo());
|
||||||
|
}
|
||||||
|
}, 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 getMatchingInfo(HttpCallback<MatchingInfoBean> callback) {
|
||||||
|
|
||||||
|
API.get().otoApi(mContext)
|
||||||
|
.getMatchingInfo()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(model -> {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(model.getData().getInfo());
|
||||||
|
}
|
||||||
|
}, 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 getChatTips(String toUid, HttpCallback<JSONObject> callback) {
|
||||||
|
|
||||||
|
API.get().otoApi(mContext)
|
||||||
|
.getChatTips(toUid)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(model -> {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(JSONObject.parseObject(model.getJsonSrc()));
|
||||||
|
}
|
||||||
|
}, 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 updateChatTips(String toUid, HttpCallback<BaseModel> callback) {
|
||||||
|
|
||||||
|
API.get().otoApi(mContext)
|
||||||
|
.updateChatTips(toUid)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(model -> {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(null);
|
||||||
|
}
|
||||||
|
}, 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();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 设置基本资料
|
* 设置基本资料
|
||||||
*/
|
*/
|
||||||
@ -849,7 +969,16 @@ public class OTONetManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置
|
* 设置
|
||||||
|
* @param key 'signature' => "签名",
|
||||||
|
* 'sex' => "性别",
|
||||||
|
* 'user_nicename' => "昵称",
|
||||||
|
* 'avatar' => "头像",
|
||||||
|
* 'birthday' => "生日",
|
||||||
|
* 'area' => "地区"
|
||||||
|
* is_login=> 首次登录
|
||||||
|
* is_chat=>聊天首次登录
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setFiled(
|
public void setFiled(
|
||||||
String key, String val,
|
String key, String val,
|
||||||
HttpCallback<HttpCallbackModel> callback) {
|
HttpCallback<HttpCallbackModel> callback) {
|
||||||
|
@ -4,6 +4,8 @@ import android.os.Bundle;
|
|||||||
|
|
||||||
import com.alibaba.android.arouter.launcher.ARouter;
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路由跳转Activity
|
* 路由跳转Activity
|
||||||
*/
|
*/
|
||||||
@ -22,6 +24,7 @@ public class RouteManager {
|
|||||||
public static final String ACTIVITY_CALL_VIDEO = "/activity/CallVideoActivity";
|
public static final String ACTIVITY_CALL_VIDEO = "/activity/CallVideoActivity";
|
||||||
public static final String ACTIVITY_CALL_AUDIO = "/activity/CallVAudioActivity";
|
public static final String ACTIVITY_CALL_AUDIO = "/activity/CallVAudioActivity";
|
||||||
public static final String PATH_EDITPROFILE = "/main/EditProfileActivity";
|
public static final String PATH_EDITPROFILE = "/main/EditProfileActivity";
|
||||||
|
public static final String ACTIVITY_MATCHING = "/activity/MatchingActivity";
|
||||||
|
|
||||||
//设置基本资料
|
//设置基本资料
|
||||||
public static final String ACTIVITY_COMPLETE = "/activity/CompleteActivity";
|
public static final String ACTIVITY_COMPLETE = "/activity/CompleteActivity";
|
||||||
@ -104,6 +107,9 @@ public class RouteManager {
|
|||||||
public static void forwardActivity(String path, Bundle bundle) {
|
public static void forwardActivity(String path, Bundle bundle) {
|
||||||
ARouter.getInstance().build(path).withBundle("bundle", bundle).navigation();
|
ARouter.getInstance().build(path).withBundle("bundle", bundle).navigation();
|
||||||
}
|
}
|
||||||
|
public static void forwardActivity(String path, Serializable serializable) {
|
||||||
|
ARouter.getInstance().build(path).withSerializable("data", serializable).navigation();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.shayu.onetoone.manager;
|
package com.shayu.onetoone.manager;
|
||||||
|
|
||||||
import com.shayu.onetoone.bean.MessageConsumeConfigBean;
|
import com.shayu.onetoone.bean.MessageConsumeConfigBean;
|
||||||
|
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||||
import com.yunbao.common.bean.HttpCallbackModel;
|
|
||||||
import com.yunbao.common.http.base.HttpCallback;
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
|
|
||||||
@ -13,8 +13,8 @@ import java.util.UUID;
|
|||||||
public class SendMessageManager {
|
public class SendMessageManager {
|
||||||
private static final Map<String, SendData> cache = new HashMap<>();
|
private static final Map<String, SendData> cache = new HashMap<>();
|
||||||
|
|
||||||
public static void sendMessageForGift(String toUid,String giftId,OnSendMessageListener listener){
|
public static void sendMessageForGift(String toUid, String giftId, OnSendMessageListener listener) {
|
||||||
SendData sendData = new SendData(Integer.parseInt(toUid),
|
SendData sendData = new SendData(toUid,
|
||||||
3,
|
3,
|
||||||
giftId,
|
giftId,
|
||||||
"礼物消息",
|
"礼物消息",
|
||||||
@ -22,8 +22,9 @@ public class SendMessageManager {
|
|||||||
1);
|
1);
|
||||||
send(sendData, listener);
|
send(sendData, listener);
|
||||||
}
|
}
|
||||||
public static void sendMessageForAudio(String toUid,OnSendMessageListener listener){
|
|
||||||
SendData sendData = new SendData(Integer.parseInt(toUid),
|
public static void sendMessageForAudio(String toUid, OnSendMessageListener listener) {
|
||||||
|
SendData sendData = new SendData(toUid,
|
||||||
1,
|
1,
|
||||||
"not",
|
"not",
|
||||||
"录音消息",
|
"录音消息",
|
||||||
@ -31,8 +32,9 @@ public class SendMessageManager {
|
|||||||
1);
|
1);
|
||||||
send(sendData, listener);
|
send(sendData, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendMessageForText(String toUid, String text, OnSendMessageListener messageListener) {
|
public static void sendMessageForText(String toUid, String text, OnSendMessageListener messageListener) {
|
||||||
SendData sendData = new SendData(Integer.parseInt(toUid),
|
SendData sendData = new SendData(toUid,
|
||||||
1,
|
1,
|
||||||
"not",
|
"not",
|
||||||
text,
|
text,
|
||||||
@ -41,6 +43,82 @@ public class SendMessageManager {
|
|||||||
send(sendData, messageListener);
|
send(sendData, messageListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void checkVideoMessage(String toUid, String time, OnSendMessageListener listener) {
|
||||||
|
SendData sendData = new SendData(toUid,
|
||||||
|
2,
|
||||||
|
"not",
|
||||||
|
"视频消息",
|
||||||
|
time,
|
||||||
|
2,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
send(sendData, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkAudioMessage(String toUid, String time, OnSendMessageListener listener) {
|
||||||
|
SendData sendData = new SendData(toUid,
|
||||||
|
5,
|
||||||
|
"not",
|
||||||
|
"音频消息",
|
||||||
|
time,
|
||||||
|
2,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
send(sendData, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void pingVideoMessage(String toUid, String time, OnSendMessageListener listener) {
|
||||||
|
SendData sendData = new SendData(toUid,
|
||||||
|
2,
|
||||||
|
"not",
|
||||||
|
"视频消息",
|
||||||
|
time,
|
||||||
|
2,
|
||||||
|
"after",
|
||||||
|
false
|
||||||
|
);
|
||||||
|
send(sendData, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void pingAudioMessage(String toUid, String time, OnSendMessageListener listener) {
|
||||||
|
SendData sendData = new SendData(toUid,
|
||||||
|
5,
|
||||||
|
"not",
|
||||||
|
"音频消息",
|
||||||
|
time,
|
||||||
|
2,
|
||||||
|
"after",
|
||||||
|
false
|
||||||
|
);
|
||||||
|
send(sendData, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void matching(OnSendMessageListener listener) {
|
||||||
|
SendData sendData = new SendData("not",
|
||||||
|
9,
|
||||||
|
"not",
|
||||||
|
"灵魂匹配",
|
||||||
|
"1",
|
||||||
|
1,
|
||||||
|
"after",
|
||||||
|
false
|
||||||
|
);
|
||||||
|
send(sendData, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void chatUp(String toUid, OnSendMessageListener listener) {
|
||||||
|
SendData sendData = new SendData(toUid,
|
||||||
|
4,
|
||||||
|
"not",
|
||||||
|
"搭讪消息",
|
||||||
|
"1",
|
||||||
|
1,
|
||||||
|
"after",
|
||||||
|
false
|
||||||
|
);
|
||||||
|
send(sendData, listener);
|
||||||
|
}
|
||||||
|
|
||||||
private static void send(SendData sendData, OnSendMessageListener messageListener) {
|
private static void send(SendData sendData, OnSendMessageListener messageListener) {
|
||||||
OTONetManager.getInstance(null)
|
OTONetManager.getInstance(null)
|
||||||
.sendMessage(sendData.toUid,
|
.sendMessage(sendData.toUid,
|
||||||
@ -49,35 +127,24 @@ public class SendMessageManager {
|
|||||||
sendData.content,
|
sendData.content,
|
||||||
sendData.time,
|
sendData.time,
|
||||||
sendData.online,
|
sendData.online,
|
||||||
"before",
|
sendData.method,
|
||||||
new HttpCallback<HttpCallbackModel>() {
|
new HttpCallback<SendConsumeBean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(HttpCallbackModel data) {
|
public void onSuccess(SendConsumeBean consumeBean) {
|
||||||
if (data.getCode() != 0) {
|
if (consumeBean.getCode() != 0) {
|
||||||
OTONetManager.getInstance(null)
|
if (consumeBean.getCode() == 500) {
|
||||||
.getMessageConsumeConfig(sendData.toUid + "", new HttpCallback<MessageConsumeConfigBean>() {
|
messageListener.onError(OnSendMessageListener.STATUS_NOT_PRICE, consumeBean.getMsg(), consumeBean);
|
||||||
@Override
|
} else {
|
||||||
public void onSuccess(MessageConsumeConfigBean data) {
|
messageListener.onError(OnSendMessageListener.STATUS_ERROR, consumeBean.getMsg(), consumeBean);
|
||||||
String msg;
|
}
|
||||||
if (sendData.type == 2) {
|
|
||||||
msg = data.getVideoPrice() + "";
|
|
||||||
} else if (sendData.type == 5) {
|
|
||||||
msg = data.getMp3Price() + "";
|
|
||||||
} else {
|
|
||||||
msg = data.getPrice() + "";
|
|
||||||
}
|
|
||||||
messageListener.onError(OnSendMessageListener.STATUS_NOT_PRICE, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(String error) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
String token = UUID.randomUUID().toString();
|
String token = null;
|
||||||
cache.put(token, sendData);
|
if (sendData.needToken) {
|
||||||
messageListener.onSuccess(token);
|
token = UUID.randomUUID().toString();
|
||||||
|
cache.put(token, sendData);
|
||||||
|
}
|
||||||
|
messageListener.onSuccess(token, consumeBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -102,17 +169,17 @@ public class SendMessageManager {
|
|||||||
sendData.time,
|
sendData.time,
|
||||||
sendData.online,
|
sendData.online,
|
||||||
"after",
|
"after",
|
||||||
new HttpCallback<HttpCallbackModel>() {
|
new HttpCallback<SendConsumeBean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(HttpCallbackModel sd) {
|
public void onSuccess(SendConsumeBean sd) {
|
||||||
if (sd.getCode() != 0) {
|
if (sd.getCode() != 0) {
|
||||||
if(listener!=null) {
|
if (listener != null) {
|
||||||
listener.onSuccess(sd.getMsg());
|
listener.onSuccess(sd.getMsg(), sd);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cache.remove(token);
|
cache.remove(token);
|
||||||
if(listener!=null) {
|
if (listener != null) {
|
||||||
listener.onSuccess(null);
|
listener.onSuccess(null, sd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +189,7 @@ public class SendMessageManager {
|
|||||||
public void onError(String error) {
|
public void onError(String error) {
|
||||||
ToastUtil.show(error);
|
ToastUtil.show(error);
|
||||||
System.err.println(error);
|
System.err.println(error);
|
||||||
if(listener!=null) {
|
if (listener != null) {
|
||||||
listener.onError(OnSendMessageListener.STATUS_ERROR, error);
|
listener.onError(OnSendMessageListener.STATUS_ERROR, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,14 +207,16 @@ public class SendMessageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class SendData {
|
public static class SendData {
|
||||||
private int toUid;
|
public boolean needToken = true;
|
||||||
|
private String toUid;
|
||||||
private int type;
|
private int type;
|
||||||
private String giftId;
|
private String giftId;
|
||||||
private String content;
|
private String content;
|
||||||
private String time;
|
private String time;
|
||||||
private int online;
|
private int online;
|
||||||
|
private String method = "before";
|
||||||
|
|
||||||
public SendData(int toUid, int type, String giftId, String content, String time, int online) {
|
public SendData(String toUid, int type, String giftId, String content, String time, int online) {
|
||||||
this.toUid = toUid;
|
this.toUid = toUid;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.giftId = giftId;
|
this.giftId = giftId;
|
||||||
@ -155,6 +224,37 @@ public class SendMessageManager {
|
|||||||
this.time = time;
|
this.time = time;
|
||||||
this.online = online;
|
this.online = online;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SendData(String toUid, int type, String giftId, String content, String time, int online, boolean needToken) {
|
||||||
|
this.needToken = needToken;
|
||||||
|
this.toUid = toUid;
|
||||||
|
this.type = type;
|
||||||
|
this.giftId = giftId;
|
||||||
|
this.content = content;
|
||||||
|
this.time = time;
|
||||||
|
this.online = online;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendData(String toUid, int type, String giftId, String content, String time, int online, String method) {
|
||||||
|
this.toUid = toUid;
|
||||||
|
this.type = type;
|
||||||
|
this.giftId = giftId;
|
||||||
|
this.content = content;
|
||||||
|
this.time = time;
|
||||||
|
this.online = online;
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendData(String toUid, int type, String giftId, String content, String time, int online, String method, boolean needToken) {
|
||||||
|
this.needToken = needToken;
|
||||||
|
this.toUid = toUid;
|
||||||
|
this.type = type;
|
||||||
|
this.giftId = giftId;
|
||||||
|
this.content = content;
|
||||||
|
this.time = time;
|
||||||
|
this.online = online;
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import com.yunbao.common.CommonAppContext;
|
|||||||
import com.yunbao.common.http.HttpLoggingInterceptor;
|
import com.yunbao.common.http.HttpLoggingInterceptor;
|
||||||
import com.yunbao.common.http.base.BaseApi;
|
import com.yunbao.common.http.base.BaseApi;
|
||||||
import com.yunbao.common.http.base.ParamsContext;
|
import com.yunbao.common.http.base.ParamsContext;
|
||||||
|
import com.yunbao.common.http.converter.JsonConverterFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -81,7 +82,7 @@ public class API extends BaseApi {
|
|||||||
.addInterceptor(initQuery(isNeedUid, isNeedToken, CommonAppContext.sInstance.getApplicationContext()))
|
.addInterceptor(initQuery(isNeedUid, isNeedToken, CommonAppContext.sInstance.getApplicationContext()))
|
||||||
.addInterceptor(loggingInterceptor);
|
.addInterceptor(loggingInterceptor);
|
||||||
return create(builder.build(),
|
return create(builder.build(),
|
||||||
GsonConverterFactory.create(gson), RxJava2CallAdapterFactory.create(), CommonAppConfig.HOST, OneToOneApi.class);
|
JsonConverterFactory.create(gson), RxJava2CallAdapterFactory.create(), CommonAppConfig.HOST, OneToOneApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
//公共参数
|
//公共参数
|
||||||
|
@ -12,12 +12,16 @@ import com.shayu.onetoone.bean.HomeItemBean;
|
|||||||
import com.shayu.onetoone.bean.HomeRankBean;
|
import com.shayu.onetoone.bean.HomeRankBean;
|
||||||
import com.shayu.onetoone.bean.JoinAnchorBean;
|
import com.shayu.onetoone.bean.JoinAnchorBean;
|
||||||
import com.shayu.onetoone.bean.LabelBean;
|
import com.shayu.onetoone.bean.LabelBean;
|
||||||
|
import com.shayu.onetoone.bean.MatchingInfoBean;
|
||||||
|
import com.shayu.onetoone.bean.MatchingItemSizeBean;
|
||||||
import com.shayu.onetoone.bean.MessageConsumeConfigBean;
|
import com.shayu.onetoone.bean.MessageConsumeConfigBean;
|
||||||
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
||||||
import com.shayu.onetoone.bean.PurseBean;
|
import com.shayu.onetoone.bean.PurseBean;
|
||||||
|
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||||
import com.shayu.onetoone.bean.SystemMessageBean;
|
import com.shayu.onetoone.bean.SystemMessageBean;
|
||||||
import com.shayu.onetoone.bean.TargetUserInfoBean;
|
import com.shayu.onetoone.bean.TargetUserInfoBean;
|
||||||
import com.shayu.onetoone.bean.UserBean;
|
import com.shayu.onetoone.bean.UserBean;
|
||||||
|
import com.shayu.onetoone.bean.UserItemBean;
|
||||||
import com.yunbao.common.bean.BaseModel;
|
import com.yunbao.common.bean.BaseModel;
|
||||||
import com.yunbao.common.bean.IMLoginModel;
|
import com.yunbao.common.bean.IMLoginModel;
|
||||||
import com.yunbao.common.bean.UserAvatarSelectBean;
|
import com.yunbao.common.bean.UserAvatarSelectBean;
|
||||||
@ -130,8 +134,8 @@ public interface OneToOneApi {
|
|||||||
Observable<ResponseModel<List<SystemMessageBean>>> getSystemMessageList(@Query("type") int type);
|
Observable<ResponseModel<List<SystemMessageBean>>> getSystemMessageList(@Query("type") int type);
|
||||||
|
|
||||||
@GET("/api/public/?service=Friendappmsg.sendAfter")
|
@GET("/api/public/?service=Friendappmsg.sendAfter")
|
||||||
Observable<ResponseModel<BaseModel>> sendMessage(
|
Observable<ResponseModel<SendConsumeBean>> sendMessage(
|
||||||
@Query("tuid") int tuid,
|
@Query("tuid") String tuid,
|
||||||
@Query("type") int type,
|
@Query("type") int type,
|
||||||
@Query("gift_id") String giftId,
|
@Query("gift_id") String giftId,
|
||||||
@Query("msg") String msg,
|
@Query("msg") String msg,
|
||||||
@ -263,6 +267,21 @@ public interface OneToOneApi {
|
|||||||
Observable<ResponseModel<AuthBean>> getAuthInfo(
|
Observable<ResponseModel<AuthBean>> getAuthInfo(
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@GET("/api/public/?service=Friendappuserprop.list")
|
||||||
|
Observable<ResponseModel<List<UserItemBean>>> getUserItems(@Query("p") String p);
|
||||||
|
|
||||||
|
@GET("/api/public/?service=Friendappuserprop.count")
|
||||||
|
Observable<ResponseModel<MatchingItemSizeBean>> getMatchingNum();
|
||||||
|
|
||||||
|
@GET("/api/public/?service=Friendappuser.makeList")
|
||||||
|
Observable<ResponseModel<MatchingInfoBean>> getMatchingInfo();
|
||||||
|
|
||||||
|
@GET("/api/public/?service=Friendappmsg.getTips")
|
||||||
|
Observable<ResponseModel<BaseModel>> getChatTips(@Query("tuid") String tuid);
|
||||||
|
@GET("/api/public/?service=Friendappmsg.setTips")
|
||||||
|
Observable<ResponseModel<BaseModel>> updateChatTips(@Query("tuid") String tuid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,8 +11,12 @@ import io.rong.imlib.model.ConversationIdentifier;
|
|||||||
* 跳转到会话页面
|
* 跳转到会话页面
|
||||||
*/
|
*/
|
||||||
public class ConversationUtils {
|
public class ConversationUtils {
|
||||||
public static void startConversation(Context mContext,String targetId){
|
public static void startConversation(Context mContext, String targetId) {
|
||||||
|
startConversation(mContext, targetId, new Bundle());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startConversation(Context mContext, String targetId, Bundle bundle) {
|
||||||
ConversationIdentifier conversationIdentifier = new ConversationIdentifier(Conversation.ConversationType.PRIVATE, targetId);
|
ConversationIdentifier conversationIdentifier = new ConversationIdentifier(Conversation.ConversationType.PRIVATE, targetId);
|
||||||
RouteUtils.routeToConversationActivity(mContext, conversationIdentifier, false, new Bundle());
|
RouteUtils.routeToConversationActivity(mContext, conversationIdentifier, false, bundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,176 @@
|
|||||||
|
package com.shayu.onetoone.view;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.animation.AlphaAnimation;
|
||||||
|
import android.view.animation.Animation;
|
||||||
|
import android.view.animation.AnimationSet;
|
||||||
|
import android.view.animation.ScaleAnimation;
|
||||||
|
import android.view.animation.TranslateAnimation;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
|
import com.shayu.onetoone.R;
|
||||||
|
import com.yunbao.common.bean.AnchorRecommendItemModel;
|
||||||
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
|
import com.yunbao.common.views.weight.ClipPathCircleImage;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页精彩推荐banner自定义组件
|
||||||
|
*/
|
||||||
|
public class MatchingBtnView extends FrameLayout {
|
||||||
|
private View rootView;
|
||||||
|
private RelativeLayout bannerLayout1, bannerLayout2, bannerLayout3, bannerLayout4;
|
||||||
|
private ClipPathCircleImage clipImage1, clipImage2, clipImage3, clipImage4;
|
||||||
|
private List<AnchorRecommendItemModel> list = new ArrayList<>();
|
||||||
|
//默认定时器时间
|
||||||
|
private int delayMillis = 1000;
|
||||||
|
//Handler定时加载下一张的数据
|
||||||
|
private Handler bannerHandler = new Handler();
|
||||||
|
private int index = 0;
|
||||||
|
private String Uid;
|
||||||
|
//小图标没必要用高清原图,压缩至x32可以节约内存
|
||||||
|
private final int iconWidth=32;
|
||||||
|
private final int iconHeight=32;
|
||||||
|
|
||||||
|
public MatchingBtnView(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MatchingBtnView(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
rootView = View.inflate(context, R.layout.view_matching_btn, this);
|
||||||
|
clipImage4 = rootView.findViewById(R.id.clip_image4);
|
||||||
|
clipImage3 = rootView.findViewById(R.id.clip_image3);
|
||||||
|
clipImage2 = rootView.findViewById(R.id.clip_image2);
|
||||||
|
clipImage1 = rootView.findViewById(R.id.clip_image1);
|
||||||
|
bannerLayout1 = rootView.findViewById(R.id.banner_layout1);
|
||||||
|
bannerLayout2 = rootView.findViewById(R.id.banner_layout2);
|
||||||
|
bannerLayout3 = rootView.findViewById(R.id.banner_layout3);
|
||||||
|
bannerLayout4 = rootView.findViewById(R.id.banner_layout4);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
|
||||||
|
super.onDraw(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUid() {
|
||||||
|
return Uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置轮播数据
|
||||||
|
*/
|
||||||
|
public void showBanner(List<AnchorRecommendItemModel> mList) {
|
||||||
|
release();
|
||||||
|
post(() -> {
|
||||||
|
if (mList.size() < 3) {
|
||||||
|
setVisibility(GONE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
list.clear();
|
||||||
|
list.addAll(mList);
|
||||||
|
ImgLoader.displayAvatar(getContext(), list.get(0).getAvatar(), clipImage3,iconWidth,iconHeight);
|
||||||
|
ImgLoader.displayAvatar(getContext(), list.get(1).getAvatar(), clipImage2,iconWidth,iconHeight);
|
||||||
|
ImgLoader.displayAvatar(getContext(), list.get(2).getAvatar(), clipImage1,iconWidth,iconHeight);
|
||||||
|
|
||||||
|
bannerHandler.post(mFlipRunnable);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 释放资源
|
||||||
|
*/
|
||||||
|
public void release() {
|
||||||
|
bannerHandler.removeCallbacks(mFlipRunnable);
|
||||||
|
bannerLayout4.clearAnimation();
|
||||||
|
bannerLayout2.clearAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Runnable mFlipRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
int next = index + 1;
|
||||||
|
next = (next >= list.size() ? 0 : next);
|
||||||
|
if (next == 0) {
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
Uid = String.valueOf(list.get(next).getUid());
|
||||||
|
float targetX = bannerLayout2.getX() - bannerLayout3.getX();
|
||||||
|
float targetY = bannerLayout2.getY() - bannerLayout3.getY();
|
||||||
|
bannerLayout3.setVisibility(GONE);
|
||||||
|
ImgLoader.displayAvatar(getContext(), list.get(next).getAvatar(), clipImage3,iconWidth,iconHeight);
|
||||||
|
ImgLoader.displayAvatar(getContext(), list.get(next).getAvatar(), clipImage2,iconWidth,iconHeight);
|
||||||
|
TranslateAnimation animationTranslate = new TranslateAnimation(0, -targetX / 1.2f, 0, -targetY / 1.2f);
|
||||||
|
ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 1.2f, 1f, 1.2f);
|
||||||
|
AnimationSet animationSet1 = new AnimationSet(true);
|
||||||
|
animationSet1.setFillAfter(true);
|
||||||
|
animationSet1.setDuration(500);
|
||||||
|
animationSet1.addAnimation(animationTranslate);
|
||||||
|
animationSet1.addAnimation(scaleAnimation);
|
||||||
|
final int finalNext = next;
|
||||||
|
animationSet1.setAnimationListener(new Animation.AnimationListener() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationStart(Animation animation) {
|
||||||
|
int show = finalNext + 1;
|
||||||
|
|
||||||
|
ImgLoader.displayAvatar(getContext(), list.get(show >= list.size() ? 0 : show).getAvatar(), clipImage1,iconWidth,iconHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animation animation) {
|
||||||
|
|
||||||
|
bannerLayout3.setVisibility(VISIBLE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationRepeat(Animation animation) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ScaleAnimation scaleAnimation2 = new ScaleAnimation(1f, 0.8f, 1f, 0.8f);
|
||||||
|
TranslateAnimation animationTranslate2 = new TranslateAnimation(0, -bannerLayout4.getX()/0.8f, 0, bannerLayout4.getY()*0.8f);
|
||||||
|
AlphaAnimation animationAlpha = new AlphaAnimation(1, 0);
|
||||||
|
AnimationSet animationSet2 = new AnimationSet(true);
|
||||||
|
animationSet2.setFillAfter(true);
|
||||||
|
animationSet2.setDuration(800);
|
||||||
|
animationSet2.addAnimation(animationTranslate2);
|
||||||
|
animationSet2.addAnimation(animationAlpha);
|
||||||
|
animationSet2.addAnimation(scaleAnimation2);
|
||||||
|
animationSet2.setAnimationListener(new Animation.AnimationListener() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationStart(Animation animation) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animation animation) {
|
||||||
|
ImgLoader.displayAvatar(getContext(), list.get(finalNext).getAvatar(), clipImage4,iconWidth,iconHeight);
|
||||||
|
index = index + 1;
|
||||||
|
bannerHandler.postDelayed(mFlipRunnable, delayMillis);
|
||||||
|
bannerLayout3.clearAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationRepeat(Animation animation) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bannerLayout4.startAnimation(animationSet2);
|
||||||
|
bannerLayout2.startAnimation(animationSet1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
@ -12,6 +12,7 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.blankj.utilcode.util.PermissionUtils;
|
import com.blankj.utilcode.util.PermissionUtils;
|
||||||
import com.shayu.onetoone.R;
|
import com.shayu.onetoone.R;
|
||||||
|
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||||
import com.shayu.onetoone.dialog.TipsDialog;
|
import com.shayu.onetoone.dialog.TipsDialog;
|
||||||
import com.shayu.onetoone.listener.OnDialogClickListener;
|
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||||
@ -115,8 +116,8 @@ public class MsgInputPanelForAudio extends AbsInputPanel {
|
|||||||
System.out.println("点击事件:调用token");
|
System.out.println("点击事件:调用token");
|
||||||
SendMessageManager.sendMessageForAudio(targetId, new OnSendMessageListener() {
|
SendMessageManager.sendMessageForAudio(targetId, new OnSendMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String token) {
|
public void onSuccess(String token, SendConsumeBean bean) {
|
||||||
super.onSuccess(token);
|
super.onSuccess(token,bean);
|
||||||
MsgInputPanelForAudio.this.token = token;
|
MsgInputPanelForAudio.this.token = token;
|
||||||
isAudio = true;
|
isAudio = true;
|
||||||
onDown(v, mLastTouchY);
|
onDown(v, mLastTouchY);
|
||||||
|
@ -13,6 +13,8 @@ import com.shayu.onetoone.adapter.GiftListAdapter;
|
|||||||
import com.shayu.onetoone.bean.GiftBean;
|
import com.shayu.onetoone.bean.GiftBean;
|
||||||
import com.shayu.onetoone.bean.MessageChatGiftContent;
|
import com.shayu.onetoone.bean.MessageChatGiftContent;
|
||||||
import com.shayu.onetoone.bean.PurseBean;
|
import com.shayu.onetoone.bean.PurseBean;
|
||||||
|
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||||
|
import com.shayu.onetoone.dialog.TipsDialog;
|
||||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||||
import com.shayu.onetoone.manager.OTONetManager;
|
import com.shayu.onetoone.manager.OTONetManager;
|
||||||
import com.shayu.onetoone.manager.SendMessageManager;
|
import com.shayu.onetoone.manager.SendMessageManager;
|
||||||
@ -69,8 +71,8 @@ public class MsgInputPanelForGift extends AbsInputPanel {
|
|||||||
GiftBean item = mAdapter.getItem();
|
GiftBean item = mAdapter.getItem();
|
||||||
SendMessageManager.sendMessageForGift(targetId, item.getId() + "", new OnSendMessageListener() {
|
SendMessageManager.sendMessageForGift(targetId, item.getId() + "", new OnSendMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String token) {
|
public void onSuccess(String token, SendConsumeBean bean) {
|
||||||
super.onSuccess(token);
|
super.onSuccess(token,bean);
|
||||||
MsgInputPanelForGift.this.token = token;
|
MsgInputPanelForGift.this.token = token;
|
||||||
sendGift(item);
|
sendGift(item);
|
||||||
|
|
||||||
@ -79,6 +81,9 @@ public class MsgInputPanelForGift extends AbsInputPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void onError(int status, String msg) {
|
public void onError(int status, String msg) {
|
||||||
super.onError(status, msg);
|
super.onError(status, msg);
|
||||||
|
new TipsDialog(mContext)
|
||||||
|
.setTitle("餘額不足")
|
||||||
|
.showDialog();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
9
OneToOne/src/main/res/drawable/bg_matching_btn.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:width="268dp" android:height="54dp">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<gradient android:type="linear" android:useLevel="true" android:startColor="#ff08c5c5" android:endColor="#ff0da3d0" android:angle="90" />
|
||||||
|
<corners android:topLeftRadius="28dp" android:topRightRadius="28dp" android:bottomLeftRadius="28dp" android:bottomRightRadius="28dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
7
OneToOne/src/main/res/layout/activity_full_image.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/image"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
</ImageView>
|
163
OneToOne/src/main/res/layout/activity_matching.xml
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:background="@mipmap/bg_matching"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="268dp"
|
||||||
|
android:layout_height="54dp"
|
||||||
|
android:layout_marginBottom="108dp"
|
||||||
|
android:background="@drawable/bg_matching_btn"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent">
|
||||||
|
|
||||||
|
<com.makeramen.roundedimageview.RoundedImageView
|
||||||
|
android:id="@+id/user1"
|
||||||
|
android:layout_width="34dp"
|
||||||
|
android:layout_height="34dp"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:src="@mipmap/icon_avatar_placeholder"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:riv_oval="true" />
|
||||||
|
|
||||||
|
<com.makeramen.roundedimageview.RoundedImageView
|
||||||
|
android:id="@+id/user2"
|
||||||
|
android:layout_width="34dp"
|
||||||
|
android:layout_height="34dp"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginStart="-20dp"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:src="@mipmap/icon_avatar_placeholder"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/user1"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:riv_oval="true" />
|
||||||
|
|
||||||
|
<com.makeramen.roundedimageview.RoundedImageView
|
||||||
|
android:id="@+id/user3"
|
||||||
|
android:layout_width="34dp"
|
||||||
|
android:layout_height="34dp"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginStart="-20dp"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:src="@mipmap/icon_avatar_placeholder"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/user2"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:riv_oval="true" />
|
||||||
|
|
||||||
|
<com.makeramen.roundedimageview.RoundedImageView
|
||||||
|
android:id="@+id/user4"
|
||||||
|
android:layout_width="34dp"
|
||||||
|
android:layout_height="34dp"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginStart="-20dp"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:src="@mipmap/icon_avatar_placeholder"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/user3"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:riv_oval="true" />
|
||||||
|
|
||||||
|
<com.makeramen.roundedimageview.RoundedImageView
|
||||||
|
android:id="@+id/user5"
|
||||||
|
android:layout_width="34dp"
|
||||||
|
android:layout_height="34dp"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginStart="-20dp"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:src="@mipmap/icon_avatar_placeholder"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/user4"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:riv_oval="true" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/num"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="9dp"
|
||||||
|
android:text="114514"
|
||||||
|
android:textColor="#FF4A85"
|
||||||
|
android:textSize="16sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/user5"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tips"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="正在热聊中"
|
||||||
|
android:textColor="#FFF"
|
||||||
|
android:textSize="14sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/num"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/num"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/num" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imageView6"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="200dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@mipmap/bg_matching_star" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tips1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="18dp"
|
||||||
|
android:text="匹配中..."
|
||||||
|
android:textColor="#FFFFFF"
|
||||||
|
android:textSize="18sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/imageView6"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/imageView6"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/imageView6" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tips2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:text="TA還在練習見面開場白,再給TA點時間吧~"
|
||||||
|
android:textColor="#FFF"
|
||||||
|
android:textSize="12sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/imageView6"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/imageView6"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/tips1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:textColor="#FFFFFF"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="42dp"
|
||||||
|
android:text="灵魂速配"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/back"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/title"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/title"
|
||||||
|
app:srcCompat="@mipmap/ic_matching_back" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
16
OneToOne/src/main/res/layout/dialog_msg_tips.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/rootView"
|
||||||
|
android:layout_margin="5dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tips"
|
||||||
|
android:layout_margin="5dp"
|
||||||
|
tools:text="通话将在****秒后断\n开,请及时充值"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
</LinearLayout>
|
@ -5,18 +5,25 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/bg_dialog_tip"
|
android:background="@drawable/bg_dialog_tip"
|
||||||
|
android:minWidth="256dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginStart="19dp"
|
||||||
|
android:layout_marginEnd="11dp"
|
||||||
android:layout_marginTop="21dp"
|
android:layout_marginTop="21dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
tools:text="餘額不足"
|
android:ellipsize="marquee"
|
||||||
|
android:maxEms="11"
|
||||||
android:textColor="#333333"
|
android:textColor="#333333"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold"
|
||||||
|
tools:text="余额不足,请充值后再进行尝试吧~" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/content_layout"
|
android:id="@+id/content_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -30,17 +37,19 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="14dp"
|
android:layout_marginStart="14dp"
|
||||||
android:layout_marginTop="9dp"
|
android:layout_marginTop="9dp"
|
||||||
|
android:visibility="visible"
|
||||||
android:layout_marginEnd="14dp"
|
android:layout_marginEnd="14dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
tools:text="與TA視頻聊天每分鐘續消耗299鑽石,您可通過充值獲取更多鑽石,以便繼續聊天" />
|
tools:text="" />
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="6dp"
|
android:layout_marginTop="16dp"
|
||||||
android:layout_marginBottom="30dp"
|
android:layout_marginBottom="20dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:listitem="@layout/item_home_recommend" />
|
tools:listitem="@layout/item_home_recommend" />
|
||||||
|
|
||||||
</io.rong.imkit.widget.refresh.SmartRefreshLayout>
|
</io.rong.imkit.widget.refresh.SmartRefreshLayout>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@ -33,6 +34,16 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent" />
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/matching"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="56dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:srcCompat="@mipmap/ic_matching_free" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/view_empty"
|
android:id="@+id/view_empty"
|
||||||
layout="@layout/view_empty_list"
|
layout="@layout/view_empty_list"
|
||||||
|
@ -157,13 +157,14 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="4dp"
|
android:layout_marginEnd="4dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:visibility="gone"
|
||||||
android:src="@mipmap/ic_msg_add" />
|
android:src="@mipmap/ic_msg_add" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/audio_layout"
|
android:id="@+id/audio_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="190dp"
|
android:layout_height="0dp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
@ -81,8 +81,8 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/money"
|
android:id="@+id/money"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="35dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="35dp"
|
||||||
android:layout_marginBottom="30dp"
|
android:layout_marginBottom="30dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/gift"
|
app:layout_constraintBottom_toTopOf="@+id/gift"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/gift"
|
app:layout_constraintEnd_toEndOf="@+id/gift"
|
||||||
|
133
OneToOne/src/main/res/layout/view_matching_btn.xml
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="268dp"
|
||||||
|
android:layout_height="54dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="268dp"
|
||||||
|
android:layout_height="54dp"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:background="@drawable/bg_matching_btn"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="7dp"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:paddingEnd="7dp"
|
||||||
|
android:paddingBottom="5dp" />
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/banner_layout1"
|
||||||
|
android:layout_width="25dp"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginStart="28dp"
|
||||||
|
android:background="@drawable/bg_white_clip"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="1dp"
|
||||||
|
android:visibility="visible">
|
||||||
|
|
||||||
|
<com.yunbao.common.views.weight.ClipPathCircleImage
|
||||||
|
android:id="@+id/clip_image1"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:layout_gravity="center" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/banner_layout2"
|
||||||
|
android:layout_width="25dp"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginStart="38dp"
|
||||||
|
android:background="@drawable/bg_white_clip"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="1dp">
|
||||||
|
|
||||||
|
<com.yunbao.common.views.weight.ClipPathCircleImage
|
||||||
|
android:id="@+id/clip_image2"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/banner_layout3"
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginStart="48dp"
|
||||||
|
android:background="@drawable/bg_white_clip"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="1dp"
|
||||||
|
android:visibility="visible">
|
||||||
|
|
||||||
|
<com.yunbao.common.views.weight.ClipPathCircleImage
|
||||||
|
android:id="@+id/clip_image3"
|
||||||
|
android:layout_width="29dp"
|
||||||
|
android:layout_height="29dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/banner_layout4"
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginStart="58dp"
|
||||||
|
android:background="@drawable/bg_white_clip"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="1dp"
|
||||||
|
|
||||||
|
android:visibility="visible">
|
||||||
|
|
||||||
|
<com.yunbao.common.views.weight.ClipPathCircleImage
|
||||||
|
android:id="@+id/clip_image4"
|
||||||
|
android:layout_width="29dp"
|
||||||
|
android:layout_height="29dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/banner_layout5"
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginStart="68dp"
|
||||||
|
android:background="@drawable/bg_white_clip"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="1dp"
|
||||||
|
|
||||||
|
android:visibility="visible">
|
||||||
|
|
||||||
|
<com.yunbao.common.views.weight.ClipPathCircleImage
|
||||||
|
android:id="@+id/clip_image5"
|
||||||
|
android:layout_width="29dp"
|
||||||
|
android:layout_height="29dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginEnd="15dp"
|
||||||
|
android:text="@string/wonderful_live"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="13sp" />
|
||||||
|
</RelativeLayout>
|
@ -4,7 +4,8 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:background="@color/white"
|
android:background="@color/white"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="210dp">
|
android:layout_marginBottom="10dp"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/gift_list"
|
android:id="@+id/gift_list"
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/btn_back"
|
android:id="@+id/btn_back"
|
||||||
android:layout_width="8dp"
|
android:layout_width="15dp"
|
||||||
android:layout_height="18dp"
|
android:layout_height="18dp"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_margin="16dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginStart="25dp"
|
||||||
|
android:layout_marginTop="25dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:srcCompat="@mipmap/ic_top_break" />
|
app:srcCompat="@mipmap/ic_top_break" />
|
||||||
|
BIN
OneToOne/src/main/res/mipmap-xxhdpi/bg_firstlogin_tips.png
Normal file
After Width: | Height: | Size: 202 KiB |
BIN
OneToOne/src/main/res/mipmap-xxhdpi/bg_firstlogin_tips_man.png
Normal file
After Width: | Height: | Size: 112 KiB |
BIN
OneToOne/src/main/res/mipmap-xxhdpi/bg_firstlogin_tips_woman.png
Normal file
After Width: | Height: | Size: 110 KiB |
BIN
OneToOne/src/main/res/mipmap-xxhdpi/bg_matching.png
Normal file
After Width: | Height: | Size: 497 KiB |
BIN
OneToOne/src/main/res/mipmap-xxhdpi/bg_matching_star.png
Normal file
After Width: | Height: | Size: 234 KiB |
BIN
OneToOne/src/main/res/mipmap-xxhdpi/ic_matching_back.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
OneToOne/src/main/res/mipmap-xxhdpi/ic_matching_free.png
Normal file
After Width: | Height: | Size: 56 KiB |
@ -208,5 +208,6 @@ dependencies {
|
|||||||
api 'com.github.xuexiangjys.XUtil:xutil-core:2.0.0'
|
api 'com.github.xuexiangjys.XUtil:xutil-core:2.0.0'
|
||||||
|
|
||||||
// api files('libs/svgaplayer-release-v1.2.1.aar')
|
// api files('libs/svgaplayer-release-v1.2.1.aar')
|
||||||
|
api 'com.blankj:utilcode:1.30.0'//獲取uuid
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.yunbao.common.dialog;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.lxj.xpopup.XPopup;
|
||||||
|
import com.lxj.xpopup.core.BottomPopupView;
|
||||||
|
import com.lxj.xpopup.impl.FullScreenPopupView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全屏弹窗
|
||||||
|
*/
|
||||||
|
public abstract class AbsFullDialogPopupWindow extends FullScreenPopupView {
|
||||||
|
public final Context mContext;
|
||||||
|
|
||||||
|
public AbsFullDialogPopupWindow(@NonNull Context context) {
|
||||||
|
super(context);
|
||||||
|
this.mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <a href="https://github.com/li-xiaojun/XPopup/wiki/5.-%E5%B8%B8%E7%94%A8%E8%AE%BE%E7%BD%AE">参考配置</a>
|
||||||
|
*/
|
||||||
|
public abstract void buildDialog(XPopup.Builder builder);
|
||||||
|
public abstract int bindLayoutId();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getImplLayoutId() {
|
||||||
|
return bindLayoutId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showDialog() {
|
||||||
|
XPopup.Builder builder = new XPopup.Builder(mContext);
|
||||||
|
builder.isDestroyOnDismiss(true);
|
||||||
|
builder.enableDrag(false);
|
||||||
|
buildDialog(builder);
|
||||||
|
builder.asCustom(this).show();
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,8 @@ public class ResponseModel<T> {
|
|||||||
@SerializedName("msg")
|
@SerializedName("msg")
|
||||||
private String msg;
|
private String msg;
|
||||||
|
|
||||||
|
private String jsonSrc;
|
||||||
|
|
||||||
public int getRet() {
|
public int getRet() {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -46,4 +48,16 @@ public class ResponseModel<T> {
|
|||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setJsonSrc(String jsonSrc) {
|
||||||
|
this.jsonSrc = jsonSrc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJsonSrc() {
|
||||||
|
return jsonSrc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isError() {
|
||||||
|
return data == null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.yunbao.common.http.converter;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
import okhttp3.ResponseBody;
|
||||||
|
import retrofit2.Converter;
|
||||||
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
|
public class JsonConverterFactory extends Converter.Factory {
|
||||||
|
private final Gson gson;
|
||||||
|
|
||||||
|
public static Converter.Factory create(Gson gson) {
|
||||||
|
return new JsonConverterFactory(gson);
|
||||||
|
}
|
||||||
|
|
||||||
|
private JsonConverterFactory(Gson gson) {
|
||||||
|
this.gson = gson;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] parameterAnnotations,
|
||||||
|
Annotation[] methodAnnotations, Retrofit retrofit) {
|
||||||
|
TypeAdapter<?> adapter = gson.getAdapter(TypeToken.get(type));
|
||||||
|
return new JsonRequestConverter<>(gson, adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations,
|
||||||
|
Retrofit retrofit) {
|
||||||
|
TypeAdapter<?> adapter = gson.getAdapter(TypeToken.get(type));
|
||||||
|
return new JsonResponseBodyConverter<>(gson, adapter);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.yunbao.common.http.converter;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
import okio.Buffer;
|
||||||
|
import retrofit2.Converter;
|
||||||
|
|
||||||
|
public class JsonRequestConverter<T> implements Converter<T, RequestBody> {
|
||||||
|
private static final MediaType MEDIA_TYPE = MediaType.parse("application/json; charset=UTF-8");
|
||||||
|
private static final Charset UTF_8 = StandardCharsets.UTF_8;
|
||||||
|
|
||||||
|
private final Gson gson;
|
||||||
|
private final TypeAdapter<T> adapter;
|
||||||
|
JsonRequestConverter(Gson gson, TypeAdapter<T> adapter) {
|
||||||
|
this.gson = gson;
|
||||||
|
this.adapter = adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RequestBody convert(T value) throws IOException {
|
||||||
|
Buffer buffer = new Buffer();
|
||||||
|
Writer writer = new OutputStreamWriter(buffer.outputStream(), UTF_8);
|
||||||
|
JsonWriter jsonWriter = gson.newJsonWriter(writer);
|
||||||
|
adapter.write(jsonWriter, value);
|
||||||
|
jsonWriter.close();
|
||||||
|
return RequestBody.create(MEDIA_TYPE, buffer.readByteString());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package com.yunbao.common.http.converter;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.yunbao.common.http.ResponseModel;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import okhttp3.ResponseBody;
|
||||||
|
import retrofit2.Converter;
|
||||||
|
|
||||||
|
public class JsonResponseBodyConverter<T> implements Converter<ResponseBody, T> {
|
||||||
|
private final Gson gson;
|
||||||
|
private final TypeAdapter<T> adapter;
|
||||||
|
|
||||||
|
public JsonResponseBodyConverter(Gson gson, TypeAdapter<T> adapter) {
|
||||||
|
this.gson = gson;
|
||||||
|
this.adapter = adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T convert(ResponseBody value) throws IOException {
|
||||||
|
byte[] copy=value.bytes().clone();
|
||||||
|
value=ResponseBody.create(value.contentType(),copy.clone());
|
||||||
|
JsonReader jsonReader = gson.newJsonReader(value.charStream());
|
||||||
|
try {
|
||||||
|
ResponseModel<T> model= (ResponseModel<T>) adapter.read(jsonReader);
|
||||||
|
model.setJsonSrc(new String(copy));
|
||||||
|
return (T) model;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
String src = new String(copy);
|
||||||
|
ResponseModel<T> model = new ResponseModel<T>();
|
||||||
|
model.setJsonSrc(src);
|
||||||
|
return (T) model;
|
||||||
|
} finally {
|
||||||
|
value.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|