增加非静态的成员类警告提示

pull/617/head
laoyuyu 5 years ago
parent ce408c0d5c
commit df310b7fbe
  1. 4
      Aria/src/main/java/com/arialyy/aria/core/common/BaseOption.java
  2. 2
      Aria/src/main/java/com/arialyy/aria/core/common/FTPSDelegate.java
  3. 2
      Aria/src/main/java/com/arialyy/aria/core/common/FtpDelegate.java
  4. 8
      Aria/src/main/java/com/arialyy/aria/core/common/HttpDelegate.java
  5. 8
      Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8Delegate.java
  6. 12
      Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8LiveDelegate.java
  7. 4
      Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8VodDelegate.java
  8. 6
      Aria/src/main/java/com/arialyy/aria/core/download/target/GroupBuilderTarget.java
  9. 3
      Aria/src/main/java/com/arialyy/aria/core/download/target/HttpBuilderTarget.java
  10. 4
      Aria/src/main/java/com/arialyy/aria/core/download/tcp/TcpDelegate.java
  11. 2
      Aria/src/main/java/com/arialyy/aria/core/upload/target/FtpBuilderTarget.java
  12. 2
      HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpULoaderUtil.java
  13. 43
      PublicComponent/src/main/java/com/arialyy/aria/util/CheckUtil.java
  14. 28
      app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java
  15. 59
      app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8LiveDLoadActivity.java
  16. 7
      app/src/main/java/com/arialyy/simple/core/upload/HttpUploadActivity.java
  17. 2
      py/upload.py

