Commit a4720b91aff96b384b674bfa714d43041cb65eb1

Authored by 陈硕
1 parent ce07866a

添加弹幕

app/src/main/java/com/cnlive/gundam/user/util/InputUtil.java 0 → 100644
  1 +package com.cnlive.gundam.user.util;
  2 +
  3 +import android.content.Context;
  4 +import android.graphics.drawable.BitmapDrawable;
  5 +import android.text.TextUtils;
  6 +import android.view.Gravity;
  7 +import android.view.KeyEvent;
  8 +import android.view.LayoutInflater;
  9 +import android.view.MotionEvent;
  10 +import android.view.View;
  11 +import android.view.ViewGroup;
  12 +import android.view.WindowManager;
  13 +import android.view.inputmethod.InputMethodManager;
  14 +import android.widget.EditText;
  15 +import android.widget.LinearLayout;
  16 +import android.widget.PopupWindow;
  17 +
  18 +import com.cnlive.gundam.R;
  19 +import com.cnlive.gundam.main.utils.ToStringUtils;
  20 +import com.google.gson.Gson;
  21 +
  22 +/**
  23 + * Created by xiansong on 2017/4/12.
  24 + */
  25 +
  26 +public class InputUtil {
  27 +
  28 + private PopupWindow mInputPopupWindow;
  29 +
  30 + private Context mContext;
  31 + private EditText mMsgEditText;
  32 +
  33 + private SendCallback mSendCallback;
  34 +
  35 + private Gson mGson;
  36 + public InputUtil(Context context, SendCallback callback) {
  37 + mContext = context;
  38 + mGson = new Gson();
  39 + mSendCallback = callback;
  40 + }
  41 +
  42 + public void dismiss() {
  43 + if (mInputPopupWindow != null) {
  44 + mInputPopupWindow.dismiss();
  45 + mInputPopupWindow = null;
  46 + }
  47 + }
  48 +
  49 + public void showInput(View view) {
  50 + // 加载popupWindow的布局
  51 + View contentView = LayoutInflater.from(mContext).inflate(R.layout.layout_chat_input, new LinearLayout(mContext), false);
  52 + contentView.findViewById(R.id.click_view).setOnClickListener(new View.OnClickListener() {
  53 + @Override
  54 + public void onClick(View v) {
  55 + mMsgEditText.setText("");
  56 + mInputPopupWindow.dismiss();
  57 + }
  58 + });
  59 + mMsgEditText = (EditText) contentView.findViewById(R.id.chat_content);
  60 + mMsgEditText.setOnKeyListener(new View.OnKeyListener() {
  61 + @Override
  62 + public boolean onKey(View v, int keyCode, KeyEvent event) {
  63 + if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
  64 + InputMethodManager inputMethodManager = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
  65 + if (inputMethodManager.isActive()) {
  66 + inputMethodManager.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);
  67 + }
  68 + sendMessage();
  69 + return true;
  70 + }
  71 + return false;
  72 + }
  73 + });
  74 + /*contentView.findViewById(R.id.post_button).setOnClickListener(new View.OnClickListener() {
  75 + @Override
  76 + public void onClick(View v) {
  77 + mMsgEditText.setText("");
  78 + mInputPopupWindow.dismiss();
  79 + }
  80 + });*/
  81 +
  82 + mInputPopupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
  83 + mInputPopupWindow.setTouchable(true);
  84 + mInputPopupWindow.setTouchInterceptor(new View.OnTouchListener() {
  85 + @Override
  86 + public boolean onTouch(View v, MotionEvent event) {
  87 + if (event.getAction() == MotionEvent.ACTION_OUTSIDE)
  88 + mInputPopupWindow.dismiss();
  89 + return false;
  90 + }
  91 + });
  92 + // 设置以下两个属性后 点击popupWindow之外的地方 就会让其消失
  93 + // 设置popupWindow 点击popupWindow外的地方 生效
  94 + mInputPopupWindow.setOutsideTouchable(true);
  95 + // 设置popupWindow 背景
  96 + mInputPopupWindow.setBackgroundDrawable(new BitmapDrawable());
  97 + mInputPopupWindow.setFocusable(true); //设置获取焦点
  98 + mInputPopupWindow.setAnimationStyle(R.style.animation);
  99 + mInputPopupWindow.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
  100 + mInputPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
  101 + mInputPopupWindow.showAtLocation(view, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
  102 + mInputPopupWindow.update();
  103 +
  104 + mMsgEditText.requestFocus();
  105 + mInputPopupWindow.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
  106 + mInputPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
  107 + InputMethodManager imm = (InputMethodManager) mContext.getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
  108 + imm.toggleSoftInput(1000, InputMethodManager.HIDE_NOT_ALWAYS);
  109 + }
  110 +
  111 +
  112 + public void sendMessage() {
  113 + //发送聊天室消息
  114 + if (TextUtils.isEmpty(mMsgEditText.getText())) {
  115 + ToastUtil.showToast(mContext, "不能发送空消息呦~");
  116 + } else {
  117 + if(mSendCallback!=null) mSendCallback.sendMessage(mGson.toJson(new ToStringUtils.CNMessageModole(mMsgEditText.getText().toString(), ToStringUtils.ChatRoomype)));
  118 + mMsgEditText.setText("");
  119 + }
  120 +
  121 + if (mInputPopupWindow != null && mInputPopupWindow.isShowing()) mInputPopupWindow.dismiss();
  122 + }
  123 +
  124 +
  125 +
  126 +
  127 + public interface SendCallback {
  128 +
  129 + void sendMessage(String message);
  130 + }
  131 +
  132 +
  133 +
  134 +}
