Commit 204c4c046cd85b813d9677bdd803c3197052632f

Authored by 吴奎庆
1 parent 747e6591

处理 评论页面刷新问题 以及 聊天页面的 bug处理

app/build.gradle
... ... @@ -86,4 +86,5 @@ dependencies {
86 86 compile 'com.squareup.okhttp3:okhttp-ws:3.2.0'
87 87 compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
88 88 compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
  89 +
89 90 }
... ...
app/src/main/java/com/cnlive/gundam/main/presenter/VodDetailPresenter.java
... ... @@ -30,7 +30,7 @@ public class VodDetailPresenter {
30 30  
31 31 private CommentUtil commentUtil = new CommentUtil();
32 32  
33   - private int pageCount = 2;
  33 + private int pageCount = 10;
34 34 CommentDetailsFragment commentFragment;
35 35  
36 36 public VodDetailPresenter(CommentDetailsFragment commentFragment) {
... ...
app/src/main/java/com/cnlive/gundam/main/ui/widget/GlideCircleTransform.java 0 → 100644
  1 +package com.cnlive.gundam.main.ui.widget;
  2 +
  3 +import android.content.Context;
  4 +import android.graphics.Bitmap;
  5 +import android.graphics.BitmapShader;
  6 +import android.graphics.Canvas;
  7 +import android.graphics.Paint;
  8 +
  9 +import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
  10 +import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
  11 +
  12 +/**
  13 + * 创建:wukuiqing
  14 + * <p>
  15 + * 时间:2017/7/13
  16 + * <p>
  17 + * 描述:
  18 + */
  19 +
  20 +//圆形图片
  21 +public class GlideCircleTransform extends BitmapTransformation {
  22 + public GlideCircleTransform(Context context) {
  23 + super(context);
  24 + }
  25 +
  26 + @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
  27 + return circleCrop(pool, toTransform);
  28 + }
  29 +
  30 + private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
  31 + if (source == null) return null;
  32 +
  33 + int size = Math.min(source.getWidth(), source.getHeight());
  34 + int x = (source.getWidth() - size) / 2;
  35 + int y = (source.getHeight() - size) / 2;
  36 +
  37 +
  38 + Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
  39 +
  40 + Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
  41 + if (result == null) {
  42 + result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
  43 + }
  44 +
  45 + Canvas canvas = new Canvas(result);
  46 + Paint paint = new Paint();
  47 + paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
  48 + paint.setAntiAlias(true);
  49 + float r = size / 2f;
  50 + canvas.drawCircle(r, r, r, paint);
  51 + return result;
  52 + }
  53 +
  54 + @Override public String getId() {
  55 + return getClass().getName();
  56 + }
  57 +}
  58 +
... ...
app/src/main/java/com/cnlive/gundam/video/activity/PlayerActivity.java
... ... @@ -104,6 +104,6 @@ public class PlayerActivity extends AppCompatActivity {
104 104 @Override
105 105 protected void onDestroy() {
106 106 super.onDestroy();
107   - EventBus.getDefault().unregister(this);
  107 +
108 108 }
109 109 }
... ...
app/src/main/java/com/cnlive/gundam/video/adpter/CommonAdapter.java
... ... @@ -63,6 +63,7 @@ public class CommonAdapter&lt;T&gt; extends BaseAdapter {
63 63 binding = DataBindingUtil.getBinding(convertView);
64 64 }
65 65 binding.setVariable(variableId, mDataList.get(position));
  66 +
