Commit bc6fd3065bac00702f84731d01b2640db5664770
1 parent
5b60b4a9
云盘上传下载功能ui展示
Showing
36 changed files
with
1462 additions
and
38 deletions
app/src/main/java/com/cnlive/updown/MainActivity.java
| ... | ... | @@ -4,7 +4,7 @@ import android.content.Intent; |
| 4 | 4 | import android.support.v7.app.AppCompatActivity; |
| 5 | 5 | import android.os.Bundle; |
| 6 | 6 | |
| 7 | -import com.cnlive.updownfile.xiaoRay.InitViewActivity; | |
| 7 | +import com.cnlive.updownfile.xiaoRay.ui.InitViewActivity; | |
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | public class MainActivity extends AppCompatActivity { | ... | ... |
updownfile/libs/mylib.jar
No preview for this file type
updownfile/src/main/AndroidManifest.xml
| ... | ... | @@ -8,8 +8,9 @@ |
| 8 | 8 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
| 9 | 9 | |
| 10 | 10 | <application> |
| 11 | - <activity android:name=".xiaoRay.DiretoryActivity" /> | |
| 12 | - <activity android:name=".xiaoRay.InitViewActivity" /> | |
| 11 | + <activity android:name=".xiaoRay.ui.TaskActivity"></activity> | |
| 12 | + <activity android:name=".xiaoRay.ui.DiretoryActivity" /> | |
| 13 | + <activity android:name=".xiaoRay.ui.InitViewActivity" /> | |
| 13 | 14 | <activity android:name="com.cnlive.filespicker.ui.FilePickerActivity" /> |
| 14 | 15 | |
| 15 | 16 | <service android:name="com.xiaoray.raysdk.service.TaskUploadService" /> | ... | ... |
updownfile/src/main/java/com/cnlive/updownfile/util/UploadUtil.java
| ... | ... | @@ -40,7 +40,7 @@ public class UploadUtil { |
| 40 | 40 | private static final String OBJECT_PIC_KEY = AppConfig.isDebug() ? TEST_OBJECT_PIC__KEY : RELEASE_OBJECT_PIC__KEY; |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | - * 七牛文件上传 | |
| 43 | + * 七牛文件上传文件 | |
| 44 | 44 | * @param context |
| 45 | 45 | * @param file |
| 46 | 46 | * @param objectKey |
| ... | ... | @@ -74,7 +74,7 @@ public class UploadUtil { |
| 74 | 74 | |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | - * 上传多张图片 | |
| 77 | + * 七牛上传多张图片 | |
| 78 | 78 | * @param context |
| 79 | 79 | * @param file |
| 80 | 80 | * @param uploadToken | ... | ... |
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/Constant.java
| ... | ... | @@ -15,13 +15,16 @@ public class Constant { |
| 15 | 15 | public static final int IMAGE_MAX_SIZE = 20 * 1024 * 1024; |
| 16 | 16 | //聊天页面文件最大28M |
| 17 | 17 | public static final int FILE_MAX_SIZE = 28 * 1024 * 1024; |
| 18 | + public static ProgressDialog waitingDialog; | |
| 18 | 19 | |
| 19 | 20 | public static void initXiaoRay(Context context, String mac, String u_id, String code, String term_id) { |
| 20 | - RayLib.init(context); | |
| 21 | - ProgressDialog waitingDialog = new ProgressDialog(context); | |
| 22 | - waitingDialog.setMessage("正在连接IP地址"); | |
| 23 | - waitingDialog.setIndeterminate(true); | |
| 24 | - waitingDialog.setCancelable(false); | |
| 21 | + if(waitingDialog == null){ | |
| 22 | + RayLib.init(context); | |
| 23 | + waitingDialog = new ProgressDialog(context); | |
| 24 | + waitingDialog.setMessage("正在连接IP地址"); | |
| 25 | + waitingDialog.setIndeterminate(true); | |
| 26 | + waitingDialog.setCancelable(false); | |
| 27 | + } | |
| 25 | 28 | waitingDialog.show(); |
| 26 | 29 | RayLib.connectCloud(context, mac, u_id, code, |
| 27 | 30 | term_id, new ConnectCloudListener() { | ... | ... |
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/adapter/TaskDoingAdapter.java
0 → 100644
| 1 | +package com.cnlive.updownfile.xiaoRay.adapter; | |
| 2 | + | |
| 3 | +import android.support.annotation.Nullable; | |
| 4 | +import android.text.TextUtils; | |
| 5 | +import android.view.View; | |
| 6 | +import android.widget.ImageView; | |
| 7 | + | |
| 8 | +import com.chad.library.adapter.base.BaseQuickAdapter; | |
| 9 | +import com.chad.library.adapter.base.BaseViewHolder; | |
| 10 | +import com.cnlive.updownfile.R; | |
| 11 | +import com.cnlive.updownfile.xiaoRay.bean.TaskInfoItem; | |
| 12 | +import com.cnlive.updownfile.xiaoRay.view.RayGlide; | |
| 13 | +import com.xiaoray.raysdk.constant.FileType; | |
| 14 | +import com.xiaoray.raysdk.constant.ProgressState; | |
| 15 | +import com.xiaoray.raysdk.constant.TaskState; | |
| 16 | +import com.xiaoray.raysdk.constant.TaskType; | |
| 17 | +import com.xiaoray.raysdk.utils.RayPath; | |
| 18 | +import com.xiaoray.raysdk.utils.RayUtil; | |
| 19 | +import java.util.List; | |
| 20 | + | |
| 21 | +public class TaskDoingAdapter extends BaseQuickAdapter<TaskInfoItem, BaseViewHolder> { | |
| 22 | + public static final int TYPE_LEVEL_0 = 0; | |
| 23 | + public static final int TYPE_LEVEL_1 = 1; | |
| 24 | + | |
| 25 | + | |
| 26 | + public TaskDoingAdapter(int layoutResId, @Nullable List<TaskInfoItem> data) { | |
| 27 | + super(layoutResId, data); | |
| 28 | + } | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + protected void convert(BaseViewHolder helper, TaskInfoItem lv1) { | |
| 32 | + | |
| 33 | + | |
| 34 | + helper.setText(R.id.tv_name, lv1.getEtDoing().getFileName()); | |
| 35 | + if (lv1.getProgress() > 0) { | |
| 36 | + helper.setVisible(R.id.tv_progress_num, true); | |
| 37 | + helper.setText(R.id.tv_progress_num, lv1.getProgress() + ""); | |
| 38 | + } else { | |
| 39 | + helper.setVisible(R.id.tv_progress_num, false); | |
| 40 | + } | |
| 41 | + | |
| 42 | + | |
| 43 | + if (lv1.getTaskType() == TaskType.UPLOAD) { | |
| 44 | +// RayGlide.loadFromRes(mContext, | |
| 45 | +// R.mipmap.icon_list_upload, (ImageView) helper.getView(R.id.iv_start)); | |
| 46 | + } else { | |
| 47 | +// RayGlide.loadFromRes(mContext, | |
| 48 | +// R.mipmap.icon_list_download, (ImageView) helper.getView(R.id.iv_start)); | |
| 49 | + } | |
| 50 | + if (!TextUtils.isEmpty(((TaskInfoItem) lv1).getSpeed())) { | |
| 51 | + helper.setText(R.id.tv_speed, ((TaskInfoItem) lv1).getSpeed()); | |
| 52 | + } | |
| 53 | + | |
| 54 | + if (lv1.getEtDoing().getTaskState() == TaskState.EXECUTE_UPLOAD_RETURN_ONE) { | |
| 55 | + helper.setText(R.id.tv_file_size, lv1.getEtDoing().getErrorInfo()); | |
| 56 | + helper.setText(R.id.tv_speed, ""); | |
| 57 | + helper.getView(R.id.tv_speed).setVisibility(View.GONE); | |
| 58 | + } else if (lv1.getEtDoing().getTaskState() == TaskState.EXECUTE_FILE_NOT_EXIT) { | |
| 59 | + helper.setText(R.id.tv_file_size, lv1.getEtDoing().getErrorInfo()); | |
| 60 | + helper.setText(R.id.tv_speed, ""); | |
| 61 | + helper.getView(R.id.tv_speed).setVisibility(View.GONE); | |
| 62 | + } else { | |
| 63 | + if (lv1.getProgress() > 0) { | |
| 64 | + helper.setText(R.id.tv_file_size, RayUtil.getFormatSize(mContext, | |
| 65 | + ((TaskInfoItem) lv1).getCurrentFileSize()) + "/" + RayUtil.getFormatSize(mContext, lv1.getTotalFileSize())); | |
| 66 | + helper.getView(R.id.tv_speed).setVisibility(View.VISIBLE); | |
| 67 | + } else if (lv1.getProgress() == 0) { | |
| 68 | + helper.setText(R.id.tv_file_size, R.string.waiting); | |
| 69 | + helper.setText(R.id.tv_speed, ""); | |
| 70 | + helper.getView(R.id.tv_speed).setVisibility(View.VISIBLE); | |
| 71 | + } else if (lv1.getProgress() == ProgressState.PROGRESS_PAUSE) { | |
| 72 | + helper.setText(R.id.tv_file_size, R.string.pause); | |
| 73 | + helper.setText(R.id.tv_speed, ""); | |
| 74 | + helper.getView(R.id.tv_speed).setVisibility(View.VISIBLE); | |
| 75 | + if (lv1.getTaskType() == TaskType.UPLOAD) { | |
| 76 | + } else if (lv1.getTaskType() == TaskType.DOWNLOAD) { | |
| 77 | + } | |
| 78 | + } else if (lv1.getProgress() == ProgressState.PROGRESS_ERROR) { | |
| 79 | + helper.setText(R.id.tv_file_size, lv1.getErrorInfo()); | |
| 80 | + helper.setText(R.id.tv_speed, ""); | |
| 81 | + helper.getView(R.id.tv_speed).setVisibility(View.GONE); | |
| 82 | + } else if (lv1.getProgress() == ProgressState.PROGRESS_CHECK_MD5) { | |
| 83 | + helper.setText(R.id.tv_file_size, R.string.upload_check_md5); | |
| 84 | + helper.setText(R.id.tv_speed, ""); | |
| 85 | + helper.getView(R.id.tv_speed).setVisibility(View.VISIBLE); | |
| 86 | + } else { | |
| 87 | + helper.setText(R.id.tv_file_size, R.string.no_known_condition_happen); | |
| 88 | + helper.setText(R.id.tv_speed, ""); | |
| 89 | + helper.getView(R.id.tv_speed).setVisibility(View.GONE); | |
| 90 | + } | |
| 91 | + } | |
| 92 | + | |
| 93 | + if (lv1.getEtDoing().getFileType() == FileType.TYPE_PHOTO) { | |
| 94 | + if (lv1.getTaskType() == TaskType.UPLOAD) { | |
| 95 | + RayGlide.loadLocalRound(mContext, lv1.getEtDoing().getLocalPath(), | |
| 96 | + R.drawable.bg_photo, (ImageView) helper.getView(R.id.iv_file_type)); | |
| 97 | + } else if (lv1.getTaskType() == TaskType.DOWNLOAD) { | |
| 98 | + RayGlide.resRound(mContext, RayPath.downloadUrl(lv1.getEtDoing().getCloudPath()), | |
| 99 | + R.drawable.bg_photo, (ImageView) helper.getView(R.id.iv_file_type)); | |
| 100 | + } | |
| 101 | + } else if (lv1.getEtDoing().getFileType() == FileType.TYPE_VIDEO) { | |
| 102 | + if (lv1.getTaskType() == TaskType.UPLOAD) { | |
| 103 | + RayGlide.loadLocalRound(mContext, lv1.getEtDoing().getLocalPath(), | |
| 104 | + R.drawable.bg_video, (ImageView) helper.getView(R.id.iv_file_type)); | |
| 105 | + } else if (lv1.getTaskType() == TaskType.DOWNLOAD) { | |
| 106 | + RayGlide.resRound(mContext, RayPath.downloadUrl(lv1.getEtDoing().getCloudPath()), | |
| 107 | + R.drawable.bg_video, (ImageView) helper.getView(R.id.iv_file_type)); | |
| 108 | + } | |
| 109 | + } else if (lv1.getEtDoing().getFileType() == FileType.TYPE_OTHER || lv1.getEtDoing().getFileType() == FileType.TYPE_DOCUMENT) { | |
| 110 | + RayGlide.resRound(mContext, R.drawable.bg_doc, | |
| 111 | + (ImageView) helper.getView(R.id.iv_file_type)); | |
| 112 | + } else if (lv1.getEtDoing().getFileType() == FileType.TYPE_MUSIC) { | |
| 113 | + RayGlide.resRound(mContext, R.drawable.bg_music, | |
| 114 | + (ImageView) helper.getView(R.id.iv_file_type)); | |
| 115 | + } else { | |
| 116 | + RayGlide.resRound(mContext, R.drawable.bg_unknown, | |
| 117 | + (ImageView) helper.getView(R.id.iv_file_type)); | |
| 118 | + } | |
| 119 | + | |
| 120 | + | |
| 121 | + } | |
| 122 | + | |
| 123 | + | |
| 124 | +} | ... | ... |
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/adapter/TaskDoneItemAdapter.java
0 → 100644
| 1 | +package com.cnlive.updownfile.xiaoRay.adapter; | |
| 2 | + | |
| 3 | +import android.support.annotation.Nullable; | |
| 4 | +import android.widget.ImageView; | |
| 5 | + | |
| 6 | +import com.chad.library.adapter.base.BaseQuickAdapter; | |
| 7 | +import com.chad.library.adapter.base.BaseViewHolder; | |
| 8 | +import com.cnlive.updownfile.R; | |
| 9 | +import com.cnlive.updownfile.xiaoRay.view.RayGlide; | |
| 10 | +import com.xiaoray.raysdk.constant.FileType; | |
| 11 | +import com.xiaoray.raysdk.entity.green.TaskDone; | |
| 12 | +import com.xiaoray.raysdk.utils.RayUtil; | |
| 13 | + | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | +public class TaskDoneItemAdapter extends BaseQuickAdapter<TaskDone, BaseViewHolder> { | |
| 17 | + | |
| 18 | + public TaskDoneItemAdapter(int layoutResId, @Nullable List<TaskDone> data) { | |
| 19 | + super(layoutResId, data); | |
| 20 | + } | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + protected void convert(BaseViewHolder helper, TaskDone item) { | |
| 24 | + helper.setText(R.id.tv_name, item.getFileName()); | |
| 25 | + helper.setText(R.id.tv_file_size, RayUtil.getFormatSize(mContext, item.getFileSize())); | |
| 26 | + helper.setText(R.id.tv_time, RayUtil.formatPhotoDateSecond(item.getTaskDoneTime())); | |
| 27 | + if (item.getFileType() == FileType.TYPE_PHOTO || item.getFileType() == FileType.TYPE_VIDEO) { | |
| 28 | + RayGlide.loadLocalRound(mContext, item.getFileLocalPath(), R.drawable.ic_launcher, (ImageView) helper.getView(R.id.iv_file_type)); | |
| 29 | + } else if (item.getFileType() == FileType.TYPE_OTHER || item.getFileType() == FileType.TYPE_DOCUMENT) { | |
| 30 | + String prefix = RayUtil.getPrefixString(item.getFileLocalPath()); | |
| 31 | + RayGlide.resRound(mContext, R.drawable.ic_launcher, (ImageView) helper.getView(R.id.iv_file_type)); | |
| 32 | + } else if (item.getFileType() == FileType.TYPE_MUSIC) { | |
| 33 | + RayGlide.resRound(mContext, R.drawable.ic_launcher, (ImageView) helper.getView(R.id.iv_file_type)); | |
| 34 | + } | |
| 35 | + } | |
| 36 | +} | ... | ... |
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/bean/TaskInfoItem.java
0 → 100644
| 1 | +package com.cnlive.updownfile.xiaoRay.bean; | |
| 2 | + | |
| 3 | +import com.xiaoray.raysdk.entity.green.TaskDone; | |
| 4 | +import com.xiaoray.raysdk.entity.green.TaskUndone; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * @author zww | |
| 8 | + * @date on 2018/6/12 | |
| 9 | + * @function | |
| 10 | + * @filename TaskInfoItem | |
| 11 | + */ | |
| 12 | +public class TaskInfoItem { | |
| 13 | + | |
| 14 | + private TaskUndone etDoing; | |
| 15 | + private int progress; | |
| 16 | + private String errorInfo; | |
| 17 | + private TaskDone etDone; | |
| 18 | + private int taskType; | |
| 19 | + private long currentFileSize; | |
| 20 | + private String speed; | |
| 21 | + private long totalFileSize; | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * 正在进行中的 | |
| 25 | + */ | |
| 26 | + public TaskInfoItem(TaskUndone etDoing, int progress, String errorInfo, int taskType) { | |
| 27 | + this.etDoing = etDoing; | |
| 28 | + this.progress = progress; | |
| 29 | + this.errorInfo = errorInfo; | |
| 30 | + this.taskType = taskType; | |
| 31 | + } | |
| 32 | + | |
| 33 | + public long getTotalFileSize() { | |
| 34 | + return totalFileSize; | |
| 35 | + } | |
| 36 | + | |
| 37 | + public void setTotalFileSize(long totalFileSize) { | |
| 38 | + this.totalFileSize = totalFileSize; | |
| 39 | + } | |
| 40 | + | |
| 41 | + public long getCurrentFileSize() { | |
| 42 | + return currentFileSize; | |
| 43 | + } | |
| 44 | + | |
| 45 | + public void setCurrentFileSize(long currentFileSize) { | |
| 46 | + this.currentFileSize = currentFileSize; | |
| 47 | + } | |
| 48 | + | |
| 49 | + public String getSpeed() { | |
| 50 | + return speed; | |
| 51 | + } | |
| 52 | + | |
| 53 | + public void setSpeed(String speed) { | |
| 54 | + this.speed = speed; | |
| 55 | + } | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * 完成的 | |
| 59 | + */ | |
| 60 | + public TaskInfoItem(TaskDone etDone) { | |
| 61 | + this.etDone = etDone; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public TaskDone getEtDone() { | |
| 65 | + return etDone; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public void setEtDone(TaskDone etDone) { | |
| 69 | + this.etDone = etDone; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public TaskUndone getEtDoing() { | |
| 73 | + return etDoing; | |
| 74 | + } | |
| 75 | + | |
| 76 | + public void setEtDoing(TaskUndone etDoing) { | |
| 77 | + this.etDoing = etDoing; | |
| 78 | + } | |
| 79 | + | |
| 80 | + public String getErrorInfo() { | |
| 81 | + return errorInfo; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public void setErrorInfo(String errorInfo) { | |
| 85 | + this.errorInfo = errorInfo; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public int getProgress() { | |
| 89 | + return progress; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public void setProgress(int progress) { | |
| 93 | + this.progress = progress; | |
| 94 | + } | |
| 95 | + | |
| 96 | + public int getTaskType() { | |
| 97 | + return taskType; | |
| 98 | + } | |
| 99 | + | |
| 100 | + public void setTaskType(int taskType) { | |
| 101 | + this.taskType = taskType; | |
| 102 | + } | |
| 103 | + | |
| 104 | +// @Override | |
| 105 | +// public int getItemType() { | |
| 106 | +// return TaskDoingAdapter.TYPE_LEVEL_1; | |
| 107 | +// } | |
| 108 | + | |
| 109 | + @Override | |
| 110 | + public String toString() { | |
| 111 | + return "TaskInfoItem{" + | |
| 112 | + "etDoing=" + etDoing + | |
| 113 | + ", progress=" + progress + | |
| 114 | + ", errorInfo='" + errorInfo + '\'' + | |
| 115 | + ", etDone=" + etDone + | |
| 116 | + ", taskType=" + taskType + | |
| 117 | + ", currentFileSize=" + currentFileSize + | |
| 118 | + ", speed='" + speed + '\'' + | |
| 119 | + '}'; | |
| 120 | + } | |
| 121 | +} | ... | ... |
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/ui/BaseFragment.java
0 → 100644
| 1 | +package com.cnlive.updownfile.xiaoRay.ui; | |
| 2 | + | |
| 3 | +import android.app.Activity; | |
| 4 | +import android.app.ProgressDialog; | |
| 5 | +import android.os.Bundle; | |
| 6 | +import android.support.v4.app.Fragment; | |
| 7 | +import android.support.v4.app.FragmentActivity; | |
| 8 | +import android.view.LayoutInflater; | |
| 9 | +import android.view.View; | |
| 10 | +import android.view.ViewGroup; | |
| 11 | + | |
| 12 | +import com.xiaoray.raysdk.utils.RayLog; | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | +public abstract class BaseFragment extends Fragment { | |
| 17 | + /* 布局View */ | |
| 18 | + public View mLayoutView = null; | |
| 19 | + public String TAG = getClass().getSimpleName(); | |
| 20 | + protected FragmentActivity mContext; | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + public void onCreate(Bundle savedInstanceState) { | |
| 24 | + super.onCreate(savedInstanceState); | |
| 25 | + RayLog.i("---------------------------------------------- " + TAG + " ---------------------------------------"); | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
| 30 | + Bundle savedInstanceState) { | |
| 31 | + mLayoutView = inflater.inflate(getLayout(), container, false); | |
| 32 | + return mLayoutView; | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public void onAttach(Activity context) { | |
| 37 | + super.onAttach(context); | |
| 38 | + mContext = (FragmentActivity) context; //保存Context引用 | |
| 39 | + } | |
| 40 | + | |
| 41 | + @Override | |
| 42 | + public void onDetach() { | |
| 43 | + super.onDetach(); | |
| 44 | + mContext = null; | |
| 45 | + } | |
| 46 | + | |
| 47 | + @Override | |
| 48 | + public void onActivityCreated(Bundle savedInstanceState) { | |
| 49 | + super.onActivityCreated(savedInstanceState); | |
| 50 | + isVisible = true; | |
| 51 | + initView(); | |
| 52 | + initData(); | |
| 53 | + initListener(); | |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * @bref 绑定视图 | |
| 58 | + */ | |
| 59 | + protected abstract int getLayout(); | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * @bref 初始化View | |
| 63 | + */ | |
| 64 | + public abstract void initView(); | |
| 65 | + | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * @bref 初始化其他工具 | |
| 69 | + */ | |
| 70 | + public abstract void initData(); | |
| 71 | + | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * @bref 设置监听器 | |
| 75 | + */ | |
| 76 | + public abstract void initListener(); | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * @bref findViewById | |
| 80 | + */ | |
| 81 | + @SuppressWarnings("unchecked") | |
| 82 | + public <T extends View> T findView(int id) { | |
| 83 | + return (T) mLayoutView.findViewById(id); | |
| 84 | + } | |
| 85 | + | |
| 86 | + private boolean isVisible; | |
| 87 | + private ProgressDialog waitDialog; | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + public void hideLoadingDialog() { | |
| 93 | + if (isVisible && waitDialog != null) { | |
| 94 | + try { | |
| 95 | + waitDialog.dismiss(); | |
| 96 | + waitDialog = null; | |
| 97 | + } catch (Exception ex) { | |
| 98 | + ex.printStackTrace(); | |
| 99 | + } | |
| 100 | + } | |
| 101 | + } | |
| 102 | + | |
| 103 | +} | ... | ... |
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/DiretoryActivity.java renamed to updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/ui/DiretoryActivity.java
| 1 | -package com.cnlive.updownfile.xiaoRay; | |
| 1 | +package com.cnlive.updownfile.xiaoRay.ui; | |
| 2 | 2 | |
| 3 | 3 | import android.Manifest; |
| 4 | 4 | import android.content.Context; |
| 5 | 5 | import android.content.DialogInterface; |
| 6 | 6 | import android.content.Intent; |
| 7 | -import android.graphics.Bitmap; | |
| 8 | -import android.media.ThumbnailUtils; | |
| 9 | 7 | import android.os.Environment; |
| 10 | -import android.provider.MediaStore; | |
| 11 | 8 | import android.support.v4.app.ActivityCompat; |
| 12 | 9 | import android.support.v7.app.AlertDialog; |
| 13 | 10 | import android.support.v7.app.AppCompatActivity; |
| ... | ... | @@ -15,7 +12,6 @@ import android.os.Bundle; |
| 15 | 12 | import android.support.v7.widget.LinearLayoutManager; |
| 16 | 13 | import android.support.v7.widget.RecyclerView; |
| 17 | 14 | import android.text.TextUtils; |
| 18 | -import android.view.Gravity; | |
| 19 | 15 | import android.view.MenuInflater; |
| 20 | 16 | import android.view.MenuItem; |
| 21 | 17 | import android.view.View; |
| ... | ... | @@ -34,7 +30,9 @@ import com.cnlive.media.picker.ImagePicker; |
| 34 | 30 | import com.cnlive.media.picker.PickerConfig; |
| 35 | 31 | import com.cnlive.media.picker.entity.Media; |
| 36 | 32 | import com.cnlive.updownfile.R; |
| 33 | +import com.cnlive.updownfile.util.DownloadUtil; | |
| 37 | 34 | import com.cnlive.updownfile.util.UploadUtil; |
| 35 | +import com.cnlive.updownfile.xiaoRay.Constant; | |
| 38 | 36 | import com.cnlive.updownfile.xiaoRay.adapter.ShowDiretoryAdapter; |
| 39 | 37 | import com.cnlive.updownfile.xiaoRay.bean.DirectoryBean; |
| 40 | 38 | import com.cnlive.updownfile.xiaoRay.bean.DirectoryTypeBean; |
| ... | ... | @@ -48,6 +46,9 @@ import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout; |
| 48 | 46 | import com.xiaoray.raysdk.RayLib; |
| 49 | 47 | import com.xiaoray.raysdk.constant.FileType; |
| 50 | 48 | import com.xiaoray.raysdk.entity.bean.LocalCloudPath; |
| 49 | +import com.xiaoray.raysdk.entity.bus.BusTaskDoneAdd; | |
| 50 | +import com.xiaoray.raysdk.entity.bus.BusTaskDoneDel; | |
| 51 | +import com.xiaoray.raysdk.listener.RayDoneListener; | |
| 51 | 52 | import com.xiaoray.raysdk.manager.RayConstant; |
| 52 | 53 | import com.xiaoray.raysdk.service.TaskDownloadService; |
| 53 | 54 | import com.xiaoray.raysdk.utils.OkHttpUtils.HttpResult; |
| ... | ... | @@ -69,6 +70,7 @@ public class DiretoryActivity extends AppCompatActivity implements View.OnClickL |
| 69 | 70 | Button add_picture; |
| 70 | 71 | Button add_file; |
| 71 | 72 | Button clear_recyfile; |
| 73 | + Button check_updown; | |
| 72 | 74 | |
| 73 | 75 | RadioGroup file_type; |
| 74 | 76 | RadioGroup file_time; |
| ... | ... | @@ -122,12 +124,14 @@ public class DiretoryActivity extends AppCompatActivity implements View.OnClickL |
| 122 | 124 | file_updown = findViewById(R.id.file_updown); |
| 123 | 125 | sure = findViewById(R.id.sure); |
| 124 | 126 | choose = findViewById(R.id.choose); |
| 127 | + check_updown = findViewById(R.id.check_updown); | |
| 125 | 128 | if ("recy".equals(type)) { |
| 126 | 129 | add_file.setVisibility(View.GONE); |
| 127 | 130 | add_picture.setVisibility(View.GONE); |
| 128 | 131 | clear_recyfile.setVisibility(View.VISIBLE); |
| 129 | 132 | choose.setVisibility(View.GONE); |
| 130 | 133 | btnCreateNewFolder.setVisibility(View.GONE); |
| 134 | + check_updown.setVisibility(View.GONE); | |
| 131 | 135 | } |
| 132 | 136 | refreshDataShow.setHeaderView(new RefreshHeaderView(this)); |
| 133 | 137 | showFilesAdapter = new ShowDiretoryAdapter(R.layout.item_directory, new ArrayList<FileBean>()); |
| ... | ... | @@ -152,6 +156,10 @@ public class DiretoryActivity extends AppCompatActivity implements View.OnClickL |
| 152 | 156 | @Override |
| 153 | 157 | public boolean onMenuItemClick(MenuItem item) { |
| 154 | 158 | if (item.getItemId() == R.id.delete) {//删除 |
| 159 | + if("61445".equals(fileBean.getInode()) || "4098".equals(fileBean.getInode()) || "65556".equals(fileBean.getInode()) ||"937991".equals(fileBean.getInode()) ){ | |
| 160 | + RayToast.showShort("该文件暂不支持删除"); | |
| 161 | + return false; | |
| 162 | + } | |
| 155 | 163 | JSONArray jsonArray = new JSONArray(); |
| 156 | 164 | JSONArray jsonArray1 = new JSONArray(); |
| 157 | 165 | jsonArray1.put(fileBean.getInode()); |
| ... | ... | @@ -193,6 +201,10 @@ public class DiretoryActivity extends AppCompatActivity implements View.OnClickL |
| 193 | 201 | }); |
| 194 | 202 | builder.create().show(); |
| 195 | 203 | } else if (item.getItemId() == R.id.rename) {//重命名 |
| 204 | + if("61445".equals(fileBean.getInode()) || "4098".equals(fileBean.getInode()) || "65556".equals(fileBean.getInode()) ||"937991".equals(fileBean.getInode()) ){ | |
| 205 | + RayToast.showShort("该文件暂不支持重命名"); | |
| 206 | + return false; | |
| 207 | + } | |
| 196 | 208 | final EditText editText = new EditText(DiretoryActivity.this); |
| 197 | 209 | editText.setText(fileBean.getFname()); |
| 198 | 210 | AlertDialog.Builder builder = new AlertDialog.Builder(DiretoryActivity.this) |
| ... | ... | @@ -282,8 +294,7 @@ public class DiretoryActivity extends AppCompatActivity implements View.OnClickL |
| 282 | 294 | localCloudPath.setCloud(fileBean.getUrl()); |
| 283 | 295 | localCloudPath.setLocal(localPath); |
| 284 | 296 | arrayLists.add(localCloudPath); |
| 285 | - RayLib.controlDownload(DiretoryActivity.this, TaskDownloadService | |
| 286 | - .FROM_SELECT_DOWNLOAD, arrayLists); | |
| 297 | + DownloadUtil.addDownload(DiretoryActivity.this, arrayLists); | |
| 287 | 298 | } |
| 288 | 299 | return false; |
| 289 | 300 | } |
| ... | ... | @@ -295,6 +306,22 @@ public class DiretoryActivity extends AppCompatActivity implements View.OnClickL |
| 295 | 306 | rcyDataShow.setAdapter(showFilesAdapter); |
| 296 | 307 | refreshDataShow.setEnableLoadmore(false); |
| 297 | 308 | refreshDataShow.startRefresh(); |
| 309 | + | |
| 310 | + //上传完成通知刷新 | |
| 311 | + RayLib.setDoneListener(new RayDoneListener() { | |
| 312 | + @Override | |
| 313 | + public void doneAdd(BusTaskDoneAdd busTaskDoneAdd) { | |
| 314 | + //下载完成 | |
| 315 | + loadingLocal.setVisibility(View.GONE); | |
| 316 | + RayToast.showShort("下载完成"); | |
| 317 | + getDiretorys(true, fileType == 0 ? true : false); | |
| 318 | + } | |
| 319 | + | |
| 320 | + @Override | |
| 321 | + public void doneDel(BusTaskDoneDel busTaskDoneDel) { | |
| 322 | + | |
| 323 | + } | |
| 324 | + }); | |
| 298 | 325 | } |
| 299 | 326 | |
| 300 | 327 | private void initListener() { |
| ... | ... | @@ -320,7 +347,6 @@ public class DiretoryActivity extends AppCompatActivity implements View.OnClickL |
| 320 | 347 | intent.putExtra("path", showFilesAdapter.getData().get(position).getPath() + showFilesAdapter.getData().get(position).getFname() + File.separator); |
| 321 | 348 | startActivity(intent); |
| 322 | 349 | } |
| 323 | - | |
| 324 | 350 | } |
| 325 | 351 | }); |
| 326 | 352 | btnCreateNewFolder.setOnClickListener(this); |
| ... | ... | @@ -329,6 +355,7 @@ public class DiretoryActivity extends AppCompatActivity implements View.OnClickL |
| 329 | 355 | add_file.setOnClickListener(this); |
| 330 | 356 | clear_recyfile.setOnClickListener(this); |
| 331 | 357 | sure.setOnClickListener(this); |
| 358 | + check_updown.setOnClickListener(this); | |
| 332 | 359 | |
| 333 | 360 | file_type.setOnCheckedChangeListener(this); |
| 334 | 361 | file_time.setOnCheckedChangeListener(this); |
| ... | ... | @@ -376,7 +403,7 @@ public class DiretoryActivity extends AppCompatActivity implements View.OnClickL |
| 376 | 403 | } |
| 377 | 404 | }); |
| 378 | 405 | } else { |
| 379 | - if (hasType) {//全部加载 | |
| 406 | + if (hasType) {//全部加载,另一个是回收站 | |
| 380 | 407 | RayLib.getFilesByDirectory(0, folderPath, page = header ? 1 : page, 50, 1, 1, this, new HttpResult() { |
| 381 | 408 | @Override |
| 382 | 409 | public void onError(int errorCode, String error) { |
| ... | ... | @@ -530,6 +557,8 @@ public class DiretoryActivity extends AppCompatActivity implements View.OnClickL |
| 530 | 557 | }); |
| 531 | 558 | } else if (vid == R.id.sure) { |
| 532 | 559 | getDiretorys(true, fileType == 0 ? true : false); |
| 560 | + }else if(vid == R.id.check_updown){//查看上传下载任务 | |
| 561 | + TaskActivity.startTaskActivity(DiretoryActivity.this); | |
| 533 | 562 | } |
| 534 | 563 | } |
| 535 | 564 | |
| ... | ... | @@ -550,6 +579,7 @@ public class DiretoryActivity extends AppCompatActivity implements View.OnClickL |
| 550 | 579 | lists.add(localCloudPath); |
| 551 | 580 | } |
| 552 | 581 | UploadUtil.xiaoRayUploadFile(this, lists); |
| 582 | + loadingLocal.setVisibility(View.VISIBLE); | |
| 553 | 583 | Toast.makeText(this, "正在开始上传", Toast.LENGTH_LONG).show(); |
| 554 | 584 | break; |
| 555 | 585 | case 1009: | ... | ... |
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/InitViewActivity.java renamed to updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/ui/InitViewActivity.java
| 1 | -package com.cnlive.updownfile.xiaoRay; | |
| 1 | +package com.cnlive.updownfile.xiaoRay.ui; | |
| 2 | 2 | |
| 3 | 3 | import android.os.Environment; |
| 4 | 4 | import android.support.v7.app.AppCompatActivity; |
| ... | ... | @@ -7,6 +7,7 @@ import android.view.View; |
| 7 | 7 | import android.widget.TextView; |
| 8 | 8 | import com.cnlive.updownfile.R; |
| 9 | 9 | import com.cnlive.updownfile.util.DownloadUtil; |
| 10 | +import com.cnlive.updownfile.xiaoRay.Constant; | |
| 10 | 11 | import com.xiaoray.raysdk.RayLib; |
| 11 | 12 | import com.xiaoray.raysdk.entity.bean.LocalCloudPath; |
| 12 | 13 | import com.xiaoray.raysdk.utils.OkHttpUtils.HttpResult; |
| ... | ... | @@ -20,6 +21,7 @@ public class InitViewActivity extends AppCompatActivity implements View.OnClickL |
| 20 | 21 | private TextView show_data; |
| 21 | 22 | private TextView enter_file; |
| 22 | 23 | private TextView recyclerFiles; |
| 24 | + private TextView again; | |
| 23 | 25 | |
| 24 | 26 | @Override |
| 25 | 27 | protected void onCreate(Bundle savedInstanceState) { |
| ... | ... | @@ -33,11 +35,13 @@ public class InitViewActivity extends AppCompatActivity implements View.OnClickL |
| 33 | 35 | show_data = findViewById(R.id.show_data); |
| 34 | 36 | enter_file = findViewById(R.id.enter_file); |
| 35 | 37 | recyclerFiles = findViewById(R.id.recyclerFiles); |
| 38 | + again = findViewById(R.id.again); | |
| 36 | 39 | |
| 37 | 40 | |
| 38 | 41 | show_data.setOnClickListener(this); |
| 39 | 42 | enter_file.setOnClickListener(this); |
| 40 | 43 | recyclerFiles.setOnClickListener(this); |
| 44 | + again.setOnClickListener(this); | |
| 41 | 45 | } |
| 42 | 46 | |
| 43 | 47 | @Override |
| ... | ... | @@ -58,19 +62,8 @@ public class InitViewActivity extends AppCompatActivity implements View.OnClickL |
| 58 | 62 | DiretoryActivity.startDiretoryActivity(InitViewActivity.this,"recy","/"); |
| 59 | 63 | } |
| 60 | 64 | }); |
| 65 | + }else if(i == R.id.again){ | |
| 66 | + Constant.initXiaoRay(this, "a4:11:63:61:00:02", "8656", "625624", "3D6B5148-98D8-4642-9909-45AEBBEEC8E0"); | |
| 61 | 67 | } |
| 62 | 68 | } |
| 63 | - | |
| 64 | - /** | |
| 65 | - * 文件下载 | |
| 66 | - */ | |
| 67 | - private void addDownload(String cloudPath) { | |
| 68 | - ArrayList<LocalCloudPath> arrayLists = new ArrayList<>(); | |
| 69 | - String localPath = Environment.getExternalStorageDirectory().toString(); | |
| 70 | - LocalCloudPath localCloudPath = new LocalCloudPath(); | |
| 71 | - localCloudPath.setCloud(cloudPath); | |
| 72 | - localCloudPath.setLocal(localPath); | |
| 73 | - arrayLists.add(localCloudPath); | |
| 74 | - DownloadUtil.addDownload(InitViewActivity.this, arrayLists); | |
| 75 | - } | |
| 76 | 69 | } | ... | ... |
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/ui/TaskActivity.java
0 → 100644
| 1 | +package com.cnlive.updownfile.xiaoRay.ui; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.content.Intent; | |
| 5 | +import android.graphics.drawable.BitmapDrawable; | |
| 6 | +import android.support.v4.app.FragmentTransaction; | |
| 7 | +import android.support.v7.app.AppCompatActivity; | |
| 8 | +import android.os.Bundle; | |
| 9 | +import android.view.Gravity; | |
| 10 | +import android.view.LayoutInflater; | |
| 11 | +import android.view.View; | |
| 12 | +import android.view.ViewGroup; | |
| 13 | +import android.widget.ImageView; | |
| 14 | +import android.widget.PopupWindow; | |
| 15 | +import android.widget.RadioGroup; | |
| 16 | +import android.widget.TextView; | |
| 17 | + | |
| 18 | +import com.cnlive.updownfile.R; | |
| 19 | +import com.xiaoray.raysdk.RayLib; | |
| 20 | +import com.xiaoray.raysdk.service.TaskDownloadService; | |
| 21 | +import com.xiaoray.raysdk.service.TaskUploadService; | |
| 22 | + | |
| 23 | +public class TaskActivity extends AppCompatActivity { | |
| 24 | + | |
| 25 | + private RadioGroup radioGroup; | |
| 26 | + private TaskDoingFragment doingFragment; | |
| 27 | + private TaskDoneFragment doneFragment; | |
| 28 | + private ImageView pop; | |
| 29 | + | |
| 30 | + public static void startTaskActivity(Context context){ | |
| 31 | + Intent intent = new Intent(context,TaskActivity.class); | |
| 32 | + context.startActivity(intent); | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + protected void onCreate(Bundle savedInstanceState) { | |
| 37 | + super.onCreate(savedInstanceState); | |
| 38 | + setContentView(R.layout.activity_task); | |
| 39 | + radioGroup = findViewById(R.id.module_task_tab); | |
| 40 | + pop = findViewById(R.id.pop); | |
| 41 | + doingFragment = new TaskDoingFragment(); | |
| 42 | + doneFragment = new TaskDoneFragment(); | |
| 43 | + | |
| 44 | + radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | |
| 45 | + @Override | |
| 46 | + public void onCheckedChanged(RadioGroup group, int checkedId) { | |
| 47 | + FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); | |
| 48 | + if ((group.getChildAt(0).getId()) == checkedId) { | |
| 49 | + fragmentTransaction.hide(doneFragment); | |
| 50 | + fragmentTransaction.show(doingFragment); | |
| 51 | + } else { | |
| 52 | + fragmentTransaction.hide(doingFragment); | |
| 53 | + fragmentTransaction.show(doneFragment); | |
| 54 | + } | |
| 55 | + fragmentTransaction.commit(); | |
| 56 | + } | |
| 57 | + }); | |
| 58 | + | |
| 59 | + pop.setOnClickListener(new View.OnClickListener() { | |
| 60 | + @Override | |
| 61 | + public void onClick(View v) { | |
| 62 | + showPopupWindow(); | |
| 63 | + } | |
| 64 | + }); | |
| 65 | + FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); | |
| 66 | + fragmentTransaction.add(R.id.fm_fragment, doingFragment); | |
| 67 | + fragmentTransaction.add(R.id.fm_fragment, doneFragment); | |
| 68 | + fragmentTransaction.commit(); | |
| 69 | + | |
| 70 | + radioGroup.check(radioGroup.getChildAt(0).getId()); | |
| 71 | + fragmentTransaction.show(doingFragment); | |
| 72 | + fragmentTransaction.hide(doneFragment); | |
| 73 | + } | |
| 74 | + | |
| 75 | + private void showPopupWindow() { | |
| 76 | + View contentView = LayoutInflater.from(getBaseContext()).inflate(R.layout.popupp_exercise, (ViewGroup) findViewById(R.id.exercise_ll), false); | |
| 77 | + TextView delete = contentView.findViewById(R.id.all_delete); | |
| 78 | + final TextView start = contentView.findViewById(R.id.all_start); | |
| 79 | + TextView cancel = contentView.findViewById(R.id.cancel_popup); | |
| 80 | + start.setVisibility(radioGroup.getCheckedRadioButtonId() == R.id.rb_doing ? View.VISIBLE : View.GONE); | |
| 81 | + if (radioGroup.getCheckedRadioButtonId() == R.id.rb_doing) { | |
| 82 | + delete.setText(R.string.all_delete); | |
| 83 | + } else { | |
| 84 | + delete.setText("清除完成的任务"); | |
| 85 | + } | |
| 86 | + if (TaskUploadService.isPauseState && TaskDownloadService.isAllPauseState) { | |
| 87 | + start.setText(R.string.all_start); | |
| 88 | + } else { | |
| 89 | + start.setText(R.string.all_pause); | |
| 90 | + } | |
| 91 | + final PopupWindow popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); | |
| 92 | + start.setOnClickListener(new View.OnClickListener() { | |
| 93 | + @Override | |
| 94 | + public void onClick(View v) { | |
| 95 | + if (TaskUploadService.isPauseState && TaskDownloadService.isAllPauseState) { | |
| 96 | + RayLib.controlUpload(getBaseContext(), TaskUploadService.FROM_START_ALL, null); | |
| 97 | + RayLib.controlDownload(getBaseContext(), TaskDownloadService.FROM_CLICK_START, null); | |
| 98 | + } else { | |
| 99 | + RayLib.controlUpload(getBaseContext(), TaskUploadService.FROM_PAUSE_ALL, null); | |
| 100 | + RayLib.controlDownload(getBaseContext(), TaskDownloadService.FROM_CLICK_PAUSE, null); | |
| 101 | + } | |
| 102 | + popupWindow.dismiss(); | |
| 103 | + } | |
| 104 | + }); | |
| 105 | + delete.setOnClickListener(new View.OnClickListener() { | |
| 106 | + @Override | |
| 107 | + public void onClick(View v) { | |
| 108 | + if (radioGroup.getCheckedRadioButtonId() == R.id.rb_doing) { | |
| 109 | + RayLib.controlUpload(getBaseContext(), TaskUploadService.FROM_DELETE_DOING, null); | |
| 110 | + RayLib.controlDownload(getBaseContext(), TaskDownloadService.FROM_DELETE_DOING, null); | |
| 111 | + } else { | |
| 112 | + RayLib.controlUpload(getBaseContext(), TaskUploadService.FROM_DELETE_DONE, null); | |
| 113 | + } | |
| 114 | + popupWindow.dismiss(); | |
| 115 | + } | |
| 116 | + }); | |
| 117 | + cancel.setOnClickListener(new View.OnClickListener() { | |
| 118 | + @Override | |
| 119 | + public void onClick(View v) { | |
| 120 | + popupWindow.dismiss(); | |
| 121 | + } | |
| 122 | + }); | |
| 123 | + popupWindow.setBackgroundDrawable(new BitmapDrawable()); | |
| 124 | + popupWindow.setOutsideTouchable(true); | |
| 125 | + popupWindow.showAtLocation(findViewById(R.id.exercise_ll), Gravity.BOTTOM, 0, 0); | |
| 126 | + | |
| 127 | + } | |
| 128 | +} | ... | ... |
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/ui/TaskDoingFragment.java
0 → 100644
| 1 | +package com.cnlive.updownfile.xiaoRay.ui; | |
| 2 | + | |
| 3 | +import android.os.Handler; | |
| 4 | +import android.support.v7.widget.LinearLayoutManager; | |
| 5 | +import android.support.v7.widget.RecyclerView; | |
| 6 | +import android.util.Log; | |
| 7 | +import android.view.ViewGroup; | |
| 8 | +import android.widget.LinearLayout; | |
| 9 | + | |
| 10 | +import com.cnlive.updownfile.R; | |
| 11 | +import com.cnlive.updownfile.xiaoRay.adapter.TaskDoingAdapter; | |
| 12 | +import com.cnlive.updownfile.xiaoRay.bean.TaskInfoItem; | |
| 13 | +import com.cnlive.updownfile.xiaoRay.view.WrapLinearLayout; | |
| 14 | +import com.xiaoray.raysdk.RayLib; | |
| 15 | +import com.xiaoray.raysdk.constant.ProgressState; | |
| 16 | +import com.xiaoray.raysdk.constant.TaskType; | |
| 17 | +import com.xiaoray.raysdk.entity.bus.BusTaskDoingDeleteDone; | |
| 18 | +import com.xiaoray.raysdk.entity.bus.TaskCheckMd5; | |
| 19 | +import com.xiaoray.raysdk.entity.bus.TaskClickPause; | |
| 20 | +import com.xiaoray.raysdk.entity.bus.TaskClickStart; | |
| 21 | +import com.xiaoray.raysdk.entity.bus.TaskDeleteDoing; | |
| 22 | +import com.xiaoray.raysdk.entity.bus.TaskErrorBus; | |
| 23 | +import com.xiaoray.raysdk.entity.bus.TaskProgress; | |
| 24 | +import com.xiaoray.raysdk.entity.green.TaskUndone; | |
| 25 | +import com.xiaoray.raysdk.listener.RayProgressListener; | |
| 26 | +import com.xiaoray.raysdk.utils.RayLog; | |
| 27 | +import com.xiaoray.raysdk.utils.dataHelper.TaskDoingHelper; | |
| 28 | + | |
| 29 | +import org.greenrobot.eventbus.EventBus; | |
| 30 | +import org.greenrobot.eventbus.Subscribe; | |
| 31 | +import org.greenrobot.eventbus.ThreadMode; | |
| 32 | + | |
| 33 | +import java.util.ArrayList; | |
| 34 | +import java.util.List; | |
| 35 | + | |
| 36 | +public class TaskDoingFragment extends BaseFragment { | |
| 37 | + | |
| 38 | + private RecyclerView taskRecyclerView; | |
| 39 | + private TaskDoingAdapter taskDoingAdapter; | |
| 40 | + private LinearLayout llRoot; | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + protected int getLayout() { | |
| 44 | + return R.layout.fragment_task; | |
| 45 | + } | |
| 46 | + | |
| 47 | + @Override | |
| 48 | + public void initView() { | |
| 49 | + taskRecyclerView = findView(R.id.task_recycler); | |
| 50 | + llRoot = findView(R.id.ll_root); | |
| 51 | + taskRecyclerView.setLayoutManager(new WrapLinearLayout(mContext, | |
| 52 | + LinearLayoutManager.VERTICAL, false)); | |
| 53 | + EventBus.getDefault().register(this); | |
| 54 | + } | |
| 55 | + | |
| 56 | + @Override | |
| 57 | + public void initData() { | |
| 58 | + getUploading(); | |
| 59 | + } | |
| 60 | + | |
| 61 | + private void getUploading() { | |
| 62 | + TaskDoingHelper.deleteLocalPathValid(); | |
| 63 | + TaskDoingHelper.deleteValidData(); | |
| 64 | + List<TaskUndone> upload = TaskDoingHelper.selectDoingFile(TaskType.UPLOAD); | |
| 65 | + List<TaskUndone> download = TaskDoingHelper.selectDoingFile(TaskType.DOWNLOAD); | |
| 66 | + | |
| 67 | + ArrayList<TaskInfoItem> adapterList = new ArrayList<>(); | |
| 68 | + if (upload != null && upload.size() > 0) { | |
| 69 | + for (int i = 0; i < upload.size(); i++) { | |
| 70 | + TaskUndone et = upload.get(i); | |
| 71 | + adapterList.add(new TaskInfoItem(et, 0, "", TaskType.UPLOAD)); | |
| 72 | + } | |
| 73 | + } | |
| 74 | + if (download != null && download.size() > 0) { | |
| 75 | + for (int i = 0; i < download.size(); i++) { | |
| 76 | + TaskUndone et = download.get(i); | |
| 77 | + adapterList.add(new TaskInfoItem(et, 0, "", TaskType.DOWNLOAD)); | |
| 78 | + } | |
| 79 | + } | |
| 80 | + taskDoingAdapter = new TaskDoingAdapter(R.layout.item_task_info, adapterList); | |
| 81 | + taskRecyclerView.setAdapter(taskDoingAdapter); | |
| 82 | + taskDoingAdapter.notifyDataSetChanged(); | |
| 83 | + showNoDataView(); | |
| 84 | + RayLog.e("taskDoingAdapter :" + taskDoingAdapter.getData()); | |
| 85 | + } | |
| 86 | + | |
| 87 | + | |
| 88 | + @Override | |
| 89 | + public void initListener() { | |
| 90 | + | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * 里面的回调都是在子线程,需要发送到主线程, 没有采用Handler,用的是Eventbus | |
| 94 | + */ | |
| 95 | + RayLib.setProgressListener(new RayProgressListener() { | |
| 96 | + @Override | |
| 97 | + public void onProgressChange(TaskProgress event) { | |
| 98 | + EventBus.getDefault().post(new TaskProgress(event.getId(), | |
| 99 | + event.getCloudPath(), | |
| 100 | + event.getTaskType(), event.getCurrentFileSize(), event.getSpeed(), | |
| 101 | + event.getProgress(), event.getTotalFileSize())); | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + /** | |
| 106 | + *检查md5 | |
| 107 | + */ | |
| 108 | + public void md5(TaskCheckMd5 event) { | |
| 109 | + EventBus.getDefault().post(new TaskCheckMd5(event.getId(), | |
| 110 | + event.getTaskType())); | |
| 111 | + } | |
| 112 | + | |
| 113 | + /** | |
| 114 | + * 删除完成的任务 | |
| 115 | + */ | |
| 116 | + public void done(BusTaskDoingDeleteDone event) { | |
| 117 | + EventBus.getDefault().post(new BusTaskDoingDeleteDone(event.getId(), | |
| 118 | + event.getCloudPath(), event.getTaskType())); | |
| 119 | + } | |
| 120 | + | |
| 121 | + /** | |
| 122 | + * 展示出错的任务 | |
| 123 | + */ | |
| 124 | + public void error(TaskErrorBus event) { | |
| 125 | + EventBus.getDefault().post(new TaskErrorBus(event.getId(), | |
| 126 | + event.getTaskType(), event.getFileName(), event.getFileSize(), | |
| 127 | + event.getErrorInfo())); | |
| 128 | + } | |
| 129 | + | |
| 130 | + /** | |
| 131 | + * 点击开始 | |
| 132 | + */ | |
| 133 | + public void start(TaskClickStart event) { | |
| 134 | + EventBus.getDefault().post(new TaskClickStart()); | |
| 135 | + } | |
| 136 | + | |
| 137 | + /** | |
| 138 | + * 点击暂停 | |
| 139 | + */ | |
| 140 | + public void pause(TaskClickPause event) { | |
| 141 | + EventBus.getDefault().post(new TaskClickPause(event.isAll(), | |
| 142 | + event.getFileId())); | |
| 143 | + } | |
| 144 | + | |
| 145 | + /** | |
| 146 | + * 删除所有的进行中的任务 | |
| 147 | + */ | |
| 148 | + public void delete(TaskDeleteDoing event) { | |
| 149 | + EventBus.getDefault().post(new TaskDeleteDoing()); | |
| 150 | + } | |
| 151 | + }); | |
| 152 | + startLog(); | |
| 153 | + } | |
| 154 | + | |
| 155 | + Handler handler = new Handler(); | |
| 156 | + private void startLog() { | |
| 157 | + handler.postDelayed(new Runnable() { | |
| 158 | + @Override | |
| 159 | + public void run() { | |
| 160 | + Log.e("打印获取任务", "进度信息:" + RayLib.getProgressInfo()); | |
| 161 | + startLog(); | |
| 162 | + } | |
| 163 | + }, 1000); | |
| 164 | + } | |
| 165 | + | |
| 166 | + | |
| 167 | + private void showNoDataView() { | |
| 168 | + if (taskDoingAdapter.getData().size() == 0) { | |
| 169 | + taskDoingAdapter.getData().clear(); | |
| 170 | + taskDoingAdapter.notifyDataSetChanged(); | |
| 171 | + taskDoingAdapter.setEmptyView(R.layout.layout_no_data_text, | |
| 172 | + (ViewGroup) taskRecyclerView.getParent()); | |
| 173 | + } | |
| 174 | + } | |
| 175 | + | |
| 176 | + @Override | |
| 177 | + public void onDestroyView() { | |
| 178 | + super.onDestroyView(); | |
| 179 | + EventBus.getDefault().unregister(this); | |
| 180 | + handler.removeCallbacksAndMessages(null); | |
| 181 | + } | |
| 182 | + | |
| 183 | + /** | |
| 184 | + * 更新进度条 | |
| 185 | + */ | |
| 186 | + @Subscribe(threadMode = ThreadMode.MAIN) | |
| 187 | + public void doing(TaskProgress event) { | |
| 188 | + for (int i = 0; i < taskDoingAdapter.getData().size(); i++) { | |
| 189 | + if (((TaskInfoItem) taskDoingAdapter.getData().get(i)).getEtDoing().getId() == | |
| 190 | + event.getId()) { | |
| 191 | + TaskInfoItem taskInfoItem = ((TaskInfoItem) taskDoingAdapter.getData().get | |
| 192 | + (i)); | |
| 193 | + taskInfoItem.setProgress(event.getProgress()); | |
| 194 | + taskInfoItem.setCurrentFileSize(event.getCurrentFileSize()); | |
| 195 | + taskInfoItem.setTotalFileSize(event.getTotalFileSize()); | |
| 196 | + taskInfoItem.setSpeed(event.getSpeed()); | |
| 197 | + taskDoingAdapter.notifyItemChanged(i); | |
| 198 | + } | |
| 199 | + } | |
| 200 | + } | |
| 201 | + | |
| 202 | + /** | |
| 203 | + * *检查md5 | |
| 204 | + */ | |
| 205 | + @Subscribe(threadMode = ThreadMode.MAIN) | |
| 206 | + public void md5(TaskCheckMd5 event) { | |
| 207 | + for (int i = 0; i < taskDoingAdapter.getData().size(); i++) { | |
| 208 | + if (((TaskInfoItem) taskDoingAdapter.getData().get(i)).getEtDoing().getId() == | |
| 209 | + event.getId()) { | |
| 210 | + TaskInfoItem taskInfoItem = ((TaskInfoItem) taskDoingAdapter.getData().get | |
| 211 | + (i)); | |
| 212 | + taskInfoItem.setProgress(ProgressState.PROGRESS_CHECK_MD5); | |
| 213 | + taskDoingAdapter.notifyItemChanged(i); | |
| 214 | + } | |
| 215 | + } | |
| 216 | + } | |
| 217 | + | |
| 218 | + /** | |
| 219 | + * 上传或者下载完成的监听。 | |
| 220 | + * | |
| 221 | + * 删除完成的任务 | |
| 222 | + */ | |
| 223 | + @Subscribe(threadMode = ThreadMode.MAIN) | |
| 224 | + public void done(BusTaskDoingDeleteDone event) { | |
| 225 | + for (int i = 0; i < taskDoingAdapter.getData().size(); i++) { | |
| 226 | + if (((TaskInfoItem) taskDoingAdapter.getData().get(i)).getEtDoing().getId() == | |
| 227 | + event.getId()) { | |
| 228 | + taskDoingAdapter.remove(i); | |
| 229 | + break; | |
| 230 | + } | |
| 231 | + } | |
| 232 | + showNoDataView(); | |
| 233 | + } | |
| 234 | + | |
| 235 | + /** | |
| 236 | + * 展示出错的任务 | |
| 237 | + */ | |
| 238 | + @Subscribe(threadMode = ThreadMode.MAIN) | |
| 239 | + public void error(TaskErrorBus event) { | |
| 240 | + for (int i = 0; i < taskDoingAdapter.getData().size(); i++) { | |
| 241 | + if (((TaskInfoItem) taskDoingAdapter.getData().get(i)).getEtDoing().getId() == | |
| 242 | + event.getId()) { | |
| 243 | + ((TaskInfoItem) taskDoingAdapter.getData().get(i)).setProgress | |
| 244 | + (ProgressState.PROGRESS_ERROR); | |
| 245 | + ((TaskInfoItem) taskDoingAdapter.getData().get(i)).setErrorInfo(event | |
| 246 | + .getErrorInfo()); | |
| 247 | + taskDoingAdapter.notifyItemChanged(i); | |
| 248 | + break; | |
| 249 | + } | |
| 250 | + } | |
| 251 | + } | |
| 252 | + | |
| 253 | + /** | |
| 254 | + * 点击开始 | |
| 255 | + */ | |
| 256 | + @Subscribe(threadMode = ThreadMode.MAIN) | |
| 257 | + public void start(TaskClickStart event) { | |
| 258 | + for (int i = 0; i < taskDoingAdapter.getData().size(); i++) { | |
| 259 | + ((TaskInfoItem) taskDoingAdapter.getData().get(i)).setProgress(0); | |
| 260 | + } | |
| 261 | + taskDoingAdapter.notifyDataSetChanged(); | |
| 262 | + } | |
| 263 | + | |
| 264 | + /** | |
| 265 | + * 点击暂停 | |
| 266 | + */ | |
| 267 | + @Subscribe(threadMode = ThreadMode.MAIN) | |
| 268 | + public void pause(TaskClickPause event) { | |
| 269 | + if (event.isAll()) { | |
| 270 | + for (int i = 0; i < taskDoingAdapter.getData().size(); i++) { | |
| 271 | + ((TaskInfoItem) taskDoingAdapter.getData().get(i)).setProgress | |
| 272 | + (ProgressState.PROGRESS_PAUSE); | |
| 273 | + } | |
| 274 | + taskDoingAdapter.notifyDataSetChanged(); | |
| 275 | + } else { | |
| 276 | + for (int i = 0; i < taskDoingAdapter.getData().size(); i++) { | |
| 277 | + if (((TaskInfoItem) taskDoingAdapter.getData().get(i)).getEtDoing().getId() | |
| 278 | + == event.getFileId()) { | |
| 279 | + ((TaskInfoItem) taskDoingAdapter.getData().get(i)).setProgress | |
| 280 | + (ProgressState.PROGRESS_PAUSE); | |
| 281 | + taskDoingAdapter.notifyItemChanged(i); | |
| 282 | + break; | |
| 283 | + } | |
| 284 | + } | |
| 285 | + } | |
| 286 | + | |
| 287 | + } | |
| 288 | + | |
| 289 | + /** | |
| 290 | + * 删除所有的进行中的任务 | |
| 291 | + */ | |
| 292 | + @Subscribe(threadMode = ThreadMode.MAIN) | |
| 293 | + public void delete(TaskDeleteDoing event) { | |
| 294 | + taskDoingAdapter.getData().clear(); | |
| 295 | + taskDoingAdapter.notifyDataSetChanged(); | |
| 296 | + taskDoingAdapter.setEmptyView(R.layout.layout_no_data_text, llRoot); | |
| 297 | + } | |
| 298 | +} | ... | ... |
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/ui/TaskDoneFragment.java
0 → 100644
| 1 | +package com.cnlive.updownfile.xiaoRay.ui; | |
| 2 | + | |
| 3 | +import android.support.v7.widget.LinearLayoutManager; | |
| 4 | +import android.support.v7.widget.RecyclerView; | |
| 5 | +import android.view.ViewGroup; | |
| 6 | +import android.widget.LinearLayout; | |
| 7 | + | |
| 8 | +import com.cnlive.updownfile.R; | |
| 9 | +import com.cnlive.updownfile.xiaoRay.adapter.TaskDoneItemAdapter; | |
| 10 | +import com.xiaoray.raysdk.RayLib; | |
| 11 | +import com.xiaoray.raysdk.entity.bus.BusTaskDoneAdd; | |
| 12 | +import com.xiaoray.raysdk.entity.bus.BusTaskDoneDel; | |
| 13 | +import com.xiaoray.raysdk.entity.green.TaskDone; | |
| 14 | +import com.xiaoray.raysdk.listener.RayDoneListener; | |
| 15 | +import com.xiaoray.raysdk.utils.dataHelper.TaskDoneHelper; | |
| 16 | + | |
| 17 | +import org.greenrobot.eventbus.EventBus; | |
| 18 | +import org.greenrobot.eventbus.Subscribe; | |
| 19 | +import org.greenrobot.eventbus.ThreadMode; | |
| 20 | + | |
| 21 | +import java.util.List; | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * 完成的任务 | |
| 25 | + */ | |
| 26 | +public class TaskDoneFragment extends BaseFragment { | |
| 27 | + | |
| 28 | + private RecyclerView taskRecyclerView; | |
| 29 | + private TaskDoneItemAdapter taskItemAdapter; | |
| 30 | + private LinearLayout llRoot; | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + protected int getLayout() { | |
| 34 | + return R.layout.fragment_task; | |
| 35 | + } | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + public void initView() { | |
| 39 | + EventBus.getDefault().register(this); | |
| 40 | + taskRecyclerView = findView(R.id.task_recycler); | |
| 41 | + llRoot = findView(R.id.ll_root); | |
| 42 | + } | |
| 43 | + | |
| 44 | + @Override | |
| 45 | + public void initListener() { | |
| 46 | + | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * 里面的回调都是在子线程,需要发送到主线程, 没有采用Handler,用的是Eventbus | |
| 50 | + */ | |
| 51 | + RayLib.setDoneListener(new RayDoneListener() { | |
| 52 | + @Override | |
| 53 | + public void doneAdd(BusTaskDoneAdd event) { | |
| 54 | + EventBus.getDefault().post(new BusTaskDoneAdd(event.getTaskDone())); | |
| 55 | + } | |
| 56 | + | |
| 57 | + @Override | |
| 58 | + public void doneDel(BusTaskDoneDel busDeleteDone) { | |
| 59 | + EventBus.getDefault().post(new BusTaskDoneDel()); | |
| 60 | + } | |
| 61 | + }); | |
| 62 | + | |
| 63 | + } | |
| 64 | + | |
| 65 | + @Override | |
| 66 | + public void initData() { | |
| 67 | + taskRecyclerView.setLayoutManager(new LinearLayoutManager(mContext)); | |
| 68 | + List<TaskDone> youngUploading = TaskDoneHelper.selectDoneFile(); | |
| 69 | + taskItemAdapter = new TaskDoneItemAdapter(R.layout.item_task_done_info, youngUploading); | |
| 70 | + taskRecyclerView.setAdapter(taskItemAdapter); | |
| 71 | + taskItemAdapter.expandAll(); | |
| 72 | + showNoDataView(); | |
| 73 | + } | |
| 74 | + | |
| 75 | + | |
| 76 | + @Override | |
| 77 | + public void onDestroyView() { | |
| 78 | + super.onDestroyView(); | |
| 79 | + EventBus.getDefault().unregister(this); | |
| 80 | + } | |
| 81 | + | |
| 82 | + private void showNoDataView() { | |
| 83 | + if (taskItemAdapter.getData().size() == 0) { | |
| 84 | + taskItemAdapter.getData().clear(); | |
| 85 | + taskItemAdapter.notifyDataSetChanged(); | |
| 86 | + taskItemAdapter.setEmptyView(R.layout.layout_no_data_text, (ViewGroup) taskRecyclerView.getParent()); | |
| 87 | + } | |
| 88 | + } | |
| 89 | + | |
| 90 | + @Subscribe(threadMode = ThreadMode.MAIN) | |
| 91 | + public void done(BusTaskDoneAdd event) { | |
| 92 | + taskItemAdapter.addData(0, event.getTaskDone()); | |
| 93 | + taskRecyclerView.smoothScrollToPosition(0); | |
| 94 | + } | |
| 95 | + | |
| 96 | + | |
| 97 | + @Subscribe(threadMode = ThreadMode.MAIN) | |
| 98 | + public void pause(BusTaskDoneDel event) { | |
| 99 | + taskItemAdapter.getData().clear(); | |
| 100 | + taskItemAdapter.notifyDataSetChanged(); | |
| 101 | + taskItemAdapter.setEmptyView(R.layout.layout_no_data_text, llRoot); | |
| 102 | + } | |
| 103 | +} | ... | ... |
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/view/GlideUrlNoToken.java
0 → 100644
| 1 | +package com.cnlive.updownfile.xiaoRay.view; | |
| 2 | + | |
| 3 | +import com.bumptech.glide.load.model.GlideUrl; | |
| 4 | +import com.bumptech.glide.load.model.Headers; | |
| 5 | +import com.xiaoray.raysdk.entity.bean.GlobalCacheBean; | |
| 6 | + | |
| 7 | +import java.net.URL; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * Created by 24479 on 2018/3/20. | |
| 11 | + */ | |
| 12 | + | |
| 13 | +public class GlideUrlNoToken extends GlideUrl { | |
| 14 | + private long size; | |
| 15 | + | |
| 16 | + public GlideUrlNoToken(URL url) { | |
| 17 | + super(url); | |
| 18 | + } | |
| 19 | + | |
| 20 | + public GlideUrlNoToken(URL url, Headers headers) { | |
| 21 | + super(url, headers); | |
| 22 | + } | |
| 23 | + | |
| 24 | + public GlideUrlNoToken(String url) { | |
| 25 | + super(url); | |
| 26 | + } | |
| 27 | + | |
| 28 | + public GlideUrlNoToken(String url, long size) { | |
| 29 | + super(url); | |
| 30 | + this.size=size; | |
| 31 | + } | |
| 32 | + | |
| 33 | + public GlideUrlNoToken(String url, Headers headers) { | |
| 34 | + super(url, headers); | |
| 35 | + } | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * http://192.168.88.36/v4/static/thumb/32/033_L2.jpg?token=8aa68cfd7c7442ff4ef6f740ee01e60b | |
| 39 | + * 这是最新的模板 | |
| 40 | + */ | |
| 41 | + @Override | |
| 42 | + public String getCacheKey() { | |
| 43 | + String url = toStringUrl(); | |
| 44 | + int startIndex = 0; | |
| 45 | + int lastIndex = 0; | |
| 46 | + if (url.contains("//")) { | |
| 47 | + String url1 = url.substring(url.indexOf("//") + 2); | |
| 48 | + if (url1.contains("/") && url1.contains("?token=")) { | |
| 49 | + startIndex = url1.indexOf("/"); | |
| 50 | + lastIndex = url1.lastIndexOf("?token="); | |
| 51 | + url1 = url1.substring(startIndex, lastIndex); | |
| 52 | + url1 = GlobalCacheBean.getCurrentCloudMac() + "/" + url1; | |
| 53 | + return url1; | |
| 54 | + } | |
| 55 | + } | |
| 56 | + return url; | |
| 57 | + } | |
| 58 | +} | ... | ... |
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/view/RayGlide.java
| ... | ... | @@ -61,4 +61,33 @@ public class RayGlide { |
| 61 | 61 | public static void GlideClearMemory(Context mContext) { |
| 62 | 62 | Glide.get(mContext).clearMemory(); |
| 63 | 63 | } |
| 64 | + /** | |
| 65 | + * 加载圆形图 本地路径 | |
| 66 | + */ | |
| 67 | + public static void loadLocalRound(Context mContext, String path, int defaultResId, ImageView mImageView) { | |
| 68 | + Glide.with(mContext).load(path).apply(roundOptions(defaultResId)).into(mImageView); | |
| 69 | + } | |
| 70 | + | |
| 71 | + private static RequestOptions roundOptions(int defaultResId) { | |
| 72 | + return normalOptions(defaultResId); | |
| 73 | + } | |
| 74 | + | |
| 75 | + /** | |
| 76 | + * 加载圆角图 | |
| 77 | + */ | |
| 78 | + public static void resRound(Context mContext, int resId, ImageView mImageView) { | |
| 79 | + Glide.with(mContext).load(resId).apply(roundOptions()).into(mImageView); | |
| 80 | + } | |
| 81 | + | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * 加载圆形图 网上路径 | |
| 85 | + */ | |
| 86 | + public static void resRound(Context mContext, String path, int defaultRedId , ImageView mImageView) { | |
| 87 | + Glide.with(mContext).load(new GlideUrlNoToken(path)).apply(roundOptions(defaultRedId)).into(mImageView); | |
| 88 | + } | |
| 89 | + | |
| 90 | + private static RequestOptions roundOptions() { | |
| 91 | + return normalOptions(R.drawable.ic_launcher); | |
| 92 | + } | |
| 64 | 93 | } | ... | ... |
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/view/WrapLinearLayout.java
0 → 100644
| 1 | +package com.cnlive.updownfile.xiaoRay.view; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.support.v7.widget.LinearLayoutManager; | |
| 5 | +import android.support.v7.widget.RecyclerView; | |
| 6 | +import android.util.AttributeSet; | |
| 7 | + | |
| 8 | + | |
| 9 | +public class WrapLinearLayout extends LinearLayoutManager { | |
| 10 | + public WrapLinearLayout(Context context) { | |
| 11 | + super(context); | |
| 12 | + } | |
| 13 | + | |
| 14 | + public WrapLinearLayout(Context context, int orientation, boolean reverseLayout) { | |
| 15 | + super(context, orientation, reverseLayout); | |
| 16 | + } | |
| 17 | + | |
| 18 | + public WrapLinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | |
| 19 | + super(context, attrs, defStyleAttr, defStyleRes); | |
| 20 | + } | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) { | |
| 24 | + try { | |
| 25 | + super.onLayoutChildren(recycler, state); | |
| 26 | + } catch (Exception e) { | |
| 27 | + e.printStackTrace(); | |
| 28 | + } | |
| 29 | + } | |
| 30 | +} | ... | ... |
updownfile/src/main/res/drawable-hdpi/bg_doc.webp
0 → 100644
No preview for this file type
updownfile/src/main/res/drawable-hdpi/bg_music.webp
0 → 100644
No preview for this file type
updownfile/src/main/res/drawable-hdpi/bg_photo.webp
0 → 100644
No preview for this file type
updownfile/src/main/res/drawable-hdpi/bg_unknown.webp
0 → 100644
No preview for this file type
updownfile/src/main/res/drawable-hdpi/bg_video.webp
0 → 100644
No preview for this file type
updownfile/src/main/res/drawable-hdpi/ic_launcher.png
0 → 100644
2.98 KB
updownfile/src/main/res/drawable-hdpi/icon_vertical_more.webp
0 → 100644
No preview for this file type
updownfile/src/main/res/drawable/sel_button_underline.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<selector | |
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" > | |
| 4 | + | |
| 5 | + <item android:state_checked="true"> | |
| 6 | + <layer-list> | |
| 7 | + | |
| 8 | + <item android:top="38dp" android:left="15dp" android:right="15dp"> | |
| 9 | + | |
| 10 | + <shape android:shape="rectangle" > | |
| 11 | + <solid android:color="@color/color_FF7733" /> | |
| 12 | + </shape> | |
| 13 | + </item> | |
| 14 | + </layer-list> | |
| 15 | + </item> | |
| 16 | + | |
| 17 | + <item android:drawable="@color/white"></item> | |
| 18 | + | |
| 19 | +</selector> | |
| 0 | 20 | \ No newline at end of file | ... | ... |
updownfile/src/main/res/drawable/sel_text_color.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 3 | + <item android:color="@color/color_FF7733" android:state_checked="true"></item> | |
| 4 | + <item android:color="@color/color_666666" android:state_checked="false"></item> | |
| 5 | +</selector> | |
| 0 | 6 | \ No newline at end of file | ... | ... |
updownfile/src/main/res/layout/activity_diretory.xml
| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | android:layout_width="match_parent" |
| 6 | 6 | android:layout_height="match_parent" |
| 7 | 7 | android:orientation="vertical" |
| 8 | - tools:context=".xiaoRay.DiretoryActivity"> | |
| 8 | + tools:context=".xiaoRay.ui.DiretoryActivity"> | |
| 9 | 9 | |
| 10 | 10 | <LinearLayout |
| 11 | 11 | android:id="@+id/choose" |
| ... | ... | @@ -210,6 +210,15 @@ |
| 210 | 210 | android:layout_gravity="right" |
| 211 | 211 | android:visibility="gone" |
| 212 | 212 | android:text="清空回收站" /> |
| 213 | + <Button | |
| 214 | + android:id="@+id/check_updown" | |
| 215 | + android:layout_width="70dp" | |
| 216 | + android:layout_height="70dp" | |
| 217 | + android:background="@drawable/gr_bg_nor" | |
| 218 | + android:padding="10dp" | |
| 219 | + android:layout_marginTop="10dp" | |
| 220 | + android:layout_gravity="right" | |
| 221 | + android:text="上传下载任务" /> | |
| 213 | 222 | </LinearLayout> |
| 214 | 223 | |
| 215 | 224 | ... | ... |
updownfile/src/main/res/layout/activity_init_view.xml
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | android:layout_height="match_parent" |
| 7 | 7 | android:orientation="vertical" |
| 8 | 8 | android:padding="50dp" |
| 9 | - tools:context=".xiaoRay.InitViewActivity"> | |
| 9 | + tools:context=".xiaoRay.ui.InitViewActivity"> | |
| 10 | 10 | <TextView |
| 11 | 11 | android:id="@+id/show_data" |
| 12 | 12 | android:layout_width="match_parent" |
| ... | ... | @@ -40,4 +40,15 @@ |
| 40 | 40 | android:text="进入回收站" |
| 41 | 41 | android:gravity="center" |
| 42 | 42 | /> |
| 43 | + | |
| 44 | + <TextView | |
| 45 | + android:id="@+id/again" | |
| 46 | + android:layout_width="match_parent" | |
| 47 | + android:layout_height="wrap_content" | |
| 48 | + android:layout_marginTop="10dp" | |
| 49 | + android:background="@drawable/anchor_barrage_bg_nor" | |
| 50 | + android:padding="10dp" | |
| 51 | + android:text="重新连接" | |
| 52 | + android:gravity="center" | |
| 53 | + /> | |
| 43 | 54 | </LinearLayout> |
| 44 | 55 | \ No newline at end of file | ... | ... |
updownfile/src/main/res/layout/activity_task.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + xmlns:tools="http://schemas.android.com/tools" | |
| 4 | + android:layout_width="match_parent" | |
| 5 | + android:layout_height="match_parent" | |
| 6 | + tools:context=".xiaoRay.ui.TaskActivity" | |
| 7 | + android:id="@+id/exercise_ll" | |
| 8 | + android:orientation="vertical"> | |
| 9 | +<RelativeLayout | |
| 10 | + android:layout_width="match_parent" | |
| 11 | + android:layout_height="48dp"> | |
| 12 | + <TextView | |
| 13 | + android:layout_width="wrap_content" | |
| 14 | + android:layout_height="wrap_content" | |
| 15 | + android:text="任务列表" | |
| 16 | + android:textSize="18sp" | |
| 17 | + android:textColor="#000000" | |
| 18 | + android:layout_centerInParent="true"/> | |
| 19 | + <ImageView | |
| 20 | + android:id="@+id/pop" | |
| 21 | + android:layout_width="wrap_content" | |
| 22 | + android:layout_height="wrap_content" | |
| 23 | + android:src="@drawable/icon_vertical_more" | |
| 24 | + android:layout_alignParentRight="true" | |
| 25 | + android:layout_centerVertical="true" | |
| 26 | + android:padding="10dp" | |
| 27 | + /> | |
| 28 | +</RelativeLayout> | |
| 29 | + <RadioGroup | |
| 30 | + android:id="@+id/module_task_tab" | |
| 31 | + android:layout_width="match_parent" | |
| 32 | + android:layout_height="@dimen/dp_40" | |
| 33 | + android:background="@color/white" | |
| 34 | + android:orientation="horizontal" | |
| 35 | + android:paddingLeft="18dp" | |
| 36 | + android:paddingRight="18dp"> | |
| 37 | + | |
| 38 | + <RadioButton | |
| 39 | + android:layout_width="0dp" | |
| 40 | + android:layout_height="match_parent" | |
| 41 | + android:layout_weight="1" | |
| 42 | + android:background="@drawable/sel_button_underline" | |
| 43 | + android:button="@null" | |
| 44 | + android:id="@+id/rb_doing" | |
| 45 | + android:gravity="center" | |
| 46 | + android:text="@string/module_task_doing" | |
| 47 | + android:textColor="@drawable/sel_text_color" | |
| 48 | + android:textSize="15dp" /> | |
| 49 | + | |
| 50 | + <RadioButton | |
| 51 | + android:layout_width="0dp" | |
| 52 | + android:layout_height="match_parent" | |
| 53 | + android:layout_weight="1" | |
| 54 | + android:background="@drawable/sel_button_underline" | |
| 55 | + android:button="@null" | |
| 56 | + android:gravity="center" | |
| 57 | + android:text="@string/module_task_finished" | |
| 58 | + android:textColor="@drawable/sel_text_color" | |
| 59 | + android:textSize="15dp" /> | |
| 60 | + </RadioGroup> | |
| 61 | + <FrameLayout | |
| 62 | + android:id="@+id/fm_fragment" | |
| 63 | + android:layout_width="match_parent" | |
| 64 | + android:layout_height="match_parent"/> | |
| 65 | +</LinearLayout> | |
| 0 | 66 | \ No newline at end of file | ... | ... |
updownfile/src/main/res/layout/fragment_task.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + android:layout_width="match_parent" | |
| 4 | + android:layout_height="match_parent" | |
| 5 | + android:background="@color/color_F4F4F4" | |
| 6 | + android:orientation="vertical" | |
| 7 | + android:id="@+id/ll_root" | |
| 8 | + > | |
| 9 | + | |
| 10 | + <android.support.v7.widget.RecyclerView | |
| 11 | + android:id="@+id/task_recycler" | |
| 12 | + android:layout_width="match_parent" | |
| 13 | + android:layout_height="match_parent" | |
| 14 | + /> | |
| 15 | + | |
| 16 | + | |
| 17 | +</LinearLayout> | |
| 0 | 18 | \ No newline at end of file | ... | ... |
updownfile/src/main/res/layout/item_task_done_info.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + android:id="@+id/com_swipe_down" | |
| 4 | + android:layout_width="match_parent" | |
| 5 | + android:layout_height="wrap_content" | |
| 6 | + android:background="@color/white" | |
| 7 | + android:gravity="center_vertical" | |
| 8 | + android:orientation="horizontal" | |
| 9 | + android:padding="@dimen/dp_10"> | |
| 10 | + | |
| 11 | + <ImageView | |
| 12 | + android:id="@+id/iv_file_type" | |
| 13 | + android:layout_width="@dimen/dp_40" | |
| 14 | + android:layout_height="@dimen/dp_40" | |
| 15 | + android:layout_gravity="center_vertical" | |
| 16 | + android:scaleType="centerCrop" /> | |
| 17 | + | |
| 18 | + <LinearLayout | |
| 19 | + android:layout_width="0dp" | |
| 20 | + android:layout_height="wrap_content" | |
| 21 | + android:layout_gravity="center_vertical" | |
| 22 | + android:layout_marginLeft="@dimen/dp_10" | |
| 23 | + android:layout_weight="1" | |
| 24 | + android:orientation="vertical"> | |
| 25 | + | |
| 26 | + <TextView | |
| 27 | + android:id="@+id/tv_name" | |
| 28 | + android:layout_width="match_parent" | |
| 29 | + android:layout_height="match_parent" | |
| 30 | + android:layout_gravity="left" | |
| 31 | + android:ellipsize="middle" | |
| 32 | + android:gravity="left" | |
| 33 | + android:singleLine="true" | |
| 34 | + android:text="" | |
| 35 | + android:textColor="@color/color_333333" | |
| 36 | + android:textSize="15sp" | |
| 37 | + android:layout_marginRight="100dp" | |
| 38 | + /> | |
| 39 | + | |
| 40 | + <LinearLayout | |
| 41 | + android:layout_width="match_parent" | |
| 42 | + android:layout_height="wrap_content" | |
| 43 | + android:layout_marginTop="@dimen/dp_4" | |
| 44 | + android:orientation="horizontal"> | |
| 45 | + | |
| 46 | + <TextView | |
| 47 | + android:id="@+id/tv_time" | |
| 48 | + android:layout_width="wrap_content" | |
| 49 | + android:layout_height="match_parent" | |
| 50 | + android:layout_gravity="left" | |
| 51 | + android:layout_weight="1" | |
| 52 | + android:gravity="left" | |
| 53 | + android:singleLine="true" | |
| 54 | + android:text="" | |
| 55 | + android:textColor="@color/color_AAAAAA" | |
| 56 | + android:textSize="@dimen/sp_12" /> | |
| 57 | + | |
| 58 | + <TextView | |
| 59 | + android:id="@+id/tv_file_size" | |
| 60 | + android:layout_width="wrap_content" | |
| 61 | + android:layout_height="wrap_content" | |
| 62 | + android:layout_marginLeft="@dimen/dp_4" | |
| 63 | + android:layout_marginRight="@dimen/dp_10" | |
| 64 | + android:ellipsize="middle" | |
| 65 | + android:gravity="right|bottom" | |
| 66 | + android:maxLength="10" | |
| 67 | + android:singleLine="true" | |
| 68 | + android:text="" | |
| 69 | + android:textColor="@color/color_AAAAAA" | |
| 70 | + android:textSize="@dimen/sp_12" /> | |
| 71 | + | |
| 72 | + </LinearLayout> | |
| 73 | + | |
| 74 | + | |
| 75 | + </LinearLayout> | |
| 76 | + | |
| 77 | + | |
| 78 | +</LinearLayout> | ... | ... |
updownfile/src/main/res/layout/item_task_info.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 4 | + android:id="@+id/com_swipe_down" | |
| 5 | + android:layout_width="match_parent" | |
| 6 | + android:layout_height="wrap_content" | |
| 7 | + android:background="@color/white" | |
| 8 | + android:gravity="center_vertical" | |
| 9 | + android:minHeight="60dp" | |
| 10 | + android:orientation="horizontal" | |
| 11 | + android:paddingLeft="@dimen/dp_10"> | |
| 12 | + | |
| 13 | + <ImageView | |
| 14 | + android:id="@+id/iv_file_type" | |
| 15 | + android:layout_width="@dimen/dp_40" | |
| 16 | + android:layout_height="@dimen/dp_40" | |
| 17 | + android:layout_gravity="center_vertical" | |
| 18 | + android:scaleType="centerCrop" /> | |
| 19 | + | |
| 20 | + <LinearLayout | |
| 21 | + android:layout_width="wrap_content" | |
| 22 | + android:layout_height="wrap_content" | |
| 23 | + android:layout_gravity="center_vertical" | |
| 24 | + android:layout_marginLeft="@dimen/dp_10" | |
| 25 | + android:layout_weight="1" | |
| 26 | + android:orientation="vertical"> | |
| 27 | + | |
| 28 | + <TextView | |
| 29 | + android:id="@+id/tv_name" | |
| 30 | + android:layout_width="wrap_content" | |
| 31 | + android:layout_height="match_parent" | |
| 32 | + android:layout_gravity="left" | |
| 33 | + android:ellipsize="middle" | |
| 34 | + android:gravity="left" | |
| 35 | + android:singleLine="true" | |
| 36 | + android:text="任务名称" | |
| 37 | + android:textColor="@color/color_333333" | |
| 38 | + android:textSize="15sp" /> | |
| 39 | + | |
| 40 | + <TextView | |
| 41 | + android:id="@+id/tv_file_size" | |
| 42 | + android:layout_width="wrap_content" | |
| 43 | + android:layout_height="match_parent" | |
| 44 | + android:layout_gravity="left|bottom" | |
| 45 | + android:ellipsize="start" | |
| 46 | + android:gravity="left" | |
| 47 | + android:maxLines="6" | |
| 48 | + android:text="filesize" | |
| 49 | + android:textColor="@color/color_999999" | |
| 50 | + android:textSize="@dimen/sp_12" /> | |
| 51 | + | |
| 52 | + </LinearLayout> | |
| 53 | + | |
| 54 | + <TextView | |
| 55 | + android:id="@+id/tv_speed" | |
| 56 | + android:layout_width="wrap_content" | |
| 57 | + android:layout_height="wrap_content" | |
| 58 | + android:layout_gravity="bottom" | |
| 59 | + android:layout_marginRight="@dimen/dp_10" | |
| 60 | + android:gravity="bottom|right" | |
| 61 | + android:minWidth="70dp" | |
| 62 | + android:singleLine="true" | |
| 63 | + android:text="速度" | |
| 64 | + android:textColor="@color/color_999999" | |
| 65 | + android:textSize="@dimen/sp_12" /> | |
| 66 | + | |
| 67 | + <TextView | |
| 68 | + android:id="@+id/tv_progress_num" | |
| 69 | + android:layout_width="wrap_content" | |
| 70 | + android:layout_height="wrap_content" | |
| 71 | + android:layout_gravity="bottom" | |
| 72 | + android:gravity="bottom|right" | |
| 73 | + android:minWidth="@dimen/dp_40" | |
| 74 | + android:singleLine="true" | |
| 75 | + android:text="进度" | |
| 76 | + android:textColor="@color/color_999999" | |
| 77 | + android:textSize="@dimen/sp_12" /> | |
| 78 | + | |
| 79 | + <ImageView | |
| 80 | + android:id="@+id/iv_start" | |
| 81 | + android:layout_width="36dp" | |
| 82 | + android:layout_height="36dp" | |
| 83 | + android:layout_marginRight="@dimen/dp_10" | |
| 84 | + android:visibility="visible" | |
| 85 | + /> | |
| 86 | +</LinearLayout> | ... | ... |
updownfile/src/main/res/layout/layout_no_data_text.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + android:layout_width="match_parent" | |
| 4 | + android:layout_height="match_parent" | |
| 5 | + android:gravity="center" | |
| 6 | + android:orientation="vertical"> | |
| 7 | + <ImageView | |
| 8 | + android:layout_width="100dp" | |
| 9 | + android:layout_height="100dp" | |
| 10 | + /> | |
| 11 | + <TextView xmlns:android="http://schemas.android.com/apk/res/android" | |
| 12 | + android:layout_width="wrap_content" | |
| 13 | + android:layout_height="wrap_content" | |
| 14 | + android:layout_gravity="center" | |
| 15 | + android:layout_marginTop="12dp" | |
| 16 | + android:gravity="center" | |
| 17 | + android:text="没有任务" | |
| 18 | + android:textColor="#999999" | |
| 19 | + android:textSize="13sp" /> | |
| 20 | +</LinearLayout> | |
| 0 | 21 | \ No newline at end of file | ... | ... |
updownfile/src/main/res/layout/popupp_exercise.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + android:layout_width="match_parent" | |
| 4 | + android:layout_height="wrap_content" | |
| 5 | + android:background="#D5D5D5" | |
| 6 | + android:orientation="vertical"> | |
| 7 | + | |
| 8 | + <TextView | |
| 9 | + android:id="@+id/all_start" | |
| 10 | + android:layout_width="match_parent" | |
| 11 | + android:layout_height="wrap_content" | |
| 12 | + android:paddingBottom="12dp" | |
| 13 | + android:paddingTop="12dp" | |
| 14 | + android:text="全部暂停" | |
| 15 | + android:gravity="center" | |
| 16 | + android:background="#ffffff" | |
| 17 | + android:textColor="@color/color_333333" | |
| 18 | + android:layout_marginBottom="0.5dp" | |
| 19 | + android:textSize="18sp" /> | |
| 20 | + | |
| 21 | + <TextView | |
| 22 | + android:id="@+id/all_delete" | |
| 23 | + android:layout_width="match_parent" | |
| 24 | + android:layout_height="wrap_content" | |
| 25 | + android:paddingBottom="12dp" | |
| 26 | + android:paddingTop="12dp" | |
| 27 | + android:text="全部删除" | |
| 28 | + android:background="#ffffff" | |
| 29 | + android:gravity="center" | |
| 30 | + android:textColor="@color/color_333333" | |
| 31 | + android:textSize="18sp" /> | |
| 32 | + <View | |
| 33 | + android:layout_width="match_parent" | |
| 34 | + android:layout_height="5dp" | |
| 35 | + /> | |
| 36 | + <TextView | |
| 37 | + android:id="@+id/cancel_popup" | |
| 38 | + android:layout_width="match_parent" | |
| 39 | + android:layout_height="wrap_content" | |
| 40 | + android:paddingBottom="12dp" | |
| 41 | + android:paddingTop="12dp" | |
| 42 | + android:text="取消" | |
| 43 | + android:background="#ffffff" | |
| 44 | + android:gravity="center" | |
| 45 | + android:textColor="@color/color_333333" | |
| 46 | + android:textSize="18sp" /> | |
| 47 | +</LinearLayout> | |
| 0 | 48 | \ No newline at end of file | ... | ... |
updownfile/src/main/res/menu/main.xml
updownfile/src/main/res/values/strings.xml
| ... | ... | @@ -5,4 +5,15 @@ |
| 5 | 5 | <string name="pull_down_refresh">下拉刷新</string> |
| 6 | 6 | <string name="release_refresh">释放刷新</string> |
| 7 | 7 | <string name="is_refreshing">正在刷新</string> |
| 8 | + <string name="module_task_doing">进行中</string> | |
| 9 | + <string name="module_task_finished">已完成</string> | |
| 10 | + | |
| 11 | + <string name="all_start">全部开始</string> | |
| 12 | + <string name="all_pause">全部暂停</string> | |
| 13 | + <string name="all_delete">全部删除</string> | |
| 14 | + <string name="pause">暂停</string> | |
| 15 | + <string name="waiting">正在等待</string> | |
| 16 | + <string name="upload_check_md5">正在检验文件, 稍等</string> | |
| 17 | + <string name="no_known_condition_happen">发生了其他的未知情况</string> | |
| 18 | + | |
| 8 | 19 | </resources> | ... | ... |