Commit 9c8bd7435673b9b9b5c46694317cc500eb39c1f3
1 parent
2f5d6c4f
1 添加小家音箱购买
Showing
5 changed files
with
114 additions
and
74 deletions
build.gradle
config.gradle
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/adapter/AllDeviceAdapter.java
| 1 | 1 | package com.cnlive.strike.xiaojiaspeaker.ui.adapter; |
| 2 | 2 | |
| 3 | +import android.app.Activity; | |
| 3 | 4 | import android.content.Context; |
| 4 | 5 | import android.databinding.DataBindingUtil; |
| 5 | 6 | import android.support.annotation.NonNull; |
| ... | ... | @@ -16,6 +17,7 @@ import com.cnlive.strike.xiaojiaspeaker.databinding.ListItemAllDeviceBinding; |
| 16 | 17 | import com.cnlive.strike.xiaojiaspeaker.model.AllDeviceInfo; |
| 17 | 18 | import com.cnlive.strike.xiaojiaspeaker.netWork.bean.FamilyListBean; |
| 18 | 19 | |
| 20 | +import java.lang.reflect.Method; | |
| 19 | 21 | import java.util.List; |
| 20 | 22 | |
| 21 | 23 | public class AllDeviceAdapter extends RecyclerView.Adapter { |
| ... | ... | @@ -50,6 +52,10 @@ public class AllDeviceAdapter extends RecyclerView.Adapter { |
| 50 | 52 | @Override |
| 51 | 53 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) { |
| 52 | 54 | final ListItemAllDeviceBinding binding = ((MyViewHolder) viewHolder).getBinding(); |
| 55 | + binding.tvBuyBox.setVisibility(View.GONE); | |
| 56 | + if (allDeviceInfos.size() < 1) { | |
| 57 | + binding.tvBuyBox.setVisibility(View.VISIBLE); | |
| 58 | + } | |
| 53 | 59 | if (i == allDeviceInfos.size()) { |
| 54 | 60 | //显示添加设备 |
| 55 | 61 | binding.llAdd.setVisibility(View.VISIBLE); |
| ... | ... | @@ -94,6 +100,7 @@ public class AllDeviceAdapter extends RecyclerView.Adapter { |
| 94 | 100 | this.binding = binding; |
| 95 | 101 | binding.rlRoot.setOnClickListener(this); |
| 96 | 102 | binding.llAdd.setOnClickListener(this); |
| 103 | + binding.tvBuyBox.setOnClickListener(this); | |
| 97 | 104 | } |
| 98 | 105 | |
| 99 | 106 | @Override |
| ... | ... | @@ -107,7 +114,24 @@ public class AllDeviceAdapter extends RecyclerView.Adapter { |
| 107 | 114 | onAddClickListener.onAddClick(); |
| 108 | 115 | } |
| 109 | 116 | } |
| 117 | + //买音响 | |
| 118 | + else if (R.id.tv_buy_box == view.getId()) { | |
| 119 | + invoke("com.cnlive.module.common.utils.WJJMainCallUtils", "jumpToXiaoJiaGoodsDetailActivity", | |
| 120 | + new Class[]{Activity.class}, | |
| 121 | + new Object[]{context}); | |
| 122 | + } | |
| 123 | + } | |
| 124 | + } | |
| 125 | + | |
| 126 | + private static Object invoke(String clazzName, String methodName, Class[] classs, Object[] datas) { | |
| 127 | + Object result = null; | |
| 128 | + try { | |
| 129 | + Class clazz = Class.forName(clazzName); | |
| 130 | + Method method = clazz.getMethod(methodName, classs); | |
| 131 | + result = method.invoke(null, datas); | |
| 132 | + } catch (Exception ignored) { | |
| 110 | 133 | } |
| 134 | + return result; | |
| 111 | 135 | } |
| 112 | 136 | |
| 113 | 137 | public interface OnItemClickListener { | ... | ... |
module_xiaojiaSoundBox/src/main/res/layout/list_item_all_device.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 | <layout xmlns:android="http://schemas.android.com/apk/res/android"> |
| 3 | 3 | |
| 4 | - | |
| 5 | - <FrameLayout | |
| 4 | + <LinearLayout | |
| 6 | 5 | android:layout_width="match_parent" |
| 7 | - android:layout_height="120dp" | |
| 8 | - android:background="@drawable/round_xiaojia_rectangle_bg"> | |
| 6 | + android:layout_height="wrap_content" | |
| 7 | + android:orientation="vertical"> | |
| 9 | 8 | |
| 10 | - <RelativeLayout | |
| 11 | - android:id="@+id/rl_root" | |
| 9 | + <FrameLayout | |
| 12 | 10 | android:layout_width="match_parent" |
| 13 | - android:layout_height="match_parent" | |
| 14 | - android:clickable="true" | |
| 15 | - android:focusable="true" | |
| 16 | - android:gravity="center_vertical" | |
| 17 | - android:paddingBottom="10dp"> | |
| 11 | + android:layout_height="120dp" | |
| 12 | + android:background="@drawable/round_xiaojia_rectangle_bg"> | |
| 13 | + | |
| 14 | + <RelativeLayout | |
| 15 | + android:id="@+id/rl_root" | |
| 16 | + android:layout_width="match_parent" | |
| 17 | + android:layout_height="match_parent" | |
| 18 | + android:clickable="true" | |
| 19 | + android:focusable="true" | |
| 20 | + android:gravity="center_vertical" | |
| 21 | + android:paddingBottom="10dp"> | |
| 22 | + | |
| 23 | + <ImageView | |
| 24 | + android:id="@+id/iv_bluetoothDevice_icon" | |
| 25 | + android:layout_width="70dp" | |
| 26 | + android:layout_height="70dp" | |
| 27 | + android:layout_centerVertical="true" | |
| 28 | + android:layout_marginLeft="10dp" | |
| 29 | + android:layout_marginRight="10dp" | |
| 30 | + android:layout_marginBottom="20dp" /> | |
| 18 | 31 | |
| 19 | - <ImageView | |
| 20 | - android:id="@+id/iv_bluetoothDevice_icon" | |
| 21 | - android:layout_width="70dp" | |
| 22 | - android:layout_height="70dp" | |
| 23 | - android:layout_centerVertical="true" | |
| 24 | - android:layout_marginLeft="10dp" | |
| 25 | - android:layout_marginRight="10dp" | |
| 26 | - android:layout_marginBottom="20dp" /> | |
| 27 | 32 | |
| 33 | + <LinearLayout | |
| 34 | + android:layout_width="wrap_content" | |
| 35 | + android:layout_height="match_parent" | |
| 36 | + android:layout_toLeftOf="@id/iv_arrow" | |
| 37 | + android:layout_toRightOf="@id/iv_bluetoothDevice_icon" | |
| 38 | + android:gravity="center_vertical" | |
| 39 | + android:orientation="vertical"> | |
| 40 | + | |
| 41 | + <TextView | |
| 42 | + android:id="@+id/tv_device_name" | |
| 43 | + android:layout_width="wrap_content" | |
| 44 | + android:layout_height="wrap_content" | |
| 45 | + android:layout_marginBottom="10dp" | |
| 46 | + android:ellipsize="end" | |
| 47 | + android:maxLines="1" | |
| 48 | + android:textColor="@color/color_282828" | |
| 49 | + android:textSize="17sp" | |
| 50 | + android:textStyle="bold" /> | |
| 51 | + | |
| 52 | + <TextView | |
| 53 | + android:id="@+id/tv_device_state" | |
| 54 | + android:layout_width="wrap_content" | |
| 55 | + android:layout_height="wrap_content" | |
| 56 | + android:layout_centerVertical="true" | |
| 57 | + android:layout_marginTop="10dp" | |
| 58 | + android:textColor="@color/color_999999" | |
| 59 | + android:textSize="14sp" /> | |
| 60 | + </LinearLayout> | |
| 28 | 61 | |
| 62 | + <ImageView | |
| 63 | + android:id="@+id/iv_arrow" | |
| 64 | + android:layout_width="10dp" | |
| 65 | + android:layout_height="16dp" | |
| 66 | + android:layout_alignParentRight="true" | |
| 67 | + android:layout_centerVertical="true" | |
| 68 | + android:layout_marginRight="20dp" | |
| 69 | + android:background="@drawable/icon_xiaojia_item_right_arrow" /> | |
| 70 | + | |
| 71 | + </RelativeLayout> | |
| 72 | + <!-- --> | |
| 29 | 73 | <LinearLayout |
| 30 | - android:layout_width="wrap_content" | |
| 74 | + android:id="@+id/ll_add" | |
| 75 | + android:layout_width="match_parent" | |
| 31 | 76 | android:layout_height="match_parent" |
| 32 | - android:layout_toLeftOf="@id/iv_arrow" | |
| 33 | - android:layout_toRightOf="@id/iv_bluetoothDevice_icon" | |
| 34 | - android:gravity="center_vertical" | |
| 35 | - android:orientation="vertical"> | |
| 77 | + android:gravity="center" | |
| 78 | + android:paddingBottom="10dp"> | |
| 36 | 79 | |
| 37 | - <TextView | |
| 38 | - android:id="@+id/tv_device_name" | |
| 39 | - android:layout_width="wrap_content" | |
| 40 | - android:layout_height="wrap_content" | |
| 41 | - android:layout_marginBottom="10dp" | |
| 42 | - android:ellipsize="end" | |
| 43 | - android:maxLines="1" | |
| 44 | - android:textColor="@color/color_282828" | |
| 45 | - android:textSize="17sp" | |
| 46 | - android:textStyle="bold" /> | |
| 80 | + <ImageView | |
| 81 | + android:layout_width="16dp" | |
| 82 | + android:layout_height="16dp" | |
| 83 | + android:background="@drawable/icon_xiaojia_item_add" /> | |
| 47 | 84 | |
| 48 | 85 | <TextView |
| 49 | - android:id="@+id/tv_device_state" | |
| 50 | 86 | android:layout_width="wrap_content" |
| 51 | 87 | android:layout_height="wrap_content" |
| 52 | - android:layout_centerVertical="true" | |
| 53 | - android:layout_marginTop="10dp" | |
| 54 | - android:textColor="@color/color_999999" | |
| 55 | - android:textSize="14sp" /> | |
| 88 | + android:layout_marginLeft="10dp" | |
| 89 | + android:text="添加设备" | |
| 90 | + android:textColor="@color/color_282828" | |
| 91 | + android:textSize="17sp" /> | |
| 56 | 92 | </LinearLayout> |
| 93 | + </FrameLayout> | |
| 57 | 94 | |
| 58 | - <ImageView | |
| 59 | - android:id="@+id/iv_arrow" | |
| 60 | - android:layout_width="10dp" | |
| 61 | - android:layout_height="16dp" | |
| 62 | - android:layout_alignParentRight="true" | |
| 63 | - android:layout_centerVertical="true" | |
| 64 | - android:layout_marginRight="20dp" | |
| 65 | - android:background="@drawable/icon_xiaojia_item_right_arrow" /> | |
| 66 | - | |
| 67 | - </RelativeLayout> | |
| 68 | - <!-- --> | |
| 69 | - <LinearLayout | |
| 70 | - android:id="@+id/ll_add" | |
| 71 | - android:layout_width="match_parent" | |
| 72 | - android:layout_height="match_parent" | |
| 73 | - android:gravity="center" | |
| 74 | - android:paddingBottom="10dp"> | |
| 75 | - | |
| 76 | - <ImageView | |
| 77 | - android:layout_width="16dp" | |
| 78 | - android:layout_height="16dp" | |
| 79 | - android:background="@drawable/icon_xiaojia_item_add" /> | |
| 80 | - | |
| 81 | - <TextView | |
| 82 | - android:layout_width="wrap_content" | |
| 83 | - android:layout_height="wrap_content" | |
| 84 | - android:layout_marginLeft="10dp" | |
| 85 | - android:text="添加设备" | |
| 86 | - android:textColor="@color/color_282828" | |
| 87 | - android:textSize="17sp" /> | |
| 88 | - </LinearLayout> | |
| 89 | - </FrameLayout> | |
| 90 | - | |
| 95 | + <TextView | |
| 96 | + android:id="@+id/tv_buy_box" | |
| 97 | + android:layout_width="wrap_content" | |
| 98 | + android:layout_height="wrap_content" | |
| 99 | + android:layout_gravity="center_horizontal" | |
| 100 | + android:layout_marginTop="-10dp" | |
| 101 | + android:text="@string/all_device_text" /> | |
| 102 | + </LinearLayout> | |
| 91 | 103 | </layout> |
| 92 | 104 | \ No newline at end of file | ... | ... |
module_xiaojiaSoundBox/src/main/res/values/strings.xml
| ... | ... | @@ -30,4 +30,8 @@ |
| 30 | 30 | <string name="save_bitmap_app_scan">-保存图片用网家家扫码-</string> |
| 31 | 31 | <string name="share_family">分享给家人</string> |
| 32 | 32 | <string name="change_device_no_pression_tip">您无修改权限</string> |
| 33 | + | |
| 34 | + <string name="all_device_text">没有音箱设备?点击<font color='#23D41E'> 去购买 ></font></string> | |
| 35 | + | |
| 36 | + | |
| 33 | 37 | </resources> | ... | ... |