... ...
app/src/main/java/com/cnlive/gundam/video/adpter/CommonAdapter.java
... ... @@ -25,9 +25,8 @@ public class CommonAdapter<T> extends BaseAdapter {
25 25 private int layoutId; // 条目布局ID
26 26 private int variableId; // DataBinding的变量ID,可通过类似R文件的BR文件来获取
27 27  
28   - public CommonAdapter(Context context, List<T> dataList, int layoutId, int variableId) {
  28 + public CommonAdapter(Context context, int layoutId, int variableId) {
29 29 this.mContext = context;
30   - this.mDataList = dataList;
31 30 this.layoutId = layoutId;
32 31 this.variableId = variableId;
33 32 }
... ...
app/src/main/java/com/cnlive/gundam/video/adpter/GiftAdapter.java
... ... @@ -7,8 +7,14 @@ import android.support.v7.widget.RecyclerView;
7 7 import android.view.LayoutInflater;
8 8 import android.view.View;
9 9 import android.view.ViewGroup;
  10 +import android.widget.Toast;
10 11  
  12 +import com.cnlive.gundam.R;
  13 +import com.cnlive.gundam.main.utils.ToStringUtils;
11 14 import com.cnlive.gundam.video.model.GiftModle;
  15 +import com.cnlive.libs.util.chat.ChatUtil;
  16 +import com.cnlive.libs.util.chat.base.IChat;
  17 +import com.cnlive.libs.util.chat.model.CNMessage;
12 18  
13 19 import java.util.List;
14 20  
... ... @@ -23,12 +29,13 @@ public class GiftAdapter extends RecyclerView.Adapter&lt;GiftAdapter.RVHolder&gt; {
23 29 private List<GiftModle> mDataList;
24 30 private int mLayoutId; // 条目布局文件ID
25 31 private int mVariableId; // DataBinding变量ID
26   -
27   - public GiftAdapter(Context context, List<GiftModle> list, int layoutId, int variableId) {
  32 + private String roomId;
  33 + public GiftAdapter(String roomId,Context context, List<GiftModle> list, int layoutId, int variableId) {
28 34 this.mContext = context;
29 35 this.mDataList = list;
30 36 this.mLayoutId = layoutId;
31 37 mVariableId = variableId;
  38 + this.roomId=roomId;
32 39  
33 40  
34 41 }
... ... @@ -45,6 +52,30 @@ public class GiftAdapter extends RecyclerView.Adapter&lt;GiftAdapter.RVHolder&gt; {
45 52 @Override
46 53 public void onBindViewHolder(RVHolder holder, final int position) {
47 54 holder.binding.setVariable(mVariableId, mDataList.get(position));
  55 + holder.binding.getRoot().findViewById(R.id.ll_item).setOnClickListener(new View.OnClickListener() {
  56 + @Override
  57 + 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() {
  61 + @Override
  62 + public void onAttached(CNMessage message) {
  63 +
  64 + }
  65 +
  66 + @Override
  67 + public void onSuccess(CNMessage message) {
  68 + Toast.makeText(mContext,mDataList.get(position).getGiftMessage(),Toast.LENGTH_SHORT).show();
  69 +
  70 + }
  71 +
  72 + @Override
  73 + public void onError(CNMessage message, int what, String extra) {
  74 +
  75 + }
  76 + });
  77 + }
  78 + });
48 79 holder.binding.executePendingBindings();
49 80 }
50 81  
... ...
app/src/main/java/com/cnlive/gundam/video/barrage/BarrageBaseMessage.java 0 → 100644
  1 +package com.cnlive.gundam.video.barrage;
  2 +
  3 +import com.cnlive.libs.video.barrage.model.BarrageMessage;
  4 +
  5 +//普通 弹幕消息
  6 +public class BarrageBaseMessage extends ChatMessage implements BarrageMessage {
  7 +
  8 + String name = "";
  9 + String message = "";
  10 + String icon = "";
  11 +
  12 + public BarrageBaseMessage() {
  13 + }
  14 +
  15 + public BarrageBaseMessage(String name, String message, String icon) {
  16 + this.name = name;
  17 + this.message = message;
  18 + this.icon = icon;
  19 + }
  20 +
  21 + @Override
  22 + public String getIcon() {
  23 + return icon;
  24 + }
  25 +
  26 + @Override
  27 + public String getName() {
  28 + return name;
  29 + }
  30 +
  31 + @Override
  32 + public String getMessage() {
  33 + return message;
  34 + }
  35 +
  36 + @Override
  37 + public boolean isSelf() {
  38 + return false;
  39 + }
  40 +
  41 +}
... ...
app/src/main/java/com/cnlive/gundam/video/barrage/BarrageBaseView.java 0 → 100644
  1 +package com.cnlive.gundam.video.barrage;
  2 +
  3 +import android.content.Context;
  4 +import android.util.AttributeSet;
  5 +import android.view.View;
  6 +
  7 +import com.cnlive.gundam.R;
  8 +import com.cnlive.libs.util.ui.emojicon.EmojiconTextView;
  9 +import com.cnlive.libs.video.barrage.MessageView;
  10 +import com.cnlive.libs.video.barrage.model.BarrageMessage;
  11 +
  12 +
  13 +/**
  14 + * Created by xiansong on 2016/5/19.
  15 + */
  16 +public class BarrageBaseView extends MessageView<BarrageMessage> {
  17 +
  18 + public EmojiconTextView chat_item_name;
  19 +
  20 + public EmojiconTextView chat_item_message;
  21 +
  22 + public View chat_item_bg;
  23 +
  24 + public BarrageBaseView(Context context) {
  25 + this(context, null);
  26 + }
  27 +
  28 + public BarrageBaseView(Context context, AttributeSet attrs) {
  29 + this(context, attrs, 0);
  30 + }
  31 +
  32 + public BarrageBaseView(Context context, AttributeSet attrs, int defStyleAttr) {
  33 + super(context, attrs, defStyleAttr);
  34 + chat_item_bg = findViewById(R.id.chat_item_bg);
  35 + chat_item_name = (EmojiconTextView) findViewById(R.id.chat_item_name);
  36 + chat_item_message = (EmojiconTextView) findViewById(R.id.chat_item_message);
  37 + }
  38 +
  39 + @Override
  40 + public int getLayoutResource() {
  41 + return R.layout.cnlive_view_chat_barrage;
  42 + }
  43 +
  44 + @Override
  45 + public void setData(BarrageMessage data) {
  46 + chat_item_bg.setBackgroundResource(data.isSelf() ? R.drawable.cnlive_chat_on : R.drawable.cnlive_chat_off);
  47 + chat_item_name.setText(data.getName() + ":");
  48 + chat_item_message.setText(data.getMessage());
  49 + }
  50 +}
... ...
app/src/main/java/com/cnlive/gundam/video/barrage/ChatMessage.java 0 → 100644
  1 +package com.cnlive.gundam.video.barrage;
  2 +
  3 +/**
  4 + * Created by xiansong on 2016/8/5.
  5 + */
  6 +public class ChatMessage {
  7 + protected String type;
  8 +
  9 + public String getType() {
  10 + return type;
  11 + }
  12 +
  13 + public void setType(String type) {
  14 + this.type = type;
  15 + }
  16 +}
... ...
app/src/main/java/com/cnlive/gundam/video/fragment/PlayerLiveFragment.java
... ... @@ -17,16 +17,18 @@ import com.cnlive.gundam.video.fragment.chat.ChatRoomFragment;
17 17 import com.cnlive.gundam.video.model.VideoModel;
18 18 import com.cnlive.gundam.video.utils.PlayerUtils;
19 19 import com.cnlive.gundam.video.view.PlayerAccelerometerSensor;
  20 +import com.cnlive.gundam.video.view.PlayerControllerView;
20 21  
21 22 /**
22 23 * Created by gujun on 2017/6/27.
23 24 */
24 25  
25   -public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerSensor.ScreenOrientationListener{
  26 +public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerSensor.ScreenOrientationListener {
26 27 private FragmentPlayerLiveBinding binding;
27 28  
28 29 private VideoListProgram program;
29 30 private PlayerAccelerometerSensor playerAccelerometerSensor;
  31 + private PlayerControllerView viewById;
30 32  
31 33 public static PlayerLiveFragment newInstance(VideoListProgram program) {
32 34  
... ... @@ -48,8 +50,7 @@ public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerS
48 50 @Override
49 51 public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
50 52 binding = DataBindingUtil.inflate(inflater, R.layout.fragment_player_live, container, false);
51   - getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.contentLayout, ChatRoomFragment.newInstance()).commit();
52   -
  53 + getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.contentLayout, ChatRoomFragment.newInstance(), "chatRoomFragment").commit();
53 54 return binding.getRoot();
54 55 }
55 56  
... ... @@ -61,7 +62,7 @@ public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerS
61 62  
62 63 private void init() {
63 64 program = (VideoListProgram) getArguments().getSerializable("program");
64   - if(program == null) return;
  65 + if (program == null) return;
65 66 VideoModel model = new VideoModel(program.getTitle(), program.getChannelId(), program.getType(), program.getRates());
66 67 binding.videoView.setVideoInfo(model);
67 68 }
... ... @@ -71,7 +72,6 @@ public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerS
71 72 super.onConfigurationChanged(newConfig);
72 73 boolean isPortrait = PlayerUtils.isPortrait(getActivity());
73 74 binding.videoView.onScreenChange(isPortrait);
74   -
75 75 PlayerUtils.setStatusBarVisibility(getActivity(), isPortrait);
76 76 }
77 77  
... ... @@ -100,9 +100,16 @@ public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerS
100 100 if (orientation == PlayerAccelerometerSensor.ORIENTATION_PORTRAIT) {
101 101 getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
102 102 } else if (orientation == PlayerAccelerometerSensor.ORIENTATION_LANDSCAPE) {
  103 +
103 104 getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
104 105 } else if (orientation == PlayerAccelerometerSensor.ORIENTATION_REVERSE_LANDSCAPE) {
105 106 getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
106 107 }
  108 +
  109 + ChatRoomFragment chatRoomFragment = (ChatRoomFragment) getActivity().getSupportFragmentManager().findFragmentByTag("chatRoomFragment");
  110 + chatRoomFragment.doBarrage();
  111 +
107 112 }
  113 +
  114 +
108 115 }
... ...
app/src/main/java/com/cnlive/gundam/video/fragment/chat/ChatRoomFragment.java
... ... @@ -7,30 +7,32 @@ import android.support.annotation.Nullable;
7 7 import android.support.v4.app.Fragment;
8 8 import android.support.v7.widget.GridLayoutManager;
9 9 import android.support.v7.widget.OrientationHelper;
  10 +import android.support.v7.widget.SwitchCompat;
