update
This commit is contained in:
@@ -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