Kaynağa Gözat

fixed one task pause the other one not show progress

hanjing 6 yıl önce
ebeveyn
işleme
ae92eb0b37

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/di/modules/NetModule.java

@@ -49,8 +49,8 @@ public class NetModule {
     public Retrofit provideRetrofit(OkHttpClient okhttpClient) {
         Retrofit retrofit = new Retrofit.Builder()
                 .client(okhttpClient)
-                .baseUrl(SheepApp.getInstance().getConnectAddress().getAppUrl()+"v1/")
-//                .baseUrl("http://ss.17xmy.com/v1/")
+//                .baseUrl(SheepApp.getInstance().getConnectAddress().getAppUrl()+"v1/")
+                .baseUrl("http://ss.17xmy.com/v1/")
 //                .baseUrl("http://10.8.220.239:8080/v1/")
 //                .baseUrl("http://10.8.240.193:8080/v1/")
                 .addConverterFactory(StringConverterFactory.create())

+ 30 - 26
app/src/main/java/com/sheep/gamegroup/module/game/fragment/FgtDownloadManager.java

@@ -27,6 +27,7 @@ import com.sheep.gamegroup.model.entity.GameEntity;
 import com.sheep.gamegroup.module.game.adapter.AdpGameCenter4_3;
 import com.sheep.gamegroup.module.game.model.DownloadInfoHelper;
 import com.sheep.gamegroup.util.DownloadUtil;
+import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.view.fragment.BaseListFragment6;
 import com.sheep.jiuyan.samllsheep.R;
@@ -58,6 +59,7 @@ import static com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp.PUBLIC_TAG_PREFIX
 public class FgtDownloadManager extends BaseListFragment6<String> {
 
     private DownloadUtil downloadUtil;
+
     @Override
     public void initListener() {
         super.initListener();
@@ -66,6 +68,7 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
 
     private AbsApiRefresh<DownLoadInfo> apiRefresh;
     private NetApiRefresh<GameEntity> apiRefresh2;
+
     @Override
     protected void addApiRefresh(List<IApiRefresh> apiRefreshList) {
         tagList.add("下载游戏");
@@ -116,13 +119,15 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
         };
         apiRefreshList.add(apiRefresh2);
     }
+
     private BaseQuickAdapter<DownLoadInfo, BaseViewHolder> downLoadInfoAdapter;
     private RecyclerView.Adapter appFormGameCenterAdapter;
 
     private List<String> tagList = new ArrayList<>();
+
     @Override
     protected BaseQuickAdapter<String, BaseViewHolder> getAdapter() {
-        downLoadInfoAdapter = new BaseQuickAdapter<DownLoadInfo, BaseViewHolder>(R.layout.item_download_manager, apiRefresh.getList()){
+        downLoadInfoAdapter = new BaseQuickAdapter<DownLoadInfo, BaseViewHolder>(R.layout.item_download_manager, apiRefresh.getList()) {
             @Override
             protected void convert(BaseViewHolder helper, DownLoadInfo item) {
                 ImageView item_dm_icon_iv = helper.getView(R.id.item_dm_icon_iv);
@@ -134,8 +139,8 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
 
                 ViewUtil.setImage(item_dm_icon_iv, item.getMIconUrl());
                 ViewUtil.setText(item_dm_name_tv, item.getMGameName());
-                if(item.getMPercent() != null && item.getMPercent() == 100){
-                    if(item.getMTotalSize() == null){
+                if (item.getMPercent() != null && item.getMPercent() == 100) {
+                    if (item.getMTotalSize() == null) {
                         ViewUtil.setText(item_dm_info_tv, "全部下载完成");
                     } else {
                         ViewUtil.setText(item_dm_info_tv, String.format(Locale.CHINA, "%dMB 下载完成", (item.getMTotalSize().intValue() / (1024 * 1024))));
@@ -145,9 +150,9 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
                 }
                 item_dm_pb.setProgress(item.getMPercent() != null ? item.getMPercent() : 0);
                 item_dm_delete_iv.setOnClickListener(view -> {
-                    if(apiRefresh != null && apiRefresh.getList() != null)
+                    if (apiRefresh != null && apiRefresh.getList() != null)
                         apiRefresh.getList().remove(item);
-                    if(baseQuickAdapter != null)
+                    if (baseQuickAdapter != null)
                         baseQuickAdapter.notifyDataSetChanged();
                     Observable.create((ObservableOnSubscribe<Boolean>) emitter -> emitter.onNext(downloadUtil.deleteDownloadTask(item)))
                             .subscribeOn(Schedulers.io())
@@ -179,7 +184,7 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
                 recyclerView.setHasFixedSize(true);
                 recyclerView.setNestedScrollingEnabled(false);
                 int position = holder.getAdapterPosition();
-                switch (position){
+                switch (position) {
                     case 0:
                         ViewUtil.setVisibility(item_play_game_list_rl, !apiRefresh.getList().isEmpty());
                         recyclerView.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
@@ -196,7 +201,7 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
 
     //删除所有下载任务与文件
     public void removeAll() {
-        if(apiRefresh == null || apiRefresh.getList().isEmpty()){
+        if (apiRefresh == null || apiRefresh.getList().isEmpty()) {
             return;
         }
         Observable.just(1).map(integer -> {
@@ -217,24 +222,24 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
             }
             return integer;
         }).subscribeOn(Schedulers.io())
-        .observeOn(AndroidSchedulers.mainThread())
-        .subscribe(new AbsObserver<Integer>() {
-            @Override
-            public void onNext(Integer integer) {
-                if(apiRefresh != null){
-                    apiRefresh.clear();
-                    if(baseQuickAdapter != null){
-                        baseQuickAdapter.notifyDataSetChanged();
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new AbsObserver<Integer>() {
+                    @Override
+                    public void onNext(Integer integer) {
+                        if (apiRefresh != null) {
+                            apiRefresh.clear();
+                            if (baseQuickAdapter != null) {
+                                baseQuickAdapter.notifyDataSetChanged();
+                            }
+                        }
                     }
-                }
-            }
-        });
+                });
     }
 
 
-
     //格式化下载大小
     private DecimalFormat decimalFormat;
+
     public String strFormat(Double fileDownloadSize, Double fileTotalSize) {
         if (fileTotalSize == null) {
             return SheepApp.getInstance().getString(R.string.calculating);
@@ -242,7 +247,7 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
         if (fileDownloadSize == null) {
             return "0MB / " + (fileTotalSize.intValue() / (1024 * 1024)) + "MB";
         }
-        if(decimalFormat == null){
+        if (decimalFormat == null) {
             decimalFormat = new DecimalFormat("######0.0");
         }
         return decimalFormat.format(fileDownloadSize / (1024 * 1024)) + "MB / " + (fileTotalSize.intValue() / (1024 * 1024)) + "MB";
@@ -261,17 +266,14 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
     }
 
 
-
-
     //更新下载进度
     private Map<String, DownloadInfoHelper> downloadInfoHelperMap = new HashMap<>();
 
 
-
     //更新按钮状态与添加点击事件
     private void updateView(Activity activity, DownLoadInfo item, TextView textView) {
         DownloadInfoHelper downloadInfoHelper = downloadInfoHelperMap.get(item.getMDownloadUrl());
-        if(downloadInfoHelper == null) {
+        if (downloadInfoHelper == null) {
             downloadInfoHelper = new DownloadInfoHelper(item);
             downloadInfoHelperMap.put(item.getMDownloadUrl(), downloadInfoHelper);
             downloadInfoHelperMap.put(item.getMPackageName(), downloadInfoHelper);
@@ -332,8 +334,10 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
             @Override
             public void running(DownLoadInfo task) {
                 int position = apiRefresh.getList().indexOf(task);
-                if(position >= 0)
-                    baseQuickAdapter.notifyItemChanged(position, task);
+                if (position >= 0) {
+                    LogUtil.logI("Download progress: " + task.getMDownloadUrl());
+                    downLoadInfoAdapter.notifyItemChanged(position, task);
+                }
             }
 
             @Override

+ 2 - 2
app/src/main/java/com/sheep/jiuyan/samllsheep/Config.java

@@ -111,8 +111,8 @@ public class Config {
         initSMALL_STATION_URL();
     }
     public static void initSMALL_STATION_URL(){
-        SMALL_STATION_URL = TextUtils.equals(SheepApp.getInstance().getConnectAddress().name(), "sheep") ? SMALL_STATION_URL_SHEEP : SMALL_STATION_URL_TEST;
-//        SMALL_STATION_URL = SMALL_STATION_URL_SHEEP;
+//        SMALL_STATION_URL = TextUtils.equals(SheepApp.getInstance().getConnectAddress().name(), "sheep") ? SMALL_STATION_URL_SHEEP : SMALL_STATION_URL_TEST;
+        SMALL_STATION_URL = SMALL_STATION_URL_SHEEP;
     }
     public static String getUrlByPath(String path, Object...query){
         String url = SMALL_STATION_URL + path;