10 11 import android.util.Log;
11 12 import android.view.LayoutInflater;
12 13 import android.view.View;
13 14 import android.view.ViewGroup;
  15 +import android.widget.CompoundButton;
14 16 import android.widget.ImageView;
15 17  
16 18 import com.bumptech.glide.Glide;
17 19 import com.cnlive.gundam.BR;
18 20 import com.cnlive.gundam.R;
19 21 import com.cnlive.gundam.databinding.FragmentChatBinding;
20   -import com.cnlive.gundam.main.utils.ToStringUtils;
21 22 import com.cnlive.gundam.user.auth.UserService;
22 23 import com.cnlive.gundam.user.model.User;
  24 +import com.cnlive.gundam.user.util.InputUtil;
23 25 import com.cnlive.gundam.video.adpter.CommonAdapter;
24 26 import com.cnlive.gundam.video.adpter.GiftAdapter;
  27 +import com.cnlive.gundam.video.barrage.BarrageBaseView;
25 28 import com.cnlive.gundam.video.model.GiftModle;
26 29 import com.cnlive.gundam.video.model.MessageContent;
  30 +import com.cnlive.gundam.video.utils.PlayerUtils;
  31 +import com.cnlive.gundam.video.view.PlayerControllerView;
27 32 import com.cnlive.libs.util.chat.ChatUtil;
28 33 import com.cnlive.libs.util.chat.base.IChat;
29   -import com.cnlive.libs.util.chat.model.CNMessage;
30 34 import com.cnlive.libs.util.chat.model.CNUserInfo;
31   -
32   -import org.json.JSONException;
33   -import org.json.JSONObject;
  35 +import com.cnlive.libs.video.barrage.BarrageLayout;
