Commit 9ccd584bb70dd2a75466c8ff6ceb3bd07d1e8003

Authored by 朱显松
2 parents 97a79de3 abfdfe1a

Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/CNLiveApp

app/src/main/java/com/cnlive/gundam/main/ui/fragment/ConfigFragment.java
... ... @@ -8,7 +8,6 @@ import android.support.v4.app.Fragment;
8 8 import android.view.LayoutInflater;
9 9 import android.view.View;
10 10 import android.view.ViewGroup;
11   -import android.widget.TextView;
12 11  
13 12 import com.bumptech.glide.Glide;
14 13 import com.cnlive.gundam.R;
... ... @@ -49,8 +48,7 @@ public class ConfigFragment extends Fragment implements View.OnClickListener {
49 48 }
50 49  
51 50 private void initUI() {
52   - TextView titleText = binding.getRoot().findViewById(R.id.toobar_tv);
53   - if (titleText != null) titleText.setText("我 的");
  51 + binding.toobar.toobarTv.setText("我 的");
54 52 binding.configHeader.setOnClickListener(this);
55 53 binding.message.setOnClickListener(this);
56 54 }
... ...
app/src/main/java/com/cnlive/gundam/stream/ui/activity/StreamActivity.java
... ... @@ -103,8 +103,8 @@ public class StreamActivity extends BaseStreamActivity implements ChatConnect.Ch
103 103 showView.setChatView(false);
104 104 showView.setViewers(false);
105 105 binding.setIsShow(showView);
106   - binding.chatRecyclerView.setLayoutManager(new LinearLayoutManager(this));
107 106 chatItemList = new ArrayList<>();
  107 + initChatRoomRecycel();
108 108 timerUtil = new TimerUtil(this);
109 109  
110 110 accelerometerSensor = new AccelerometerSensor(this);
... ... @@ -123,6 +123,13 @@ public class StreamActivity extends BaseStreamActivity implements ChatConnect.Ch
123 123 orientationChange();
124 124 }
125 125  
  126 + private void initChatRoomRecycel() {
  127 + LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
  128 + linearLayoutManager.setStackFromEnd(true);
  129 + binding.chatRecyclerView.setLayoutManager(linearLayoutManager);
  130 + chatAdapter = new SimpleAdapter(this, R.layout.item_chat, com.cnlive.gundam.BR.chat);
  131 + }
  132 +
126 133 private void initData() {
127 134 activityId = getIntent().getStringExtra("activityId");
128 135 channelId = getIntent().getStringExtra("channelId");
... ... @@ -427,8 +434,10 @@ public class StreamActivity extends BaseStreamActivity implements ChatConnect.Ch
427 434 } catch (Exception e) {
428 435 e.printStackTrace();
429 436 }
430   - chatAdapter = new SimpleAdapter(this, chatItemList, R.layout.item_chat, com.cnlive.gundam.BR.chat);
  437 +
  438 + chatAdapter.addItems(chatItemList);
431 439 binding.setChatAdapter(chatAdapter);
  440 +
