Commit b5c673a55b906146ffe3c76ec1e84faa30eec6fd
1 parent
025af0a4
工程整理
Showing
13 changed files
with
40 additions
and
80 deletions
app/libs/libcnliveutil.jar
No preview for this file type
app/src/main/java/com/cnlive/gundam/user/util/InputUtil.java
| @@ -75,7 +75,7 @@ public class InputUtil { | @@ -75,7 +75,7 @@ public class InputUtil { | ||
| 75 | } | 75 | } |
| 76 | if(sendCommentCallBack!=null){ | 76 | if(sendCommentCallBack!=null){ |
| 77 | if (TextUtils.isEmpty(mMsgEditText.getText())) { | 77 | if (TextUtils.isEmpty(mMsgEditText.getText())) { |
| 78 | - ToastUtil.showToast(mContext, "不能发送空消息呦~"); | 78 | + ToastUtil.show(mContext, "不能发送空消息呦~"); |
| 79 | } else { | 79 | } else { |
| 80 | sendCommentCallBack.sendComment(mMsgEditText.getText().toString()); | 80 | sendCommentCallBack.sendComment(mMsgEditText.getText().toString()); |
| 81 | mMsgEditText.setText(""); | 81 | mMsgEditText.setText(""); |
| @@ -130,7 +130,7 @@ public class InputUtil { | @@ -130,7 +130,7 @@ public class InputUtil { | ||
| 130 | //发送聊天室消息 | 130 | //发送聊天室消息 |
| 131 | if(mSendCallback!=null){ | 131 | if(mSendCallback!=null){ |
| 132 | if (TextUtils.isEmpty(mMsgEditText.getText())) { | 132 | if (TextUtils.isEmpty(mMsgEditText.getText())) { |
| 133 | - ToastUtil.showToast(mContext, "不能发送空消息呦~"); | 133 | + ToastUtil.show(mContext, "不能发送空消息呦~"); |
| 134 | } else { | 134 | } else { |
| 135 | mSendCallback.sendMessage(mGson.toJson(new CNMessageModle("chatRoom",new MessageInfo("","","","",mMsgEditText.getText().toString())))); | 135 | mSendCallback.sendMessage(mGson.toJson(new CNMessageModle("chatRoom",new MessageInfo("","","","",mMsgEditText.getText().toString())))); |
| 136 | mMsgEditText.setText(""); | 136 | mMsgEditText.setText(""); |
app/src/main/java/com/cnlive/gundam/user/util/ToastUtil.java
| @@ -11,15 +11,12 @@ import android.widget.Toast; | @@ -11,15 +11,12 @@ import android.widget.Toast; | ||
| 11 | import com.cnlive.gundam.R; | 11 | import com.cnlive.gundam.R; |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | - | ||
| 15 | /** | 14 | /** |
| 16 | * Created by xiansong on 2016/12/12. | 15 | * Created by xiansong on 2016/12/12. |
| 17 | */ | 16 | */ |
| 18 | 17 | ||
| 19 | public class ToastUtil { | 18 | public class ToastUtil { |
| 20 | - private static Toast toast; | ||
| 21 | - | ||
| 22 | - private static long back_pressed; | 19 | + private static long showTime; |
| 23 | private static String show_msg = ""; | 20 | private static String show_msg = ""; |
| 24 | private static Toast current_toast; | 21 | private static Toast current_toast; |
| 25 | private static final int TOAST_LAYOUT_ID = R.layout.test_layout_toast; | 22 | private static final int TOAST_LAYOUT_ID = R.layout.test_layout_toast; |
| @@ -29,45 +26,29 @@ public class ToastUtil { | @@ -29,45 +26,29 @@ public class ToastUtil { | ||
| 29 | } | 26 | } |
| 30 | 27 | ||
| 31 | public static Toast show(Context context, String msg) { | 28 | public static Toast show(Context context, String msg) { |
| 32 | -// if (!ShockwaveApplication.appOnline) | ||
| 33 | -// return; | ||
| 34 | - hide(); | ||
| 35 | if (null == context || TextUtils.isEmpty(msg)) | 29 | if (null == context || TextUtils.isEmpty(msg)) |
| 36 | return null; | 30 | return null; |
| 37 | - if (back_pressed + 2000 < System.currentTimeMillis() || !show_msg.equals(msg)) { | 31 | + if (showTime + 2000 < System.currentTimeMillis() || !show_msg.equals(msg)) { |
| 38 | hideToast(); | 32 | hideToast(); |
| 39 | - show_msg = msg; | ||
| 40 | - toast = new Toast(context); | 33 | + |
| 41 | View view = LayoutInflater.from(context).inflate(TOAST_LAYOUT_ID, null, false); | 34 | View view = LayoutInflater.from(context).inflate(TOAST_LAYOUT_ID, null, false); |
| 35 | + | ||
| 42 | ImageView imageView = view.findViewById(R.id.image); | 36 | ImageView imageView = view.findViewById(R.id.image); |
| 43 | - TextView textView = view.findViewById(R.id.text); | ||
| 44 | imageView.setVisibility(View.GONE); | 37 | imageView.setVisibility(View.GONE); |
| 45 | 38 | ||
| 39 | + TextView textView = view.findViewById(R.id.text); | ||
| 46 | textView.setText(msg); | 40 | textView.setText(msg); |
| 41 | + | ||
| 42 | + Toast toast = new Toast(context); | ||
| 47 | toast.setDuration(Toast.LENGTH_SHORT); | 43 | toast.setDuration(Toast.LENGTH_SHORT); |
| 48 | toast.setView(view); | 44 | toast.setView(view); |
| 49 | toast.show(); | 45 | toast.show(); |
| 50 | - current_toast = toast; | ||
| 51 | - } | ||
| 52 | - back_pressed = System.currentTimeMillis(); | ||
| 53 | - return toast; | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - public static boolean checkNetwork(Context context) { | ||
| 57 | - if (context == null) return false; | ||
| 58 | - if (NetworkUtil.isConnectInternet(context.getApplicationContext())) { | ||
| 59 | - return true; | ||
| 60 | - } else { | ||
| 61 | - show(context.getApplicationContext(), context.getString(R.string.net_connect_toast)); | ||
| 62 | - return false; | ||
| 63 | - } | ||
| 64 | - } | ||
| 65 | 46 | ||
| 66 | - public static void showToast(Context context, String text) { | ||
| 67 | - show(context,text); | 47 | + show_msg = msg; |
| 48 | + current_toast = toast; | ||
| 49 | + showTime = System.currentTimeMillis(); | ||
| 50 | + return toast; | ||
| 51 | + } else return null; | ||
| 68 | } | 52 | } |
| 69 | 53 | ||
| 70 | - public static void hide() { | ||
| 71 | - if (toast != null) toast.cancel(); | ||
| 72 | - } | ||
| 73 | } | 54 | } |
app/src/main/java/com/cnlive/gundam/video/adpter/GiftAdapter.java
| @@ -32,15 +32,14 @@ public class GiftAdapter extends RecyclerView.Adapter<GiftAdapter.RVHolder> { | @@ -32,15 +32,14 @@ public class GiftAdapter extends RecyclerView.Adapter<GiftAdapter.RVHolder> { | ||
| 32 | private List<GiftModle> mDataList; | 32 | private List<GiftModle> mDataList; |
| 33 | private int mLayoutId; // 条目布局文件ID | 33 | private int mLayoutId; // 条目布局文件ID |
| 34 | private int mVariableId; // DataBinding变量ID | 34 | private int mVariableId; // DataBinding变量ID |
| 35 | - private String roomId; | ||
| 36 | - public GiftAdapter(String roomId,Context context, List<GiftModle> list, int layoutId, int variableId) { | 35 | + private String roomId; |
| 36 | + | ||
| 37 | + public GiftAdapter(String roomId, Context context, List<GiftModle> list, int layoutId, int variableId) { | ||
| 37 | this.mContext = context; | 38 | this.mContext = context; |
| 38 | this.mDataList = list; | 39 | this.mDataList = list; |
| 39 | this.mLayoutId = layoutId; | 40 | this.mLayoutId = layoutId; |
| 40 | - mVariableId = variableId; | ||
| 41 | - this.roomId=roomId; | ||
| 42 | - | ||
| 43 | - | 41 | + this.mVariableId = variableId; |
| 42 | + this.roomId = roomId; | ||
| 44 | } | 43 | } |
| 45 | 44 | ||
| 46 | 45 | ||
| @@ -58,9 +57,9 @@ public class GiftAdapter extends RecyclerView.Adapter<GiftAdapter.RVHolder> { | @@ -58,9 +57,9 @@ public class GiftAdapter extends RecyclerView.Adapter<GiftAdapter.RVHolder> { | ||
| 58 | holder.binding.getRoot().findViewById(R.id.ll_item).setOnClickListener(new View.OnClickListener() { | 57 | holder.binding.getRoot().findViewById(R.id.ll_item).setOnClickListener(new View.OnClickListener() { |
| 59 | @Override | 58 | @Override |
| 60 | public void onClick(View v) { | 59 | public void onClick(View v) { |
| 61 | - CNMessageModle cnMessageModle = new CNMessageModle("giftType",new MessageInfo("0",mDataList.get(position).getGiftMessage(),"1","0",mDataList.get(position).getGiftMessage())); | ||
| 62 | - Gson gson2=new Gson(); | ||
| 63 | - String obj2=gson2.toJson(cnMessageModle); | 60 | + CNMessageModle cnMessageModle = new CNMessageModle("giftType", new MessageInfo("0", mDataList.get(position).getGiftMessage(), "1", "0", mDataList.get(position).getGiftMessage())); |
| 61 | + Gson gson2 = new Gson(); | ||
| 62 | + String obj2 = gson2.toJson(cnMessageModle); | ||
| 64 | ChatUtil.sendMessage(IChat.CHATROOM, roomId, obj2, new IChat.OnSendMessageListener() { | 63 | ChatUtil.sendMessage(IChat.CHATROOM, roomId, obj2, new IChat.OnSendMessageListener() { |
| 65 | @Override | 64 | @Override |
| 66 | public void onAttached(CNMessage message) { | 65 | public void onAttached(CNMessage message) { |
app/src/main/java/com/cnlive/gundam/video/fragment/chat/ChatRoomFragment.java
| @@ -6,7 +6,6 @@ import android.os.Bundle; | @@ -6,7 +6,6 @@ import android.os.Bundle; | ||
| 6 | import android.support.annotation.Nullable; | 6 | import android.support.annotation.Nullable; |
| 7 | import android.support.v4.app.Fragment; | 7 | import android.support.v4.app.Fragment; |
| 8 | import android.support.v7.widget.GridLayoutManager; | 8 | import android.support.v7.widget.GridLayoutManager; |
| 9 | -import android.support.v7.widget.OrientationHelper; | ||
| 10 | import android.support.v7.widget.SwitchCompat; | 9 | import android.support.v7.widget.SwitchCompat; |
| 11 | import android.view.LayoutInflater; | 10 | import android.view.LayoutInflater; |
| 12 | import android.view.View; | 11 | import android.view.View; |
| @@ -81,8 +80,6 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | @@ -81,8 +80,6 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | ||
| 81 | initDate(); | 80 | initDate(); |
| 82 | initGift(); | 81 | initGift(); |
| 83 | initChat(); | 82 | initChat(); |
| 84 | - | ||
| 85 | - | ||
| 86 | } | 83 | } |
| 87 | 84 | ||
| 88 | 85 | ||
| @@ -171,8 +168,7 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | @@ -171,8 +168,7 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | ||
| 171 | fragmentChatBinding.rlGift.setVisibility(i); | 168 | fragmentChatBinding.rlGift.setVisibility(i); |
| 172 | } | 169 | } |
| 173 | }); | 170 | }); |
| 174 | - GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2); | ||
| 175 | - gridLayoutManager.setOrientation(OrientationHelper.HORIZONTAL); | 171 | + GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 6); |
| 176 | fragmentChatBinding.recyclerGift.setLayoutManager(gridLayoutManager); | 172 | fragmentChatBinding.recyclerGift.setLayoutManager(gridLayoutManager); |
| 177 | fragmentChatBinding.setGiftAdapter(new GiftAdapter(roomId, getActivity(), giftArray, R.layout.fragment_gift_receycel, BR.dataBean)); | 173 | fragmentChatBinding.setGiftAdapter(new GiftAdapter(roomId, getActivity(), giftArray, R.layout.fragment_gift_receycel, BR.dataBean)); |
| 178 | } | 174 | } |
app/src/main/res/drawable-hdpi/tab_bar_bg.9.png
app/src/main/res/drawable-mdpi/tab_bar_bg.9.png
app/src/main/res/drawable-xhdpi/tab_bar_bg.9.png
app/src/main/res/drawable-xxhdpi/tab_bar_bg.9.png
app/src/main/res/drawable-xxxhdpi/tab_bar_bg.9.png
app/src/main/res/drawable-xxhdpi/toolbar_bg.9.png renamed to app/src/main/res/drawable/toolbar_bg.9.png
94 Bytes
app/src/main/res/layout/fragment_chat.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <layout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <layout xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | - xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 4 | - > | 3 | + xmlns:app="http://schemas.android.com/apk/res-auto"> |
| 5 | 4 | ||
| 6 | <data> | 5 | <data> |
| 7 | 6 | ||
| 8 | <variable | 7 | <variable |
| 9 | name="messageAdapter" | 8 | name="messageAdapter" |
| 10 | type="com.cnlive.gundam.video.adpter.CommonAdapter" /> | 9 | type="com.cnlive.gundam.video.adpter.CommonAdapter" /> |
| 11 | - | 10 | + |
| 12 | <variable | 11 | <variable |
| 13 | name="giftAdapter" | 12 | name="giftAdapter" |
| 14 | type="com.cnlive.gundam.video.adpter.GiftAdapter" /> | 13 | type="com.cnlive.gundam.video.adpter.GiftAdapter" /> |
| @@ -25,14 +24,14 @@ | @@ -25,14 +24,14 @@ | ||
| 25 | android:id="@+id/list_message" | 24 | android:id="@+id/list_message" |
| 26 | android:layout_width="match_parent" | 25 | android:layout_width="match_parent" |
| 27 | android:layout_height="match_parent" | 26 | android:layout_height="match_parent" |
| 27 | + android:layout_above="@+id/edit_layout" | ||
| 28 | android:layout_alignParentLeft="true" | 28 | android:layout_alignParentLeft="true" |
| 29 | android:layout_alignParentStart="true" | 29 | android:layout_alignParentStart="true" |
| 30 | android:divider="@null" | 30 | android:divider="@null" |
| 31 | android:scrollbars="none" | 31 | android:scrollbars="none" |
| 32 | android:stackFromBottom="true" | 32 | android:stackFromBottom="true" |
| 33 | android:transcriptMode="alwaysScroll" | 33 | android:transcriptMode="alwaysScroll" |
| 34 | - app:Adapter="@{messageAdapter}" | ||
| 35 | - android:layout_above="@+id/edit_layout"/> | 34 | + app:Adapter="@{messageAdapter}" /> |
| 36 | 35 | ||
| 37 | 36 | ||
| 38 | <RelativeLayout | 37 | <RelativeLayout |
| @@ -87,8 +86,7 @@ | @@ -87,8 +86,7 @@ | ||
| 87 | android:id="@+id/recycler_gift" | 86 | android:id="@+id/recycler_gift" |
| 88 | android:layout_width="match_parent" | 87 | android:layout_width="match_parent" |
| 89 | android:layout_height="wrap_content" | 88 | android:layout_height="wrap_content" |
| 90 | - app:adapter="@{giftAdapter}" | ||
| 91 | - /> | 89 | + app:adapter="@{giftAdapter}" /> |
| 92 | 90 | ||
| 93 | </RelativeLayout> | 91 | </RelativeLayout> |
| 94 | 92 |
app/src/main/res/layout/fragment_gift_receycel.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | 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 | ||
| 6 | <data> | 5 | <data> |
| @@ -10,40 +9,27 @@ | @@ -10,40 +9,27 @@ | ||
| 10 | type="com.cnlive.gundam.video.model.GiftModle" /> | 9 | type="com.cnlive.gundam.video.model.GiftModle" /> |
| 11 | </data> | 10 | </data> |
| 12 | 11 | ||
| 13 | - <LinearLayout | 12 | + <RelativeLayout |
| 14 | android:id="@+id/ll_item" | 13 | 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"> | 14 | + android:layout_width="match_parent" |
| 15 | + android:layout_height="wrap_content"> | ||
| 20 | 16 | ||
| 21 | <ImageView | 17 | <ImageView |
| 22 | android:id="@+id/avaimg" | 18 | android:id="@+id/avaimg" |
| 23 | android:layout_width="40dp" | 19 | android:layout_width="40dp" |
| 24 | android:layout_height="40dp" | 20 | android:layout_height="40dp" |
| 25 | android:src="@{dataBean.imgSource}" | 21 | android:src="@{dataBean.imgSource}" |
| 26 | - /> | 22 | + android:layout_centerHorizontal="true"/> |
| 27 | 23 | ||
| 28 | - <RelativeLayout | 24 | + <TextView |
| 29 | android:layout_width="wrap_content" | 25 | 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 | - | 26 | + android:layout_height="wrap_content" |
| 27 | + android:layout_centerHorizontal="true" | ||
| 28 | + android:layout_below="@+id/avaimg" | ||
| 29 | + android:text="@{dataBean.giftMessage}" | ||
| 30 | + android:textColor="@android:color/white" /> | ||
| 45 | 31 | ||
| 46 | - </LinearLayout> | 32 | + </RelativeLayout> |
| 47 | 33 | ||
| 48 | 34 | ||
| 49 | </layout> | 35 | </layout> |
| 50 | \ No newline at end of file | 36 | \ No newline at end of file |