34 36  
35 37 import java.util.ArrayList;
36 38  
... ... @@ -40,16 +42,17 @@ import java.util.ArrayList;
40 42 * @time 2017/5/27 13:57
41 43 * @desc ${TODD}
42 44 */
43   -public class ChatRoomFragment extends Fragment implements View.OnClickListener {
  45 +public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback, MessageContentInfo.SendAndRecevieSucessCall {
44 46  
45 47  
46 48 private FragmentChatBinding fragmentChatBinding;
47 49 private ArrayList<GiftModle> giftArray;
48   - private ArrayList<MessageContent> messageContentArrayList;
49 50 private CommonAdapter<MessageContent> messageContentCommonAdapter;
50   - private IChat.OnConnectListener onConnectListener;
51   - private String roomId = "ChatRoom05";
52   - private IChat.OnSendMessageListener onSendMessageListener;
  51 + private String roomId = "ChatRoom06";
  52 + private MessageContentInfo messageContentInfo;
  53 + public SwitchCompat switchCompatBottom;
  54 + private BarrageLayout barrageLayout;
  55 +
53 56  
54 57 public static ChatRoomFragment newInstance() {
55 58 Bundle args = new Bundle();
... ... @@ -63,77 +66,47 @@ public class ChatRoomFragment extends Fragment implements View.OnClickListener {
63 66 @Override
64 67 public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
65 68 fragmentChatBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_chat, container, false);
66   -
67 69 return fragmentChatBinding.getRoot();
68 70  
69 71 }
70 72  
71   -
72   - private void initChat() {
73   - User activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo();
74   - String faceurl = activeAccountInfo.getFaceurl();
75   - String nickname = activeAccountInfo.getNickname();
76   - int uid = activeAccountInfo.getUid();
77   - ChatUtil.connect(new CNUserInfo(uid + "", nickname, faceurl), onConnectListener);
78   -
79   - }
80   -
81   -
  73 + SwitchCompat barrageTop;
  74 + PlayerControllerView.SwitchCompatChangeListener switchCompatChangeListener;
82 75 @Override
83 76 public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
84 77 super.onViewCreated(view, savedInstanceState);
85   - initDate();
86   - init();
  78 +
  79 +
87 80 initListener();
  81 + initDate();
  82 + initGift();
88 83 initChat();
89   - }
90 84  
91   - private void initDate() {
92   - int[] imaSource = new int[]{R.drawable.porsch_small80, R.drawable.fighter_small80,
93   - R.drawable.plane_small80,
94   - R.drawable.beer, R.drawable.chicken,
95   - R.drawable.cucumber, R.drawable.flower,
96   - R.drawable.hug, R.drawable.mouth,
97   - R.drawable.ring, R.drawable.rose, R.drawable.continuous};
98   - String[] gitName = new String[]{"跑车", "歼灭机", "飞机", "啤酒",
99   - "小鸡", "小黄瓜", "鲜花", "抱抱", "亲吻", "戒指", "玫瑰花", "荧光棒"};
100   - giftArray = new ArrayList<>();
101   - for (int i = 0; i < 12; i++) {
102   - giftArray.add(new GiftModle(gitName[i], imaSource[i]));
103   - }
104   - }
105   -
106   - private void init() {
107   - initGiftAdapter();
108   - initMessageAdapter();
109 85  
110 86 }
111 87  
112   - private void initMessageAdapter() {
113   - messageContentArrayList = new ArrayList<>();
114   - if (messageContentCommonAdapter == null)
115   - messageContentCommonAdapter = new CommonAdapter<>(getActivity(), messageContentArrayList, R.layout.item_list_right, BR.user);
116   - }
117 88  
118   - private void initGiftAdapter() {
119   - fragmentChatBinding.recyclerGift.setOnClickListener(this);
120   - GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2);
121   - gridLayoutManager.setOrientation(OrientationHelper.HORIZONTAL);
122   - fragmentChatBinding.recyclerGift.setLayoutManager(gridLayoutManager);
123   - fragmentChatBinding.setGiftAdapter(new GiftAdapter(getActivity(), giftArray, R.layout.fragment_gift_receycel, BR.dataBean));
124   - }
  89 + private void barrageBottom() {
  90 + switchCompatBottom = fragmentChatBinding.barrage;
  91 + switchCompatBottom.setChecked(false);
  92 + barrageLayout = getActivity().findViewById(R.id.private_message);
  93 + barrageLayout.init(BarrageBaseView.class, 300, 10, 10, 0.5f);
  94 + barrageLayout.pause();
  95 + switchCompatBottom.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  96 + @Override
  97 + public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
  98 + if (isChecked) {
  99 + barrageLayout.resume();
125 100  
  101 + } else {
  102 + barrageLayout.pause();
126 103  
127   - @Override
128   - public void onClick(View view) {
129   - switch (view.getId()) {
130   - case R.id.img_gift:
131   - int i = View.VISIBLE == fragmentChatBinding.recyclerGift.getVisibility() ? View.INVISIBLE : View.VISIBLE;
132   - fragmentChatBinding.recyclerGift.setVisibility(i);
133   - break;
134   - }
  104 + }
  105 + }
  106 + });
135 107 }
136 108  
  109 +
137 110 @BindingAdapter("android:src")
138 111 public static void setSrc(ImageView view, int resId) {
139 112 view.setImageResource(resId);
... ... @@ -149,85 +122,137 @@ public class ChatRoomFragment extends Fragment implements View.OnClickListener {
149 122 }
150 123  
151 124  
152   - private void initListener() {
  125 + @Override
  126 + public void sendMessage(String message) {
  127 + ChatUtil.sendMessage(IChat.CHATROOM, roomId, message, messageContentInfo.onSendMessageListener);
  128 + }
153 129  
154   - onSendMessageListener = new IChat.OnSendMessageListener() {
155   - @Override
156   - public void onAttached(CNMessage message) {
  130 + @Override
  131 + public void sentSucess(ArrayList<MessageContent> messageContents) {
157 132  
158   - }
  133 + messageContentCommonAdapter.setDataList((messageContents));
  134 + ChatRoomFragment.this.fragmentChatBinding.setMessageAdapter(messageContentCommonAdapter);
  135 + }
159 136  
160   - @Override
161   - public void onSuccess(CNMessage message) {
162   - JSONObject jsonObject = null;
163   - try {
164   - jsonObject = new JSONObject(message.getContent().toString());
165   - String messagecontent = (String) jsonObject.get("message");
166   - String messageType = (String) jsonObject.get("type");
167   - if (messageType.equals(ToStringUtils.ChatRoomype)) {
168   - messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), messagecontent + " :", message.getUserInfo().getHeadUrl(), false));
169   - messageContentCommonAdapter.setDataList((messageContentArrayList));
170   - ChatRoomFragment.this.fragmentChatBinding.setMessageAdapter(messageContentCommonAdapter);
171   - }
172   -
173   - } catch (JSONException e) {
174   - e.printStackTrace();
175   - }
  137 + @Override
  138 + public void receaviceSucess(ArrayList<MessageContent> messageContents) {
  139 + messageContentCommonAdapter.setDataList((messageContents));
  140 + ChatRoomFragment.this.fragmentChatBinding.setMessageAdapter(messageContentCommonAdapter);
  141 + }
176 142  
177 143  
178   - }
  144 + @Override
  145 + public void onDestroy() {
  146 + super.onDestroy();
  147 + ChatUtil.disconnect(false);
  148 + }