@ -23,12 +23,12 @@ import com.arialyy.aria.core.inf.Suggest;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
public abstract class BaseDelegate<TARGET extends AbsTarget> { public abstract class BaseOption<TARGET extends AbsTarget> {
protected final String TAG; protected final String TAG;
protected TARGET mTarget; protected TARGET mTarget;
protected AbsTaskWrapper mWrapper; protected AbsTaskWrapper mWrapper;
public BaseDelegate(TARGET target, AbsTaskWrapper wrapper) { public BaseOption(TARGET target, AbsTaskWrapper wrapper) {
TAG = CommonUtil.getClassName(getClass()); TAG = CommonUtil.getClassName(getClass());
mTarget = target; mTarget = target;
mWrapper = wrapper; mWrapper = wrapper;

@ -28,7 +28,7 @@ import com.arialyy.aria.util.ALog;
/** /**
* D_FTP SSL/TSL 参数委托 * D_FTP SSL/TSL 参数委托
*/ */
public class FTPSDelegate<TARGET extends AbsTarget> extends BaseDelegate<TARGET> { public class FTPSDelegate<TARGET extends AbsTarget> extends BaseOption<TARGET> {
private FtpUrlEntity mUrlEntity; private FtpUrlEntity mUrlEntity;

@ -28,7 +28,7 @@ import com.arialyy.aria.util.ALog;
/** /**
* Created by laoyuyu on 2018/3/9. * Created by laoyuyu on 2018/3/9.
*/ */
public class FtpDelegate<TARGET extends AbsTarget> extends BaseDelegate<TARGET> { public class FtpDelegate<TARGET extends AbsTarget> extends BaseOption<TARGET> {
private static final String TAG = "FtpDelegate"; private static final String TAG = "FtpDelegate";
public FtpDelegate(TARGET target, AbsTaskWrapper wrapper) { public FtpDelegate(TARGET target, AbsTaskWrapper wrapper) {

@ -18,19 +18,19 @@ package com.arialyy.aria.core.common;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.annotation.CheckResult; import androidx.annotation.CheckResult;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.arialyy.aria.core.inf.Suggest;
import com.arialyy.aria.core.inf.AbsTarget; import com.arialyy.aria.core.inf.AbsTarget;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.core.inf.IOptionConstant; import com.arialyy.aria.core.inf.IOptionConstant;
import com.arialyy.aria.core.inf.Suggest;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.ALog;
import java.net.Proxy; import java.net.Proxy;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* HTTP协议处理 * HTTP任务设置
*/ */
public class HttpDelegate<TARGET extends AbsTarget> extends BaseDelegate<TARGET> { public class HttpDelegate<TARGET extends AbsTarget> extends BaseOption<TARGET> {
private Map<String, String> params; private Map<String, String> params;
private Map<String, String> headers; private Map<String, String> headers;

@ -16,7 +16,7 @@
package com.arialyy.aria.core.download.m3u8; package com.arialyy.aria.core.download.m3u8;
import androidx.annotation.CheckResult; import androidx.annotation.CheckResult;
import com.arialyy.aria.core.common.BaseDelegate; import com.arialyy.aria.core.common.BaseOption;
import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.inf.AbsTarget; import com.arialyy.aria.core.inf.AbsTarget;
import com.arialyy.aria.core.inf.IOptionConstant; import com.arialyy.aria.core.inf.IOptionConstant;
@ -25,12 +25,13 @@ import com.arialyy.aria.core.processor.IBandWidthUrlConverter;
import com.arialyy.aria.core.processor.ITsMergeHandler; import com.arialyy.aria.core.processor.ITsMergeHandler;
import com.arialyy.aria.core.processor.IVodTsUrlConverter; import com.arialyy.aria.core.processor.IVodTsUrlConverter;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.ComponentUtil; import com.arialyy.aria.util.ComponentUtil;
/** /**
* m3u8 委托 * m3u8 委托
*/ */
public class M3U8Delegate<TARGET extends AbsTarget> extends BaseDelegate<TARGET> { public class M3U8Delegate<TARGET extends AbsTarget> extends BaseOption<TARGET> {
private DTaskWrapper mTaskWrapper; private DTaskWrapper mTaskWrapper;
public M3U8Delegate(TARGET target, AbsTaskWrapper wrapper) { public M3U8Delegate(TARGET target, AbsTaskWrapper wrapper) {
@ -67,6 +68,7 @@ public class M3U8Delegate<TARGET extends AbsTarget> extends BaseDelegate<TARGET>
*/ */
@CheckResult(suggest = Suggest.TO_CONTROLLER) @CheckResult(suggest = Suggest.TO_CONTROLLER)
public M3U8Delegate<TARGET> setMergeHandler(ITsMergeHandler handler) { public M3U8Delegate<TARGET> setMergeHandler(ITsMergeHandler handler) {
CheckUtil.checkMemberClass(handler.getClass());
mTaskWrapper.getM3U8Params().setObjs(IOptionConstant.mergeHandler, handler); mTaskWrapper.getM3U8Params().setObjs(IOptionConstant.mergeHandler, handler);
return this; return this;
} }
@ -79,6 +81,7 @@ public class M3U8Delegate<TARGET extends AbsTarget> extends BaseDelegate<TARGET>
*/ */
@CheckResult(suggest = Suggest.TO_CONTROLLER) @CheckResult(suggest = Suggest.TO_CONTROLLER)
public M3U8Delegate<TARGET> setTsUrlConvert(IVodTsUrlConverter converter) { public M3U8Delegate<TARGET> setTsUrlConvert(IVodTsUrlConverter converter) {
CheckUtil.checkMemberClass(converter.getClass());
mTaskWrapper.getM3U8Params().setObjs(IOptionConstant.vodUrlConverter, converter); mTaskWrapper.getM3U8Params().setObjs(IOptionConstant.vodUrlConverter, converter);
return this; return this;
} }
@ -102,6 +105,7 @@ public class M3U8Delegate<TARGET extends AbsTarget> extends BaseDelegate<TARGET>
*/ */
@CheckResult(suggest = Suggest.TO_CONTROLLER) @CheckResult(suggest = Suggest.TO_CONTROLLER)
public M3U8Delegate<TARGET> setBandWidthUrlConverter(IBandWidthUrlConverter converter) { public M3U8Delegate<TARGET> setBandWidthUrlConverter(IBandWidthUrlConverter converter) {
CheckUtil.checkMemberClass(converter.getClass());
mTaskWrapper.getM3U8Params().setObjs(IOptionConstant.bandWidthUrlConverter, converter); mTaskWrapper.getM3U8Params().setObjs(IOptionConstant.bandWidthUrlConverter, converter);
return this; return this;
} }

@ -16,19 +16,20 @@
package com.arialyy.aria.core.download.m3u8; package com.arialyy.aria.core.download.m3u8;
import androidx.annotation.CheckResult; import androidx.annotation.CheckResult;
import com.arialyy.aria.core.common.BaseDelegate; import com.arialyy.aria.core.common.BaseOption;
import com.arialyy.aria.core.processor.ILiveTsUrlConverter;
import com.arialyy.aria.core.inf.Suggest;
import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.inf.AbsTarget; import com.arialyy.aria.core.inf.AbsTarget;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.core.inf.IOptionConstant; import com.arialyy.aria.core.inf.IOptionConstant;
import com.arialyy.aria.core.inf.Suggest;
import com.arialyy.aria.core.processor.ILiveTsUrlConverter;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CheckUtil;
/** /**
* m3u8直播参数设置 * m3u8直播参数设置
*/ */
public class M3U8LiveDelegate<TARGET extends AbsTarget> extends BaseDelegate<TARGET> { public class M3U8LiveDelegate<TARGET extends AbsTarget> extends BaseOption<TARGET> {
M3U8LiveDelegate(TARGET target, AbsTaskWrapper wrapper) { M3U8LiveDelegate(TARGET target, AbsTaskWrapper wrapper) {
super(target, wrapper); super(target, wrapper);
@ -43,6 +44,7 @@ public class M3U8LiveDelegate<TARGET extends AbsTarget> extends BaseDelegate<TAR
*/ */
@CheckResult(suggest = Suggest.TO_CONTROLLER) @CheckResult(suggest = Suggest.TO_CONTROLLER)
public M3U8LiveDelegate<TARGET> setLiveTsUrlConvert(ILiveTsUrlConverter converter) { public M3U8LiveDelegate<TARGET> setLiveTsUrlConvert(ILiveTsUrlConverter converter) {
CheckUtil.checkMemberClass(converter.getClass());
((DTaskWrapper) getTaskWrapper()).getM3U8Params() ((DTaskWrapper) getTaskWrapper()).getM3U8Params()
.setObjs(IOptionConstant.liveTsUrlConverter, converter); .setObjs(IOptionConstant.liveTsUrlConverter, converter);
return this; return this;

@ -16,7 +16,7 @@
package com.arialyy.aria.core.download.m3u8; package com.arialyy.aria.core.download.m3u8;
import androidx.annotation.CheckResult; import androidx.annotation.CheckResult;
import com.arialyy.aria.core.common.BaseDelegate; import com.arialyy.aria.core.common.BaseOption;
import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.inf.Suggest;
import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.event.EventMsgUtil; import com.arialyy.aria.core.event.EventMsgUtil;
@ -30,7 +30,7 @@ import com.arialyy.aria.util.ALog;
/** /**
* m3u8点播文件参数设置 * m3u8点播文件参数设置
*/ */
public class M3U8VodDelegate<TARGET extends AbsTarget> extends BaseDelegate<TARGET> { public class M3U8VodDelegate<TARGET extends AbsTarget> extends BaseOption<TARGET> {
private DTaskWrapper mTaskWrapper; private DTaskWrapper mTaskWrapper;
M3U8VodDelegate(TARGET target, AbsTaskWrapper wrapper) { M3U8VodDelegate(TARGET target, AbsTaskWrapper wrapper) {

@ -17,14 +17,15 @@ package com.arialyy.aria.core.download.target;
import androidx.annotation.CheckResult; import androidx.annotation.CheckResult;
import com.arialyy.aria.core.common.AbsBuilderTarget; import com.arialyy.aria.core.common.AbsBuilderTarget;
import com.arialyy.aria.core.inf.Suggest;
import com.arialyy.aria.core.common.HttpDelegate; import com.arialyy.aria.core.common.HttpDelegate;
import com.arialyy.aria.core.download.DGTaskWrapper; import com.arialyy.aria.core.download.DGTaskWrapper;
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
import com.arialyy.aria.core.inf.IOptionConstant; import com.arialyy.aria.core.inf.IOptionConstant;
import com.arialyy.aria.core.inf.Suggest;
import com.arialyy.aria.core.manager.SubTaskManager; import com.arialyy.aria.core.manager.SubTaskManager;
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
import com.arialyy.aria.core.wrapper.ITaskWrapper; import com.arialyy.aria.core.wrapper.ITaskWrapper;
import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CheckUtil;
import java.util.List; import java.util.List;
/** /**
@ -151,6 +152,7 @@ public class GroupBuilderTarget extends AbsBuilderTarget<GroupBuilderTarget> {
if (adapter == null) { if (adapter == null) {
throw new IllegalArgumentException("adapter为空"); throw new IllegalArgumentException("adapter为空");
} }
CheckUtil.checkMemberClass(adapter.getClass());
getTaskWrapper().getOptionParams().setObjs(IOptionConstant.fileLenAdapter, adapter); getTaskWrapper().getOptionParams().setObjs(IOptionConstant.fileLenAdapter, adapter);
return this; return this;
} }

@ -24,6 +24,7 @@ import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
import com.arialyy.aria.core.inf.IOptionConstant; import com.arialyy.aria.core.inf.IOptionConstant;
import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.inf.Suggest;
import com.arialyy.aria.core.wrapper.ITaskWrapper; import com.arialyy.aria.core.wrapper.ITaskWrapper;
import com.arialyy.aria.util.CheckUtil;
public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> { public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
@ -95,7 +96,7 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
if (adapter == null) { if (adapter == null) {
throw new IllegalArgumentException("adapter为空"); throw new IllegalArgumentException("adapter为空");
} }
CheckUtil.checkMemberClass(adapter.getClass());
getTaskWrapper().getOptionParams().setObjs(IOptionConstant.fileLenAdapter, adapter); getTaskWrapper().getOptionParams().setObjs(IOptionConstant.fileLenAdapter, adapter);
return this; return this;
} }

@ -17,7 +17,7 @@ package com.arialyy.aria.core.download.tcp;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.annotation.CheckResult; import androidx.annotation.CheckResult;
import com.arialyy.aria.core.common.BaseDelegate; import com.arialyy.aria.core.common.BaseOption;
import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.inf.Suggest;
import com.arialyy.aria.core.inf.AbsTarget; import com.arialyy.aria.core.inf.AbsTarget;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
@ -28,7 +28,7 @@ import java.nio.charset.Charset;
* @Author aria * @Author aria
* @Date 2019-09-06 * @Date 2019-09-06
*/ */
public class TcpDelegate<TARGET extends AbsTarget> extends BaseDelegate<TARGET> { public class TcpDelegate<TARGET extends AbsTarget> extends BaseOption<TARGET> {
private TcpTaskConfig mTcpConfig; private TcpTaskConfig mTcpConfig;

@ -22,6 +22,7 @@ import com.arialyy.aria.core.common.AbsBuilderTarget;
import com.arialyy.aria.core.common.FtpDelegate; import com.arialyy.aria.core.common.FtpDelegate;
import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.inf.Suggest;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.util.CheckUtil;
/** /**
* Created by Aria.Lao on 2017/7/27. * Created by Aria.Lao on 2017/7/27.
@ -52,6 +53,7 @@ public class FtpBuilderTarget extends AbsBuilderTarget<FtpBuilderTarget> {
*/ */
@CheckResult(suggest = Suggest.TASK_CONTROLLER) @CheckResult(suggest = Suggest.TASK_CONTROLLER)
public FtpBuilderTarget setUploadInterceptor(@NonNull IFtpUploadInterceptor uploadInterceptor) { public FtpBuilderTarget setUploadInterceptor(@NonNull IFtpUploadInterceptor uploadInterceptor) {
CheckUtil.checkMemberClass(uploadInterceptor.getClass());
return mConfigHandler.setUploadInterceptor(uploadInterceptor); return mConfigHandler.setUploadInterceptor(uploadInterceptor);
} }

@ -27,7 +27,7 @@ import com.arialyy.aria.http.HttpTaskOption;
* @Date 2019-09-19 * @Date 2019-09-19
*/ */
public class HttpULoaderUtil extends AbsNormalLoaderUtil { public class HttpULoaderUtil extends AbsNormalLoaderUtil {
protected HttpULoaderUtil(AbsTaskWrapper wrapper, IEventListener listener) { public HttpULoaderUtil(AbsTaskWrapper wrapper, IEventListener listener) {
super(wrapper, listener); super(wrapper, listener);
wrapper.generateTaskOption(HttpTaskOption.class); wrapper.generateTaskOption(HttpTaskOption.class);
} }

@ -19,11 +19,11 @@ package com.arialyy.aria.util;
import android.text.TextUtils; import android.text.TextUtils;
import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.core.upload.UTaskWrapper; import com.arialyy.aria.core.upload.UTaskWrapper;
import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.exception.ParamException; import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import java.io.File; import java.io.File;
import java.lang.reflect.Modifier;
import java.util.List; import java.util.List;
/** /**
@ -34,26 +34,15 @@ public class CheckUtil {
private static final String TAG = "CheckUtil"; private static final String TAG = "CheckUtil";
/** /**
* 检查ftp上传路径如果ftp上传路径为空抛出空指针异常 * 检查成员类是否是静态和public
* 如果ftp上传路径不是以"ftp""sftp"抛出参数异常
*
* @param ftpUrl ftp上传路径
*/ */
public static void checkFtpUploadUrl(String ftpUrl) { public static void checkMemberClass(Class clazz) {
if (TextUtils.isEmpty(ftpUrl)) { int modifiers = clazz.getModifiers();
throw new ParamException("ftp上传路径为空"); if (!clazz.isMemberClass() || !Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers)) {
} else if (!ftpUrl.startsWith("ftp") || !ftpUrl.startsWith("sftp")) { ALog.e(TAG, "为了放置内存泄漏,请使用静态的成员类(public static class xxx)或文件类(A.java)");
throw new ParamException("ftp上传路径无效");
} }
} }
/**
* 判空
*/
public static void checkNull(Object obj) {
if (obj == null) throw new IllegalArgumentException("不能传入空对象");
}
/** /**
* 检查分页数据需要查询的页数从1开始如果page小于1 num 小于1则抛出{@link NullPointerException} * 检查分页数据需要查询的页数从1开始如果page小于1 num 小于1则抛出{@link NullPointerException}
* *
@ -64,15 +53,6 @@ public class CheckUtil {
if (page < 1 || num < 1) throw new NullPointerException("page和num不能小于1"); if (page < 1 || num < 1) throw new NullPointerException("page和num不能小于1");
} }
/**
* 检查下载实体
*/
public static void checkDownloadEntity(DownloadEntity entity) {
checkUrlInvalidThrow(entity.getUrl());
entity.setUrl(entity.getUrl());
checkPath(entity.getDownloadPath());
}
/** /**
* 检测下载链接是否为null * 检测下载链接是否为null
*/ */
@ -150,15 +130,6 @@ public class CheckUtil {
} }
} }
/**
* 检查下载任务组保存路径
*/
public static void checkDownloadPaths(List<String> paths) {
if (paths == null || paths.isEmpty()) {
throw new IllegalArgumentException("链接保存路径不能为null");
}
}
/** /**
* 检测上传地址是否为null * 检测上传地址是否为null
*/ */

@ -31,11 +31,11 @@ import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProviders;
import com.arialyy.annotations.Download; import com.arialyy.annotations.Download;
import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
import com.arialyy.aria.core.common.controller.ControllerType; import com.arialyy.aria.core.common.controller.ControllerType;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.listener.ISchedulers; import com.arialyy.aria.core.listener.ISchedulers;
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
import com.arialyy.aria.core.task.DownloadTask; import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
@ -291,18 +291,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
.load(mUrl) .load(mUrl)
.useServerFileName(true) .useServerFileName(true)
.setFilePath(mFilePath, true) .setFilePath(mFilePath, true)
.setFileLenAdapter(new IHttpFileLenAdapter() { .setFileLenAdapter(new FileLenAdapter())
@Override public long handleFileLen(Map<String, List<String>> headers) {
List<String> sLength = headers.get("Content-Length");
if (sLength == null || sLength.isEmpty()) {
return -1;
}
String temp = sLength.get(0);
return Long.parseLong(temp);
}
})
.option() .option()
.addHeader("1", "@") .addHeader("1", "@")
.controller(ControllerType.CREATE_CONTROLLER) .controller(ControllerType.CREATE_CONTROLLER)
@ -327,4 +316,17 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
mModule.updateFilePath(this, String.valueOf(data)); mModule.updateFilePath(this, String.valueOf(data));
} }
} }
static class FileLenAdapter implements IHttpFileLenAdapter {
@Override public long handleFileLen(Map<String, List<String>> headers) {
List<String> sLength = headers.get("Content-Length");
if (sLength == null || sLength.isEmpty()) {
return -1;
}
String temp = sLength.get(0);
return Long.parseLong(temp);
}
}
} }

@ -212,27 +212,28 @@ public class M3U8LiveDLoadActivity extends BaseActivity<ActivityM3u8LiveBinding>
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.start: case R.id.start:
if (!AppUtil.chekEntityValid(mEntity)) { startD();
startD(); //if (!AppUtil.chekEntityValid(mEntity)) {
break; // startD();
} // break;
if (Aria.download(this).load(mEntity.getId()).isRunning()) { //}
Aria.download(this).load(mEntity.getId()).stop(); //if (Aria.download(this).load(mEntity.getId()).isRunning()) {
} else { // Aria.download(this).load(mEntity.getId()).stop();
Aria.download(this).load(mEntity.getId()) //} else {
.asM3U8() // Aria.download(this).load(mEntity.getId())
.asLive() // .asM3U8()
.setLiveTsUrlConvert(new ILiveTsUrlConverter() { // .asLive()
@Override public String convert(String m3u8Url, String tsUrl) { // .setLiveTsUrlConvert(new ILiveTsUrlConverter() {
int index = m3u8Url.lastIndexOf("/"); // @Override public String convert(String m3u8Url, String tsUrl) {
String parentUrl = m3u8Url.substring(0, index + 1); // int index = m3u8Url.lastIndexOf("/");
return parentUrl + tsUrl; // String parentUrl = m3u8Url.substring(0, index + 1);
} // return parentUrl + tsUrl;
}) // }
.controller(ControllerType.TASK_CONTROLLER) // })
.resume(); // .controller(ControllerType.TASK_CONTROLLER)
} // .resume();
break; //}
//break;
case R.id.cancel: case R.id.cancel:
if (AppUtil.chekEntityValid(mEntity)) { if (AppUtil.chekEntityValid(mEntity)) {
Aria.download(this).load(mEntity.getId()).cancel(true); Aria.download(this).load(mEntity.getId()).cancel(true);
@ -254,13 +255,7 @@ public class M3U8LiveDLoadActivity extends BaseActivity<ActivityM3u8LiveBinding>
// } // }
//}) //})
.asLive() .asLive()
.setLiveTsUrlConvert(new ILiveTsUrlConverter() { .setLiveTsUrlConvert(new LiveTsUrlConverter())
@Override public String convert(String m3u8Url, String tsUrl) {
int index = m3u8Url.lastIndexOf("/");
String parentUrl = m3u8Url.substring(0, index + 1);
return parentUrl + tsUrl;
}
})
.controller(ControllerType.CREATE_CONTROLLER) .controller(ControllerType.CREATE_CONTROLLER)
//.setLiveTsUrlConvert(new IVodTsUrlConverter() { //.setLiveTsUrlConvert(new IVodTsUrlConverter() {
// @Override public List<String> convert(String m3u8Url, List<String> tsUrls) { // @Override public List<String> convert(String m3u8Url, List<String> tsUrls) {
@ -285,4 +280,12 @@ public class M3U8LiveDLoadActivity extends BaseActivity<ActivityM3u8LiveBinding>
mModule.updateFilePath(this, String.valueOf(data)); mModule.updateFilePath(this, String.valueOf(data));
} }
} }
static class LiveTsUrlConverter implements ILiveTsUrlConverter {
@Override public String convert(String m3u8Url, String tsUrl) {
int index = m3u8Url.lastIndexOf("/");
String parentUrl = m3u8Url.substring(0, index + 1);
return parentUrl + tsUrl;
}
}
} }

@ -17,13 +17,14 @@
package com.arialyy.simple.core.upload; package com.arialyy.simple.core.upload;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment;
import android.view.View; import android.view.View;
import com.arialyy.annotations.Upload; import com.arialyy.annotations.Upload;
import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.common.RequestEnum; import com.arialyy.aria.core.common.RequestEnum;
import com.arialyy.aria.core.common.controller.ControllerType; import com.arialyy.aria.core.common.controller.ControllerType;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.core.task.UploadTask; import com.arialyy.aria.core.task.UploadTask;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.frame.util.FileUtil; import com.arialyy.frame.util.FileUtil;
import com.arialyy.frame.util.show.L; import com.arialyy.frame.util.show.L;
import com.arialyy.simple.R; import com.arialyy.simple.R;
@ -40,7 +41,9 @@ public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> {
private static final String TAG = "HttpUploadActivity"; private static final String TAG = "HttpUploadActivity";
HorizontalProgressBarWithNumber mPb; HorizontalProgressBarWithNumber mPb;
private final String FILE_PATH = "/mnt/sdcard/ggsg14.apk"; //private final String FILE_PATH = "/mnt/sdcard/ggsg14.apk";
private final String FILE_PATH =
Environment.getExternalStorageDirectory().getPath() + "/Download/PaNTFS15562.zip";
private UploadEntity mEntity; private UploadEntity mEntity;
@Override protected int setLayoutId() { @Override protected int setLayoutId() {

@ -6,7 +6,7 @@ from werkzeug import secure_filename
ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif', 'rar', 'apk']) ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif', 'rar', 'apk'])
app = Flask(__name__) app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = 'd:/db/' app.config['UPLOAD_FOLDER'] = '/Users/aria/temp/test/'
app.config['MAX_CONTENT_LENGTH'] = 1600 * 1024 * 1024 app.config['MAX_CONTENT_LENGTH'] = 1600 * 1024 * 1024
""" """

Loading…
Cancel
Save