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 | 75 | } |
| 76 | 76 | if(sendCommentCallBack!=null){ |
| 77 | 77 | if (TextUtils.isEmpty(mMsgEditText.getText())) { |
| 78 | - ToastUtil.showToast(mContext, "不能发送空消息呦~"); | |
| 78 | + ToastUtil.show(mContext, "不能发送空消息呦~"); | |
| 79 | 79 | } else { |
| 80 | 80 | sendCommentCallBack.sendComment(mMsgEditText.getText().toString()); |
| 81 | 81 | mMsgEditText.setText(""); |
| ... | ... | @@ -130,7 +130,7 @@ public class InputUtil { |
| 130 | 130 | //发送聊天室消息 |
| 131 | 131 | if(mSendCallback!=null){ |
| 132 | 132 | if (TextUtils.isEmpty(mMsgEditText.getText())) { |
| 133 | - ToastUtil.showToast(mContext, "不能发送空消息呦~"); | |
| 133 | + ToastUtil.show(mContext, "不能发送空消息呦~"); | |
| 134 | 134 | } else { |
| 135 | 135 | mSendCallback.sendMessage(mGson.toJson(new CNMessageModle("chatRoom",new MessageInfo("","","","",mMsgEditText.getText().toString())))); |
| 136 | 136 | mMsgEditText.setText(""); | ... | ... |
app/src/main/java/com/cnlive/gundam/user/util/ToastUtil.java
| ... | ... | @@ -11,15 +11,12 @@ import android.widget.Toast; |
| 11 | 11 | import com.cnlive.gundam.R; |
| 12 | 12 | |
| 13 | 13 | |
| 14 | - | |
| 15 | 14 | /** |
| 16 | 15 | * Created by xiansong on 2016/12/12. |
| 17 | 16 | */ |
| 18 | 17 | |
| 19 | 18 | public class ToastUtil { |
| 20 | - private static Toast toast; | |
| 21 | - | |
| 22 | - private static long back_pressed; | |
| 19 | + private static long showTime; | |
| 23 | 20 | private static String show_msg = ""; |
| 24 | 21 | private static Toast current_toast; |
| 25 | 22 | private static final int TOAST_LAYOUT_ID = R.layout.test_layout_toast; |
| ... | ... | @@ -29,45 +26,29 @@ public class ToastUtil { |
| 29 | 26 | } |
| 30 | 27 | |
| 31 | 28 | public static Toast show(Context context, String msg) { |
| 32 | -// if (!ShockwaveApplication.appOnline) | |
| 33 | -// return; | |
| 34 | - hide(); | |
| 35 | 29 | if (null == context || TextUtils.isEmpty(msg)) |
| 36 | 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 | 32 | hideToast(); |
| 39 | - show_msg = msg; | |
| 40 | - toast = new Toast(context); | |
| 33 | + | |
| 41 | 34 | View view = LayoutInflater.from(context).inflate(TOAST_LAYOUT_ID, null, false); |
| 35 | + | |
| 42 | 36 | ImageView imageView = view.findViewById(R.id.image); |
| 43 | - TextView textView = view.findViewById(R.id.text); | |
| 44 | 37 | imageView.setVisibility(View.GONE); |
| 45 | 38 | |
| 39 | + TextView textView = view.findViewById(R.id.text); | |
| 46 | 40 | textView.setText(msg); |
| 41 | + | |
| 42 | + Toast toast = new Toast(context); | |
| 47 | 43 | toast.setDuration(Toast.LENGTH_SHORT); |
| 48 | 44 | toast.setView(view); |
| 49 | 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 | 32 | private List<GiftModle> mDataList; |
| 33 | 33 | private int mLayoutId; // 条目布局文件ID |
| 34 | 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 | 38 | this.mContext = context; |
| 38 | 39 | this.mDataList = list; |
| 39 | 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 | 57 | holder.binding.getRoot().findViewById(R.id.ll_item).setOnClickListener(new View.OnClickListener() { |
| 59 | 58 | @Override |
| 60 | 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 | 63 | ChatUtil.sendMessage(IChat.CHATROOM, roomId, obj2, new IChat.OnSendMessageListener() { |
| 65 | 64 | @Override |
| 66 | 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 | 6 | import android.support.annotation.Nullable; |
| 7 | 7 | import android.support.v4.app.Fragment; |
| 8 | 8 | import android.support.v7.widget.GridLayoutManager; |
| 9 | -import android.support.v7.widget.OrientationHelper; | |
| 10 | 9 | import android.support.v7.widget.SwitchCompat; |
| 11 | 10 | import android.view.LayoutInflater; |
| 12 | 11 | import android.view.View; |
| ... | ... | @@ -81,8 +80,6 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback |
| 81 | 80 | initDate(); |
| 82 | 81 | initGift(); |
| 83 | 82 | initChat(); |
| 84 | - | |
| 85 | - | |
| 86 | 83 | } |
| 87 | 84 | |
| 88 | 85 | |
| ... | ... | @@ -171,8 +168,7 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback |
| 171 | 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 | 172 | fragmentChatBinding.recyclerGift.setLayoutManager(gridLayoutManager); |
| 177 | 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 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 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 | 5 | <data> |
| 7 | 6 | |
| 8 | 7 | <variable |
| 9 | 8 | name="messageAdapter" |
| 10 | 9 | type="com.cnlive.gundam.video.adpter.CommonAdapter" /> |
| 11 | - | |
| 10 | + | |
| 12 | 11 | <variable |
| 13 | 12 | name="giftAdapter" |
| 14 | 13 | type="com.cnlive.gundam.video.adpter.GiftAdapter" /> |
| ... | ... | @@ -25,14 +24,14 @@ |
| 25 | 24 | android:id="@+id/list_message" |
| 26 | 25 | android:layout_width="match_parent" |
| 27 | 26 | android:layout_height="match_parent" |
| 27 | + android:layout_above="@+id/edit_layout" | |
| 28 | 28 | android:layout_alignParentLeft="true" |
| 29 | 29 | android:layout_alignParentStart="true" |
| 30 | 30 | android:divider="@null" |
| 31 | 31 | android:scrollbars="none" |
| 32 | 32 | android:stackFromBottom="true" |
| 33 | 33 | android:transcriptMode="alwaysScroll" |
| 34 | - app:Adapter="@{messageAdapter}" | |
| 35 | - android:layout_above="@+id/edit_layout"/> | |
| 34 | + app:Adapter="@{messageAdapter}" /> | |
| 36 | 35 | |
| 37 | 36 | |
| 38 | 37 | <RelativeLayout |
| ... | ... | @@ -87,8 +86,7 @@ |
| 87 | 86 | android:id="@+id/recycler_gift" |
| 88 | 87 | android:layout_width="match_parent" |
| 89 | 88 | android:layout_height="wrap_content" |
| 90 | - app:adapter="@{giftAdapter}" | |
| 91 | - /> | |
| 89 | + app:adapter="@{giftAdapter}" /> | |
| 92 | 90 | |
| 93 | 91 | </RelativeLayout> |
| 94 | 92 | ... | ... |
app/src/main/res/layout/fragment_gift_receycel.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 | |
| 6 | 5 | <data> |
| ... | ... | @@ -10,40 +9,27 @@ |
| 10 | 9 | type="com.cnlive.gundam.video.model.GiftModle" /> |
| 11 | 10 | </data> |
| 12 | 11 | |
| 13 | - <LinearLayout | |
| 12 | + <RelativeLayout | |
| 14 | 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 | 17 | <ImageView |
| 22 | 18 | android:id="@+id/avaimg" |
| 23 | 19 | android:layout_width="40dp" |
| 24 | 20 | android:layout_height="40dp" |
| 25 | 21 | android:src="@{dataBean.imgSource}" |
| 26 | - /> | |
| 22 | + android:layout_centerHorizontal="true"/> | |
| 27 | 23 | |
| 28 | - <RelativeLayout | |
| 24 | + <TextView | |
| 29 | 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 | 35 | </layout> |
| 50 | 36 | \ No newline at end of file | ... | ... |