179 149  
180   - @Override
181   - public void onError(CNMessage message, int what, String extra) {
182 150  
183   - }
184   - };
185 151  
  152 + private void initChat() {
  153 + User activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo();
  154 + String faceurl = activeAccountInfo.getFaceurl();
  155 + String nickname = activeAccountInfo.getNickname();
  156 + int uid = activeAccountInfo.getUid();
  157 + if (uid != 0) {
  158 + ChatUtil.connect(new CNUserInfo(uid + "", nickname, faceurl), messageContentInfo.onConnectListener);
  159 + } else {
  160 + ChatUtil.connect(messageContentInfo.onConnectListener);
  161 + }
  162 + ChatUtil.setOnReceiveMessageListener(messageContentInfo.onReceiveMessageListener);
186 163  
187   - onConnectListener = new IChat.OnConnectListener() {
188   - @Override
189   - public void onTokenIncorrect(String s) {
190   - Log.v("hcatRooomFragment","onTokenIncorrect");
  164 + }
191 165  
192   - }
  166 + private void initMessageAdapter() {
  167 + if (messageContentCommonAdapter == null)
  168 + messageContentCommonAdapter = new CommonAdapter<>(getActivity(), R.layout.item_list_right, BR.user);
193 169  
  170 + }
  171 +
  172 + private void initGiftAdapter() {
  173 + fragmentChatBinding.imgGift.setOnClickListener(new View.OnClickListener() {
194 174 @Override
195   - public void onSuccess(String s) {
196   - joinChatRoom();
  175 + public void onClick(View view) {
  176 + int i = View.INVISIBLE == fragmentChatBinding.rlGift.getVisibility() ? View.VISIBLE : View.INVISIBLE;
  177 + fragmentChatBinding.rlGift.setVisibility(i);
  178 + }
  179 + });
  180 + GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2);
  181 + gridLayoutManager.setOrientation(OrientationHelper.HORIZONTAL);
  182 + fragmentChatBinding.recyclerGift.setLayoutManager(gridLayoutManager);
  183 + fragmentChatBinding.setGiftAdapter(new GiftAdapter(roomId, getActivity(), giftArray, R.layout.fragment_gift_receycel, BR.dataBean));
  184 + }
197 185  
198   - Log.v("hcatRooomFragment","onSuccess");
199 186  
  187 + private void initDate() {
  188 + int[] imaSource = new int[]{R.drawable.porsch_small80, R.drawable.fighter_small80,
  189 + R.drawable.plane_small80,
  190 + R.drawable.beer, R.drawable.chicken,
  191 + R.drawable.cucumber, R.drawable.flower,
  192 + R.drawable.hug, R.drawable.mouth,
  193 + R.drawable.ring, R.drawable.rose, R.drawable.continuous};
  194 + String[] gitName = new String[]{"跑车", "歼灭机", "飞机", "啤酒",
  195 + "小鸡", "小黄瓜", "鲜花", "抱抱", "亲吻", "戒指", "玫瑰花", "荧光棒"};
  196 + giftArray = new ArrayList<>();
  197 + for (int i = 0; i < 12; i++) {
  198 + giftArray.add(new GiftModle(gitName[i], imaSource[i]));
  199 + }
  200 + }
200 201  
201   - }
  202 + private void initGift() {
  203 + fragmentChatBinding.sendMessage.setOnClickListener(new View.OnClickListener() {
202 204  
  205 + private InputUtil inputUtil;
203 206  
204 207 @Override
205   - public void onError(int i, String s) {
206   - Log.v("hcatRooomFragment","onError");
207   -
  208 + public void onClick(View view) {
  209 + inputUtil = new InputUtil(getContext(), ChatRoomFragment.this);
  210 + inputUtil.showInput(view);
208 211 }
209   - };
  212 + });
  213 + initGiftAdapter();
210 214  
211   - }
212 215  
  216 + }
213 217  
  218 + private void initListener() {
  219 + barrageBottom();
  220 + initMessageAdapter();
  221 + messageContentInfo = new MessageContentInfo();
  222 + messageContentInfo.setOnReceiveAndSendListener(barrageLayout, roomId, getActivity(), ChatRoomFragment.this);
  223 + }
214 224  
215   - private void joinChatRoom() {
216   - ChatUtil.joinChatRoom(roomId, 0, new IChat.OnOperationListener() {
217   - @Override
218   - public void onSuccess(int what, String extra) {
219   - Log.v("hcatRooomFragment","joinChatRoomnonSuccess");
220 225  
221   - String objToJsonString = ToStringUtils.objToJsonString(new ToStringUtils.CNMessageModole("加入聊天室", ToStringUtils.JoinType));
222   - ChatUtil.sendMessage(IChat.CHATROOM, roomId, objToJsonString, onSendMessageListener);
223   - }
  226 + public void doBarrage(){
  227 + boolean isPortrait = PlayerUtils.isPortrait(getActivity());
  228 + final BarrageLayout barrageLayout = getActivity().findViewById(R.id.private_message);
  229 + barrageLayout.pause();
  230 + SwitchCompat switchCompat = getActivity().findViewById(R.id.barrage);
  231 + switchCompat.setChecked(false);
  232 + if (!isPortrait ) {
  233 + PlayerControllerView viewById = getActivity().findViewById(R.id.controllerView);
  234 + viewById.setonswitchCompatChangeListene( switchCompatChangeListener = new PlayerControllerView.SwitchCompatChangeListener() {
  235 + @Override
  236 + public void onSwitchCompatChange(SwitchCompat barrageTop) {
  237 + barrageTop.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  238 + @Override
  239 + public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
  240 + if (b) {
  241 + Log.v("fsdas","fasdf");
  242 + barrageLayout.resume();
  243 +
  244 + } else {
  245 + barrageLayout.pause();
  246 +
  247 + }
  248 + }
  249 + });
  250 + }
  251 + });
224 252  
225   - @Override
226   - public void onError(int what, String extra) {
227   - Log.v("hcatRooomFragment","joinChatRoomnError");
228 253  
229   - }
230   - });
  254 + }
231 255 }
232 256  
  257 +
