diff --git a/app/src/main/java/com/unionmed/unionmedtv/activity/DoctorDetailActivity.java b/app/src/main/java/com/unionmed/unionmedtv/activity/DoctorDetailActivity.java index 877511c..2dcf91f 100644 --- a/app/src/main/java/com/unionmed/unionmedtv/activity/DoctorDetailActivity.java +++ b/app/src/main/java/com/unionmed/unionmedtv/activity/DoctorDetailActivity.java @@ -126,7 +126,7 @@ public class DoctorDetailActivity extends BaseActivity implements View.OnClickLi //所属医院 tv_affiliation_hospital.setText("所属医院: " + choscodeInfoBean.getChosname()); if (TextUtils.isEmpty(choscodeInfoBean.getJj()) - ||choscodeInfoBean.getJj().equals("null")) { + || choscodeInfoBean.getJj().equals("null")) { tv_doctor_brief.setText("医生简介: 暂无医生简介"); } else { tv_doctor_brief.setText("医生简介: " + choscodeInfoBean.getJj()); @@ -184,32 +184,33 @@ public class DoctorDetailActivity extends BaseActivity implements View.OnClickLi return; } if (checkCamera(DoctorDetailActivity.this)) { - List pKeys = new ArrayList<>(); - pKeys.add(targetId); - EasyHttp.post(DoctorDetailActivity.this) - .api(new ApplyVideoApi(pKeys, "10001")) - .request(new OnHttpListener>>() { - @Override - public void onSucceed(ApiResponse> result) { - if (null != result.getData() && result.getData().isInnerRequestSucceed() && - null != result.getData().getData()) { - - VideoCallActivity.startActivity(DoctorDetailActivity.this, targetId, - result.getData().getData().getGroupID(), VideoCallActivity.CALL); - } else { - ToastUtils.showLong("发起视频失败"); - LogUtils.e("applyVideo失败", "数据解析失败"); + if (HomeActivity.connectIsSuccess(DoctorDetailActivity.this)) { + List pKeys = new ArrayList<>(); + pKeys.add(targetId); + EasyHttp.post(DoctorDetailActivity.this) + .api(new ApplyVideoApi(pKeys, "10001")) + .request(new OnHttpListener>>() { + @Override + public void onSucceed(ApiResponse> result) { + if (null != result.getData() && result.getData().isInnerRequestSucceed() && + null != result.getData().getData()) { + + VideoCallActivity.startActivity(DoctorDetailActivity.this, targetId, + result.getData().getData().getGroupID(), VideoCallActivity.CALL); + } else { + ToastUtils.showLong("发起视频失败"); + LogUtils.e("applyVideo失败", "数据解析失败"); + } } - } - - @Override - public void onFail(Exception e) { - ToastUtils.showLong("发起视频失败"); - LogUtils.e("applyVideo失败", "失败:" + e); - } - }); + @Override + public void onFail(Exception e) { + ToastUtils.showLong("发起视频失败"); + LogUtils.e("applyVideo失败", "失败:" + e); + } + }); + } } } diff --git a/app/src/main/java/com/unionmed/unionmedtv/activity/HomeActivity.java b/app/src/main/java/com/unionmed/unionmedtv/activity/HomeActivity.java index 694e69f..7ac64b6 100644 --- a/app/src/main/java/com/unionmed/unionmedtv/activity/HomeActivity.java +++ b/app/src/main/java/com/unionmed/unionmedtv/activity/HomeActivity.java @@ -161,7 +161,16 @@ public class HomeActivity extends BaseActivity implements View.OnFocusChangeList }); } - + public static boolean connectIsSuccess(Context context) { + if (!RongIMClient.getInstance() + .getCurrentConnectionStatus() + .equals(RongIMClient.ConnectionStatusListener.ConnectionStatus.CONNECTED)) { + ToastUtils.showLong( "融云未登录"); + return false; + } else { + return true; + } + } @Override public void onFocusChange(View view, boolean b) { if (view.getId() == R.id.tv_my_doctor) { @@ -198,7 +207,9 @@ public class HomeActivity extends BaseActivity implements View.OnFocusChangeList } else if (view.getId() == R.id.tv_city) { AddressSelectActivity.StartActivity(HomeActivity.this); } else if (view.getId() == R.id.iv_msg) { - MsgActivity.StartActivity(HomeActivity.this); + if(HomeActivity.connectIsSuccess(HomeActivity.this)) { + MsgActivity.StartActivity(HomeActivity.this); + } } } diff --git a/app/src/main/java/com/unionmed/unionmedtv/activity/MsgActivity.java b/app/src/main/java/com/unionmed/unionmedtv/activity/MsgActivity.java index b884ed3..99f218b 100644 --- a/app/src/main/java/com/unionmed/unionmedtv/activity/MsgActivity.java +++ b/app/src/main/java/com/unionmed/unionmedtv/activity/MsgActivity.java @@ -6,6 +6,7 @@ import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.FrameLayout; +import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; @@ -23,6 +24,7 @@ import androidx.viewpager2.widget.ViewPager2; import com.blankj.utilcode.util.LogUtils; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; +import com.example.yideng.loaddialoglibrary.LmiotDialog; import com.hjq.http.EasyHttp; import com.hjq.http.listener.OnHttpListener; import com.unionmed.unionmedtv.R; @@ -58,7 +60,10 @@ public class MsgActivity extends BaseActivity { private FrameLayout frameLayout; private TextView tv_title; private int lastSelectedPosition = 0; - + private MsgFragment msgFragment; + private LinearLayout lin; + private TextView tv_retry; + private TextView tv_content; public static void StartActivity(Context context) { Intent intent = new Intent(context, MsgActivity.class); context.startActivity(intent); @@ -70,19 +75,24 @@ public class MsgActivity extends BaseActivity { setContentView(R.layout.activity_msg); initView(); } - - public void initView() { - recyclerView = findViewById(R.id.recyclerView); - tv_title = findViewById(R.id.tv_title); - MyLinearLayoutManager myLinearLayoutManager = new MyLinearLayoutManager(MsgActivity.this); - recyclerView.setLayoutManager(myLinearLayoutManager); + public void getMsgList(){ + LmiotDialog.show(MsgActivity.this,"获取聊天数据"); Conversation.ConversationType[] conversationTypes = {Conversation.ConversationType.PRIVATE, Conversation.ConversationType.GROUP}; RongIMClient.getInstance().getConversationListByPage(new RongIMClient. ResultCallback>() { @Override public void onSuccess(List conversations) { + LmiotDialog.hidden(); + if(conversations==null){ + tv_content.setText("暂无数据"); + return; + } + lin.setVisibility(View.GONE); for (int i=0;i void onChildClick(View view, int position, T data) { @@ -104,8 +130,10 @@ public class MsgActivity extends BaseActivity { recyclerView.setAdapter(msgListAdapter); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); - fragmentTransaction.replace(R.id.framelayout, new MsgFragment()); + msgFragment=new MsgFragment(); + fragmentTransaction.replace(R.id.framelayout, msgFragment); fragmentTransaction.commit(); + getMsgList(); LiveDataBus.get().with(Constants.MSG_LIST_SELECT_ITEM, Integer.class).observe(this, new Observer() { @Override @@ -113,7 +141,12 @@ public class MsgActivity extends BaseActivity { lastSelectedPosition = integer; msgListAdapter.setPostion(lastSelectedPosition); msgListAdapter.notifyDataSetChanged(); + tv_title.setText(list.get(integer).getName()); + msgFragment.setTargetId(list.get(integer).getConversation().getTargetId()); + msgFragment.setName(list.get(integer).getName()); + msgFragment.setImgPath(list.get(integer).getImgPath()); LiveDataBus.get().with(Constants.MSG_REFRESH_ITEM).postValue(""); + } }); LiveDataBus.get().with(Constants.MSG_LIST_REFRESH_ITEM, String.class).observe(this, new Observer() { diff --git a/app/src/main/java/com/unionmed/unionmedtv/adapter/MsgItemAdapter.java b/app/src/main/java/com/unionmed/unionmedtv/adapter/MsgItemAdapter.java index b6db8fc..aac801f 100644 --- a/app/src/main/java/com/unionmed/unionmedtv/adapter/MsgItemAdapter.java +++ b/app/src/main/java/com/unionmed/unionmedtv/adapter/MsgItemAdapter.java @@ -1,6 +1,7 @@ package com.unionmed.unionmedtv.adapter; import android.graphics.Color; +import android.util.Log; import android.view.View; import android.widget.ImageView; import android.widget.TextView; @@ -8,6 +9,7 @@ import android.widget.TextView; import androidx.annotation.Nullable; import androidx.recyclerview.widget.RecyclerView; +import com.blankj.utilcode.util.TimeUtils; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import com.chad.library.adapter.base.BaseDelegateMultiAdapter; @@ -15,72 +17,162 @@ import com.chad.library.adapter.base.delegate.BaseMultiTypeDelegate; import com.chad.library.adapter.base.viewholder.BaseViewHolder; import com.unionmed.unionmedtv.R; import com.unionmed.unionmedtv.activity.MsgActivity; +import com.unionmed.unionmedtv.im.MeetingMsgModel; +import com.unionmed.unionmedtv.utils.CacheUtil; import com.unionmed.unionmedtv.utils.OnChildClickListener; import org.jetbrains.annotations.NotNull; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; -public class MsgItemAdapter extends BaseDelegateMultiAdapter { +import io.rong.imlib.model.Message; +import io.rong.imlib.model.UnknownMessage; +import io.rong.message.ImageMessage; +import io.rong.message.TextMessage; + +public class MsgItemAdapter extends BaseDelegateMultiAdapter { private OnChildClickListener onChildClickListener; + private String name; + private String imgPath; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getImgPath() { + return imgPath; + } + + public void setImgPath(String imgPath) { + this.imgPath = imgPath; + } - public MsgItemAdapter(@Nullable List data, OnChildClickListener onChildClickListener) { + public MsgItemAdapter(@Nullable List data, OnChildClickListener onChildClickListener) { super(data); this.onChildClickListener = onChildClickListener; - setMultiTypeDelegate(new BaseMultiTypeDelegate() { + setMultiTypeDelegate(new BaseMultiTypeDelegate() { @Override - public int getItemType(@NotNull List data, int position) { + public int getItemType(@NotNull List data, int position) { // 根据数据,自己判断应该返回的类型 - if (data.get(position).equals("1")) { + Message message = data.get(position); + if (message.getContent() instanceof TextMessage && + message.getMessageDirection() == Message.MessageDirection.RECEIVE) {//文本类型发送方 return 0; - } else if (data.get(position).equals("2")) { + } else if (message.getContent() instanceof TextMessage && + message.getMessageDirection() == Message.MessageDirection.SEND) {//文本类型接收方 return 1; - } else if (data.get(position).equals("3")) { + } else if (message.getContent() instanceof ImageMessage && + message.getMessageDirection() == Message.MessageDirection.RECEIVE) { return 2; - } else if (data.get(position).equals("4")) { + } else if (message.getContent() instanceof ImageMessage && + message.getMessageDirection() == Message.MessageDirection.SEND) { return 3; - } else if (data.get(position).equals("5")) { + } else if (message.getContent() instanceof MeetingMsgModel && + message.getMessageDirection() == Message.MessageDirection.RECEIVE) { return 4; - } else if (data.get(position).equals("6")) { + } else if (message.getContent() instanceof MeetingMsgModel && + message.getMessageDirection() == Message.MessageDirection.SEND) { return 5; + }else if (message.getContent() instanceof UnknownMessage && + message.getMessageDirection() == Message.MessageDirection.RECEIVE) { + return 6; + } else if (message.getContent() instanceof UnknownMessage && + message.getMessageDirection() == Message.MessageDirection.SEND) { + return 7; } else { return 0; } } }); getMultiTypeDelegate() - .addItemType(0, R.layout.item_msg_text_left_layout) + .addItemType(0, R.layout.item_msg_text_left_layout)//文本类型 .addItemType(1, R.layout.item_msg_text_right_layout) - .addItemType(2, R.layout.item_msg_image_left_layout) + .addItemType(2, R.layout.item_msg_image_left_layout)//图片类型 .addItemType(3, R.layout.item_msg_image_right_layout) - .addItemType(4, R.layout.item_msg_order_left_layout) - .addItemType(5, R.layout.item_msg_order_right_layout); + .addItemType(4, R.layout.item_msg_video_left_layout)//视频类型 + .addItemType(5, R.layout.item_msg_video_right_layout) + .addItemType(6, R.layout.item_msg_order_left_layout)//订单类型 + .addItemType(7, R.layout.item_msg_order_right_layout) + .addItemType(8, R.layout.item_msg_unknown_left_layout)//未知类型 + .addItemType(9, R.layout.item_msg_unknown_right_layout); } @Override - protected void convert(@NotNull BaseViewHolder vh, String s) { - if (vh.getItemViewType() == 0) { - - } else if (vh.getItemViewType() == 2) { - ImageView iv_imag = vh.findView(R.id.iv_image); + protected void convert(@NotNull BaseViewHolder vh, Message message) { + TextView tv_time = vh.findView(R.id.tv_time); + TextView tv_name = vh.findView(R.id.tv_name); + ImageView iv_avatar = vh.findView(R.id.iv_avatar); + tv_time.setText(TimeUtils.millis2String(message.getSentTime()) + ""); + if (message.getMessageDirection() == Message.MessageDirection.SEND) {//右边样式 + tv_name.setText(CacheUtil.getToken().getName()); + Glide.with(getContext()) + .load((CacheUtil.getToken().getHeadImg())) + .apply(new RequestOptions() + .placeholder(R.drawable.icon_default_doctor) + .circleCrop() + ) + .into(iv_avatar); + if (vh.getItemViewType() == 1) {//文本 + TextView tv_content = vh.findView(R.id.tv_content); + TextMessage textMessage = (TextMessage) message.getContent(); + tv_content.setText(textMessage.getContent()); + } else if (vh.getItemViewType() == 3) {//图片 + ImageView iv_imag = vh.findView(R.id.iv_image); + ImageMessage imageMessage = (ImageMessage) message.getContent(); + Glide.with(getContext()) + .load((imageMessage.getRemoteUri())) + .apply(new RequestOptions() + .placeholder(R.color.white_e1e1e1) + ) + .into(iv_imag); + } else if (vh.getItemViewType() == 5) {//视频 + TextView tv_content = vh.findView(R.id.tv_content); + TextView tv_title = vh.findView(R.id.tv_title); + MeetingMsgModel meetingMsgModel = (MeetingMsgModel) message.getContent(); + tv_title.setText(meetingMsgModel.getTitle()); + tv_content.setText(meetingMsgModel.getText()); + } + } else {//左边样式 + tv_name.setText(name); Glide.with(getContext()) - .load("https://lmg.jj20.com/up/allimg/4k/s/02/210924233115O14-0-lp.jpg") + .load(imgPath) .apply(new RequestOptions() - .placeholder(R.color.white_e1e1e1) + .placeholder(R.drawable.icon_default_doctor) + .circleCrop() ) - .into(iv_imag); + .into(iv_avatar); + if (vh.getItemViewType() == 0) {//文本 + TextView tv_content = vh.findView(R.id.tv_content); + TextMessage textMessage = (TextMessage) message.getContent(); + tv_content.setText(textMessage.getContent()); + } else if (vh.getItemViewType() == 2) {//图片 + ImageView iv_imag = vh.findView(R.id.iv_image); + ImageMessage imageMessage = (ImageMessage) message.getContent(); + Glide.with(getContext()) + .load((imageMessage.getRemoteUri())) + .apply(new RequestOptions() + .placeholder(R.color.white_e1e1e1) + ) + .into(iv_imag); + } else if (vh.getItemViewType() == 4) {//视频 + TextView tv_content = vh.findView(R.id.tv_content); + TextView tv_title = vh.findView(R.id.tv_title); + MeetingMsgModel meetingMsgModel = (MeetingMsgModel) message.getContent(); + tv_title.setText(meetingMsgModel.getTitle()); + tv_content.setText(meetingMsgModel.getText()); + } } -// TextView tv_content=vh.findView(R.id.tv_content); -// if(getContext() instanceof MsgActivity){ -// RecyclerView recyclerView=((MsgActivity) getContext()).findViewById(R.id.recyclerView); -// tv_content.setNextFocusLeftId(recyclerView.getId()); -// } - vh.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - onChildClickListener.onChildClick(view, vh.getLayoutPosition(), s); + onChildClickListener.onChildClick(view, vh.getLayoutPosition(), message); } }); diff --git a/app/src/main/java/com/unionmed/unionmedtv/adapter/MsgListAdapter.java b/app/src/main/java/com/unionmed/unionmedtv/adapter/MsgListAdapter.java index db27aea..e78b89b 100644 --- a/app/src/main/java/com/unionmed/unionmedtv/adapter/MsgListAdapter.java +++ b/app/src/main/java/com/unionmed/unionmedtv/adapter/MsgListAdapter.java @@ -63,19 +63,15 @@ public class MsgListAdapter extends BaseQuickAdapter>>() { @Override public void onSucceed(ApiResponse> result) { + if(postion==0){ + LiveDataBus.get().with(Constants.MSG_LIST_SELECT_ITEM).postValue(0); + } conversation.setFirstLoad(false); if (null != result.getData() && result.getData().isInnerRequestSucceed() && null != result.getData().getData()) { conversation.setName(result.getData().getData().getName()); conversation.setImgPath(result.getData().getData().getHeadImg()); - tv_title.setText(conversation.getName()); - Glide.with(getContext()) - .load(conversation.getImgPath()) - .apply(new RequestOptions() - .placeholder(R.mipmap.rc_default_portrait) - .circleCrop() - ) - .into(iv_avatar); + notifyDataSetChanged(); } } @@ -89,6 +85,14 @@ public class MsgListAdapter extends BaseQuickAdapter list = new ArrayList<>(); + private List list = new ArrayList<>(); private LinearLayout lin; private TextView tv_look; + private String targetId; + private String name; + private String imgPath; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getImgPath() { + return imgPath; + } + + public void setImgPath(String imgPath) { + this.imgPath = imgPath; + } + + public String getTargetId() { + return targetId; + } + + public void setTargetId(String targetId) { + this.targetId = targetId; + } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -54,19 +88,29 @@ public class MsgFragment extends Fragment implements View.OnClickListener { msgItemLinearLayoutManager.setRecyclerView(recyclerView); recyclerView.setLayoutManager(msgItemLinearLayoutManager); recyclerView.addItemDecoration(new LinearSpacingItemDecoration(getActivity(), 14)); - list.clear(); - list.add("1"); - list.add("2"); - list.add("3"); - list.add("4"); - list.add("5"); - list.add("6"); +// list.clear(); +// list.add("1"); +// list.add("2"); +// list.add("3"); +// list.add("4"); +// list.add("5"); +// list.add("6"); + msgItemAdapter = new MsgItemAdapter(list, new OnChildClickListener() { @Override public void onChildClick(View view, int position, T data) { } }); + View emptyView = LayoutInflater.from(getActivity()) + .inflate( + R.layout.layout_appointment_record_empty, + recyclerView, + false + ); + TextView tv_hint = emptyView.findViewById(R.id.tv_hint); + tv_hint.setText("暂无聊天记录"); + msgItemAdapter.setEmptyView(emptyView); recyclerView.setAdapter(msgItemAdapter); if (list.size() > 0) { recyclerView.smoothScrollToPosition(list.size() - 1); @@ -86,7 +130,7 @@ public class MsgFragment extends Fragment implements View.OnClickListener { View selectView = msgItemLinearLayoutManager.findViewByPosition(pos); if (selectView != null) { selectView.requestFocus(); - }else { + } else { recyclerView.requestFocus(); } } else { @@ -103,12 +147,41 @@ public class MsgFragment extends Fragment implements View.OnClickListener { public void onChanged(String s) { lin.setVisibility(View.VISIBLE); recyclerView.setVisibility(View.GONE); + msgItemAdapter.setName(name); + msgItemAdapter.setImgPath(imgPath); // LmiotDialog.show(getActivity()); + } }); return view; } + public void getRemoteHistory() { + Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE; + long dateTime = 0; + int count = 20; + RongIMClient.getInstance().getHistoryMessages(conversationType, targetId, -1, count, new RongIMClient.ResultCallback>() { + + @Override + public void onSuccess(List messages) { + for (int i=0;i doctorInfo = stringHttpData.getData().getData().getMember(); if (doctorInfo.size()==0) { tv_title.setVisibility(View.GONE); diff --git a/app/src/main/java/com/unionmed/unionmedtv/im/MeetingMsgModel.java b/app/src/main/java/com/unionmed/unionmedtv/im/MeetingMsgModel.java new file mode 100644 index 0000000..9633479 --- /dev/null +++ b/app/src/main/java/com/unionmed/unionmedtv/im/MeetingMsgModel.java @@ -0,0 +1,308 @@ +package com.unionmed.unionmedtv.im; + +import android.os.Parcel; +import android.os.Parcelable; +import android.text.TextUtils; +import android.util.Log; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.UnsupportedEncodingException; + +import io.rong.common.ParcelUtils; +import io.rong.imlib.MessageTag; +import io.rong.imlib.model.MentionedInfo; +import io.rong.imlib.model.MessageContent; +import io.rong.imlib.model.UserInfo; + +@MessageTag(value = "UMCustonMessage", flag = MessageTag.ISCOUNTED) +public class MeetingMsgModel extends MessageContent { + private static final String TAG = "MeetingMsgModel"; + + public static final Creator CREATOR = new Creator() { + public MeetingMsgModel createFromParcel(Parcel source) { + return new MeetingMsgModel(source); + } + + public MeetingMsgModel[] newArray(int size) { + return new MeetingMsgModel[size]; + } + }; + + private String content; + private String contentType; + private String ext; + private String logo; + private String text; + private String title; + private String url; + + + /** + * 将本地消息对象序列化为消息数据。 + * + * @return 消息数据。 + */ + @Override + public byte[] encode() { + JSONObject jsonObj = new JSONObject(); + try { + // 消息携带用户信息时, 自定义消息需添加下面代码 + if (getJSONUserInfo() != null) { + jsonObj.putOpt("user", getJSONUserInfo()); + } + // 用于群组聊天, 消息携带 @ 人信息时, 自定义消息需添加下面代码 + if (getJsonMentionInfo() != null) { + jsonObj.putOpt("mentionedInfo", getJsonMentionInfo()); + } + // 将所有自定义消息的内容,都序列化至 json 对象中 + jsonObj.put("content", this.content); + jsonObj.put("contentType", this.contentType); + jsonObj.put("logo", this.logo); + jsonObj.put("text", this.text); + jsonObj.put("title", this.title); + jsonObj.put("url", this.url); + jsonObj.put("ext", this.ext); + } catch (JSONException e) { + Log.e(TAG, "JSONException " + e.getMessage()); + } + + try { + return jsonObj.toString().getBytes("UTF-8"); + } catch (UnsupportedEncodingException e) { + Log.e(TAG, "UnsupportedEncodingException ", e); + } + return null; + } + + /** + * 创建 MyMyTextContent(byte[] data) 带有 byte[] 的构造方法用于解析消息内容. + */ + public MeetingMsgModel(byte[] data) { + if (data == null) { + return; + } + String jsonStr = null; + try { + jsonStr = new String(data, "UTF-8"); + } catch (UnsupportedEncodingException e) { + Log.e(TAG, "UnsupportedEncodingException ", e); + } + if (jsonStr == null) { + Log.e(TAG, "jsonStr is null "); + return; + } + + try { + JSONObject jsonObj = new JSONObject(jsonStr); + // 消息携带用户信息时, 自定义消息需添加下面代码 + if (jsonObj.has("user")) { + setUserInfo(parseJsonToUserInfo(jsonObj.getJSONObject("user"))); + } + // 用于群组聊天, 消息携带 @ 人信息时, 自定义消息需添加下面代码 + if (jsonObj.has("mentionedInfo")) { + setMentionedInfo(parseJsonToMentionInfo(jsonObj.getJSONObject("mentionedInfo"))); + } + // 将所有自定义变量从收到的 json 解析并赋值 + if (jsonObj.has("content")) { + content = jsonObj.optString("content"); + } + if (jsonObj.has("contentType")) { + contentType = jsonObj.optString("contentType"); + } + if (jsonObj.has("logo")) { + logo = jsonObj.optString("logo"); + } + if (jsonObj.has("text")) { + text = jsonObj.optString("text"); + } + if (jsonObj.has("title")) { + title = jsonObj.optString("title"); + } + if (jsonObj.has("url")) { + url = jsonObj.optString("url"); + } + if (jsonObj.has("ext")) { + ext = jsonObj.optString("ext"); + } +// if (jsonObj.has("ext")) { +// setExt(parseJsonToExt(jsonObj.getJSONObject("ext"))); +// } + } catch (JSONException e) { + Log.e(TAG, "JSONException " + e.getMessage()); + } + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + ParcelUtils.writeToParcel(dest, this.getExtra()); + ParcelUtils.writeToParcel(dest, this.getUserInfo()); + ParcelUtils.writeToParcel(dest, this.getMentionedInfo()); + ParcelUtils.writeToParcel(dest, this.isDestruct() ? 1 : 0); + ParcelUtils.writeToParcel(dest, this.getDestructTime()); + + ParcelUtils.writeToParcel(dest, this.content); + ParcelUtils.writeToParcel(dest, this.contentType); + ParcelUtils.writeToParcel(dest, this.logo); + ParcelUtils.writeToParcel(dest, this.text); + ParcelUtils.writeToParcel(dest, this.title); + ParcelUtils.writeToParcel(dest, this.url); + ParcelUtils.writeToParcel(dest, this.ext); + } + + public ExtBean parseJsonToExt(JSONObject jsonObj) { + ExtBean info = null; + String roomID = jsonObj.optString("roomID"); + String GroupID = jsonObj.optString("GroupID"); + + if (!TextUtils.isEmpty(roomID) && !TextUtils.isEmpty(GroupID)) { + info = new ExtBean(roomID, GroupID); + } + + return info; + } + + /** + * 构造函数。 + * + * @param in 初始化传入的 Parcel。 + */ + public MeetingMsgModel(Parcel in) { + this.setExtra(ParcelUtils.readFromParcel(in)); + this.setUserInfo((UserInfo) ParcelUtils.readFromParcel(in, UserInfo.class)); + this.setMentionedInfo((MentionedInfo) ParcelUtils.readFromParcel(in, MentionedInfo.class)); + this.setDestruct(ParcelUtils.readIntFromParcel(in) == 1); + this.setDestructTime(ParcelUtils.readLongFromParcel(in)); + + this.setContent(ParcelUtils.readFromParcel(in)); + this.setContentType(ParcelUtils.readFromParcel(in)); + this.setLogo(ParcelUtils.readFromParcel(in)); + this.setText(ParcelUtils.readFromParcel(in)); + this.setTitle(ParcelUtils.readFromParcel(in)); + this.setUrl(ParcelUtils.readFromParcel(in)); + this.setExt(ParcelUtils.readFromParcel(in)); +// this.setExt((ExtBean) ParcelUtils.readFromParcel(in, ExtBean.class)); + } + + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + public String getExt() { + return ext; + } + + public void setExt(String ext) { + this.ext = ext; + } + + public String getLogo() { + return logo; + } + + public void setLogo(String logo) { + this.logo = logo; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public static class ExtBean implements Parcelable { + private String roomID; + private String groupID; + + public String getRoomID() { + return roomID; + } + + public void setRoomID(String roomID) { + this.roomID = roomID; + } + + public String getGroupID() { + return groupID; + } + + public void setGroupID(String groupID) { + groupID = groupID; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(this.roomID); + dest.writeString(this.groupID); + } + + public void readFromParcel(Parcel source) { + this.roomID = source.readString(); + this.groupID = source.readString(); + } + + public ExtBean(String roomID, String groupID) { + this.roomID = roomID; + this.groupID = groupID; + } + + protected ExtBean(Parcel in) { + this.roomID = in.readString(); + this.groupID = in.readString(); + } + + public static final Creator CREATOR = new Creator() { + @Override + public ExtBean createFromParcel(Parcel source) { + return new ExtBean(source); + } + + @Override + public ExtBean[] newArray(int size) { + return new ExtBean[size]; + } + }; + } +} diff --git a/app/src/main/java/com/unionmed/unionmedtv/login/activity/fragment/LoginPhoneFragment.java b/app/src/main/java/com/unionmed/unionmedtv/login/activity/fragment/LoginPhoneFragment.java index da8174d..811535c 100644 --- a/app/src/main/java/com/unionmed/unionmedtv/login/activity/fragment/LoginPhoneFragment.java +++ b/app/src/main/java/com/unionmed/unionmedtv/login/activity/fragment/LoginPhoneFragment.java @@ -270,7 +270,7 @@ public class LoginPhoneFragment extends Fragment implements View.OnClickListener } }); } - }, 0, 5000); // 设置定时任务的时间间隔为 5 秒 + }, 0, 3000); // 设置定时任务的时间间隔为3 秒 } @Override diff --git a/app/src/main/res/layout/activity_msg.xml b/app/src/main/res/layout/activity_msg.xml index 05a1739..21025c0 100644 --- a/app/src/main/res/layout/activity_msg.xml +++ b/app/src/main/res/layout/activity_msg.xml @@ -4,6 +4,36 @@ android:layout_height="match_parent" xmlns:tools="http://schemas.android.com/tools" android:orientation="horizontal"> + + + + + + android:descendantFocusability="afterDescendants"> \ No newline at end of file diff --git a/app/src/main/res/layout/item_msg_text_right_layout.xml b/app/src/main/res/layout/item_msg_text_right_layout.xml index 958bab5..2f0abe2 100644 --- a/app/src/main/res/layout/item_msg_text_right_layout.xml +++ b/app/src/main/res/layout/item_msg_text_right_layout.xml @@ -1,12 +1,12 @@ + android:descendantFocusability="afterDescendants"> \ No newline at end of file diff --git a/app/src/main/res/layout/item_msg_unknown_left_layout.xml b/app/src/main/res/layout/item_msg_unknown_left_layout.xml new file mode 100644 index 0000000..1f327b1 --- /dev/null +++ b/app/src/main/res/layout/item_msg_unknown_left_layout.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_msg_unknown_right_layout.xml b/app/src/main/res/layout/item_msg_unknown_right_layout.xml new file mode 100644 index 0000000..baf2bd2 --- /dev/null +++ b/app/src/main/res/layout/item_msg_unknown_right_layout.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_msg_video_left_layout.xml b/app/src/main/res/layout/item_msg_video_left_layout.xml new file mode 100644 index 0000000..982712e --- /dev/null +++ b/app/src/main/res/layout/item_msg_video_left_layout.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_msg_video_right_layout.xml b/app/src/main/res/layout/item_msg_video_right_layout.xml new file mode 100644 index 0000000..de8414a --- /dev/null +++ b/app/src/main/res/layout/item_msg_video_right_layout.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_appointment_record_empty.xml b/app/src/main/res/layout/layout_appointment_record_empty.xml new file mode 100644 index 0000000..e7c74a8 --- /dev/null +++ b/app/src/main/res/layout/layout_appointment_record_empty.xml @@ -0,0 +1,38 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-xhdpi/icon_appointment_record_empty.png b/app/src/main/res/mipmap-xhdpi/icon_appointment_record_empty.png new file mode 100644 index 0000000..282d176 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/icon_appointment_record_empty.png differ