66 67 MessageContent user = (MessageContent) mDataList.get(position);
67 68  
68 69 if(((MessageContent) mDataList.get(position)).isSendInfo()){
... ...
app/src/main/java/com/cnlive/gundam/video/fragment/CommentDetailsFragment.java
... ... @@ -238,9 +238,10 @@ public class CommentDetailsFragment extends Fragment implements VodDetialView {
238 238 if (isLoad) {
239 239 binding.srvVodDetail.stopLoadingMore();
240 240 isLoad = false;
241   - } else {
242   - binding.srvVodDetail.complete();
  241 + }
243 242  
  243 + if (binding.srvVodDetail.isRefreshing()) {
  244 + binding.srvVodDetail.complete();
244 245 }
245 246 if (mDatas == null) {
246 247 binding.srvVodDetail.onNoMore("快来抢沙发喽~");
... ...
app/src/main/java/com/cnlive/gundam/video/fragment/chat/ChatRoomFragment.java
... ... @@ -8,10 +8,10 @@ import android.os.Bundle;
8 8 import android.support.annotation.NonNull;
9 9 import android.support.annotation.Nullable;
10 10 import android.support.v4.app.Fragment;
  11 +import android.support.v4.app.FragmentActivity;
11 12 import android.support.v4.content.ContextCompat;
12 13 import android.support.v7.widget.GridLayoutManager;
13 14 import android.support.v7.widget.SwitchCompat;
14   -import android.util.Log;
15 15 import android.view.LayoutInflater;
16 16 import android.view.View;
17 17 import android.view.ViewGroup;
... ... @@ -23,12 +23,14 @@ import com.cnlive.gundam.BR;
23 23 import com.cnlive.gundam.R;
24 24 import com.cnlive.gundam.databinding.FragmentChatBinding;
25 25 import com.cnlive.gundam.main.model.MsgEvent;
  26 +import com.cnlive.gundam.main.ui.widget.GlideCircleTransform;
26 27 import com.cnlive.gundam.main.ui.widget.RecyclerSpace;
27 28 import com.cnlive.gundam.main.utils.SharedPreferencesHelper;
28 29 import com.cnlive.gundam.user.auth.UserService;
29 30 import com.cnlive.gundam.user.model.User;
30 31 import com.cnlive.gundam.user.util.InputUtil;
31 32 import com.cnlive.gundam.user.util.ToastUtil;
  33 +import com.cnlive.gundam.video.activity.PlayerActivity;
32 34 import com.cnlive.gundam.video.adpter.CommonAdapter;
33 35 import com.cnlive.gundam.video.adpter.GiftAdapter;
34 36 import com.cnlive.gundam.video.barrage.BarrageBaseMessage;
... ... @@ -38,7 +40,6 @@ import com.cnlive.gundam.video.model.MessageContent;
38 40 import com.cnlive.libs.util.chat.ChatUtil;
39 41 import com.cnlive.libs.util.chat.base.IChat;
40 42 import com.cnlive.libs.util.chat.model.CNUserInfo;
41   -import com.cnlive.libs.util.data.okhttpUtil.utils.L;
42 43 import com.cnlive.libs.video.barrage.BarrageLayout;
43 44  
44 45 import org.greenrobot.eventbus.EventBus;
... ... @@ -86,11 +87,14 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback
86 87  
87 88 }
88 89  
  90 + String faceurl;
  91 +
89 92 @Override
90 93 public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
91 94 super.onViewCreated(view, savedInstanceState);
92 95 initListener();
93 96 EventBus.getDefault().register(this);
  97 + faceurl = UserService.getInstance(getActivity()).getActiveAccountInfo().getFaceurl();
94 98 initDate();
95 99 initGift();
96 100 int checkCallPhonePermission = ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_PHONE_STATE);
... ... @@ -142,12 +146,12 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback
142 146  
143 147 @BindingAdapter({"imageUrl"})
144 148 public static void loadImage(ImageView imageView, String url) {
145   - if (url == null) {
  149 + if (url == null || url.equals("")) {
146 150 // imageView.setImageResource(R.mipmap.ic_launcher);
147 151  
148   - Glide.with(imageView.getContext()).load("https://yweb0.cnliveimg.com/main/cnlive/150819151803915_969.jpg").error(R.mipmap.ic_launcher).into(imageView);
  152 + Glide.with(imageView.getContext()).load(R.mipmap.ic_launcher).bitmapTransform(new GlideCircleTransform(imageView.getContext())).error(R.mipmap.ic_launcher).into(imageView);
149 153 } else {
150   - Glide.with(imageView.getContext()).load(url).error(R.mipmap.ic_launcher).into(imageView);
  154 + Glide.with(imageView.getContext()).load(url).bitmapTransform(new GlideCircleTransform(imageView.getContext())).error(R.mipmap.ic_launcher).into(imageView);
151 155 }
152 156 }
153 157  
... ... @@ -192,7 +196,7 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback
192 196 @Override
193 197 public void onClick(View view) {
194 198 int i = View.INVISIBLE == fragmentChatBinding.rlGift.getVisibility() ? View.VISIBLE : View.INVISIBLE;
195   - SharedPreferencesHelper.getInstance(getActivity()).setValue("ishow",i);
  199 + SharedPreferencesHelper.getInstance(getActivity()).setValue("ishow", i);
196 200 fragmentChatBinding.rlGift.setVisibility(i);
197 201 }
198 202 });
... ... @@ -219,6 +223,9 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback
219 223 }
220 224 }
221 225  
  226 + /**
  227 + * 设置礼物
  228 + */