233 258 }
... ...
app/src/main/java/com/cnlive/gundam/video/fragment/chat/MessageContentInfo.java 0 → 100644
  1 +package com.cnlive.gundam.video.fragment.chat;
  2 +
  3 +import android.content.Context;
  4 +import android.os.Handler;
  5 +import android.text.TextUtils;
  6 +import android.util.Log;
  7 +
  8 +import com.cnlive.gundam.main.utils.ToStringUtils;
  9 +import com.cnlive.gundam.user.auth.UserService;
  10 +import com.cnlive.gundam.video.barrage.BarrageBaseMessage;
  11 +import com.cnlive.gundam.video.model.MessageContent;
  12 +import com.cnlive.libs.util.chat.ChatUtil;
  13 +import com.cnlive.libs.util.chat.base.IChat;
  14 +import com.cnlive.libs.util.chat.model.CNMessage;
  15 +import com.cnlive.libs.video.barrage.BarrageLayout;
  16 +
  17 +import org.json.JSONException;
  18 +import org.json.JSONObject;
  19 +
  20 +import java.util.ArrayList;
  21 +
  22 +/**
  23 + * @author 陈硕
  24 + * @time 2017/6/29 11:02
  25 + * @desc ${TODD}
  26 + */
  27 +public class MessageContentInfo {
  28 +
  29 +
  30 + public IChat.OnReceiveMessageListener onReceiveMessageListener;
  31 + public IChat.OnSendMessageListener onSendMessageListener;
  32 + public IChat.OnConnectListener onConnectListener;
  33 + private Handler mHandler;
  34 + private ArrayList<com.cnlive.gundam.video.model.MessageContent> messageContentArrayList;
  35 + private Context mContext;
  36 + private SendAndRecevieSucessCall mSendAndRecevieSucessCall;
  37 + private String roomId;
  38 + private BarrageLayout barrageLayout;
  39 +
  40 +
  41 + public void setOnReceiveAndSendListener(BarrageLayout barrageLayout,String roomID, Context context, SendAndRecevieSucessCall sendAndRecevieSucessCall) {
  42 + this.roomId = roomID;
  43 + this.mContext = context;
  44 + this.mSendAndRecevieSucessCall = sendAndRecevieSucessCall;
  45 + mHandler = new Handler();
  46 + messageContentArrayList = new ArrayList<>();
  47 + this.barrageLayout =barrageLayout;
  48 + initListener();
  49 +
  50 + }
  51 +
  52 +
  53 + private void initListener() {
  54 +
  55 +
  56 + onReceiveMessageListener = new IChat.OnReceiveMessageListener() {
  57 + @Override
  58 + public void processMessage(final CNMessage message) {
  59 +
  60 + mHandler.post(new Runnable() {
  61 + @Override
  62 + public void run() {
  63 + try {
  64 + JSONObject jsonObject = new JSONObject(message.getContent().toString());
  65 + String type = (String) jsonObject.get("type");
  66 + String messagecontent = (String) jsonObject.get("message");
  67 +
  68 + if (type.equals(ToStringUtils.GiftType)) {
  69 +
  70 + barrageLayout.addMessage(new BarrageBaseMessage(message.getUserInfo().getUserName(), "送了" + messagecontent, ""));
  71 + messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), ": 送了" + messagecontent, message.getUserInfo().getHeadUrl(), true));
  72 + } else if (type.equals(ToStringUtils.ChatRoomype)) {
  73 + if (message.getUserInfo().getUserId().equals(ChatUtil.getCurrentUserInfo().getUserId())) {
  74 + messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), messagecontent + " :", message.getUserInfo().getHeadUrl(), false));
  75 + } else {
  76 + messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), " :" + messagecontent, message.getUserInfo().getHeadUrl(), true));
  77 +
  78 + }
  79 + barrageLayout.addMessage(new BarrageBaseMessage(message.getUserInfo().getUserName(), messagecontent, ""));
  80 +
  81 +
  82 + } else if (type.equals(ToStringUtils.JoinType)) {
  83 + String userName = message.getUserInfo().getUserName();
  84 + if (TextUtils.isEmpty(userName)) {
  85 + return;
  86 + }
  87 + if (userName.equals(UserService.getInstance(mContext).getActiveAccountInfo().getNickname())) {
  88 + return;
  89 + }
  90 + barrageLayout.addMessage(new BarrageBaseMessage(message.getUserInfo().getUserName(), messagecontent, ""));
  91 +
  92 + messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), ": " + messagecontent, message.getUserInfo().getHeadUrl(), true));
  93 +
  94 + }
  95 +
  96 + mSendAndRecevieSucessCall.receaviceSucess(messageContentArrayList);
  97 + /* messageContentCommonAdapter.setDataList((messageContentArrayList));
  98 + ChatRoomFragment.this.fragmentChatBinding.setMessageAdapter(messageContentCommonAdapter);*/
  99 +
  100 + } catch (JSONException e) {
  101 + e.printStackTrace();
  102 + }
  103 + }
  104 + });
  105 +
  106 + }
  107 + };
  108 +
  109 +
  110 + onSendMessageListener = new IChat.OnSendMessageListener() {
  111 + @Override
  112 + public void onAttached(CNMessage message) {
  113 + Log.v("hcatRooomFragment", "onSendMessageListeneronAttached");
  114 +
  115 + }
  116 +
  117 + @Override
  118 + public void onSuccess(CNMessage message) {
  119 + Log.v("hcatRooomFragment", "onSendMessageListeneronSuccess");
  120 +
  121 + JSONObject jsonObject = null;
  122 + try {
  123 + jsonObject = new JSONObject(message.getContent().toString());
  124 + String messagecontent = (String) jsonObject.get("message");
  125 + String messageType = (String) jsonObject.get("type");
  126 + if (messageType.equals(ToStringUtils.ChatRoomype)) {
  127 + barrageLayout.addMessage(new BarrageBaseMessage(message.getUserInfo().getUserName(), messagecontent, ""));
  128 +
  129 + messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), messagecontent + " :", message.getUserInfo().getHeadUrl(), false));
  130 +
  131 + mSendAndRecevieSucessCall.sentSucess(messageContentArrayList);
  132 + /*messageContentCommonAdapter.setDataList((messageContentArrayList));
  133 + ChatRoomFragment.this.fragmentChatBinding.setMessageAdapter(messageContentCommonAdapter);*/
  134 + }
  135 +
  136 + } catch (JSONException e) {
  137 + e.printStackTrace();
  138 + }
  139 +
  140 +
  141 + }
  142 +
  143 + @Override
  144 + public void onError(CNMessage message, int what, String extra) {
  145 + Log.v("hcatRooomFragment", "onSendMessageListeneronError");
  146 +
  147 + }
  148 + };
  149 +
  150 +
  151 + onConnectListener = new IChat.OnConnectListener() {
  152 + @Override
  153 + public void onTokenIncorrect(String s) {
  154 + Log.v("hcatRooomFragment", "onTokenIncorrect");
  155 +
  156 + }
  157 +
  158 + @Override
  159 + public void onSuccess(String s) {
  160 + joinChatRoom();
  161 +
  162 + Log.v("hcatRooomFragment", "onSuccess");
  163 +
  164 +
  165 + }
  166 +
  167 +
  168 + @Override
  169 + public void onError(int i, String s) {
  170 + Log.v("hcatRooomFragment", "onError");
  171 +
  172 + }
  173 + };
  174 +
  175 + }
  176 +
  177 +
  178 + private void joinChatRoom() {
  179 + ChatUtil.joinChatRoom(roomId, 0, new IChat.OnOperationListener() {
  180 + @Override
  181 + public void onSuccess(int what, String extra) {
  182 + Log.v("hcatRooomFragment", "joinChatRoomnonSuccess");
  183 +
  184 + String objToJsonString = ToStringUtils.objToJsonString(new ToStringUtils.CNMessageModole("加入聊天室", ToStringUtils.JoinType));
  185 + ChatUtil.sendMessage(IChat.CHATROOM, roomId, objToJsonString, onSendMessageListener);
  186 + }
  187 +
  188 + @Override
  189 + public void onError(int what, String extra) {
  190 + Log.v("hcatRooomFragment", "joinChatRoomnError");
  191 +
  192 + }
  193 + });
  194 + }
  195 +
  196 + public interface SendAndRecevieSucessCall {
  197 + void sentSucess(ArrayList<com.cnlive.gundam.video.model.MessageContent> messageContents);
  198 +
  199 + void receaviceSucess(ArrayList<com.cnlive.gundam.video.model.MessageContent> messageContents);
  200 + }
  201 +
  202 +
  203 +
  204 +}
