优化大量代码
This commit is contained in:
@@ -130,10 +130,20 @@ class Configuration {
|
||||
* 保存key
|
||||
*/
|
||||
void saveKey(String key, String value) {
|
||||
boolean isDownload = this instanceof DownloadConfig;
|
||||
String path = null;
|
||||
switch (getType()) {
|
||||
case TYPE_DOWNLOAD:
|
||||
path = DOWNLOAD_CONFIG_FILE;
|
||||
break;
|
||||
case TYPE_UPLOAD:
|
||||
path = UPLOAD_CONFIG_FILE;
|
||||
break;
|
||||
case TYPE_APP:
|
||||
path = APP_CONFIG_FILE;
|
||||
break;
|
||||
}
|
||||
File file = new File(
|
||||
AriaManager.APP.getFilesDir().getPath() + (isDownload ? DOWNLOAD_CONFIG_FILE
|
||||
: UPLOAD_CONFIG_FILE));
|
||||
AriaManager.APP.getFilesDir().getPath() + path);
|
||||
if (file.exists()) {
|
||||
Properties properties = CommonUtil.loadConfig(file);
|
||||
properties.setProperty(key, value);
|
||||
@@ -146,11 +156,21 @@ class Configuration {
|
||||
*/
|
||||
void saveAll() {
|
||||
List<Field> fields = CommonUtil.getAllFields(getClass());
|
||||
boolean isDownload = this instanceof DownloadConfig;
|
||||
try {
|
||||
String path = null;
|
||||
switch (getType()) {
|
||||
case TYPE_DOWNLOAD:
|
||||
path = DOWNLOAD_CONFIG_FILE;
|
||||
break;
|
||||
case TYPE_UPLOAD:
|
||||
path = UPLOAD_CONFIG_FILE;
|
||||
break;
|
||||
case TYPE_APP:
|
||||
path = APP_CONFIG_FILE;
|
||||
break;
|
||||
}
|
||||
File file = new File(
|
||||
AriaManager.APP.getFilesDir().getPath() + (isDownload ? DOWNLOAD_CONFIG_FILE
|
||||
: UPLOAD_CONFIG_FILE));
|
||||
AriaManager.APP.getFilesDir().getPath() + path);
|
||||
Properties properties = CommonUtil.loadConfig(file);
|
||||
for (Field field : fields) {
|
||||
int m = field.getModifiers();
|
||||
|
||||
@@ -28,23 +28,23 @@ import java.util.Map;
|
||||
* 上传任务实体
|
||||
*/
|
||||
public class UploadTaskEntity extends AbsNormalTaskEntity<UploadEntity> {
|
||||
public String attachment; //文件上传需要的key
|
||||
public String contentType = "multipart/form-data"; //上传的文件类型
|
||||
public String userAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.6)";
|
||||
private String attachment; //文件上传需要的key
|
||||
private String contentType = "multipart/form-data"; //上传的文件类型
|
||||
private String userAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.6)";
|
||||
|
||||
@Ignore public UploadEntity entity;
|
||||
@Ignore private UploadEntity entity;
|
||||
|
||||
public String filePath = "";
|
||||
private String filePath;
|
||||
|
||||
@Primary
|
||||
@Foreign(parent = UploadEntity.class, column = "filePath",
|
||||
onUpdate = ActionPolicy.CASCADE, onDelete = ActionPolicy.CASCADE)
|
||||
public String key;
|
||||
private String key;
|
||||
|
||||
/**
|
||||
* 文件上传表单
|
||||
*/
|
||||
public Map<String, String> formFields = new HashMap<>();
|
||||
private Map<String, String> formFields = new HashMap<>();
|
||||
|
||||
public UploadTaskEntity() {
|
||||
}
|
||||
@@ -56,4 +56,52 @@ public class UploadTaskEntity extends AbsNormalTaskEntity<UploadEntity> {
|
||||
@Override public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setEntity(UploadEntity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public Map<String, String> getFormFields() {
|
||||
return formFields;
|
||||
}
|
||||
|
||||
public void setFormFields(Map<String, String> formFields) {
|
||||
this.formFields = formFields;
|
||||
}
|
||||
|
||||
public String getAttachment() {
|
||||
return attachment;
|
||||
}
|
||||
|
||||
public void setAttachment(String attachment) {
|
||||
this.attachment = attachment;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
public String getUserAgent() {
|
||||
return userAgent;
|
||||
}
|
||||
|
||||
public void setUserAgent(String userAgent) {
|
||||
this.userAgent = userAgent;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user