Commit 2739bb5c7b58a8efad665d4d341960060edbbead
1 parent
c162866b
修改json 格式
Showing
10 changed files
with
184 additions
and
126 deletions
app/src/main/java/com/cnlive/gundam/main/utils/ToStringUtils.java deleted
100644 → 0
| 1 | -package com.cnlive.gundam.main.utils; | ||
| 2 | - | ||
| 3 | - | ||
| 4 | -import com.cnlive.libs.util.chat.base.IChat; | ||
| 5 | - | ||
| 6 | -/** | ||
| 7 | - * @author 陈硕 | ||
| 8 | - * @time 2017/3/28 10:20 | ||
| 9 | - * @desc ${TODD} | ||
| 10 | - */ | ||
| 11 | -public class ToStringUtils { | ||
| 12 | - | ||
| 13 | - public static String GiftType = "giftType"; | ||
| 14 | - public static String ChatRoomype = IChat.CHATROOM; | ||
| 15 | - public static String PrivateType = IChat.PRIVATE; | ||
| 16 | - public static String JoinType = "JOINTYPE"; | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - public static String objToJsonString(CNMessageModole cnMessageModole) { | ||
| 20 | - | ||
| 21 | - // 初始化返回值 | ||
| 22 | - String json = "str_empty"; | ||
| 23 | - | ||
| 24 | - if (cnMessageModole == null) { | ||
| 25 | - return json; | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - StringBuilder buff = new StringBuilder(); | ||
| 29 | - buff.append("{"); | ||
| 30 | - buff.append("message"); | ||
| 31 | - buff.append(":"); | ||
| 32 | - buff.append("\""); | ||
| 33 | - buff.append(cnMessageModole.getMessage() == null ? "" : cnMessageModole.getMessage()); | ||
| 34 | - buff.append("\""); | ||
| 35 | - buff.append(","); | ||
| 36 | - buff.append("type"); | ||
| 37 | - buff.append(":"); | ||
| 38 | - buff.append("\""); | ||
| 39 | - buff.append(cnMessageModole.getType() == null ? "" : cnMessageModole.getType()); | ||
| 40 | - buff.append("\""); | ||
| 41 | - buff.append("}"); | ||
| 42 | - json = buff.toString(); | ||
| 43 | - return json; | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - public static class CNMessageModole { | ||
| 47 | - | ||
| 48 | - | ||
| 49 | - public CNMessageModole(String message, String type) { | ||
| 50 | - this.message = message; | ||
| 51 | - this.type = type; | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - /** | ||
| 55 | - * message : Sass | ||
| 56 | - * | ||
| 57 | - * type : 2 | ||
| 58 | - */ | ||
| 59 | - | ||
| 60 | - private String message; | ||
| 61 | - private String type; | ||
| 62 | - | ||
| 63 | - public String getMessage() { | ||
| 64 | - return message; | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - public void setMessage(String message) { | ||
| 68 | - this.message = message; | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - | ||
| 72 | - public String getType() { | ||
| 73 | - return type; | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - public void setType(String type) { | ||
| 77 | - this.type = type; | ||
| 78 | - } | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | -} |
app/src/main/java/com/cnlive/gundam/user/util/InputUtil.java
| @@ -16,7 +16,8 @@ import android.widget.LinearLayout; | @@ -16,7 +16,8 @@ import android.widget.LinearLayout; | ||
| 16 | import android.widget.PopupWindow; | 16 | import android.widget.PopupWindow; |
| 17 | 17 | ||
| 18 | import com.cnlive.gundam.R; | 18 | import com.cnlive.gundam.R; |
| 19 | -import com.cnlive.gundam.main.utils.ToStringUtils; | 19 | +import com.cnlive.gundam.video.model.CNMessageModle; |
| 20 | +import com.cnlive.gundam.video.model.MessageInfo; | ||
| 20 | import com.google.gson.Gson; | 21 | import com.google.gson.Gson; |
| 21 | 22 | ||
| 22 | /** | 23 | /** |
| @@ -114,10 +115,9 @@ public class InputUtil { | @@ -114,10 +115,9 @@ public class InputUtil { | ||
| 114 | if (TextUtils.isEmpty(mMsgEditText.getText())) { | 115 | if (TextUtils.isEmpty(mMsgEditText.getText())) { |
| 115 | ToastUtil.showToast(mContext, "不能发送空消息呦~"); | 116 | ToastUtil.showToast(mContext, "不能发送空消息呦~"); |
| 116 | } else { | 117 | } else { |
| 117 | - if(mSendCallback!=null) mSendCallback.sendMessage(mGson.toJson(new ToStringUtils.CNMessageModole(mMsgEditText.getText().toString(), ToStringUtils.ChatRoomype))); | 118 | + if(mSendCallback!=null) mSendCallback.sendMessage(mGson.toJson(new CNMessageModle("chatRoom",new MessageInfo("","","","",mMsgEditText.getText().toString())))); |
| 118 | mMsgEditText.setText(""); | 119 | mMsgEditText.setText(""); |
| 119 | } | 120 | } |
| 120 | - | ||
| 121 | if (mInputPopupWindow != null && mInputPopupWindow.isShowing()) mInputPopupWindow.dismiss(); | 121 | if (mInputPopupWindow != null && mInputPopupWindow.isShowing()) mInputPopupWindow.dismiss(); |
| 122 | } | 122 | } |
| 123 | 123 |
app/src/main/java/com/cnlive/gundam/video/adpter/GiftAdapter.java
| @@ -10,11 +10,13 @@ import android.view.ViewGroup; | @@ -10,11 +10,13 @@ import android.view.ViewGroup; | ||
| 10 | import android.widget.Toast; | 10 | import android.widget.Toast; |
| 11 | 11 | ||
| 12 | import com.cnlive.gundam.R; | 12 | import com.cnlive.gundam.R; |
| 13 | -import com.cnlive.gundam.main.utils.ToStringUtils; | 13 | +import com.cnlive.gundam.video.model.CNMessageModle; |
| 14 | import com.cnlive.gundam.video.model.GiftModle; | 14 | import com.cnlive.gundam.video.model.GiftModle; |
| 15 | +import com.cnlive.gundam.video.model.MessageInfo; | ||
| 15 | import com.cnlive.libs.util.chat.ChatUtil; | 16 | import com.cnlive.libs.util.chat.ChatUtil; |
| 16 | import com.cnlive.libs.util.chat.base.IChat; | 17 | import com.cnlive.libs.util.chat.base.IChat; |
| 17 | import com.cnlive.libs.util.chat.model.CNMessage; | 18 | import com.cnlive.libs.util.chat.model.CNMessage; |
| 19 | +import com.google.gson.Gson; | ||
| 18 | 20 | ||
| 19 | import java.util.List; | 21 | import java.util.List; |
| 20 | 22 | ||
| @@ -55,9 +57,10 @@ public class GiftAdapter extends RecyclerView.Adapter<GiftAdapter.RVHolder> { | @@ -55,9 +57,10 @@ public class GiftAdapter extends RecyclerView.Adapter<GiftAdapter.RVHolder> { | ||
| 55 | holder.binding.getRoot().findViewById(R.id.ll_item).setOnClickListener(new View.OnClickListener() { | 57 | holder.binding.getRoot().findViewById(R.id.ll_item).setOnClickListener(new View.OnClickListener() { |
| 56 | @Override | 58 | @Override |
| 57 | public void onClick(View v) { | 59 | public void onClick(View v) { |
| 58 | - String objToJsonString = ToStringUtils.objToJsonString(new ToStringUtils.CNMessageModole(mDataList.get(position).getGiftMessage(), ToStringUtils.GiftType)); | ||
| 59 | -// | ||
| 60 | - ChatUtil.sendMessage(IChat.CHATROOM, roomId, objToJsonString, new IChat.OnSendMessageListener() { | 60 | + CNMessageModle cnMessageModle = new CNMessageModle("giftType",new MessageInfo("0",mDataList.get(position).getGiftMessage(),"1","0",mDataList.get(position).getGiftMessage())); |
| 61 | + Gson gson2=new Gson(); | ||
| 62 | + String obj2=gson2.toJson(cnMessageModle); | ||
| 63 | + ChatUtil.sendMessage(IChat.CHATROOM, roomId, obj2, new IChat.OnSendMessageListener() { | ||
| 61 | @Override | 64 | @Override |
| 62 | public void onAttached(CNMessage message) { | 65 | public void onAttached(CNMessage message) { |
| 63 | 66 |
app/src/main/java/com/cnlive/gundam/video/fragment/chat/ChatRoomFragment.java
| @@ -83,6 +83,7 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | @@ -83,6 +83,7 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | ||
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | 85 | ||
| 86 | + | ||
| 86 | private void barrageBottom() { | 87 | private void barrageBottom() { |
| 87 | switchCompatBottom = fragmentChatBinding.barrage; | 88 | switchCompatBottom = fragmentChatBinding.barrage; |
| 88 | switchCompatBottom.setChecked(false); | 89 | switchCompatBottom.setChecked(false); |
| @@ -139,11 +140,14 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | @@ -139,11 +140,14 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | ||
| 139 | @Override | 140 | @Override |
| 140 | public void onDestroy() { | 141 | public void onDestroy() { |
| 141 | super.onDestroy(); | 142 | super.onDestroy(); |
| 143 | + Log.v("fdfsfaf","dfasdfsafdfadf"); | ||
| 142 | ChatUtil.disconnect(false); | 144 | ChatUtil.disconnect(false); |
| 143 | } | 145 | } |
| 144 | 146 | ||
| 145 | 147 | ||
| 146 | 148 | ||
| 149 | + | ||
| 150 | + | ||
| 147 | private void initChat() { | 151 | private void initChat() { |
| 148 | User activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo(); | 152 | User activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo(); |
| 149 | String faceurl = activeAccountInfo.getFaceurl(); | 153 | String faceurl = activeAccountInfo.getFaceurl(); |
| @@ -218,6 +222,9 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | @@ -218,6 +222,9 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | ||
| 218 | } | 222 | } |
| 219 | 223 | ||
| 220 | 224 | ||
| 225 | + | ||
| 226 | + | ||
| 227 | + | ||
| 221 | public void doBarrage(){ | 228 | public void doBarrage(){ |
| 222 | boolean isPortrait = PlayerUtils.isPortrait(getActivity()); | 229 | boolean isPortrait = PlayerUtils.isPortrait(getActivity()); |
| 223 | final BarrageLayout barrageLayout = getActivity().findViewById(R.id.private_message); | 230 | final BarrageLayout barrageLayout = getActivity().findViewById(R.id.private_message); |
| @@ -233,7 +240,6 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | @@ -233,7 +240,6 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | ||
| 233 | @Override | 240 | @Override |
| 234 | public void onCheckedChanged(CompoundButton compoundButton, boolean b) { | 241 | public void onCheckedChanged(CompoundButton compoundButton, boolean b) { |
| 235 | if (b) { | 242 | if (b) { |
| 236 | - Log.v("fsdas","fasdf"); | ||
| 237 | barrageLayout.resume(); | 243 | barrageLayout.resume(); |
| 238 | 244 | ||
| 239 | } else { | 245 | } else { |
app/src/main/java/com/cnlive/gundam/video/fragment/chat/MessageContentInfo.java
| @@ -3,18 +3,18 @@ package com.cnlive.gundam.video.fragment.chat; | @@ -3,18 +3,18 @@ package com.cnlive.gundam.video.fragment.chat; | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.os.Handler; | 4 | import android.os.Handler; |
| 5 | import android.text.TextUtils; | 5 | import android.text.TextUtils; |
| 6 | +import android.util.Log; | ||
| 6 | 7 | ||
| 7 | -import com.cnlive.gundam.main.utils.ToStringUtils; | ||
| 8 | import com.cnlive.gundam.user.auth.UserService; | 8 | import com.cnlive.gundam.user.auth.UserService; |
| 9 | import com.cnlive.gundam.video.barrage.BarrageBaseMessage; | 9 | import com.cnlive.gundam.video.barrage.BarrageBaseMessage; |
| 10 | +import com.cnlive.gundam.video.model.CNMessageModle; | ||
| 10 | import com.cnlive.gundam.video.model.MessageContent; | 11 | import com.cnlive.gundam.video.model.MessageContent; |
| 12 | +import com.cnlive.gundam.video.model.MessageInfo; | ||
| 11 | import com.cnlive.libs.util.chat.ChatUtil; | 13 | import com.cnlive.libs.util.chat.ChatUtil; |
| 12 | import com.cnlive.libs.util.chat.base.IChat; | 14 | import com.cnlive.libs.util.chat.base.IChat; |
| 13 | import com.cnlive.libs.util.chat.model.CNMessage; | 15 | import com.cnlive.libs.util.chat.model.CNMessage; |
| 14 | import com.cnlive.libs.video.barrage.BarrageLayout; | 16 | import com.cnlive.libs.video.barrage.BarrageLayout; |
| 15 | - | ||
| 16 | -import org.json.JSONException; | ||
| 17 | -import org.json.JSONObject; | 17 | +import com.google.gson.Gson; |
| 18 | 18 | ||
| 19 | import java.util.ArrayList; | 19 | import java.util.ArrayList; |
| 20 | 20 | ||
| @@ -35,6 +35,9 @@ public class MessageContentInfo { | @@ -35,6 +35,9 @@ public class MessageContentInfo { | ||
| 35 | private SendAndRecevieSucessCall mSendAndRecevieSucessCall; | 35 | private SendAndRecevieSucessCall mSendAndRecevieSucessCall; |
| 36 | private String roomId; | 36 | private String roomId; |
| 37 | private BarrageLayout barrageLayout; | 37 | private BarrageLayout barrageLayout; |
| 38 | + private String JoinType = "joinType"; | ||
| 39 | + private String ChatRoom ="chatRoom"; | ||
| 40 | + private String giftType = "giftType"; | ||
| 38 | 41 | ||
| 39 | 42 | ||
| 40 | public void setOnReceiveAndSendListener(BarrageLayout barrageLayout,String roomID, Context context, SendAndRecevieSucessCall sendAndRecevieSucessCall) { | 43 | public void setOnReceiveAndSendListener(BarrageLayout barrageLayout,String roomID, Context context, SendAndRecevieSucessCall sendAndRecevieSucessCall) { |
| @@ -60,15 +63,18 @@ public class MessageContentInfo { | @@ -60,15 +63,18 @@ public class MessageContentInfo { | ||
| 60 | @Override | 63 | @Override |
| 61 | public void run() { | 64 | public void run() { |
| 62 | try { | 65 | try { |
| 63 | - JSONObject jsonObject = new JSONObject(message.getContent().toString()); | ||
| 64 | - String type = (String) jsonObject.get("type"); | ||
| 65 | - String messagecontent = (String) jsonObject.get("message"); | ||
| 66 | 66 | ||
| 67 | - if (type.equals(ToStringUtils.GiftType)) { | 67 | + Gson gson = new Gson(); |
| 68 | + CNMessageModle cnMessageModle = gson.fromJson(message.getContent(), CNMessageModle.class); | ||
| 69 | + String messagecontent =cnMessageModle.getMessage().getContent(); | ||
| 70 | + String messageType = cnMessageModle.getType(); | ||
| 71 | + | ||
| 72 | + | ||
| 73 | + if (messageType.equals(giftType)) { | ||
| 68 | 74 | ||
| 69 | barrageLayout.addMessage(new BarrageBaseMessage(message.getUserInfo().getUserName(), "送了" + messagecontent, "")); | 75 | barrageLayout.addMessage(new BarrageBaseMessage(message.getUserInfo().getUserName(), "送了" + messagecontent, "")); |
| 70 | messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), ": 送了" + messagecontent, message.getUserInfo().getHeadUrl(), true)); | 76 | messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), ": 送了" + messagecontent, message.getUserInfo().getHeadUrl(), true)); |
| 71 | - } else if (type.equals(ToStringUtils.ChatRoomype)) { | 77 | + } else if (messageType.equals(ChatRoom)) { |
| 72 | if (message.getUserInfo().getUserId().equals(ChatUtil.getCurrentUserInfo().getUserId())) { | 78 | if (message.getUserInfo().getUserId().equals(ChatUtil.getCurrentUserInfo().getUserId())) { |
| 73 | messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), messagecontent + " :", message.getUserInfo().getHeadUrl(), false)); | 79 | messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), messagecontent + " :", message.getUserInfo().getHeadUrl(), false)); |
| 74 | } else { | 80 | } else { |
| @@ -78,7 +84,7 @@ public class MessageContentInfo { | @@ -78,7 +84,7 @@ public class MessageContentInfo { | ||
| 78 | barrageLayout.addMessage(new BarrageBaseMessage(message.getUserInfo().getUserName(), messagecontent, "")); | 84 | barrageLayout.addMessage(new BarrageBaseMessage(message.getUserInfo().getUserName(), messagecontent, "")); |
| 79 | 85 | ||
| 80 | 86 | ||
| 81 | - } else if (type.equals(ToStringUtils.JoinType)) { | 87 | + } else if (messageType.equals(JoinType)) { |
| 82 | String userName = message.getUserInfo().getUserName(); | 88 | String userName = message.getUserInfo().getUserName(); |
| 83 | if (TextUtils.isEmpty(userName)) { | 89 | if (TextUtils.isEmpty(userName)) { |
| 84 | return; | 90 | return; |
| @@ -86,15 +92,15 @@ public class MessageContentInfo { | @@ -86,15 +92,15 @@ public class MessageContentInfo { | ||
| 86 | if (userName.equals(UserService.getInstance(mContext).getActiveAccountInfo().getNickname())) { | 92 | if (userName.equals(UserService.getInstance(mContext).getActiveAccountInfo().getNickname())) { |
| 87 | return; | 93 | return; |
| 88 | } | 94 | } |
| 89 | - barrageLayout.addMessage(new BarrageBaseMessage(message.getUserInfo().getUserName(), messagecontent, "")); | 95 | + barrageLayout.addMessage(new BarrageBaseMessage(message.getUserInfo().getUserName(), "来了", "")); |
| 90 | 96 | ||
| 91 | - messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), ": " + messagecontent, message.getUserInfo().getHeadUrl(), true)); | 97 | + messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), ": " + "来了", message.getUserInfo().getHeadUrl(), true)); |
| 92 | 98 | ||
| 93 | } | 99 | } |
| 94 | 100 | ||
| 95 | mSendAndRecevieSucessCall.receaviceSucess(messageContentArrayList); | 101 | mSendAndRecevieSucessCall.receaviceSucess(messageContentArrayList); |
| 96 | 102 | ||
| 97 | - } catch (JSONException e) { | 103 | + } catch (Exception e) { |
| 98 | e.printStackTrace(); | 104 | e.printStackTrace(); |
| 99 | } | 105 | } |
| 100 | } | 106 | } |
| @@ -113,12 +119,15 @@ public class MessageContentInfo { | @@ -113,12 +119,15 @@ public class MessageContentInfo { | ||
| 113 | @Override | 119 | @Override |
| 114 | public void onSuccess(CNMessage message) { | 120 | public void onSuccess(CNMessage message) { |
| 115 | 121 | ||
| 116 | - JSONObject jsonObject = null; | ||
| 117 | try { | 122 | try { |
| 118 | - jsonObject = new JSONObject(message.getContent().toString()); | ||
| 119 | - String messagecontent = (String) jsonObject.get("message"); | ||
| 120 | - String messageType = (String) jsonObject.get("type"); | ||
| 121 | - if (messageType.equals(ToStringUtils.ChatRoomype)) { | 123 | + |
| 124 | + Gson gson = new Gson(); | ||
| 125 | + CNMessageModle cnMessageModle = gson.fromJson(message.getContent(), CNMessageModle.class); | ||
| 126 | + String messagecontent =cnMessageModle.getMessage().getContent(); | ||
| 127 | + String messageType = cnMessageModle.getType(); | ||
| 128 | + | ||
| 129 | + | ||
| 130 | + if (messageType.equals(ChatRoom)) { | ||
| 122 | barrageLayout.addMessage(new BarrageBaseMessage(message.getUserInfo().getUserName(), messagecontent, "")); | 131 | barrageLayout.addMessage(new BarrageBaseMessage(message.getUserInfo().getUserName(), messagecontent, "")); |
| 123 | 132 | ||
| 124 | messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), messagecontent + " :", message.getUserInfo().getHeadUrl(), false)); | 133 | messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), messagecontent + " :", message.getUserInfo().getHeadUrl(), false)); |
| @@ -126,7 +135,7 @@ public class MessageContentInfo { | @@ -126,7 +135,7 @@ public class MessageContentInfo { | ||
| 126 | mSendAndRecevieSucessCall.sentSucess(messageContentArrayList); | 135 | mSendAndRecevieSucessCall.sentSucess(messageContentArrayList); |
| 127 | } | 136 | } |
| 128 | 137 | ||
| 129 | - } catch (JSONException e) { | 138 | + } catch (Exception e) { |
| 130 | e.printStackTrace(); | 139 | e.printStackTrace(); |
| 131 | } | 140 | } |
| 132 | 141 | ||
| @@ -166,10 +175,11 @@ public class MessageContentInfo { | @@ -166,10 +175,11 @@ public class MessageContentInfo { | ||
| 166 | ChatUtil.joinChatRoom(roomId, 0, new IChat.OnOperationListener() { | 175 | ChatUtil.joinChatRoom(roomId, 0, new IChat.OnOperationListener() { |
| 167 | @Override | 176 | @Override |
| 168 | public void onSuccess(int what, String extra) { | 177 | public void onSuccess(int what, String extra) { |
| 169 | - | ||
| 170 | - | ||
| 171 | - String objToJsonString = ToStringUtils.objToJsonString(new ToStringUtils.CNMessageModole("加入聊天室", ToStringUtils.JoinType)); | ||
| 172 | - ChatUtil.sendMessage(IChat.CHATROOM, roomId, objToJsonString, onSendMessageListener); | 178 | + CNMessageModle cnMessageModle = new CNMessageModle(JoinType,new MessageInfo("","","","","")); |
| 179 | + Gson gson2=new Gson(); | ||
| 180 | + String obj2=gson2.toJson(cnMessageModle); | ||
| 181 | + Log.v("dfsd",obj2); | ||
| 182 | + ChatUtil.sendMessage(IChat.CHATROOM, roomId, obj2, onSendMessageListener); | ||
| 173 | } | 183 | } |
| 174 | 184 | ||
| 175 | @Override | 185 | @Override |
app/src/main/java/com/cnlive/gundam/video/model/CNMessageModle.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.model; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * @author 陈硕 | ||
| 5 | + * @time 2017/6/30 10:20 | ||
| 6 | + * @desc ${TODD} | ||
| 7 | + */ | ||
| 8 | +public class CNMessageModle { | ||
| 9 | + | ||
| 10 | + /* { | ||
| 11 | + "type" : "giftType",//"chatRoom"//"joinType" | ||
| 12 | + "message" : { | ||
| 13 | + "giftPrice" : "0", | ||
| 14 | + "giftName" : "小黄瓜", | ||
| 15 | + "giftNumber" : "1", | ||
| 16 | + "messageBarrage" : "0", | ||
| 17 | + "content" : "聊天内容" | ||
| 18 | + } | ||
| 19 | + }*/ | ||
| 20 | + | ||
| 21 | + private String type; | ||
| 22 | + private MessageInfo message; | ||
| 23 | + | ||
| 24 | + @Override | ||
| 25 | + public String toString() { | ||
| 26 | + return "CNMessageModle{" + | ||
| 27 | + "type='" + type + '\'' + | ||
| 28 | + ", message=" + message + | ||
| 29 | + '}'; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public CNMessageModle(String type, MessageInfo message) { | ||
| 33 | + this.type = type; | ||
| 34 | + this.message = message; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + public String getType() { | ||
| 39 | + return type; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public void setType(String type) { | ||
| 43 | + this.type = type; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public MessageInfo getMessage() { | ||
| 47 | + return message; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public void setMessage(MessageInfo message) { | ||
| 51 | + this.message = message; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + | ||
| 56 | +} |
app/src/main/java/com/cnlive/gundam/video/model/MessageInfo.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.model; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * @author 陈硕 | ||
| 5 | + * @time 2017/6/30 10:34 | ||
| 6 | + * @desc ${TODD} | ||
| 7 | + */ | ||
| 8 | +public class MessageInfo { | ||
| 9 | + | ||
| 10 | + private String giftPrice; | ||
| 11 | + private String giftName; | ||
| 12 | + | ||
| 13 | + private String giftNumber; | ||
| 14 | + private String messageBarrage; | ||
| 15 | + | ||
| 16 | + private String content; | ||
| 17 | + | ||
| 18 | + public MessageInfo(String giftPrice, String giftName, String giftNumber, String messageBarrage, String content) { | ||
| 19 | + this.giftPrice = giftPrice; | ||
| 20 | + this.giftName = giftName; | ||
| 21 | + this.giftNumber = giftNumber; | ||
| 22 | + this.messageBarrage = messageBarrage; | ||
| 23 | + this.content = content; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + @Override | ||
| 27 | + public String toString() { | ||
| 28 | + return "MessageInfo{" + | ||
| 29 | + "giftPrice='" + giftPrice + '\'' + | ||
| 30 | + ", giftName='" + giftName + '\'' + | ||
| 31 | + ", giftNumber='" + giftNumber + '\'' + | ||
| 32 | + ", messageBarrage='" + messageBarrage + '\'' + | ||
| 33 | + ", content='" + content + '\'' + | ||
| 34 | + '}'; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public String getGiftPrice() { | ||
| 38 | + return giftPrice; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public void setGiftPrice(String giftPrice) { | ||
| 42 | + this.giftPrice = giftPrice; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public String getGiftName() { | ||
| 46 | + return giftName; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public void setGiftName(String giftName) { | ||
| 50 | + this.giftName = giftName; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + public String getGiftNumber() { | ||
| 54 | + return giftNumber; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public void setGiftNumber(String giftNumber) { | ||
| 58 | + this.giftNumber = giftNumber; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public String getMessageBarrage() { | ||
| 62 | + return messageBarrage; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public void setMessageBarrage(String messageBarrage) { | ||
| 66 | + this.messageBarrage = messageBarrage; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public String getContent() { | ||
| 70 | + return content; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public void setContent(String content) { | ||
| 74 | + this.content = content; | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + |
app/src/main/java/com/cnlive/gundam/video/view/PlayerControllerView.java
| @@ -22,7 +22,6 @@ import android.widget.SeekBar; | @@ -22,7 +22,6 @@ import android.widget.SeekBar; | ||
| 22 | import com.cnlive.gundam.BR; | 22 | import com.cnlive.gundam.BR; |
| 23 | import com.cnlive.gundam.R; | 23 | import com.cnlive.gundam.R; |
| 24 | import com.cnlive.gundam.databinding.LayoutPlayerControllerLiveLBinding; | 24 | import com.cnlive.gundam.databinding.LayoutPlayerControllerLiveLBinding; |
| 25 | -import com.cnlive.gundam.databinding.LayoutPlayerControllerUgcLiveLBinding; | ||
| 26 | import com.cnlive.gundam.video.utils.PlayerUtils; | 25 | import com.cnlive.gundam.video.utils.PlayerUtils; |
| 27 | import com.cnlive.gundam.video.utils.VideoRateUtil; | 26 | import com.cnlive.gundam.video.utils.VideoRateUtil; |
| 28 | import com.cnlive.libs.util.Config; | 27 | import com.cnlive.libs.util.Config; |
| @@ -224,7 +223,6 @@ public class PlayerControllerView extends RelativeLayout implements SeekBar.OnSe | @@ -224,7 +223,6 @@ public class PlayerControllerView extends RelativeLayout implements SeekBar.OnSe | ||
| 224 | this.binding.setVariable(BR.title, observableTitle); | 223 | this.binding.setVariable(BR.title, observableTitle); |
| 225 | this.binding.setVariable(BR.showController, observableShow); | 224 | this.binding.setVariable(BR.showController, observableShow); |
| 226 | this.binding.setVariable(BR.isPlay, observableIsPlay); | 225 | this.binding.setVariable(BR.isPlay, observableIsPlay); |
| 227 | - if(switchCompatChangeListener!=null)switchCompatChangeListener.onSwitchCompatChange(((LayoutPlayerControllerUgcLiveLBinding) this.binding).barrageTop); | ||
| 228 | isUgc = true; | 226 | isUgc = true; |
| 229 | break; | 227 | break; |
| 230 | } | 228 | } |
app/src/main/res/layout/fragment_player_ugc_live.xml
| @@ -23,6 +23,7 @@ | @@ -23,6 +23,7 @@ | ||
| 23 | 23 | ||
| 24 | <RelativeLayout | 24 | <RelativeLayout |
| 25 | android:id="@+id/contentLayout" | 25 | android:id="@+id/contentLayout" |
| 26 | + android:paddingTop="100dp" | ||
| 26 | android:layout_width="match_parent" | 27 | android:layout_width="match_parent" |
| 27 | android:layout_height="match_parent" | 28 | android:layout_height="match_parent" |
| 28 | android:layout_alignParentBottom="true"> | 29 | android:layout_alignParentBottom="true"> |
app/src/main/res/layout/layout_player_controller_ugc_live_l.xml
| @@ -78,18 +78,6 @@ | @@ -78,18 +78,6 @@ | ||
| 78 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" /> | 78 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" /> |
| 79 | 79 | ||
| 80 | 80 | ||
| 81 | - <android.support.v7.widget.SwitchCompat | ||
| 82 | - android:id="@+id/barrage_top" | ||
| 83 | - android:layout_marginRight="50dp" | ||
| 84 | - android:layout_width="wrap_content" | ||
| 85 | - android:layout_height="wrap_content" | ||
| 86 | - android:layout_centerVertical="true" | ||
| 87 | - android:background="@null" | ||
| 88 | - android:textIsSelectable="false" | ||
| 89 | - android:layout_alignParentRight="true" | ||
| 90 | - android:thumb="@drawable/switch_thumb" | ||
| 91 | - app:switchMinWidth="30dp" | ||
| 92 | - app:track="@drawable/switch_track" /> | ||
| 93 | 81 | ||
| 94 | </RelativeLayout> | 82 | </RelativeLayout> |
| 95 | 83 |