... ...
app/src/main/java/com/cnlive/gundam/video/view/PlayerControllerView.java
... ... @@ -11,6 +11,7 @@ import android.databinding.ObservableLong;
11 11 import android.databinding.ViewDataBinding;
12 12 import android.os.Handler;
13 13 import android.os.Message;
  14 +import android.support.v7.widget.SwitchCompat;
14 15 import android.text.TextUtils;
15 16 import android.util.AttributeSet;
16 17 import android.view.LayoutInflater;
... ... @@ -18,8 +19,10 @@ import android.view.View;
18 19 import android.widget.RelativeLayout;
19 20 import android.widget.SeekBar;
20 21  
21   -import com.android.databinding.library.baseAdapters.BR;
  22 +import com.cnlive.gundam.BR;
22 23 import com.cnlive.gundam.R;
  24 +import com.cnlive.gundam.databinding.LayoutPlayerControllerLiveLBinding;
  25 +import com.cnlive.gundam.databinding.LayoutPlayerControllerUgcLiveLBinding;
23 26 import com.cnlive.gundam.video.utils.PlayerUtils;
24 27 import com.cnlive.gundam.video.utils.VideoRateUtil;
25 28 import com.cnlive.libs.util.Config;
... ... @@ -184,42 +187,44 @@ public class PlayerControllerView extends RelativeLayout implements SeekBar.OnSe
184 187 binding.setVariable(BR.title, observableTitle);
185 188 binding.setVariable(BR.showController, observableShow);
186 189 binding.setVariable(BR.isPlay, observableIsPlay);
  190 + switchCompatChangeListener.onSwitchCompatChange(((LayoutPlayerControllerLiveLBinding) this.binding).barrageTop);
187 191 isUgc = false;
188 192 break;
189 193 case UGC_VOD_P:
190   - binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_ugc_vod_p));
191   - binding.setVariable(BR.playerControllerView, this);
192   - binding.setVariable(BR.title, observableTitle);
193   - binding.setVariable(BR.showController, observableShow);
194   - binding.setVariable(BR.isPlay, observableIsPlay);
195   - binding.setVariable(BR.durProgress, observableDurProgress);
196   - binding.setVariable(BR.curProgress, observableCurProgress);
  194 + this.binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_ugc_vod_p));
  195 + this.binding.setVariable(BR.playerControllerView, this);
  196 + this.binding.setVariable(BR.title, observableTitle);
  197 + this.binding.setVariable(BR.showController, observableShow);
  198 + this.binding.setVariable(BR.isPlay, observableIsPlay);
  199 + this.binding.setVariable(BR.durProgress, observableDurProgress);
  200 + this.binding.setVariable(BR.curProgress, observableCurProgress);
197 201 isUgc = true;
198 202 break;
199 203 case UGC_VOD_L:
200   - binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_ugc_vod_l));
201   - binding.setVariable(BR.playerControllerView, this);
202   - binding.setVariable(BR.title, observableTitle);
203   - binding.setVariable(BR.showController, observableShow);
204   - binding.setVariable(BR.isPlay, observableIsPlay);
205   - binding.setVariable(BR.durProgress, observableDurProgress);
206   - binding.setVariable(BR.curProgress, observableCurProgress);
  204 + this.binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_ugc_vod_l));
  205 + this.binding.setVariable(BR.playerControllerView, this);
  206 + this.binding.setVariable(BR.title, observableTitle);
  207 + this.binding.setVariable(BR.showController, observableShow);
  208 + this.binding.setVariable(BR.isPlay, observableIsPlay);
  209 + this.binding.setVariable(BR.durProgress, observableDurProgress);
  210 + this.binding.setVariable(BR.curProgress, observableCurProgress);
207 211 isUgc = true;
208 212 break;
209 213 case UGC_LIVE_P:
210   - binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_ugc_live_p));
211   - binding.setVariable(BR.playerControllerView, this);
212   - binding.setVariable(BR.title, observableTitle);
213   - binding.setVariable(BR.showController, observableShow);
214   - binding.setVariable(BR.isPlay, observableIsPlay);
  214 + this.binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_ugc_live_p));
  215 + this.binding.setVariable(BR.playerControllerView, this);
  216 + this.binding.setVariable(BR.title, observableTitle);
  217 + this.binding.setVariable(BR.showController, observableShow);
  218 + this.binding.setVariable(BR.isPlay, observableIsPlay);
215 219 isUgc = true;
216 220 break;
217 221 case UGC_LIVE_L:
218   - binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_ugc_live_l));
219   - binding.setVariable(BR.playerControllerView, this);
220   - binding.setVariable(BR.title, observableTitle);
221   - binding.setVariable(BR.showController, observableShow);
222   - binding.setVariable(BR.isPlay, observableIsPlay);
  222 + this.binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_ugc_live_l));
  223 + this.binding.setVariable(BR.playerControllerView, this);
  224 + this.binding.setVariable(BR.title, observableTitle);
  225 + this.binding.setVariable(BR.showController, observableShow);
  226 + this.binding.setVariable(BR.isPlay, observableIsPlay);
  227 + switchCompatChangeListener.onSwitchCompatChange(((LayoutPlayerControllerUgcLiveLBinding) this.binding).barrageTop);
