update
This commit is contained in:
@@ -40,6 +40,7 @@ public abstract class AbsOTOActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
onCreate();
|
||||
setStatusBar();
|
||||
setContentView(getLayoutId());
|
||||
mContext = this;
|
||||
@@ -64,6 +65,8 @@ public abstract class AbsOTOActivity extends AppCompatActivity {
|
||||
|
||||
protected abstract void main(Bundle savedInstanceState);
|
||||
|
||||
protected void onCreate(){}
|
||||
|
||||
/**
|
||||
* 设置标题
|
||||
*/
|
||||
|
||||
@@ -150,13 +150,8 @@ public class MainActivity extends AbsOTOActivity {
|
||||
}
|
||||
|
||||
private void updateUnreadCount(int count) {
|
||||
if(count==0){
|
||||
dslTabLayout.setDrawBadge(false);
|
||||
}else {
|
||||
dslTabLayout.setDrawBadge(true);
|
||||
}
|
||||
dslTabLayout.setDrawBadge(count > 0);
|
||||
dslTabLayout.updateTabBadge(2, count + "");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,7 +10,12 @@ import androidx.annotation.NonNull;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.BaseFragment;
|
||||
import com.shayu.onetoone.adapter.HomeHotListAdapter;
|
||||
import com.shayu.onetoone.bean.HomeItemBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
@@ -48,6 +53,20 @@ public class HotFragment extends BaseFragment {
|
||||
|
||||
private void onConversationListRefresh(RefreshLayout refreshLayout) {
|
||||
|
||||
}
|
||||
private void initData(){
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getHomeHot(new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
@@ -10,7 +10,12 @@ import androidx.annotation.NonNull;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.BaseFragment;
|
||||
import com.shayu.onetoone.adapter.HomeRecommendListAdapter;
|
||||
import com.shayu.onetoone.bean.HomeItemBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
@@ -47,13 +52,30 @@ public class RecommendFragment extends BaseFragment {
|
||||
top.setOnClickListener(view -> {
|
||||
recyclerView.scrollToPosition(0);
|
||||
});
|
||||
initData();
|
||||
}
|
||||
|
||||
private void onConversationListLoadMore() {
|
||||
mRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
private void onConversationListRefresh(RefreshLayout refreshLayout) {
|
||||
|
||||
initData();
|
||||
}
|
||||
private void initData(){
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getHomeRecommend(new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
adapter.setList(data);
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,17 +1,28 @@
|
||||
package com.shayu.onetoone.activity.fragments.message;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.MessageChatTipsContent;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
@@ -23,6 +34,10 @@ import java.util.Date;
|
||||
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imkit.conversation.ConversationFragment;
|
||||
import io.rong.imkit.manager.AudioPlayManager;
|
||||
import io.rong.imkit.manager.AudioRecordManager;
|
||||
import io.rong.imkit.utils.PermissionCheckUtil;
|
||||
import io.rong.imkit.utils.RongOperationPermissionUtils;
|
||||
import io.rong.imlib.IRongCallback;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
@@ -38,7 +53,13 @@ public class ChatMessageFragment extends ConversationFragment {
|
||||
ImageView img, call, video, gift;
|
||||
ProcessImageUtil cameraUtil;
|
||||
String targetId;
|
||||
Conversation.ConversationType conversationType= Conversation.ConversationType.PRIVATE;
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
View audioLayout;
|
||||
ImageView btnAudio;
|
||||
ImageView btnText;
|
||||
ImageView btnClose;
|
||||
private float mLastTouchY;
|
||||
private boolean mUpDirection;
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
@@ -51,7 +72,7 @@ public class ChatMessageFragment extends ConversationFragment {
|
||||
initCamera();
|
||||
|
||||
call.setOnClickListener(v -> {
|
||||
MessageChatTipsContent bean= MessageChatTipsContent.obtain(WordUtil.getString(R.string.message_chat_tip1));
|
||||
MessageChatTipsContent bean = MessageChatTipsContent.obtain(WordUtil.getString(R.string.message_chat_tip1));
|
||||
IMCenter.getInstance().insertOutgoingMessage(conversationType, targetId, Message.SentStatus.SENT, bean, System.currentTimeMillis(), new RongIMClient.ResultCallback<Message>() {
|
||||
@Override
|
||||
public void onSuccess(Message message) {
|
||||
@@ -61,11 +82,12 @@ public class ChatMessageFragment extends ConversationFragment {
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
ToastUtil.show(R.string.system_tip_failure);
|
||||
System.out.println("失败:"+e.getMessage());
|
||||
System.out.println("失败:" + e.getMessage());
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
updateMyInfo();
|
||||
}
|
||||
|
||||
private void initCamera() {
|
||||
@@ -87,6 +109,7 @@ public class ChatMessageFragment extends ConversationFragment {
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private void initBtn() {
|
||||
try {
|
||||
Field field = mRongExtension.getInputPanel().getClass().getDeclaredField("mInputPanel");
|
||||
@@ -94,15 +117,83 @@ public class ChatMessageFragment extends ConversationFragment {
|
||||
mInputPanel = (View) field.get(mRongExtension.getInputPanel());
|
||||
assert mInputPanel != null;
|
||||
mSendBtn = mInputPanel.findViewById(R.id.send_btn);
|
||||
ImageView mVoiceToggleBtn = (ImageView) mInputPanel.findViewById(R.id.input_panel_voice_toggle);
|
||||
assert mVoiceToggleBtn != null;
|
||||
|
||||
mVoiceToggleBtn.setOnClickListener(v -> {
|
||||
changeAudioLayout();
|
||||
});
|
||||
img = mInputPanel.findViewById(R.id.input_panel_image_btn);
|
||||
video = mInputPanel.findViewById(R.id.input_panel_video_btn);
|
||||
call = mInputPanel.findViewById(R.id.input_panel_call_btn);
|
||||
gift = mInputPanel.findViewById(R.id.input_panel_gift_btn);
|
||||
audioLayout = mInputPanel.findViewById(R.id.audio_layout);
|
||||
btnAudio = mInputPanel.findViewById(R.id.audio_btn);
|
||||
btnText = mInputPanel.findViewById(R.id.text_btn);
|
||||
btnClose = mInputPanel.findViewById(R.id.close_btn);
|
||||
|
||||
btnText.setOnClickListener(v -> changeAudioLayout());
|
||||
btnClose.setOnClickListener(v -> changeAudioLayout());
|
||||
|
||||
btnAudio.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
float mOffsetLimit = 70.0F * v.getContext().getResources().getDisplayMetrics().density;
|
||||
String[] permissions = new String[]{"android.permission.RECORD_AUDIO"};
|
||||
if (!PermissionCheckUtil.checkPermissions(v.getContext(), permissions) && event.getAction() == 0) {
|
||||
PermissionCheckUtil.requestPermissions(ChatMessageFragment.this, permissions, 100);
|
||||
return true;
|
||||
} else {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
if (AudioPlayManager.getInstance().isPlaying()) {
|
||||
AudioPlayManager.getInstance().stopPlay();
|
||||
}
|
||||
|
||||
if (RongOperationPermissionUtils.isOnRequestHardwareResource()) {
|
||||
Toast.makeText(v.getContext(), v.getContext().getResources().getString(io.rong.imkit.R.string.rc_voip_occupying), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
ChatMessageFragment.this.mLastTouchY = event.getY();
|
||||
ChatMessageFragment.this.mUpDirection = false;
|
||||
AudioRecordManager.getInstance().startRecord(v.getRootView(), mRongExtension.getConversationIdentifier());
|
||||
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
if (ChatMessageFragment.this.mLastTouchY - event.getY() > mOffsetLimit && !ChatMessageFragment.this.mUpDirection) {
|
||||
AudioRecordManager.getInstance().willCancelRecord();
|
||||
ChatMessageFragment.this.mUpDirection = true;
|
||||
} else if (event.getY() - ChatMessageFragment.this.mLastTouchY > -mOffsetLimit && ChatMessageFragment.this.mUpDirection) {
|
||||
AudioRecordManager.getInstance().continueRecord();
|
||||
ChatMessageFragment.this.mUpDirection = false;
|
||||
}
|
||||
|
||||
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
|
||||
AudioRecordManager.getInstance().stopRecord();
|
||||
}
|
||||
|
||||
if (mRongExtension.getConversationIdentifier().getType().equals(Conversation.ConversationType.PRIVATE)) {
|
||||
RongIMClient.getInstance().sendTypingStatus(mRongExtension.getConversationIdentifier().getType(),
|
||||
mRongExtension.getConversationIdentifier().getTargetId(), "RC:VcMsg");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void changeAudioLayout() {
|
||||
if (audioLayout.getVisibility() == View.VISIBLE) {
|
||||
audioLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
audioLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendText() {
|
||||
try {
|
||||
Field field = mRongExtension.getInputPanel().getClass().getDeclaredField("mSendBtn");
|
||||
@@ -116,7 +207,7 @@ public class ChatMessageFragment extends ConversationFragment {
|
||||
}
|
||||
|
||||
private void sendImage(File file) {
|
||||
ImageMessage imageMessage = ImageMessage.obtain(Uri.parse("file://"+file.getAbsolutePath()),true);
|
||||
ImageMessage imageMessage = ImageMessage.obtain(Uri.parse("file://" + file.getAbsolutePath()), true);
|
||||
Message message = Message.obtain(targetId, conversationType, imageMessage);
|
||||
message.setSenderUserId(CommonAppConfig.getInstance().getUid());
|
||||
message.setObjectName("RC:ImgMsg");
|
||||
@@ -152,4 +243,19 @@ public class ChatMessageFragment extends ConversationFragment {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void updateMyInfo() {
|
||||
OTONetManager.getInstance(getActivity())
|
||||
.getBaseInfos(false, new HttpCallback<UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserBean data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.shayu.onetoone.activity.fragments.message;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -20,6 +21,7 @@ import com.shayu.onetoone.activity.fragments.BaseFragment;
|
||||
import com.shayu.onetoone.adapter.MsgMessageRecyclerViewAdapter;
|
||||
import com.shayu.onetoone.bean.MsgMessageBean;
|
||||
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
||||
import com.shayu.onetoone.bean.TargetUserInfoBean;
|
||||
import com.shayu.onetoone.event.MessageMsgBusEvent;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.yanzhenjie.recyclerview.OnItemMenuClickListener;
|
||||
@@ -34,6 +36,7 @@ import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.RandomUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@@ -48,6 +51,7 @@ import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import io.rong.common.RLog;
|
||||
import io.rong.imkit.GlideKitImageEngine;
|
||||
import io.rong.imkit.IMCenter;
|
||||
@@ -75,6 +79,7 @@ import io.rong.imlib.IRongCoreEnum;
|
||||
import io.rong.imlib.RongCoreClient;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.ConversationIdentifier;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.imlib.model.UserInfo;
|
||||
|
||||
@@ -151,8 +156,8 @@ public class MsgMessageFragment extends BaseFragment implements BaseAdapter.OnIt
|
||||
}
|
||||
});
|
||||
initSystemNotice();
|
||||
initUserInfo(0);
|
||||
initRongConfig();
|
||||
updateUserInfo();
|
||||
}
|
||||
|
||||
private void initRongConfig() {
|
||||
@@ -165,36 +170,6 @@ public class MsgMessageFragment extends BaseFragment implements BaseAdapter.OnIt
|
||||
});
|
||||
}
|
||||
|
||||
private void initUserInfo(long timer) {
|
||||
RongIMClient.getInstance().getConversationListByPage(new RongIMClient.ResultCallback<List<Conversation>>() {
|
||||
@Override
|
||||
public void onSuccess(List<Conversation> conversations) {
|
||||
long destructTime = 0;
|
||||
for (Conversation conversation : conversations) {
|
||||
String targetId = conversation.getTargetId();
|
||||
Log.i(TAG, "targetId = " + targetId);
|
||||
UserInfo info = new UserInfo(targetId, "用户名" + targetId, Uri.parse("https://downs.yaoulive.com/avatar/12.jpg"));
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("sex", RandomUtil.nextInt(20) % 2);
|
||||
json.put("age", RandomUtil.nextInt(40));
|
||||
info.setExtra(json.toJSONString());
|
||||
RongUserInfoManager.getInstance().refreshUserInfoCache(info);
|
||||
if (conversations.size() < 10) {
|
||||
destructTime = conversation.getSentTime();
|
||||
}
|
||||
}
|
||||
if (destructTime > 0) {
|
||||
initUserInfo(destructTime);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
|
||||
}
|
||||
}, timer, 10, Conversation.ConversationType.PRIVATE);
|
||||
}
|
||||
|
||||
|
||||
private void initSystemNotice() {
|
||||
|
||||
@@ -205,9 +180,17 @@ public class MsgMessageFragment extends BaseFragment implements BaseAdapter.OnIt
|
||||
public void onSuccess(List<OfficialNoticeBean> data) {
|
||||
for (OfficialNoticeBean datum : data) {
|
||||
if (datum.getType() == 3) {
|
||||
SpUtil.setStringValue("customerService", JSONObject.toJSONString(datum));
|
||||
continue;
|
||||
}
|
||||
mAdapter.add(setTopData(datum.getTitle(), datum.getContent(), datum.getAddtime()*1000, datum.getNew_image(), datum.getNum(), datum.getType()), datum.getType());
|
||||
mAdapter.add(setTopData(datum.getTitle(),
|
||||
datum.getContent(),
|
||||
datum.getAddtime() * 1000,
|
||||
datum.getNew_image(),
|
||||
datum.getNum(),
|
||||
datum.getType(),
|
||||
JSONObject.toJSONString(datum)
|
||||
), datum.getType());
|
||||
}
|
||||
onConversationListRefresh(mRefreshLayout);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
@@ -223,7 +206,7 @@ public class MsgMessageFragment extends BaseFragment implements BaseAdapter.OnIt
|
||||
|
||||
}
|
||||
|
||||
private SingleConversation setTopData(String title, String content, long time, String avatar, int num, int id) {
|
||||
private SingleConversation setTopData(String title, String content, long time, String avatar, int num, int id, String exp) {
|
||||
SingleConversation conversation = new SingleConversation(getContext(), new Conversation());
|
||||
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
||||
conversation.mCore.setSenderUserName(title);
|
||||
@@ -233,6 +216,7 @@ public class MsgMessageFragment extends BaseFragment implements BaseAdapter.OnIt
|
||||
conversation.mConversationContent = new SpannableString(content);
|
||||
conversation.mCore.setUnreadMessageCount(num);
|
||||
conversation.mCore.setTargetId(id + "");
|
||||
conversation.mCore.setLatestMessageExtra(exp);
|
||||
UserInfo info = new UserInfo(id + "", title, Uri.parse(avatar));
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("sex", -1);
|
||||
@@ -376,6 +360,7 @@ public class MsgMessageFragment extends BaseFragment implements BaseAdapter.OnIt
|
||||
this.mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
MsgMessageFragment.this.onConversationListRefresh(refreshLayout);
|
||||
updateUserInfo();
|
||||
}
|
||||
});
|
||||
this.mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
@@ -467,12 +452,13 @@ public class MsgMessageFragment extends BaseFragment implements BaseAdapter.OnIt
|
||||
BaseUiConversation baseUiConversation = (BaseUiConversation) this.mAdapter.getItem(position);
|
||||
String targetId = baseUiConversation.mCore.getTargetId();
|
||||
try {
|
||||
long type=Integer.parseInt(targetId);
|
||||
if(type<100){
|
||||
int type = Integer.parseInt(targetId);
|
||||
if (type < 100) {
|
||||
ToastUtil.showDebug("还没做");
|
||||
startSystem(JSONObject.parseObject(mAdapter.getSystemItem(type).mCore.getLatestMessageExtra(), OfficialNoticeBean.class), baseUiConversation.getConversationIdentifier());
|
||||
return;
|
||||
}
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ConversationListBehaviorListener listBehaviorListener = RongConfigCenter.conversationListConfig().getListener();
|
||||
@@ -493,53 +479,18 @@ public class MsgMessageFragment extends BaseFragment implements BaseAdapter.OnIt
|
||||
}
|
||||
}
|
||||
|
||||
private void startSystem(OfficialNoticeBean noticeBean, ConversationIdentifier conversationIdentifier) {
|
||||
if (noticeBean.getType() != 3) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("model", noticeBean.getType());
|
||||
bundle.putString("data", JSONObject.toJSONString(noticeBean));
|
||||
RouteUtils.routeToConversationActivity(getContext(), conversationIdentifier, bundle);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(View view, ViewHolder holder, int position) {
|
||||
/*if (position >= 0 && position < this.mAdapter.getData().size()) {
|
||||
final BaseUiConversation baseUiConversation = (BaseUiConversation) this.mAdapter.getItem(position);
|
||||
ConversationListBehaviorListener listBehaviorListener = RongConfigCenter.conversationListConfig().getListener();
|
||||
if (listBehaviorListener != null && listBehaviorListener.onConversationLongClick(view.getContext(), view, baseUiConversation)) {
|
||||
RLog.d(this.TAG, "ConversationList item click event has been intercepted by App.");
|
||||
return true;
|
||||
} else {
|
||||
final ArrayList<String> items = new ArrayList();
|
||||
final String removeItem = view.getContext().getResources().getString(io.rong.imkit.R.string.rc_conversation_list_dialog_remove);
|
||||
final String setTopItem = view.getContext().getResources().getString(io.rong.imkit.R.string.rc_conversation_list_dialog_set_top);
|
||||
final String cancelTopItem = view.getContext().getResources().getString(io.rong.imkit.R.string.rc_conversation_list_dialog_cancel_top);
|
||||
if (!(baseUiConversation instanceof GatheredConversation)) {
|
||||
if (baseUiConversation.mCore.isTop()) {
|
||||
items.add(cancelTopItem);
|
||||
} else {
|
||||
items.add(setTopItem);
|
||||
}
|
||||
}
|
||||
|
||||
items.add(removeItem);
|
||||
int size = items.size();
|
||||
OptionsPopupDialog.newInstance(view.getContext(), (String[]) items.toArray(new String[size])).setOptionsPopupDialogListener(new OptionsPopupDialog.OnOptionsItemClickedListener() {
|
||||
public void onOptionsItemClicked(final int which) {
|
||||
if (!((String) items.get(which)).equals(setTopItem) && !((String) items.get(which)).equals(cancelTopItem)) {
|
||||
if (((String) items.get(which)).equals(removeItem)) {
|
||||
IMCenter.getInstance().removeConversation(baseUiConversation.mCore.getConversationType(), baseUiConversation.mCore.getTargetId(), (RongIMClient.ResultCallback) null);
|
||||
}
|
||||
} else {
|
||||
IMCenter.getInstance().setConversationToTop(baseUiConversation.getConversationIdentifier(), !baseUiConversation.mCore.isTop(), false, new RongIMClient.ResultCallback<Boolean>() {
|
||||
public void onSuccess(Boolean value) {
|
||||
Toast.makeText(view.getContext(), (CharSequence) items.get(which), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public void onError(RongIMClient.ErrorCode errorCode) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}).show();
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}*/
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -564,11 +515,42 @@ public class MsgMessageFragment extends BaseFragment implements BaseAdapter.OnIt
|
||||
return creator;
|
||||
}
|
||||
|
||||
private void updateUserInfo() {
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
for (BaseUiConversation datum : mAdapter.getData()) {
|
||||
String targetId = datum.mCore.getTargetId();
|
||||
try {
|
||||
int id = Integer.parseInt(targetId);
|
||||
if (id > 100) {
|
||||
ids.add(id);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getTargetUserInfoList(ids, new HttpCallback<List<TargetUserInfoBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<TargetUserInfoBean> data) {
|
||||
for (TargetUserInfoBean item : data) {
|
||||
UserInfo info = new UserInfo(item.getId() + "", item.getUser_nicename(), Uri.parse(item.getAvatar()));
|
||||
info.setExtra(JSONObject.toJSONString(item));
|
||||
RongUserInfoManager.getInstance().refreshUserInfoCache(info);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void busEvent(MessageMsgBusEvent event) {
|
||||
if (event.getType() == MessageMsgBusEvent.TYPE_ALL_READ) {
|
||||
allRead();
|
||||
}else if(event.getType()==MessageMsgBusEvent.TYPE_UPDATE_SYSTEM){
|
||||
} else if (event.getType() == MessageMsgBusEvent.TYPE_UPDATE_SYSTEM) {
|
||||
initSystemNotice();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.shayu.onetoone.activity.fragments.message;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.shayu.onetoone.bean.SystemMessageBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imkit.conversation.ConversationFragment;
|
||||
import io.rong.imkit.conversation.MessageListAdapter;
|
||||
import io.rong.imkit.model.UiMessage;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
public class SystemMessageFragment extends ConversationFragment {
|
||||
View mInputPanel;
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
init();
|
||||
initData();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
try {
|
||||
Field field = mRongExtension.getInputPanel().getClass().getDeclaredField("mInputPanel");
|
||||
field.setAccessible(true);
|
||||
mInputPanel = (View) field.get(mRongExtension.getInputPanel());
|
||||
assert mInputPanel != null;
|
||||
mInputPanel.setVisibility(View.GONE);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
OTONetManager.getInstance(getContext())
|
||||
.getSystemMessageList(SystemMessageBean.TYPE_SYSTEM, new HttpCallback<List<SystemMessageBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<SystemMessageBean> data) {
|
||||
for (SystemMessageBean item : data) {
|
||||
sendMessage(item);
|
||||
}
|
||||
mAdapter.notifyDataSetChanged();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
|
||||
private void sendMessage(SystemMessageBean item) {
|
||||
TextMessage content = TextMessage.obtain(item.getContent());
|
||||
UiMessage message = new UiMessage(Message.obtain("4", Conversation.ConversationType.PRIVATE, content));
|
||||
message.setSentStatus(Message.SentStatus.SENT);
|
||||
message.setTargetId("4");
|
||||
mAdapter.add(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,31 @@
|
||||
package com.shayu.onetoone.activity.message;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
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.AbsOTOActivity;
|
||||
import com.shayu.onetoone.activity.fragments.message.ChatMessageFragment;
|
||||
import com.shayu.onetoone.activity.fragments.message.SystemMessageFragment;
|
||||
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
||||
import com.shayu.onetoone.bean.SystemMessageBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
|
||||
import io.rong.imkit.conversation.ConversationFragment;
|
||||
|
||||
@@ -18,17 +34,120 @@ import io.rong.imkit.conversation.ConversationFragment;
|
||||
*/
|
||||
@Route(path = RouteManager.ACTIVITY_MSG_CHAT)
|
||||
public class ChatActivity extends AbsOTOActivity {
|
||||
String targetId;
|
||||
RoundedImageView avatar;
|
||||
TextView uname;
|
||||
TextView sign;
|
||||
TextView home;
|
||||
ImageView sex;
|
||||
ImageView status;
|
||||
Button follow;
|
||||
OfficialNoticeBean noticeBean;
|
||||
|
||||
View titleBar;
|
||||
int model;
|
||||
Button callService;
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
model = getIntent().getIntExtra("model", 0);
|
||||
String data = getIntent().getStringExtra("data");
|
||||
if (!StringUtil.isEmpty(data)) {
|
||||
noticeBean = JSONObject.parseObject(data, OfficialNoticeBean.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
switch (model) {
|
||||
case SystemMessageBean.TYPE_SYSTEM:
|
||||
return R.layout.activity_msg_message;
|
||||
}
|
||||
return R.layout.activity_msg_chat;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
ConversationFragment conversationFragment = new ChatMessageFragment();
|
||||
|
||||
|
||||
ConversationFragment conversationFragment;
|
||||
switch (model) {
|
||||
case SystemMessageBean.TYPE_SYSTEM:
|
||||
conversationFragment = new SystemMessageFragment();
|
||||
initSystemMessage();
|
||||
break;
|
||||
default:
|
||||
conversationFragment = new ChatMessageFragment();
|
||||
initChat();
|
||||
}
|
||||
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
transaction.replace(R.id.container, conversationFragment);
|
||||
transaction.commit();
|
||||
|
||||
}
|
||||
|
||||
private void initSystemMessage() {
|
||||
titleBar = findViewById(R.id.include);
|
||||
callService=findViewById(R.id.call_service);
|
||||
titleBar.setVisibility(View.VISIBLE);
|
||||
setTitle(noticeBean.getTitle());
|
||||
callService.setOnClickListener(v -> {
|
||||
String value = SpUtil.getStringValue("customerService");
|
||||
if(!StringUtil.isEmpty(value)) {
|
||||
OfficialNoticeBean service=JSONObject.parseObject(value, OfficialNoticeBean.class);
|
||||
RouteUtil.forwardZhuangBanActivity(service.getTitle(),service.getLink());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initChat() {
|
||||
avatar = findViewById(R.id.avatar);
|
||||
uname = findViewById(R.id.user_name);
|
||||
sign = findViewById(R.id.signature);
|
||||
sex = findViewById(R.id.sex);
|
||||
status = findViewById(R.id.status);
|
||||
home = findViewById(R.id.home);
|
||||
follow = findViewById(R.id.follow);
|
||||
targetId = getIntent().getStringExtra("targetId");
|
||||
updateUserInfo();
|
||||
follow.setOnClickListener(v -> {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void updateUserInfo() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getTargetUserInfo(Integer.parseInt(targetId), new HttpCallback<UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserBean data) {
|
||||
ImgLoader.display(mContext, data.getUser().getAvatar(), avatar);
|
||||
uname.setText(data.getUser().getUserNicename());
|
||||
sign.setText(data.getUser().getSignature());
|
||||
if (data.getUser().getSex() == 1) {
|
||||
sex.setImageResource(R.mipmap.ic_message_tab_man);
|
||||
} else {
|
||||
sex.setImageResource(R.mipmap.ic_message_tab_woman);
|
||||
}
|
||||
|
||||
switch (Integer.parseInt(data.getUser().getOnline())) {
|
||||
case 0:
|
||||
status.setImageResource(R.mipmap.ic_message_msg_status_online);
|
||||
break;
|
||||
case 2:
|
||||
status.setImageResource(R.mipmap.ic_message_msg_status_busy);
|
||||
break;
|
||||
default:
|
||||
status.setImageResource(R.mipmap.ic_message_msg_status_offline);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,8 @@ public class MsgMoreGreetConfigActivity extends AbsOTOActivity {
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
System.out.println("file = " + file.getAbsolutePath());
|
||||
System.out.println("file.exists() = " + file.exists());
|
||||
OTONetManager.getInstance(mContext)
|
||||
.updateFile(file, new HttpCallback<AvatarBean>() {
|
||||
@Override
|
||||
@@ -188,7 +190,15 @@ public class MsgMoreGreetConfigActivity extends AbsOTOActivity {
|
||||
.getMessageMoreGreetConfig(new HttpCallback<List<GreetBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<GreetBean> data) {
|
||||
adapter.setList(data);
|
||||
List<GreetBean> list=new ArrayList<>();
|
||||
for (GreetBean item : data) {
|
||||
if(item.getType()==0){
|
||||
list.add(item);
|
||||
}else if(item.getType()==2){
|
||||
ImgLoader.display(mContext,item.getContent(), (ImageView) findViewById(R.id.imageView5));
|
||||
}
|
||||
}
|
||||
adapter.setList(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user