432 441 }
433 442  
434 443 private void getOnlinePerson() {
... ...
app/src/main/java/com/cnlive/gundam/stream/ui/adapter/SimpleAdapter.java
... ... @@ -8,6 +8,7 @@ import android.view.LayoutInflater;
8 8 import android.view.View;
9 9 import android.view.ViewGroup;
10 10  
  11 +import java.util.ArrayList;
11 12 import java.util.List;
12 13  
13 14 /**
... ... @@ -21,13 +22,18 @@ public class SimpleAdapter&lt;T&gt; extends RecyclerView.Adapter&lt;SimpleAdapter.ViewHol
21 22 private int variableId;
22 23  
23 24  
24   - public SimpleAdapter(Context mContext, List<T> activeInfoList, int layoutId, int variableId) {
  25 + public SimpleAdapter(Context mContext, int layoutId, int variableId) {
25 26 this.mContext = mContext;
26   - this.activeInfoList = activeInfoList;
  27 + if(activeInfoList==null){this.activeInfoList = new ArrayList<>();}
27 28 this.layoutId = layoutId;
28 29 this.variableId = variableId;
29 30 }
30 31  
  32 + public void addItems(List<T> items){
  33 + if(items == null) return ;
  34 + this.activeInfoList=items;
  35 + }
  36 +
31 37 @Override
32 38 public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
33 39 LayoutInflater inflater = LayoutInflater.from(parent.getContext());
... ...
app/src/main/java/com/cnlive/gundam/user/activity/LoginActivity.java
1 1 package com.cnlive.gundam.user.activity;
2 2  
3   -import android.content.Context;
4 3 import android.databinding.DataBindingUtil;
5 4 import android.os.Bundle;
6   -import android.view.MotionEvent;
7   -import android.view.View;
8   -import android.view.inputmethod.InputMethodManager;
9 5  
10 6 import com.cnlive.gundam.R;
11 7 import com.cnlive.gundam.user.auth.AccountAuthenticatorActivity;
12 8 import com.cnlive.gundam.user.fragment.LoginFragment;
13   -import com.cnlive.gundam.user.util.DevilUtil;
14 9  
15 10  
16 11 /**
... ... @@ -26,20 +21,4 @@ public class LoginActivity extends AccountAuthenticatorActivity {
26 21 getSupportFragmentManager().beginTransaction().replace(R.id.login_fragment, LoginFragment.newInstance()).commit();
27 22 }
28 23  
29   - /**
30   - * 隐藏软键盘
31   - */
32   - @Override
33   - public boolean dispatchTouchEvent(MotionEvent ev){
34   - // TODO Auto-generated method stub
35   - if(ev.getAction()== MotionEvent.ACTION_DOWN){
36   -
37   - View v=getCurrentFocus();
38   - if(DevilUtil.isShouldHideInput(v,ev)){
39   - InputMethodManager im=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
40   - DevilUtil.hideSoftInput(v.getWindowToken(),im);
41   - }
42   - }
43   - return super.dispatchTouchEvent(ev);
44   - }
45 24 }
... ...
app/src/main/java/com/cnlive/gundam/video/adpter/CommonAdapter.java
... ... @@ -12,6 +12,7 @@ import android.widget.LinearLayout;
12 12 import com.cnlive.gundam.databinding.ItemListRightBinding;
13 13 import com.cnlive.gundam.video.model.MessageContent;
14 14  
  15 +import java.util.ArrayList;