223 228 isUgc = true;
224 229 break;
225 230 }
... ... @@ -402,4 +407,15 @@ public class PlayerControllerView extends RelativeLayout implements SeekBar.OnSe
402 407  
403 408 void onSwitchRate(String rate);
404 409 }
  410 +
  411 + public interface SwitchCompatChangeListener{
  412 + void onSwitchCompatChange(SwitchCompat barrageTop);
  413 + }
  414 + private SwitchCompatChangeListener switchCompatChangeListener;
  415 + public void setonswitchCompatChangeListene(SwitchCompatChangeListener switchCompatChangeListener){
  416 + this.switchCompatChangeListener=switchCompatChangeListener;
  417 + }
  418 +
  419 +
  420 +
405 421 }
... ...
app/src/main/res/layout/cnlive_view_chat_barrage.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + android:id="@+id/chat_item_bg"
  5 + android:layout_width="wrap_content"
  6 + android:layout_height="wrap_content"
  7 + android:layout_marginTop="8dp">
  8 +
  9 + <com.cnlive.libs.util.ui.emojicon.EmojiconTextView
  10 + android:id="@+id/chat_item_name"
  11 + android:layout_width="wrap_content"
  12 + android:layout_height="wrap_content"
  13 + android:layout_centerVertical="true"
  14 + android:ellipsize="end"
  15 + android:maxEms="6"
  16 + android:singleLine="true"
  17 + android:padding="4dp"
  18 + android:textColor="#FF0000"
  19 + android:textSize="15sp"
  20 + tools:text="游客:" />
  21 +
  22 + <com.cnlive.libs.util.ui.emojicon.EmojiconTextView
  23 + android:id="@+id/chat_item_message"
  24 + android:layout_width="wrap_content"
  25 + android:layout_height="wrap_content"
  26 + android:layout_centerVertical="true"
  27 + android:padding="4dp"
  28 + android:layout_toRightOf="@id/chat_item_name"
  29 + android:singleLine="true"
  30 + android:textColor="#ffffff"
  31 + android:textSize="15sp"
  32 + tools:text="Message" />
  33 +
  34 +
  35 +</RelativeLayout>
0 36 \ No newline at end of file
... ...
app/src/main/res/layout/fragment_chat.xml
... ... @@ -31,7 +31,8 @@
31 31 android:scrollbars="none"
32 32 android:stackFromBottom="true"
33 33 android:transcriptMode="alwaysScroll"
34   - app:Adapter="@{messageAdapter}" />
  34 + app:Adapter="@{messageAdapter}"
  35 + android:layout_above="@+id/edit_layout"/>
35 36  
36 37  
37 38 <RelativeLayout
... ... @@ -80,7 +81,7 @@
80 81 android:layout_height="wrap_content"
81 82 android:layout_above="@id/edit_layout"
82 83 android:background="#979797"
83   - android:visibility="visible">
  84 + android:visibility="invisible">
84 85  
85 86 <android.support.v7.widget.RecyclerView
86 87 android:id="@+id/recycler_gift"
... ...
app/src/main/res/layout/layout_chat_input.xml 0 → 100644
  1 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2 + android:layout_width="match_parent"
  3 + android:layout_height="match_parent">
  4 +
  5 + <View
  6 + android:id="@+id/click_view"
  7 + android:layout_width="match_parent"
  8 + android:layout_height="match_parent"
  9 + android:layout_above="@+id/input_layout" />
  10 +
  11 + <ImageView
  12 + android:layout_width="match_parent"
  13 + android:layout_height="1px"
  14 + android:layout_above="@+id/input_layout"
  15 + android:background="#D5D5D5" />
  16 +
  17 + <LinearLayout
  18 + android:id="@+id/input_layout"
  19 + android:layout_width="match_parent"
  20 + android:layout_height="48dp"
  21 + android:layout_alignParentBottom="true"
  22 + android:background="@android:color/white">
  23 +
  24 + <RelativeLayout
  25 + android:layout_width="match_parent"
  26 + android:layout_height="match_parent"
  27 + android:background="@android:color/white"
  28 + android:paddingBottom="9dp"
  29 + android:paddingTop="9dp">
  30 +
  31 +
  32 + <LinearLayout
  33 + android:layout_width="match_parent"
  34 + android:layout_height="30dp"
  35 + android:layout_centerVertical="true"
  36 + android:layout_marginLeft="8dp"
  37 + android:background="#ffffff"
  38 + android:orientation="horizontal">
  39 +
  40 + <EditText
  41 + android:id="@+id/chat_content"
  42 + android:layout_width="match_parent"
  43 + android:layout_height="match_parent"
  44 + android:background="@null"
  45 + android:gravity="center_vertical"
  46 + android:hint="请输入聊天内容"
  47 + android:imeOptions="actionSend|flagNoExtractUi"
  48 + android:inputType="textLongMessage"
  49 + android:maxLength="120"
  50 + android:paddingLeft="8dp"
  51 + android:textColor="#323333"
  52 + android:textColorHint="#c3c3c9"
  53 + android:textSize="16sp" />
  54 + </LinearLayout>
  55 +
  56 + </RelativeLayout>
  57 +
  58 + </LinearLayout>
  59 +</RelativeLayout>
... ...
user/src/main/res/drawable-xxhdpi/cnlive_chat_off.9.png 0 → 100644

182 Bytes

user/src/main/res/drawable-xxhdpi/cnlive_chat_on.9.png 0 → 100644

378 Bytes

user/src/main/res/values/styles.xml
1 1 <resources>
2 2  
  3 + <style name="animation">
  4 + <item name="android:windowEnterAnimation">@anim/pop_enter_anim</item>
  5 + <item name="android:windowExitAnimation">@anim/pop_exit_anim</item>
  6 + </style>
  7 +
  8 +
3 9  
4 10 <style name="ActionbarTitleStyle">
5 11 <item name="android:textSize">22sp</item>
... ... @@ -10,6 +16,8 @@
10 16 <item name="android:background">@drawable/list_item_selector</item>
11 17 </style>
12 18  
  19 +
  20 +
13 21 <style name="ConfigItemImageStyle">
14 22 <item name="android:layout_marginLeft">18dp</item>
15 23 <item name="android:layout_marginRight">10dp</item>
... ...