Commit db9c45f0781c649434a4d064a30d3fd3988fc199
1 parent
54453777
添加聊天
Showing
26 changed files
with
776 additions
and
0 deletions
app/src/main/java/com/cnlive/gundam/main/utils/ToStringUtils.java
0 → 100644
| 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/video/adpter/CommonAdapter.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.adpter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.databinding.DataBindingUtil; | |
| 5 | +import android.databinding.ViewDataBinding; | |
| 6 | +import android.view.LayoutInflater; | |
| 7 | +import android.view.View; | |
| 8 | +import android.view.ViewGroup; | |
| 9 | +import android.widget.BaseAdapter; | |
| 10 | +import android.widget.LinearLayout; | |
| 11 | + | |
| 12 | +import com.cnlive.gundam.databinding.ItemListRightBinding; | |
| 13 | +import com.cnlive.gundam.video.model.MessageContent; | |
| 14 | + | |
| 15 | +import java.util.List; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * @author 陈硕 | |
| 19 | + * @time 2017/5/25 19:23 | |
| 20 | + * @desc ${TODD} | |
| 21 | + */ | |
| 22 | +public class CommonAdapter<T> extends BaseAdapter { | |
| 23 | + private Context mContext; | |
| 24 | + private List<T> mDataList; | |
| 25 | + private int layoutId; // 条目布局ID | |
| 26 | + private int variableId; // DataBinding的变量ID,可通过类似R文件的BR文件来获取 | |
| 27 | + | |
| 28 | + public CommonAdapter(Context context, List<T> dataList, int layoutId, int variableId) { | |
| 29 | + this.mContext = context; | |
| 30 | + this.mDataList = dataList; | |
| 31 | + this.layoutId = layoutId; | |
| 32 | + this.variableId = variableId; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public void setDataList(List<T> dataList){ | |
| 36 | + this.mDataList= dataList; | |
| 37 | + } | |
| 38 | + | |
| 39 | + @Override | |
| 40 | + public int getCount() { return mDataList.size(); } | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + public Object getItem(int position) { return mDataList.get(position); } | |
| 44 | + | |
| 45 | + @Override | |
| 46 | + public long getItemId(int position) { return position; } | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + public View getView(int position, View convertView, ViewGroup parent) { | |
| 50 | + // 没有ViewHolder的复用,但Databinding内部已经实现了复用 | |
| 51 | + | |
| 52 | + | |
| 53 | + ViewDataBinding binding; | |
| 54 | + if (convertView == null) { | |
| 55 | + binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), layoutId, parent, false); | |
| 56 | + } else { | |
| 57 | + binding = DataBindingUtil.getBinding(convertView); | |
| 58 | + } | |
| 59 | + binding.setVariable(variableId, mDataList.get(position)); | |
| 60 | + MessageContent user = (MessageContent) mDataList.get(position); | |
| 61 | + | |
| 62 | + if(((MessageContent) mDataList.get(position)).isSendInfo()){ | |
| 63 | + ItemListRightBinding binding1 = (ItemListRightBinding) binding; | |
| 64 | + LinearLayout rightLin = binding1.rightLin; | |
| 65 | + LinearLayout leftLin = binding1.leftLin; | |
| 66 | + leftLin.setVisibility(View.VISIBLE); | |
| 67 | + rightLin.setVisibility(View.INVISIBLE); | |
| 68 | + }else { | |
| 69 | + ItemListRightBinding binding1 = (ItemListRightBinding) binding; | |
| 70 | + LinearLayout leftLin = binding1.leftLin; | |
| 71 | + LinearLayout rightLin = binding1.rightLin; | |
| 72 | + rightLin.setVisibility(View.VISIBLE); | |
| 73 | + | |
| 74 | + leftLin.setVisibility(View.INVISIBLE); | |
| 75 | + } | |
| 76 | + | |
| 77 | + | |
| 78 | + return binding.getRoot(); | |
| 79 | + } | |
| 80 | +} | |
| 81 | + | ... | ... |
app/src/main/java/com/cnlive/gundam/video/adpter/GiftAdapter.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.adpter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.databinding.DataBindingUtil; | |
| 5 | +import android.databinding.ViewDataBinding; | |
| 6 | +import android.support.v7.widget.RecyclerView; | |
| 7 | +import android.view.LayoutInflater; | |
| 8 | +import android.view.View; | |
| 9 | +import android.view.ViewGroup; | |
| 10 | + | |
| 11 | +import com.cnlive.gundam.video.model.GiftModle; | |
| 12 | + | |
| 13 | +import java.util.List; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * @author 陈硕 | |
| 17 | + * @time 2017/5/27 16:04 | |
| 18 | + * @desc ${TODD} | |
| 19 | + */ | |
| 20 | + | |
| 21 | +public class GiftAdapter extends RecyclerView.Adapter<GiftAdapter.RVHolder> { | |
| 22 | + private Context mContext; | |
| 23 | + private List<GiftModle> mDataList; | |
| 24 | + private int mLayoutId; // 条目布局文件ID | |
| 25 | + private int mVariableId; // DataBinding变量ID | |
| 26 | + | |
| 27 | + public GiftAdapter(Context context, List<GiftModle> list, int layoutId, int variableId) { | |
| 28 | + this.mContext = context; | |
| 29 | + this.mDataList = list; | |
| 30 | + this.mLayoutId = layoutId; | |
| 31 | + mVariableId = variableId; | |
| 32 | + | |
| 33 | + | |
| 34 | + } | |
| 35 | + | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + public RVHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
| 39 | + ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), mLayoutId, parent, false); | |
| 40 | + RVHolder holder = new RVHolder(binding.getRoot()); | |
| 41 | + holder.binding = binding; | |
| 42 | + return holder; | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Override | |
| 46 | + public void onBindViewHolder(RVHolder holder, final int position) { | |
| 47 | + holder.binding.setVariable(mVariableId, mDataList.get(position)); | |
| 48 | + holder.binding.executePendingBindings(); | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public int getItemCount() { | |
| 53 | + return mDataList == null ? 0 : mDataList.size(); | |
| 54 | + } | |
| 55 | + | |
| 56 | + class RVHolder extends RecyclerView.ViewHolder { | |
| 57 | + ViewDataBinding binding; | |
| 58 | + | |
| 59 | + RVHolder(View view) { | |
| 60 | + super(view); | |
| 61 | + } | |
| 62 | + } | |
| 63 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/video/fragment/PlayerLiveFragment.java
| ... | ... | @@ -13,6 +13,7 @@ import android.view.ViewGroup; |
| 13 | 13 | import com.cnlive.gundam.R; |
| 14 | 14 | import com.cnlive.gundam.databinding.FragmentPlayerLiveBinding; |
| 15 | 15 | import com.cnlive.gundam.main.model.VideoListProgram; |
| 16 | +import com.cnlive.gundam.video.fragment.chat.ChatRoomFragment; | |
| 16 | 17 | import com.cnlive.gundam.video.model.VideoModel; |
| 17 | 18 | import com.cnlive.gundam.video.utils.PlayerUtils; |
| 18 | 19 | import com.cnlive.gundam.video.view.PlayerAccelerometerSensor; |
| ... | ... | @@ -47,6 +48,8 @@ public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerS |
| 47 | 48 | @Override |
| 48 | 49 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| 49 | 50 | binding = DataBindingUtil.inflate(inflater, R.layout.fragment_player_live, container, false); |
| 51 | + getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.contentLayout, ChatRoomFragment.newInstance()).commit(); | |
| 52 | + | |
| 50 | 53 | return binding.getRoot(); |
| 51 | 54 | } |
| 52 | 55 | ... | ... |
app/src/main/java/com/cnlive/gundam/video/fragment/chat/ChatRoomFragment.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.fragment.chat; | |
| 2 | + | |
| 3 | +import android.databinding.BindingAdapter; | |
| 4 | +import android.databinding.DataBindingUtil; | |
| 5 | +import android.os.Bundle; | |
| 6 | +import android.support.annotation.Nullable; | |
| 7 | +import android.support.v4.app.Fragment; | |
| 8 | +import android.support.v7.widget.GridLayoutManager; | |
| 9 | +import android.support.v7.widget.OrientationHelper; | |
| 10 | +import android.view.LayoutInflater; | |
| 11 | +import android.view.View; | |
| 12 | +import android.view.ViewGroup; | |
| 13 | +import android.widget.ImageView; | |
| 14 | + | |
| 15 | +import com.bumptech.glide.Glide; | |
| 16 | +import com.cnlive.gundam.BR; | |
| 17 | +import com.cnlive.gundam.R; | |
| 18 | +import com.cnlive.gundam.databinding.FragmentChatBinding; | |
| 19 | +import com.cnlive.gundam.main.utils.ToStringUtils; | |
| 20 | +import com.cnlive.gundam.user.auth.UserService; | |
| 21 | +import com.cnlive.gundam.user.model.User; | |
| 22 | +import com.cnlive.gundam.video.adpter.CommonAdapter; | |
| 23 | +import com.cnlive.gundam.video.adpter.GiftAdapter; | |
| 24 | +import com.cnlive.gundam.video.model.GiftModle; | |
| 25 | +import com.cnlive.gundam.video.model.MessageContent; | |
| 26 | +import com.cnlive.libs.util.chat.ChatUtil; | |
| 27 | +import com.cnlive.libs.util.chat.base.IChat; | |
| 28 | +import com.cnlive.libs.util.chat.model.CNMessage; | |
| 29 | +import com.cnlive.libs.util.chat.model.CNUserInfo; | |
| 30 | + | |
| 31 | +import org.json.JSONException; | |
| 32 | +import org.json.JSONObject; | |
| 33 | + | |
| 34 | +import java.util.ArrayList; | |
| 35 | + | |
| 36 | + | |
| 37 | +/** | |
| 38 | + * @author 陈硕 | |
| 39 | + * @time 2017/5/27 13:57 | |
| 40 | + * @desc ${TODD} | |
| 41 | + */ | |
| 42 | +public class ChatRoomFragment extends Fragment implements View.OnClickListener { | |
| 43 | + | |
| 44 | + | |
| 45 | + private FragmentChatBinding fragmentChatBinding; | |
| 46 | + private ArrayList<GiftModle> giftArray; | |
| 47 | + private ArrayList<MessageContent> messageContentArrayList; | |
| 48 | + private CommonAdapter<MessageContent> messageContentCommonAdapter; | |
| 49 | + private IChat.OnConnectListener onConnectListener; | |
| 50 | + private String roomId = "ChatRoom05"; | |
| 51 | + private IChat.OnSendMessageListener onSendMessageListener; | |
| 52 | + | |
| 53 | + public static ChatRoomFragment newInstance() { | |
| 54 | + Bundle args = new Bundle(); | |
| 55 | + ChatRoomFragment fragment = new ChatRoomFragment(); | |
| 56 | + fragment.setArguments(args); | |
| 57 | + return fragment; | |
| 58 | + } | |
| 59 | + | |
| 60 | + | |
| 61 | + @Nullable | |
| 62 | + @Override | |
| 63 | + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |
| 64 | + fragmentChatBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_chat, container, false); | |
| 65 | + | |
| 66 | + return fragmentChatBinding.getRoot(); | |
| 67 | + | |
| 68 | + } | |
| 69 | + | |
| 70 | + | |
| 71 | + private void initChat() { | |
| 72 | + User activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo(); | |
| 73 | + String faceurl = activeAccountInfo.getFaceurl(); | |
| 74 | + String nickname = activeAccountInfo.getNickname(); | |
| 75 | + int uid = activeAccountInfo.getUid(); | |
| 76 | + ChatUtil.connect(new CNUserInfo(uid + "", nickname, faceurl), onConnectListener); | |
| 77 | + | |
| 78 | + } | |
| 79 | + | |
| 80 | + | |
| 81 | + @Override | |
| 82 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | |
| 83 | + super.onViewCreated(view, savedInstanceState); | |
| 84 | + initDate(); | |
| 85 | + init(); | |
| 86 | + initListener(); | |
| 87 | + initChat(); | |
| 88 | + } | |
| 89 | + | |
| 90 | + private void initDate() { | |
| 91 | + int[] imaSource = new int[]{R.drawable.porsch_small80, R.drawable.fighter_small80, | |
| 92 | + R.drawable.plane_small80, | |
| 93 | + R.drawable.beer, R.drawable.chicken, | |
| 94 | + R.drawable.cucumber, R.drawable.flower, | |
| 95 | + R.drawable.hug, R.drawable.mouth, | |
| 96 | + R.drawable.ring, R.drawable.rose, R.drawable.continuous}; | |
| 97 | + String[] gitName = new String[]{"跑车", "歼灭机", "飞机", "啤酒", | |
| 98 | + "小鸡", "小黄瓜", "鲜花", "抱抱", "亲吻", "戒指", "玫瑰花", "荧光棒"}; | |
| 99 | + giftArray = new ArrayList<>(); | |
| 100 | + for (int i = 0; i < 12; i++) { | |
| 101 | + giftArray.add(new GiftModle(gitName[i], imaSource[i])); | |
| 102 | + } | |
| 103 | + } | |
| 104 | + | |
| 105 | + private void init() { | |
| 106 | + initGiftAdapter(); | |
| 107 | + initMessageAdapter(); | |
| 108 | + | |
| 109 | + } | |
| 110 | + | |
| 111 | + private void initMessageAdapter() { | |
| 112 | + messageContentArrayList = new ArrayList<>(); | |
| 113 | + if (messageContentCommonAdapter == null) | |
| 114 | + messageContentCommonAdapter = new CommonAdapter<>(getActivity(), messageContentArrayList, R.layout.item_list_right, BR.user); | |
| 115 | + } | |
| 116 | + | |
| 117 | + private void initGiftAdapter() { | |
| 118 | + fragmentChatBinding.recyclerGift.setOnClickListener(this); | |
| 119 | + GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2); | |
| 120 | + gridLayoutManager.setOrientation(OrientationHelper.HORIZONTAL); | |
| 121 | + fragmentChatBinding.recyclerGift.setLayoutManager(gridLayoutManager); | |
| 122 | + fragmentChatBinding.setGiftAdapter(new GiftAdapter(getActivity(), giftArray, R.layout.fragment_gift_receycel, BR.dataBean)); | |
| 123 | + } | |
| 124 | + | |
| 125 | + | |
| 126 | + @Override | |
| 127 | + public void onClick(View view) { | |
| 128 | + switch (view.getId()) { | |
| 129 | + case R.id.img_gift: | |
| 130 | + int i = View.VISIBLE == fragmentChatBinding.recyclerGift.getVisibility() ? View.INVISIBLE : View.VISIBLE; | |
| 131 | + fragmentChatBinding.recyclerGift.setVisibility(i); | |
| 132 | + break; | |
| 133 | + } | |
| 134 | + } | |
| 135 | + | |
| 136 | + @BindingAdapter("android:src") | |
| 137 | + public static void setSrc(ImageView view, int resId) { | |
| 138 | + view.setImageResource(resId); | |
| 139 | + } | |
| 140 | + | |
| 141 | + @BindingAdapter({"imageUrl"}) | |
| 142 | + public static void loadImage(ImageView imageView, String url) { | |
| 143 | + if (url == null) { | |
| 144 | + imageView.setImageResource(R.mipmap.ic_launcher); | |
| 145 | + } else { | |
| 146 | + Glide.with(imageView.getContext()).load(url).error(R.mipmap.ic_launcher).into(imageView); | |
| 147 | + } | |
| 148 | + } | |
| 149 | + | |
| 150 | + | |
| 151 | + private void initListener() { | |
| 152 | + | |
| 153 | + onSendMessageListener = new IChat.OnSendMessageListener() { | |
| 154 | + @Override | |
| 155 | + public void onAttached(CNMessage message) { | |
| 156 | + | |
| 157 | + } | |
| 158 | + | |
| 159 | + @Override | |
| 160 | + public void onSuccess(CNMessage message) { | |
| 161 | + JSONObject jsonObject = null; | |
| 162 | + try { | |
| 163 | + jsonObject = new JSONObject(message.getContent().toString()); | |
| 164 | + String messagecontent = (String) jsonObject.get("message"); | |
| 165 | + String messageType = (String) jsonObject.get("type"); | |
| 166 | + if (messageType.equals(ToStringUtils.ChatRoomype)) { | |
| 167 | + messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), messagecontent + " :", message.getUserInfo().getHeadUrl(), false)); | |
| 168 | + messageContentCommonAdapter.setDataList((messageContentArrayList)); | |
| 169 | + ChatRoomFragment.this.fragmentChatBinding.setMessageAdapter(messageContentCommonAdapter); | |
| 170 | + } | |
| 171 | + | |
| 172 | + } catch (JSONException e) { | |
| 173 | + e.printStackTrace(); | |
| 174 | + } | |
| 175 | + | |
| 176 | + | |
| 177 | + } | |
| 178 | + | |
| 179 | + @Override | |
| 180 | + public void onError(CNMessage message, int what, String extra) { | |
| 181 | + | |
| 182 | + } | |
| 183 | + }; | |
| 184 | + | |
| 185 | + | |
| 186 | + onConnectListener = new IChat.OnConnectListener() { | |
| 187 | + @Override | |
| 188 | + public void onTokenIncorrect(String s) { | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + @Override | |
| 193 | + public void onSuccess(String s) { | |
| 194 | + joinChatRoom(); | |
| 195 | + | |
| 196 | + } | |
| 197 | + | |
| 198 | + | |
| 199 | + @Override | |
| 200 | + public void onError(int i, String s) { | |
| 201 | + | |
| 202 | + } | |
| 203 | + }; | |
| 204 | + | |
| 205 | + } | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + private void joinChatRoom() { | |
| 210 | + ChatUtil.joinChatRoom(roomId, 0, new IChat.OnOperationListener() { | |
| 211 | + @Override | |
| 212 | + public void onSuccess(int what, String extra) { | |
| 213 | + String objToJsonString = ToStringUtils.objToJsonString(new ToStringUtils.CNMessageModole("加入聊天室", ToStringUtils.JoinType)); | |
| 214 | + ChatUtil.sendMessage(IChat.CHATROOM, roomId, objToJsonString, onSendMessageListener); | |
| 215 | + } | |
| 216 | + | |
| 217 | + @Override | |
| 218 | + public void onError(int what, String extra) { | |
| 219 | + | |
| 220 | + } | |
| 221 | + }); | |
| 222 | + } | |
| 223 | + | |
| 224 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/video/model/GiftModle.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.model; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * @author 陈硕 | |
| 5 | + * @time 2017/6/28 19:05 | |
| 6 | + * @desc ${TODD} | |
| 7 | + */ | |
| 8 | +public class GiftModle { | |
| 9 | + private String giftMessage; | |
| 10 | + private int imgSource; | |
| 11 | + | |
| 12 | + public GiftModle(String giftMessage, int imgSource) { | |
| 13 | + this.giftMessage = giftMessage; | |
| 14 | + this.imgSource = imgSource; | |
| 15 | + } | |
| 16 | + | |
| 17 | + public String getGiftMessage() { | |
| 18 | + return giftMessage; | |
| 19 | + } | |
| 20 | + | |
| 21 | + public void setGiftMessage(String giftMessage) { | |
| 22 | + this.giftMessage = giftMessage; | |
| 23 | + } | |
| 24 | + | |
| 25 | + public int getImgSource() { | |
| 26 | + return imgSource; | |
| 27 | + } | |
| 28 | + | |
| 29 | + public void setImgSource(int imgSource) { | |
| 30 | + this.imgSource = imgSource; | |
| 31 | + } | |
| 32 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/video/model/MessageContent.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.model; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * @author 陈硕 | |
| 5 | + * @time 2017/6/28 20:42 | |
| 6 | + * @desc ${TODD} | |
| 7 | + */ | |
| 8 | +public class MessageContent { | |
| 9 | + | |
| 10 | + String name; | |
| 11 | + | |
| 12 | + | |
| 13 | + String messaage; | |
| 14 | + | |
| 15 | + | |
| 16 | + String icon; | |
| 17 | + | |
| 18 | + public boolean isSendInfo() { | |
| 19 | + return isSendInfo; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public void setSendInfo(boolean sendInfo) { | |
| 23 | + isSendInfo = sendInfo; | |
| 24 | + } | |
| 25 | + | |
| 26 | + boolean isSendInfo; | |
| 27 | + | |
| 28 | + public String getName() { | |
| 29 | + return name; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public void setName(String name) { | |
| 33 | + this.name = name; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public String getMessaage() { | |
| 37 | + return messaage; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public void setMessaage(String messaage) { | |
| 41 | + this.messaage = messaage; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public String getIcon() { | |
| 45 | + return icon; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public void setIcon(String icon) { | |
| 49 | + this.icon = icon; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public MessageContent(String name, String icon) { | |
| 53 | + this.name = name; | |
| 54 | + this.icon = icon; | |
| 55 | + } | |
| 56 | + | |
| 57 | + public MessageContent(String name, String messaage, String icon) { | |
| 58 | + this.name = name; | |
| 59 | + this.messaage = messaage; | |
| 60 | + this.icon = icon; | |
| 61 | + } | |
| 62 | + | |
| 63 | + public MessageContent(String name, String messaage, String icon, boolean isSendInfo) { | |
| 64 | + this.name = name; | |
| 65 | + this.messaage = messaage; | |
| 66 | + this.icon = icon; | |
| 67 | + this.isSendInfo = isSendInfo; | |
| 68 | + } | |
| 69 | + | |
| 70 | + | |
| 71 | +} | ... | ... |
app/src/main/res/layout/fragment_chat.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 4 | + > | |
| 5 | + | |
| 6 | + <data> | |
| 7 | + | |
| 8 | + <variable | |
| 9 | + name="messageAdapter" | |
| 10 | + type="com.cnlive.gundam.video.adpter.CommonAdapter" /> | |
| 11 | + | |
| 12 | + <variable | |
| 13 | + name="giftAdapter" | |
| 14 | + type="com.cnlive.gundam.video.adpter.GiftAdapter" /> | |
| 15 | + </data> | |
| 16 | + | |
| 17 | + <RelativeLayout | |
| 18 | + android:id="@+id/lin" | |
| 19 | + android:layout_width="match_parent" | |
| 20 | + android:layout_height="match_parent" | |
| 21 | + android:background="@android:color/transparent"> | |
| 22 | + | |
| 23 | + | |
| 24 | + <ListView | |
| 25 | + android:id="@+id/list_message" | |
| 26 | + android:layout_width="match_parent" | |
| 27 | + android:layout_height="match_parent" | |
| 28 | + android:layout_alignParentLeft="true" | |
| 29 | + android:layout_alignParentStart="true" | |
| 30 | + android:divider="@null" | |
| 31 | + android:scrollbars="none" | |
| 32 | + android:stackFromBottom="true" | |
| 33 | + android:transcriptMode="alwaysScroll" | |
| 34 | + app:Adapter="@{messageAdapter}" /> | |
| 35 | + | |
| 36 | + | |
| 37 | + <RelativeLayout | |
| 38 | + android:id="@+id/edit_layout" | |
| 39 | + android:layout_width="match_parent" | |
| 40 | + android:layout_height="50dp" | |
| 41 | + android:layout_alignParentBottom="true" | |
| 42 | + android:background="#e0000000" | |
| 43 | + android:orientation="horizontal"> | |
| 44 | + | |
| 45 | + <ImageView | |
| 46 | + android:id="@+id/sendMessage" | |
| 47 | + android:layout_width="wrap_content" | |
| 48 | + android:layout_height="wrap_content" | |
| 49 | + android:layout_centerVertical="true" | |
| 50 | + android:layout_marginLeft="5dp" | |
| 51 | + android:src="@drawable/btn_send_message" /> | |
| 52 | + | |
| 53 | + | |
| 54 | + <ImageView | |
| 55 | + android:id="@+id/img_gift" | |
| 56 | + android:layout_width="wrap_content" | |
| 57 | + android:layout_height="wrap_content" | |
| 58 | + android:layout_centerInParent="true" | |
| 59 | + android:src="@drawable/gift" /> | |
| 60 | + | |
| 61 | + <android.support.v7.widget.SwitchCompat | |
| 62 | + android:id="@+id/barrage" | |
| 63 | + android:layout_width="wrap_content" | |
| 64 | + android:layout_height="wrap_content" | |
| 65 | + android:layout_alignParentRight="true" | |
| 66 | + android:layout_centerVertical="true" | |
| 67 | + android:background="@null" | |
| 68 | + android:textIsSelectable="false" | |
| 69 | + android:thumb="@drawable/switch_thumb" | |
| 70 | + app:switchMinWidth="30dp" | |
| 71 | + app:track="@drawable/switch_track" /> | |
| 72 | + | |
| 73 | + | |
| 74 | + </RelativeLayout> | |
| 75 | + | |
| 76 | + | |
| 77 | + <RelativeLayout | |
| 78 | + android:id="@+id/rl_gift" | |
| 79 | + android:layout_width="match_parent" | |
| 80 | + android:layout_height="wrap_content" | |
| 81 | + android:layout_above="@id/edit_layout" | |
| 82 | + android:background="#979797" | |
| 83 | + android:visibility="visible"> | |
| 84 | + | |
| 85 | + <android.support.v7.widget.RecyclerView | |
| 86 | + android:id="@+id/recycler_gift" | |
| 87 | + android:layout_width="match_parent" | |
| 88 | + android:layout_height="wrap_content" | |
| 89 | + app:adapter="@{giftAdapter}" | |
| 90 | + /> | |
| 91 | + | |
| 92 | + </RelativeLayout> | |
| 93 | + | |
| 94 | + | |
| 95 | + </RelativeLayout> | |
| 96 | + | |
| 97 | + | |
| 98 | +</layout> | |
| 0 | 99 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/fragment_gift_receycel.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + > | |
| 4 | + | |
| 5 | + | |
| 6 | + <data> | |
| 7 | + | |
| 8 | + <variable | |
| 9 | + name="dataBean" | |
| 10 | + type="com.cnlive.gundam.video.model.GiftModle" /> | |
| 11 | + </data> | |
| 12 | + | |
| 13 | + <LinearLayout | |
| 14 | + android:id="@+id/ll_item" | |
| 15 | + android:layout_width="wrap_content" | |
| 16 | + android:layout_height="wrap_content" | |
| 17 | + android:padding="5dp" | |
| 18 | + | |
| 19 | + android:orientation="vertical"> | |
| 20 | + | |
| 21 | + <ImageView | |
| 22 | + android:id="@+id/avaimg" | |
| 23 | + android:layout_width="40dp" | |
| 24 | + android:layout_height="40dp" | |
| 25 | + android:src="@{dataBean.imgSource}" | |
| 26 | + /> | |
| 27 | + | |
| 28 | + <RelativeLayout | |
| 29 | + android:layout_width="wrap_content" | |
| 30 | + android:layout_height="wrap_content"> | |
| 31 | + | |
| 32 | + | |
| 33 | + <TextView | |
| 34 | + android:layout_width="wrap_content" | |
| 35 | + android:layout_height="wrap_content" | |
| 36 | + android:textColor="@android:color/white" | |
| 37 | + android:layout_centerInParent="true" | |
| 38 | + android:text="@{dataBean.giftMessage}"/> | |
| 39 | + | |
| 40 | + </RelativeLayout> | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + </LinearLayout> | |
| 47 | + | |
| 48 | + | |
| 49 | +</layout> | |
| 0 | 50 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/item_list_right.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 4 | + xmlns:tools="http://schemas.android.com/tools"> | |
| 5 | + | |
| 6 | + <data> | |
| 7 | + | |
| 8 | + <variable | |
| 9 | + name="user" | |
| 10 | + type="com.cnlive.gundam.video.model.MessageContent" /> | |
| 11 | + </data> | |
| 12 | + | |
| 13 | + <RelativeLayout | |
| 14 | + android:layout_width="match_parent" | |
| 15 | + android:layout_height="match_parent"> | |
| 16 | + | |
| 17 | + <LinearLayout | |
| 18 | + android:id="@+id/left_lin" | |
| 19 | + | |
| 20 | + android:layout_width="wrap_content" | |
| 21 | + android:layout_height="50dp" | |
| 22 | + android:orientation="horizontal"> | |
| 23 | + | |
| 24 | + <com.cnlive.gundam.user.view.CircleImageView | |
| 25 | + android:layout_width="20dp" | |
| 26 | + android:layout_height="20dp" | |
| 27 | + app:imageUrl="@{user.icon}"/> | |
| 28 | + | |
| 29 | + <TextView | |
| 30 | + android:layout_width="wrap_content" | |
| 31 | + android:layout_height="wrap_content" | |
| 32 | + android:textColor="@android:color/white" | |
| 33 | + android:text="@{user.name}" /> | |
| 34 | + | |
| 35 | + <TextView | |
| 36 | + android:layout_width="wrap_content" | |
| 37 | + android:layout_height="wrap_content" | |
| 38 | + android:textColor="@android:color/white" | |
| 39 | + android:text="@{user.messaage}" /> | |
| 40 | + </LinearLayout> | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + <LinearLayout | |
| 45 | + android:id="@+id/right_lin" | |
| 46 | + | |
| 47 | + android:layout_alignParentRight="true" | |
| 48 | + android:layout_width="wrap_content" | |
| 49 | + android:layout_height="50dp" | |
| 50 | + android:orientation="horizontal"> | |
| 51 | + | |
| 52 | + <TextView | |
| 53 | + android:layout_width="wrap_content" | |
| 54 | + android:layout_height="wrap_content" | |
| 55 | + android:textColor="@android:color/white" | |
| 56 | + android:text="@{user.messaage}" /> | |
| 57 | + <TextView | |
| 58 | + android:layout_width="wrap_content" | |
| 59 | + android:layout_height="wrap_content" | |
| 60 | + android:textColor="@android:color/white" | |
| 61 | + android:text="@{user.name}" /> | |
| 62 | + | |
| 63 | + <com.cnlive.gundam.user.view.CircleImageView | |
| 64 | + android:layout_width="20dp" | |
| 65 | + android:layout_height="20dp" | |
| 66 | + app:imageUrl="@{user.icon}" | |
| 67 | + /> | |
| 68 | + | |
| 69 | + </LinearLayout> | |
| 70 | + | |
| 71 | + | |
| 72 | + </RelativeLayout> | |
| 73 | + | |
| 74 | +</layout> | |
| 0 | 75 | \ No newline at end of file | ... | ... |
user/src/main/res/drawable-hdpi/beer.png
0 → 100644
5.11 KB
user/src/main/res/drawable-hdpi/btn_send_message.png
0 → 100644
6.08 KB
user/src/main/res/drawable-hdpi/chicken.png
0 → 100644
4.37 KB
user/src/main/res/drawable-hdpi/continuous.png
0 → 100644
1.94 KB
user/src/main/res/drawable-hdpi/cucumber.png
0 → 100644
7.15 KB
user/src/main/res/drawable-hdpi/diamond.png
0 → 100644
1.01 KB
user/src/main/res/drawable-hdpi/fighter_small80.png
0 → 100644
7.91 KB
user/src/main/res/drawable-hdpi/flower.png
0 → 100644
4.82 KB
user/src/main/res/drawable-hdpi/gift.png
0 → 100644
2.94 KB
user/src/main/res/drawable-hdpi/hug.png
0 → 100644
4.34 KB
user/src/main/res/drawable-hdpi/mouth.png
0 → 100644
5.06 KB
user/src/main/res/drawable-hdpi/plane_small80.png
0 → 100644
6.96 KB
user/src/main/res/drawable-hdpi/porsch_small80.png
0 → 100644
8.48 KB
user/src/main/res/drawable-hdpi/ring.png
0 → 100644
6.54 KB
user/src/main/res/drawable-hdpi/rose.png
0 → 100644
5.39 KB
user/src/main/res/drawable-hdpi/sticks.png
0 → 100644
4.44 KB