|
@@ -7,9 +7,10 @@ import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
|
|
|
+import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
-import androidx.annotation.IntegerRes;
|
|
|
|
|
|
|
+import androidx.annotation.IdRes;
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.NonNull;
|
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.Nullable;
|
|
|
import androidx.recyclerview.widget.AsyncListDiffer;
|
|
import androidx.recyclerview.widget.AsyncListDiffer;
|
|
@@ -25,7 +26,6 @@ import com.atmob.task.utils.AppTaskEvent;
|
|
|
import com.atmob.task.utils.InstallFaultToleranceUtils;
|
|
import com.atmob.task.utils.InstallFaultToleranceUtils;
|
|
|
import com.atmob.task.utils.RetrofitDownloader;
|
|
import com.atmob.task.utils.RetrofitDownloader;
|
|
|
import com.atmob.utils.AppInfoUtils;
|
|
import com.atmob.utils.AppInfoUtils;
|
|
|
-import com.atmob.utils.ResUtils;
|
|
|
|
|
import com.atmob.utils.RxSchedulersUtils;
|
|
import com.atmob.utils.RxSchedulersUtils;
|
|
|
import com.atmob.utils.Utils;
|
|
import com.atmob.utils.Utils;
|
|
|
|
|
|
|
@@ -105,17 +105,17 @@ public class AppTaskItemAdapter extends RecyclerView.Adapter<AppTaskItemAdapter.
|
|
|
}
|
|
}
|
|
|
AppTaskDownloadWrapper appTaskDownloadWrapper = asyncListDiffer.getCurrentList().get(position);
|
|
AppTaskDownloadWrapper appTaskDownloadWrapper = asyncListDiffer.getCurrentList().get(position);
|
|
|
// download status
|
|
// download status
|
|
|
- appTaskAdapter.onDownloadStatusChanged(appTaskDownloadWrapper.isDownloading());
|
|
|
|
|
|
|
+ appTaskAdapter.onDownloadStatusChanged(holder, appTaskDownloadWrapper.isDownloading());
|
|
|
// app name
|
|
// app name
|
|
|
- appTaskAdapter.onRenderAppName(appTaskDownloadWrapper, appTaskDownloadWrapper.getAppName());
|
|
|
|
|
|
|
+ appTaskAdapter.onRenderAppName(holder, appTaskDownloadWrapper, appTaskDownloadWrapper.getAppName());
|
|
|
// app icon
|
|
// app icon
|
|
|
- appTaskAdapter.onRenderAppIcon(appTaskDownloadWrapper, appTaskDownloadWrapper.getAppIcon());
|
|
|
|
|
|
|
+ appTaskAdapter.onRenderAppIcon(holder, appTaskDownloadWrapper, appTaskDownloadWrapper.getAppIcon());
|
|
|
// click view
|
|
// click view
|
|
|
setTag2ClickViews(appTaskDownloadWrapper);
|
|
setTag2ClickViews(appTaskDownloadWrapper);
|
|
|
// task status
|
|
// task status
|
|
|
- appTaskAdapter.onRenderTaskStatus(appTaskDownloadWrapper, appTaskDownloadWrapper.getTaskStatus());
|
|
|
|
|
|
|
+ appTaskAdapter.onRenderTaskStatus(holder, appTaskDownloadWrapper, appTaskDownloadWrapper.getTaskStatus());
|
|
|
// download progress
|
|
// download progress
|
|
|
- appTaskAdapter.onRenderDownloadProgress(appTaskDownloadWrapper.getTotal(), appTaskDownloadWrapper.getProgress());
|
|
|
|
|
|
|
+ appTaskAdapter.onRenderDownloadProgress(holder, appTaskDownloadWrapper.getTotal(), appTaskDownloadWrapper.getProgress());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void setTag2ClickViews(AppTaskDownloadWrapper appTaskDownloadWrapper) {
|
|
private void setTag2ClickViews(AppTaskDownloadWrapper appTaskDownloadWrapper) {
|
|
@@ -145,20 +145,20 @@ public class AppTaskItemAdapter extends RecyclerView.Adapter<AppTaskItemAdapter.
|
|
|
for (String key : bundle.keySet()) {
|
|
for (String key : bundle.keySet()) {
|
|
|
switch (key) {
|
|
switch (key) {
|
|
|
case "payload_app_name":
|
|
case "payload_app_name":
|
|
|
- appTaskAdapter.onRenderAppName(appTaskDownloadWrapper, bundle.getString(key));
|
|
|
|
|
|
|
+ appTaskAdapter.onRenderAppName(holder, appTaskDownloadWrapper, bundle.getString(key));
|
|
|
break;
|
|
break;
|
|
|
case "payload_task_status":
|
|
case "payload_task_status":
|
|
|
- appTaskAdapter.onRenderTaskStatus(appTaskDownloadWrapper, bundle.getInt(key));
|
|
|
|
|
|
|
+ appTaskAdapter.onRenderTaskStatus(holder, appTaskDownloadWrapper, bundle.getInt(key));
|
|
|
break;
|
|
break;
|
|
|
case "payload_downloading":
|
|
case "payload_downloading":
|
|
|
- appTaskAdapter.onDownloadStatusChanged(bundle.getBoolean(key));
|
|
|
|
|
|
|
+ appTaskAdapter.onDownloadStatusChanged(holder, bundle.getBoolean(key));
|
|
|
break;
|
|
break;
|
|
|
case "payload_progress":
|
|
case "payload_progress":
|
|
|
case "payload_total":
|
|
case "payload_total":
|
|
|
if (bundle.get("payload_progress") == null || bundle.get("payload_total") == null) {
|
|
if (bundle.get("payload_progress") == null || bundle.get("payload_total") == null) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- appTaskAdapter.onRenderDownloadProgress(bundle.getLong("payload_total"), bundle.getLong("payload_progress"));
|
|
|
|
|
|
|
+ appTaskAdapter.onRenderDownloadProgress(holder, bundle.getLong("payload_total"), bundle.getLong("payload_progress"));
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -472,53 +472,22 @@ public class AppTaskItemAdapter extends RecyclerView.Adapter<AppTaskItemAdapter.
|
|
|
Log.d(TAG, "triggerFirstTask: not has available task.");
|
|
Log.d(TAG, "triggerFirstTask: not has available task.");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 列表内部通过这个类获取item必要组件
|
|
|
|
|
- */
|
|
|
|
|
public static class AppTaskItemViewHolder extends RecyclerView.ViewHolder {
|
|
public static class AppTaskItemViewHolder extends RecyclerView.ViewHolder {
|
|
|
|
|
|
|
|
public AppTaskItemViewHolder(@NonNull View itemView) {
|
|
public AppTaskItemViewHolder(@NonNull View itemView) {
|
|
|
super(itemView);
|
|
super(itemView);
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public static class AppIconConfig {
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 默认图标
|
|
|
|
|
- */
|
|
|
|
|
- @IntegerRes
|
|
|
|
|
- private int placeholderResId;
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 图标的圆角 in dip
|
|
|
|
|
- */
|
|
|
|
|
- private int round;
|
|
|
|
|
-
|
|
|
|
|
- @SuppressWarnings("ResourceType")
|
|
|
|
|
- public AppIconConfig() {
|
|
|
|
|
- placeholderResId = ResUtils.getRes("atmob_default_icon", "drawable");
|
|
|
|
|
- round = 0;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- public AppIconConfig placeholderResId(int placeholderResId) {
|
|
|
|
|
- this.placeholderResId = placeholderResId;
|
|
|
|
|
- return this;
|
|
|
|
|
|
|
+ public void setText(@IdRes int id, CharSequence text) {
|
|
|
|
|
+ TextView textView = itemView.findViewById(id);
|
|
|
|
|
+ textView.setText(text);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public AppIconConfig round(int round) {
|
|
|
|
|
- this.round = round;
|
|
|
|
|
- return this;
|
|
|
|
|
|
|
+ public void setVisible(@IdRes int id, boolean visible) {
|
|
|
|
|
+ itemView.findViewById(id).setVisibility(visible ? View.VISIBLE : View.GONE);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 用于构建积分墙item, see{@link AppTaskItemViewHolder}
|
|
|
|
|
- */
|
|
|
|
|
- public interface ViewHolderCreator {
|
|
|
|
|
- AppTaskItemViewHolder onCreateViewHolder(LayoutInflater layoutInflater, ViewGroup parent);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private static class DiffCallback extends DiffUtil.ItemCallback<AppTaskDownloadWrapper> {
|
|
private static class DiffCallback extends DiffUtil.ItemCallback<AppTaskDownloadWrapper> {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|