222 229 private void initGift() {
223 230 fragmentChatBinding.sendMessage.setOnClickListener(new View.OnClickListener() {
224 231  
... ... @@ -235,6 +242,9 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback
235 242  
236 243 }
237 244  
  245 + /**
  246 + * 初始化监听事件
  247 + */
238 248 private void initListener() {
239 249 barrageBottom();
240 250 initMessageAdapter();
... ... @@ -246,12 +256,17 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback
246 256 public void giftItem(int postion) {
247 257 fragmentChatBinding.rlGift.setVisibility(View.INVISIBLE);
248 258  
249   - messageContents.add(new MessageContent(messageContents.get(0).getName(), "送了" + gitName[postion] + ":", messageContents.get(0).getIcon(), false));
  259 + messageContents.add(new MessageContent(messageContents.get(0).getName(), "送了" + gitName[postion] + ":", faceurl, false));
250 260 messageContentCommonAdapter.addItems((messageContents));
251 261 }
252 262  
253 263 ArrayList<MessageContent> messageContents;
254 264  
  265 + /**
  266 + * 聊天的回调接口
  267 + *
  268 + * @param messageContents
  269 + */
255 270 @Override
256 271 public void onchat(ArrayList<MessageContent> messageContents) {
257 272 this.messageContents = messageContents;
... ... @@ -259,17 +274,29 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback
259 274  
260 275 }
261 276  
  277 + /**
  278 + * 弹幕
  279 + *
  280 + * @param barrageBaseMessage
  281 + */
262 282 @Override
263 283 public void onbarrage(BarrageBaseMessage barrageBaseMessage) {
264 284 barrageLayout.addMessage(barrageBaseMessage);
265 285 }
266 286  
267   - //在注册了的Activity中,声明处理事件的方法
  287 + //在处理礼物返回问题
  288 +
  289 +
  290 + /**
  291 + * 接收页面 {@link PlayerActivity}
  292 + *
  293 + * @param event 处理 礼物出现后activity 和fragment的返回问题.
  294 + */
268 295 @Subscribe(threadMode = ThreadMode.MAIN) //第2步:注册一个在后台线程执行的方法,用于接收事件
269 296 public void onUserEvent(MsgEvent event) {
270 297  
271 298 fragmentChatBinding.rlGift.setVisibility(View.INVISIBLE);
272   - SharedPreferencesHelper.getInstance(getActivity()).setValue("ishow",4);
  299 + SharedPreferencesHelper.getInstance(getActivity()).setValue("ishow", 4);
273 300 }
274 301  
275 302 }
... ...
app/src/main/res/color/chat_send_text.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<selector xmlns:android="http://schemas.android.com/apk/res/android">
  3 + <item android:color="#515151" android:state_selected="true" />
  4 + <item android:color="#515151" android:state_pressed="true" />
  5 + <item android:color="#515151" android:state_focused="true" />
  6 + <item android:color="#656565" />
  7 +</selector>
0 8 \ No newline at end of file
... ...
app/src/main/res/drawable-xhdpi/btn_expression_nor.png 0 → 100644

705 Bytes

app/src/main/res/drawable-xhdpi/btn_expression_sel.png 0 → 100644

682 Bytes

app/src/main/res/drawable/btn_chat_send_nor.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<shape xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:shape="rectangle">
  4 + <solid android:color="#e6e6e6" />
  5 + <corners android:radius="2dp" />
  6 + <stroke android:width="1px" android:color="#bfbfbf" android:dashWidth="1px"
  7 + android:dashGap="0dp" />
  8 +</shape>
0 9 \ No newline at end of file
... ...
app/src/main/res/drawable/btn_chat_send_sel.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<shape xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:shape="rectangle">
  4 + <solid android:color="#d2d2d2" />
  5 + <corners android:radius="2dp" />
  6 + <stroke android:width="1px" android:color="#ababab" android:dashWidth="1px"
  7 + android:dashGap="0dp" />
  8 +</shape>
0 9 \ No newline at end of file
... ...
app/src/main/res/drawable/btn_input.png 0 → 100644

1 KB

app/src/main/res/drawable/btn_send_chat_selector.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +
  3 +<selector xmlns:android="http://schemas.android.com/apk/res/android">
  4 + <item android:drawable="@drawable/btn_chat_send_sel" android:state_pressed="true" />
  5 + <item android:drawable="@drawable/btn_chat_send_nor" android:state_pressed="false" />
  6 + <item android:drawable="@drawable/btn_chat_send_nor" />
  7 +</selector>
0 8 \ No newline at end of file
... ...
app/src/main/res/drawable/edit_text.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<shape xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:shape="rectangle">
  4 + <solid android:color="#e6e6e6" />
  5 + <corners android:radius="2dp" />
  6 + <stroke android:width="1dp" android:color="#bfbfbf" android:dashWidth="1dp"
  7 + android:dashGap="0dp" />
  8 +</shape>
0 9 \ No newline at end of file
... ...
app/src/main/res/drawable/expression_face_selector.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<selector xmlns:android="http://schemas.android.com/apk/res/android">
  3 + <item android:state_pressed="true" android:drawable="@drawable/btn_expression_sel" />
  4 + <item android:state_pressed="false" android:drawable="@drawable/btn_expression_nor" />
  5 +</selector>
... ...
app/src/main/res/layout/item_list_right.xml
... ... @@ -29,9 +29,10 @@
29 29 android:paddingTop="5dp">
30 30  
31 31 <ImageView
  32 +
32 33 android:id="@+id/iv_left_user_icon"
33   - android:layout_width="wrap_content"
34   - android:layout_height="wrap_content"
  34 + android:layout_width="30dp"
  35 + android:layout_height="30dp"
35 36 android:layout_centerVertical="true"
36 37 app:imageUrl="@{user.icon}" />
37 38  
... ... @@ -46,7 +47,7 @@
46 47 android:id="@+id/tv_left_user_name"
47 48 android:layout_width="wrap_content"
48 49 android:layout_height="wrap_content"
49   - android:text="@{user.name}"
  50 + android:text='@{user.name}'
50 51 android:textColor="@android:color/white" />
51 52  
52 53 <TextView
... ... @@ -54,7 +55,7 @@
54 55 android:layout_width="wrap_content"
55 56 android:layout_height="wrap_content"
56 57 android:layout_marginTop="5dp"
57   - android:text="@{user.messaage}"
  58 + android:text='@{user.messaage}'
58 59 android:textColor="@android:color/white" />
59 60 </LinearLayout>
60 61  
... ... @@ -93,8 +94,8 @@
93 94  
94 95 <ImageView
95 96 android:layout_gravity="center_vertical"
96   - android:layout_width="wrap_content"
97   - android:layout_height="wrap_content"
  97 + android:layout_width="30dp"
  98 + android:layout_height="30dp"
98 99 app:imageUrl="@{user.icon}"
99 100 />
100 101  
... ...
app/src/main/res/layout/layout_input.xml 0 → 100644
  1 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:emojicon="http://schemas.android.com/apk/res-auto"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="48dp"
  5 + android:background="@android:color/white">
  6 +
  7 + <ImageView
  8 + android:layout_width="match_parent"
  9 + android:layout_height="1px"
  10 + android:background="@color/main_tab_spinner_line_color" />
  11 +
  12 + <ImageView
  13 + android:id="@+id/emoticons_button"
  14 + android:layout_width="30dp"
  15 + android:layout_height="30dp"
  16 + android:layout_centerVertical="true"
  17 + android:layout_marginLeft="8dp"
  18 + android:src="@drawable/expression_face_selector" />
  19 +
  20 +
  21 + <LinearLayout
  22 + android:layout_width="match_parent"
  23 + android:layout_height="30dp"
  24 + android:layout_centerVertical="true"
  25 + android:layout_marginLeft="8dp"
  26 + android:layout_toLeftOf="@+id/post_button"
  27 + android:layout_toRightOf="@+id/emoticons_button"
  28 + android:background="@drawable/edit_text"
  29 + android:orientation="horizontal">
  30 +
  31 +
  32 + <EditText
  33 + android:id="@+id/chat_content"
  34 + android:layout_width="match_parent"
  35 + android:layout_height="match_parent"
  36 + android:background="@null"
  37 + android:gravity="center_vertical"
  38 + android:hint="@string/input_button_text"
  39 + android:imeOptions="actionSend"
  40 + android:inputType="textLongMessage"
  41 + android:maxLength="120"
  42 + android:paddingLeft="8dp"
  43 + android:textColor="@color/text_input_color"
  44 + android:textColorHint="@color/text_hint_color"
  45 + android:textSize="16sp"
  46 + />
  47 + </LinearLayout>
  48 +
  49 +
  50 + <TextView
  51 + android:id="@+id/post_button"
  52 + android:layout_width="50dp"
  53 + android:layout_height="30dp"
  54 + android:layout_alignParentRight="true"
  55 + android:layout_centerVertical="true"
  56 + android:layout_marginLeft="8dp"
  57 + android:layout_marginRight="8dp"
  58 + android:background="@drawable/btn_send_chat_selector"
  59 + android:gravity="center"
  60 + android:text="发送"
  61 + android:textColor="@color/chat_send_text"
  62 + android:textSize="16sp" />
  63 +
  64 +</RelativeLayout>
0 65 \ No newline at end of file
... ...
app/src/main/res/values/colors.xml
... ... @@ -28,4 +28,6 @@
28 28 <color name="color_text_normal_999">#999</color>
29 29 <color name="color_cutline_ececec">#ececec</color>
30 30 <color name="color_9d9d9d">#9d9d9d</color>
  31 +
  32 + <color name="main_tab_spinner_line_color">#D5D5D5</color>
31 33 </resources>
... ...