Quellcode durchsuchen

添加游戏组详情中比一比里的立即下载与next

zengjiebin vor 7 Jahren
Ursprung
Commit
af51ae41b8

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/model/entity/WebParams.java

@@ -98,7 +98,7 @@ public class WebParams implements Serializable {
     }
 
     public String getUrl() {
-        return url;
+        return url == null ? null : url.trim();
     }
 
     public String getTitle() {

+ 44 - 7
app/src/main/java/com/sheep/gamegroup/module/game/activity/ActGameGroupOrGameDetail.java

@@ -55,8 +55,10 @@ import org.afinal.simplecache.ApiKey;
 import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.Subscribe;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 
 import butterknife.BindView;
 import butterknife.OnClick;
@@ -64,6 +66,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
 import io.reactivex.schedulers.Schedulers;
 
 import static com.sheep.gamegroup.util.UMConfigUtils.Event.FIND_SHARE;
+import static com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp.PUBLIC_TAG_PREFIX_TEXTVIEW_LIST;
 
 
 /**
@@ -187,14 +190,20 @@ public class ActGameGroupOrGameDetail extends BaseActivity {
             item_gc_game_app_list_rv.setHasFixedSize(true);
             item_gc_game_app_list_rv.setNestedScrollingEnabled(false);
             item_gc_game_app_list_rv.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
-            BaseQuickAdapter baseQuickAdapter = new AdpGameGroupGameCompare(gameGroup.getApplications());
-            baseQuickAdapter.bindToRecyclerView(item_gc_game_app_list_rv);
-            baseQuickAdapter.setOnItemClickListener((adapter, view, position) -> {
-                Applications item = ListUtil.getItem(gameGroup.getApplications(), position);
-                if(item != null){
-                    Jump2View.getInstance().goEntity(item);
+            if(!ListUtil.isEmpty(gameGroup.getApplications())) {
+                for (Applications item : gameGroup.getApplications()) {
+                    applicationsMap.put(item.getDownload_link(), item);
+                    applicationsMap.put(item.getPackage_name(), item);
                 }
-            });
+                BaseQuickAdapter baseQuickAdapter = new AdpGameGroupGameCompare(gameGroup.getApplications());
+                baseQuickAdapter.bindToRecyclerView(item_gc_game_app_list_rv);
+                baseQuickAdapter.setOnItemClickListener((adapter, view, position) -> {
+                    Applications item = ListUtil.getItem(gameGroup.getApplications(), position);
+                    if (item != null) {
+                        Jump2View.getInstance().goEntity(item);
+                    }
+                });
+            }
         }
     }
 
@@ -440,14 +449,42 @@ public class ActGameGroupOrGameDetail extends BaseActivity {
         }
     };
 
+    //更新下载进度
+    private Map<String, Applications> applicationsMap = new HashMap<>();
+
+    private AbsGetDownloadListener absGetDownloadListener2 = new AbsGetDownloadListener(true) {
+        @Override
+        public String getDownloadUrl(String packageName) {
+            Applications item = applicationsMap.get(packageName);
+            return item != null ? item.getDownload_link() : null;
+        }
+
+        @Override
+        public TextView getTextView2(String packageName) {
+            return recyclerView.findViewWithTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + getDownloadUrl(packageName));
+        }
+
+        @Override
+        public TextView getTextView(String downloadUrl) {
+            return recyclerView.findViewWithTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + downloadUrl);
+        }
+
+        @Override
+        public DownloadHelper getDownloadHelper(String downloadUrl) {
+            Applications item = applicationsMap.get(downloadUrl);
+            return item != null ? item.getDownloadHelper() : null;
+        }
+    };
     @Subscribe
     public void onEventMainThread(Intent intent) {
         absGetDownloadListener.onEventMainThread(intent);
+        absGetDownloadListener2.onEventMainThread(intent);
     }
 
     @Subscribe
     public void onEventMainThread(BigEvent event) {
         absGetDownloadListener.onEventMainThread(event);
+        absGetDownloadListener2.onEventMainThread(event);
     }
 
     @Override

+ 6 - 1
app/src/main/java/com/sheep/gamegroup/module/game/adapter/AdpGameGroupGameCompare.java

@@ -27,6 +27,8 @@ public class AdpGameGroupGameCompare extends BaseQuickAdapter<Applications, Base
 
     @Override
     protected void convert(BaseViewHolder helper, Applications item) {
+        TextView item_gggc_download_tv = helper.itemView.findViewById(R.id.item_gggc_download_tv);
+        TextView item_gggc_v_line = helper.itemView.findViewById(R.id.item_gggc_v_line);
         TextView item_gggc_vip_tv = helper.itemView.findViewById(R.id.item_gggc_vip_tv);
         TextView item_gggc_name_tv = helper.itemView.findViewById(R.id.item_gggc_name_tv);
         TextView item_gggc_info_tv = helper.itemView.findViewById(R.id.item_gggc_info_tv);
@@ -35,7 +37,10 @@ public class AdpGameGroupGameCompare extends BaseQuickAdapter<Applications, Base
         View item_gggc_line = helper.itemView.findViewById(R.id.item_gggc_line);
 
         item_gggc_vip_tv.setOnClickListener(view -> Jump2View.getInstance().gotoGameVipRecharge(item));
-        ViewUtil.setVisibility2(item_gggc_vip_tv, item.hasGameDiscountId());
+        item.getFindAppHelper().updateDownloadTaskView(false, item, item_gggc_download_tv);
+        item_gggc_download_tv.setTag("PUBLIC_TAG_PREFIX_TEXTVIEW_LIST" + item.getDownload_link());
+        ViewUtil.setVisibility(item_gggc_vip_tv, item.hasGameDiscountId());
+        ViewUtil.setVisibility(item_gggc_v_line, item.hasGameDiscountId());
         ViewUtil.setText(item_gggc_name_tv, item.getGameFrom());
         ViewUtil.setText(item_gggc_info_tv, item.getSimpleInfo());
         ViewUtil.setText(item_gggc_score_tv, NumberFormatUtils.retain1(item.getScore())+"分");

+ 30 - 5
app/src/main/res/layout/item_game_group_game_compare.xml

@@ -8,22 +8,48 @@
     android:paddingEnd="16dp">
 
     <TextView
+        android:id="@+id/item_gggc_download_tv"
+        style="@style/style_vip_td_tv"
+        android:background="@drawable/selector_button_full_main"
+        android:text="下载游戏"
+        android:layout_marginEnd="@dimen/end_igggc_line"
+        android:textColor="@color/btn_color_main"
+        app:layout_constraintBottom_toTopOf="@id/item_gggc_v_line"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="@id/item_gggc_ll1" />
+
+    <View
+        android:id="@+id/item_gggc_v_line"
+        android:layout_width="1dp"
+        android:layout_height="10dp"
+        app:layout_constraintBottom_toTopOf="@id/item_gggc_vip_tv"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/item_gggc_download_tv" />
+
+    <TextView
         android:id="@+id/item_gggc_vip_tv"
         style="@style/style_vip_td_tv"
+        android:layout_marginEnd="@dimen/end_igggc_line"
+        app:layout_constraintBottom_toBottomOf="@id/item_gggc_ll2"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/item_gggc_v_line" />
+
+    <TextView
+        style="@style/style_item_end_next"
+        android:layout_width="10dp"
         app:layout_constraintBottom_toBottomOf="@id/item_gggc_ll2"
         app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toEndOf="@id/item_gggc_ll1"
         app:layout_constraintTop_toTopOf="@id/item_gggc_ll1" />
 
     <LinearLayout
         android:id="@+id/item_gggc_ll1"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
-        android:layout_marginEnd="10dp"
+        android:layout_marginEnd="110dp"
         android:gravity="center_vertical"
         android:orientation="horizontal"
         app:layout_constraintBottom_toTopOf="@id/item_gggc_ll2"
-        app:layout_constraintEnd_toStartOf="@id/item_gggc_vip_tv"
+        app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent">
 
@@ -51,11 +77,10 @@
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_marginTop="10dp"
-        android:layout_marginEnd="10dp"
         android:gravity="center_vertical"
         android:orientation="horizontal"
         app:layout_constraintBottom_toTopOf="@id/item_gggc_line"
-        app:layout_constraintEnd_toStartOf="@id/item_gggc_vip_tv"
+        app:layout_constraintEnd_toEndOf="@id/item_gggc_ll1"
         app:layout_constraintStart_toStartOf="@id/item_gggc_ll1"
         app:layout_constraintTop_toBottomOf="@id/item_gggc_ll1">
 

+ 1 - 3
app/src/main/res/values/dd_styles.xml

@@ -515,12 +515,10 @@
     </style>
     <!-- 会员通道textView 样式-->
     <style name="style_vip_td_tv">
-        <item name="android:layout_width">wrap_content</item>
+        <item name="android:layout_width">80dp</item>
         <item name="android:layout_height">30dp</item>
         <item name="android:background">@drawable/shape_vip_gradient_rectangle_15</item>
         <item name="android:gravity">center</item>
-        <item name="android:paddingStart">10dp</item>
-        <item name="android:paddingEnd">10dp</item>
         <item name="android:text">会员通道</item>
         <item name="android:textColor">#714E36</item>
         <item name="android:textSize">14sp</item>

+ 1 - 0
app/src/main/res/values/dimens.xml

@@ -7,5 +7,6 @@
 
     <dimen name="textSize1">12sp</dimen>
     <dimen name="ts_dialog_gtg_name">16sp</dimen>
+    <dimen name="end_igggc_line">20dp</dimen>
 
 </resources>