15 16 import java.util.List;
16 17  
17 18 /**
... ... @@ -29,12 +30,17 @@ public class CommonAdapter&lt;T&gt; extends BaseAdapter {
29 30 this.mContext = context;
30 31 this.layoutId = layoutId;
31 32 this.variableId = variableId;
  33 + this.mDataList= new ArrayList<>();
32 34 }
33 35  
34   - public void setDataList(List<T> dataList){
35   - this.mDataList= dataList;
  36 + public void addItems(List<T> items){
  37 + if(items == null) return ;
  38 + this.mDataList=items;
  39 + notifyDataSetChanged();
36 40 }
37 41  
  42 +
  43 +
38 44 @Override
39 45 public int getCount() { return mDataList.size(); }
40 46  
... ...
app/src/main/java/com/cnlive/gundam/video/adpter/GiftAdapter.java
... ... @@ -7,9 +7,10 @@ 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;
11 10  
12 11 import com.cnlive.gundam.R;
  12 +import com.cnlive.gundam.video.activity.PlayerActivity;
  13 +import com.cnlive.gundam.video.fragment.chat.ChatRoomFragment;
13 14 import com.cnlive.gundam.video.model.CNMessageModle;
14 15 import com.cnlive.gundam.video.model.GiftModle;
15 16 import com.cnlive.gundam.video.model.MessageInfo;
... ... @@ -52,7 +53,7 @@ public class GiftAdapter extends RecyclerView.Adapter&lt;GiftAdapter.RVHolder&gt; {
52 53 }
53 54  
54 55 @Override
55   - public void onBindViewHolder(RVHolder holder, final int position) {
  56 + public void onBindViewHolder(final RVHolder holder, final int position) {
56 57 holder.binding.setVariable(mVariableId, mDataList.get(position));
57 58 holder.binding.getRoot().findViewById(R.id.ll_item).setOnClickListener(new View.OnClickListener() {
58 59 @Override
... ... @@ -68,7 +69,10 @@ public class GiftAdapter extends RecyclerView.Adapter&lt;GiftAdapter.RVHolder&gt; {
68 69  
69 70 @Override
70 71 public void onSuccess(CNMessage message) {
71   - Toast.makeText(mContext,mDataList.get(position).getGiftMessage(),Toast.LENGTH_SHORT).show();
  72 + PlayerActivity context = (PlayerActivity) GiftAdapter.this.mContext;
  73 +
  74 + ChatRoomFragment chatRoomFragment = (ChatRoomFragment) context.getSupportFragmentManager().findFragmentByTag("chatRoomFragment");
  75 + chatRoomFragment.giftItem(position);
72 76  
73 77 }
74 78  
... ...
app/src/main/java/com/cnlive/gundam/video/fragment/chat/ChatRoomFragment.java
... ... @@ -8,11 +8,13 @@ import android.support.v4.app.Fragment;
8 8 import android.support.v7.widget.GridLayoutManager;
9 9 import android.support.v7.widget.OrientationHelper;
10 10 import android.support.v7.widget.SwitchCompat;
  11 +import android.util.Log;
11 12 import android.view.LayoutInflater;
12 13 import android.view.View;
13 14 import android.view.ViewGroup;
14 15 import android.widget.CompoundButton;
15 16 import android.widget.ImageView;
  17 +import android.widget.Toast;
16 18  
17 19 import com.bumptech.glide.Glide;
18 20 import com.cnlive.gundam.BR;
... ... @@ -43,7 +45,7 @@ import java.util.ArrayList;
43 45 */
44 46 public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback, MessageContentInfo.SendAndRecevieSucessCall {
45 47  
46   -
  48 + PlayerControllerView.SwitchCompatChangeListener switchCompatChangeListener;
47 49 private FragmentChatBinding fragmentChatBinding;
48 50 private ArrayList<GiftModle> giftArray;
49 51 private CommonAdapter<MessageContent> messageContentCommonAdapter;
... ... @@ -51,6 +53,8 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback
51 53 public SwitchCompat switchCompatBottom;
52 54 private BarrageLayout barrageLayout;
53 55 private String roomId;
  56 + private int[] imaSource;
  57 + private String[] gitName;
54 58  
55 59  
56 60 public static ChatRoomFragment newInstance(String id ) {
... ... @@ -71,7 +75,6 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback
71 75  
72 76 }
73 77  
74   - PlayerControllerView.SwitchCompatChangeListener switchCompatChangeListener;
75 78 @Override
76 79 public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
77 80 super.onViewCreated(view, savedInstanceState);
... ... @@ -126,15 +129,12 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback
126 129  
127 130 @Override
128 131 public void sentSucess(ArrayList<MessageContent> messageContents) {
129   -
130   - messageContentCommonAdapter.setDataList((messageContents));
131   - ChatRoomFragment.this.fragmentChatBinding.setMessageAdapter(messageContentCommonAdapter);
  132 + messageContentCommonAdapter.addItems((messageContents));
132 133 }
133 134  
134 135 @Override
135 136 public void receaviceSucess(ArrayList<MessageContent> messageContents) {
136   - messageContentCommonAdapter.setDataList((messageContents));
137   - ChatRoomFragment.this.fragmentChatBinding.setMessageAdapter(messageContentCommonAdapter);
  137 + messageContentCommonAdapter.addItems((messageContents));
138 138 }
139 139  
140 140  
... ... @@ -144,10 +144,6 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback
144 144 ChatUtil.disconnect(false);
145 145 }
146 146  
147   -
148   -
149   -
150   -
151 147 private void initChat() {
152 148 User activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo();
153 149 String faceurl = activeAccountInfo.getFaceurl();
... ... @@ -165,6 +161,7 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback
165 161 private void initMessageAdapter() {
166 162 if (messageContentCommonAdapter == null)
167 163 messageContentCommonAdapter = new CommonAdapter<>(getActivity(), R.layout.item_list_right, BR.user);
  164 + ChatRoomFragment.this.fragmentChatBinding.setMessageAdapter(messageContentCommonAdapter);
168 165  
169 166 }
170 167  
... ... @@ -184,13 +181,13 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback
184 181  
185 182  
186 183 private void initDate() {
187   - int[] imaSource = new int[]{R.drawable.porsch_small80, R.drawable.fighter_small80,
  184 + imaSource = new int[]{R.drawable.porsch_small80, R.drawable.fighter_small80,
188 185 R.drawable.plane_small80,
189 186 R.drawable.beer, R.drawable.chicken,
190 187 R.drawable.cucumber, R.drawable.flower,
191 188 R.drawable.hug, R.drawable.mouth,
192 189 R.drawable.ring, R.drawable.rose, R.drawable.continuous};
193   - String[] gitName = new String[]{"跑车", "歼灭机", "飞机", "啤酒",
  190 + gitName = new String[]{"跑车", "歼灭机", "飞机", "啤酒",
194 191 "小鸡", "小黄瓜", "鲜花", "抱抱", "亲吻", "戒指", "玫瑰花", "荧光棒"};
195 192 giftArray = new ArrayList<>();
196 193 for (int i = 0; i < 12; i++) {
... ... @@ -256,4 +253,15 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback
256 253 }
257 254  
258 255  
  256 + public void giftItem(int postion){
  257 + Toast.makeText(getActivity(),gitName[postion],Toast.LENGTH_SHORT).show();
  258 + Log.d("giftItem", "giftItem: " +gitName[postion]);
  259 + int i = imaSource[postion];
  260 +
  261 +
  262 +
  263 +
  264 + }
  265 +
  266 +
259 267 }
... ...
app/src/main/java/com/cnlive/gundam/video/fragment/chat/MessageContentInfo.java
... ... @@ -37,11 +37,13 @@ public class MessageContentInfo {
37 37 private String JoinType = "joinType";
38 38 private String ChatRoom = "chatRoom";
39 39 private String giftType = "giftType";
  40 + private Gson gson;
40 41  
41 42  
42 43 public void setOnReceiveAndSendListener(BarrageLayout barrageLayout, String roomID, Context context, SendAndRecevieSucessCall sendAndRecevieSucessCall) {
43 44 this.roomId = roomID;
44 45 this.mContext = context;
  46 + gson = new Gson();
45 47 this.mSendAndRecevieSucessCall = sendAndRecevieSucessCall;
46 48 mHandler = new Handler();
47 49 messageContentArrayList = new ArrayList<>();
... ... @@ -63,7 +65,7 @@ public class MessageContentInfo {
63 65 public void run() {
64 66 try {
65 67  
66   - Gson gson = new Gson();
  68 +
67 69 CNMessageModle cnMessageModle = gson.fromJson(message.getContent(), CNMessageModle.class);
68 70 String messagecontent = cnMessageModle.getMessage().getContent();
69 71 String messageType = cnMessageModle.getType();
... ... @@ -115,7 +117,6 @@ public class MessageContentInfo {
115 117  
116 118 try {
117 119  
118   - Gson gson = new Gson();
119 120 CNMessageModle cnMessageModle = gson.fromJson(message.getContent(), CNMessageModle.class);
120 121 String messagecontent = cnMessageModle.getMessage().getContent();
121 122 String messageType = cnMessageModle.getType();
... ... @@ -169,8 +170,7 @@ public class MessageContentInfo {
169 170 @Override
170 171 public void onSuccess(int what, String extra) {
171 172 CNMessageModle cnMessageModle = new CNMessageModle(JoinType, new MessageInfo("", "", "", "", ""));
172   - Gson gson2 = new Gson();
173   - String obj2 = gson2.toJson(cnMessageModle);
  173 + String obj2 = gson.toJson(cnMessageModle);
174 174 ChatUtil.sendMessage(IChat.CHATROOM, roomId, obj2, onSendMessageListener);
175 175 }
176 176  
... ...
app/src/main/res/layout/item_toolbar.xml
1 1 <?xml version="1.0" encoding="utf-8"?>
2   -<layout xmlns:android="http://schemas.android.com/apk/res/android"
3   - >
  2 +<layout xmlns:android="http://schemas.android.com/apk/res/android">
4 3  
5 4 <RelativeLayout
6 5 android:id="@+id/toobar"
7 6 android:layout_width="match_parent"
8   - android:layout_height="50dp">
  7 + android:layout_height="60dp"
  8 + >
9 9  
10   - <TextView
11   - android:id="@+id/toobar_tv"
12   - android:layout_width="wrap_content"
13   - android:layout_height="wrap_content"
14   - android:layout_centerInParent="true"
15   - android:singleLine="true"
16   - android:text="我的"
17   - android:textColor="@color/config_black_color"
18   - android:textSize="22sp" />
  10 + <TextView
  11 + android:id="@+id/toobar_tv"
  12 + android:layout_width="wrap_content"
  13 + android:layout_height="wrap_content"
  14 + android:layout_centerInParent="true"
  15 + android:singleLine="true"
  16 + android:text=""
  17 + android:textColor="@color/config_black_color"
  18 + android:textSize="22sp" />
19 19  
20   - <View
21   - android:layout_width="match_parent"
22   - android:layout_height="1px"
23   - android:paddingTop="@dimen/_20px"
24   - android:background="@color/gray_line_color" />
25   - </RelativeLayout>
  20 + <View
  21 + android:id="@+id/view"
  22 + android:layout_width="match_parent"
  23 + android:layout_height="@dimen/_10px"
  24 + android:layout_alignParentBottom="true"
  25 + android:background="@color/gray_bg" />
  26 +
  27 + <View
  28 + android:id="@+id/line"
  29 + android:layout_width="match_parent"
  30 + android:layout_height="1px"
  31 + android:layout_above="@id/view"
  32 + android:background="@color/gray_line_color" />
  33 +
  34 +
  35 + </RelativeLayout>
26 36  
27 37 </layout>
28 38 \ No newline at end of file
... ...