|
@@ -1,15 +1,17 @@
|
|
|
package com.sheep.gamegroup.module.game.fragment;
|
|
package com.sheep.gamegroup.module.game.fragment;
|
|
|
|
|
|
|
|
|
|
+import static com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp.PUBLIC_TAG_PREFIX_TEXTVIEW_LIST;
|
|
|
|
|
+
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
-import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
|
-import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
-
|
|
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
-import android.widget.ImageView;
|
|
|
|
|
import android.widget.ProgressBar;
|
|
import android.widget.ProgressBar;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
+import androidx.recyclerview.widget.DividerItemDecoration;
|
|
|
|
|
+import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
|
+import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
+
|
|
|
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
|
import com.chad.library.adapter.base.BaseViewHolder;
|
|
import com.chad.library.adapter.base.BaseViewHolder;
|
|
|
import com.liulishuo.okdownload.OkDownload;
|
|
import com.liulishuo.okdownload.OkDownload;
|
|
@@ -33,6 +35,8 @@ import com.sheep.gamegroup.util.ViewUtil;
|
|
|
import com.sheep.gamegroup.view.fragment.BaseListFragment6;
|
|
import com.sheep.gamegroup.view.fragment.BaseListFragment6;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
|
|
+import com.sheep.jiuyan.samllsheep.databinding.ItemDownloadManagerBinding;
|
|
|
|
|
+import com.sheep.jiuyan.samllsheep.databinding.ItemPlayGameListBinding;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
|
|
import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
|
|
|
|
|
|
|
|
import org.afinal.simplecache.ApiKey;
|
|
import org.afinal.simplecache.ApiKey;
|
|
@@ -50,8 +54,6 @@ import io.reactivex.ObservableOnSubscribe;
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
|
|
|
|
|
-import static com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp.PUBLIC_TAG_PREFIX_TEXTVIEW_LIST;
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Created by realicing on 2019/1/21.
|
|
* Created by realicing on 2019/1/21.
|
|
|
* realicing@sina.com
|
|
* realicing@sina.com
|
|
@@ -131,26 +133,20 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
|
|
|
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
|
|
@Override
|
|
|
protected void convert(BaseViewHolder helper, DownLoadInfo item) {
|
|
protected void convert(BaseViewHolder helper, DownLoadInfo item) {
|
|
|
- ImageView item_dm_icon_iv = helper.getView(R.id.item_dm_icon_iv);
|
|
|
|
|
- TextView item_dm_name_tv = helper.getView(R.id.item_dm_name_tv);
|
|
|
|
|
- TextView item_dm_info_tv = helper.getView(R.id.item_dm_info_tv);
|
|
|
|
|
- ProgressBar item_dm_pb = helper.getView(R.id.item_dm_pb);
|
|
|
|
|
- ImageView item_dm_delete_iv = helper.getView(R.id.item_dm_delete_iv);
|
|
|
|
|
- TextView item_dm_btn_tv = helper.getView(R.id.item_dm_btn_tv);
|
|
|
|
|
-
|
|
|
|
|
- ViewUtil.setImage(item_dm_icon_iv, item.getMIconUrl());
|
|
|
|
|
- ViewUtil.setText(item_dm_name_tv, item.getMGameName());
|
|
|
|
|
|
|
+ ItemDownloadManagerBinding binding = ItemDownloadManagerBinding.bind(helper.itemView);
|
|
|
|
|
+ ViewUtil.setImage(binding.itemDmIconIv, item.getMIconUrl());
|
|
|
|
|
+ ViewUtil.setText(binding.itemDmNameTv, item.getMGameName());
|
|
|
if (item.getMPercent() != null && item.getMPercent() == 100) {
|
|
if (item.getMPercent() != null && item.getMPercent() == 100) {
|
|
|
if (item.getMTotalSize() == null) {
|
|
if (item.getMTotalSize() == null) {
|
|
|
- ViewUtil.setText(item_dm_info_tv, "全部下载完成");
|
|
|
|
|
|
|
+ ViewUtil.setText(binding.itemDmInfoTv, "全部下载完成");
|
|
|
} else {
|
|
} else {
|
|
|
- ViewUtil.setText(item_dm_info_tv, String.format(Locale.CHINA, "%dMB 下载完成", (item.getMTotalSize().intValue() / (1024 * 1024))));
|
|
|
|
|
|
|
+ ViewUtil.setText(binding.itemDmInfoTv, String.format(Locale.CHINA, "%dMB 下载完成", (item.getMTotalSize().intValue() / (1024 * 1024))));
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- ViewUtil.setText(item_dm_info_tv, strFormat(item.getMDownloadedSize(), item.getMTotalSize()));
|
|
|
|
|
|
|
+ ViewUtil.setText(binding.itemDmInfoTv, strFormat(item.getMDownloadedSize(), item.getMTotalSize()));
|
|
|
}
|
|
}
|
|
|
- item_dm_pb.setProgress(item.getMPercent() != null ? item.getMPercent() : 0);
|
|
|
|
|
- item_dm_delete_iv.setOnClickListener(view -> {
|
|
|
|
|
|
|
+ binding.itemDmPb.setProgress(item.getMPercent() != null ? item.getMPercent() : 0);
|
|
|
|
|
+ binding.itemDmDeleteIv.setOnClickListener(view -> {
|
|
|
if (apiRefresh != null && apiRefresh.getList() != null)
|
|
if (apiRefresh != null && apiRefresh.getList() != null)
|
|
|
apiRefresh.getList().remove(item);
|
|
apiRefresh.getList().remove(item);
|
|
|
if (baseQuickAdapter != null)
|
|
if (baseQuickAdapter != null)
|
|
@@ -165,7 +161,7 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
- updateView(getActivity(), item, item_dm_btn_tv, item_dm_pb, item_dm_info_tv);
|
|
|
|
|
|
|
+ updateView(getActivity(), item, binding.itemDmBtnTv, binding.itemDmPb, binding.itemDmInfoTv);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
@@ -174,24 +170,25 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected void convert(BaseViewHolder holder, String item) {
|
|
protected void convert(BaseViewHolder holder, String item) {
|
|
|
- View item_play_game_list_rl = holder.itemView.findViewById(R.id.item_play_game_list_rl);
|
|
|
|
|
- View item_play_game_list_top = holder.itemView.findViewById(R.id.item_play_game_list_top);
|
|
|
|
|
- ViewUtil.setVisibility(item_play_game_list_top, false);
|
|
|
|
|
- TextView item_play_game_list_tv = holder.itemView.findViewById(R.id.item_play_game_list_tv);
|
|
|
|
|
- ViewUtil.setText(item_play_game_list_tv, item);
|
|
|
|
|
- TextView item_play_game_list_more_tv = holder.itemView.findViewById(R.id.item_play_game_list_more_tv);
|
|
|
|
|
- ViewUtil.setVisibility(item_play_game_list_more_tv, false);
|
|
|
|
|
- RecyclerView recyclerView = holder.itemView.findViewById(R.id.item_play_game_list_rv);
|
|
|
|
|
|
|
+ ItemPlayGameListBinding binding = ItemPlayGameListBinding.bind(holder.itemView);
|
|
|
|
|
+ ViewUtil.setVisibility(binding.itemPlayGameListTop, false);
|
|
|
|
|
+ ViewUtil.setText(binding.itemPlayGameListTv, item);
|
|
|
|
|
+ ViewUtil.setVisibility(binding.itemPlayGameListMoreTv, false);
|
|
|
|
|
+ RecyclerView recyclerView = binding.itemPlayGameListRv;
|
|
|
recyclerView.setHasFixedSize(true);
|
|
recyclerView.setHasFixedSize(true);
|
|
|
recyclerView.setNestedScrollingEnabled(false);
|
|
recyclerView.setNestedScrollingEnabled(false);
|
|
|
int position = holder.getAdapterPosition();
|
|
int position = holder.getAdapterPosition();
|
|
|
switch (position) {
|
|
switch (position) {
|
|
|
case 0:
|
|
case 0:
|
|
|
- ViewUtil.setVisibility(item_play_game_list_rl, !apiRefresh.getList().isEmpty());
|
|
|
|
|
|
|
+ binding.itemPlayGameListRl.setVisibility(View.GONE);
|
|
|
recyclerView.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
recyclerView.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
|
|
|
+ DividerItemDecoration itemDecoration = new DividerItemDecoration(getContext(), RecyclerView.VERTICAL);
|
|
|
|
|
+ itemDecoration.setDrawable(getResources().getDrawable(R.drawable.divider_12dp));
|
|
|
|
|
+ recyclerView.addItemDecoration(itemDecoration);
|
|
|
recyclerView.setAdapter(downLoadInfoAdapter);
|
|
recyclerView.setAdapter(downLoadInfoAdapter);
|
|
|
break;
|
|
break;
|
|
|
case 1:
|
|
case 1:
|
|
|
|
|
+ binding.itemPlayGameListRl.setVisibility(View.VISIBLE);
|
|
|
recyclerView.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance(), LinearLayoutManager.HORIZONTAL, false));
|
|
recyclerView.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance(), LinearLayoutManager.HORIZONTAL, false));
|
|
|
recyclerView.setAdapter(appFormGameCenterAdapter);
|
|
recyclerView.setAdapter(appFormGameCenterAdapter);
|
|
|
break;
|
|
break;
|
|
@@ -206,23 +203,23 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
Observable.just(1).map(integer -> {
|
|
Observable.just(1).map(integer -> {
|
|
|
- try {
|
|
|
|
|
- downloadUtil.deleteAllDownloadTask();
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
- try {
|
|
|
|
|
- OkDownload.with().downloadDispatcher().cancelAll();
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
- try {
|
|
|
|
|
- ClassFileHelper.getInstance().clearDir();
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
- return integer;
|
|
|
|
|
- }).subscribeOn(Schedulers.io())
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ downloadUtil.deleteAllDownloadTask();
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ OkDownload.with().downloadDispatcher().cancelAll();
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ ClassFileHelper.getInstance().clearDir();
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return integer;
|
|
|
|
|
+ }).subscribeOn(Schedulers.io())
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new AbsObserver<Integer>() {
|
|
.subscribe(new AbsObserver<Integer>() {
|
|
|
@Override
|
|
@Override
|
|
@@ -280,10 +277,10 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
|
|
|
downloadInfoHelperMap.put(item.getMPackageName(), downloadInfoHelper);
|
|
downloadInfoHelperMap.put(item.getMPackageName(), downloadInfoHelper);
|
|
|
}
|
|
}
|
|
|
downloadInfoHelper.updateDownloadTaskView(activity, textView);
|
|
downloadInfoHelper.updateDownloadTaskView(activity, textView);
|
|
|
- downloadInfoHelper.getDownloadStatus(downloadUtil, (o)->{
|
|
|
|
|
|
|
+ downloadInfoHelper.getDownloadStatus(downloadUtil, (o) -> {
|
|
|
if (o instanceof Integer) {
|
|
if (o instanceof Integer) {
|
|
|
int st = (int) o;
|
|
int st = (int) o;
|
|
|
- if(st == DownloadUtil.STATUS_FINISH){
|
|
|
|
|
|
|
+ if (st == DownloadUtil.STATUS_FINISH) {
|
|
|
progressBar.setProgress(100);
|
|
progressBar.setProgress(100);
|
|
|
ViewUtil.setText(completeView, "全部下载完成");
|
|
ViewUtil.setText(completeView, "全部下载完成");
|
|
|
}
|
|
}
|
|
@@ -328,6 +325,7 @@ public class FgtDownloadManager extends BaseListFragment6<String> {
|
|
|
@Override
|
|
@Override
|
|
|
public void initView() {
|
|
public void initView() {
|
|
|
super.initView();
|
|
super.initView();
|
|
|
|
|
+ findViewById(R.id.swipeRefreshLayout).setBackgroundColor(getResources().getColor(R.color.ver4Bg));
|
|
|
absGetDownloadListener.addDownloadListener(new AbsDownloadListener() {
|
|
absGetDownloadListener.addDownloadListener(new AbsDownloadListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void removedApk(String packageName) {
|
|
public void removedApk(String packageName) {
|