添加Serializable接口支持 https://github.com/AriaLyy/Aria/issues/320 失败回调增加错误原因 https://github.com/AriaLyy/Aria/issues/310
	
		
	
				
					
				
			
							parent
							
								
									0b095b9b11
								
							
						
					
					
						commit
						66b36b355a
					
				| @ -0,0 +1,28 @@ | ||||
| /* | ||||
|  * Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
 | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  * You may obtain a copy of the License at | ||||
|  * | ||||
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, | ||||
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
|  * See the License for the specific language governing permissions and | ||||
|  * limitations under the License. | ||||
|  */ | ||||
| package com.arialyy.aria.exception; | ||||
| 
 | ||||
| public class AriaIOException extends BaseException{ | ||||
|   private static final String ARIA_NET_EXCEPTION = "Aria Net Exception:"; | ||||
| 
 | ||||
|   public AriaIOException(String tag, String message) { | ||||
|     super(tag, String.format("%s%s", ARIA_NET_EXCEPTION, message)); | ||||
|   } | ||||
| 
 | ||||
|   public AriaIOException(String tag, String message, Exception e){ | ||||
|     super(tag, message, e); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,35 @@ | ||||
| /* | ||||
|  * Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
 | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  * You may obtain a copy of the License at | ||||
|  * | ||||
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, | ||||
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
|  * See the License for the specific language governing permissions and | ||||
|  * limitations under the License. | ||||
|  */ | ||||
| package com.arialyy.aria.exception; | ||||
| 
 | ||||
| public abstract class BaseException extends Exception { | ||||
| 
 | ||||
|   private String tag; | ||||
| 
 | ||||
|   public BaseException(String tag, String message) { | ||||
|     super(message); | ||||
|     this.tag = tag; | ||||
|   } | ||||
| 
 | ||||
|   public BaseException(String tag, String message, Exception e) { | ||||
|     super(String.format("%s\n%s", message == null ? "" : message, e == null ? "" : e.getMessage())); | ||||
|     this.tag = tag; | ||||
|   } | ||||
| 
 | ||||
|   public String getTag() { | ||||
|     return tag; | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,31 @@ | ||||
| /* | ||||
|  * Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
 | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  * You may obtain a copy of the License at | ||||
|  * | ||||
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, | ||||
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
|  * See the License for the specific language governing permissions and | ||||
|  * limitations under the License. | ||||
|  */ | ||||
| package com.arialyy.aria.exception; | ||||
| 
 | ||||
| /** | ||||
|  * 任务异常 | ||||
|  */ | ||||
| public class TaskException extends BaseException { | ||||
|   private static final String ARIA_TASK_EXCEPTION = "Aria Task Exception:"; | ||||
| 
 | ||||
|   public TaskException(String tag, String detailMessage) { | ||||
|     super(tag, String.format("%s, %s", ARIA_TASK_EXCEPTION, detailMessage)); | ||||
|   } | ||||
| 
 | ||||
|   public TaskException(String tag, String message, Exception e){ | ||||
|     super(tag, message, e); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,27 @@ | ||||
| /* | ||||
|  * Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
 | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  * You may obtain a copy of the License at | ||||
|  * | ||||
|  *      http://www.apache.org/licenses/LICENSE-2.0
 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, | ||||
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
|  * See the License for the specific language governing permissions and | ||||
|  * limitations under the License. | ||||
|  */ | ||||
| package com.arialyy.compiler; | ||||
| 
 | ||||
| import java.util.List; | ||||
| import javax.lang.model.element.VariableElement; | ||||
| 
 | ||||
| /** | ||||
|  * 方法信息 | ||||
|  */ | ||||
| final class MethodInfo { | ||||
|   String methodName; | ||||
|   List<VariableElement> params; | ||||
| } | ||||
| @ -1,75 +1,75 @@ | ||||
| package com.arialyy.simple.download | ||||
| 
 | ||||
| import android.os.Bundle | ||||
| import android.os.Environment | ||||
| import android.support.v7.app.AppCompatActivity | ||||
| import android.util.Log | ||||
| import android.view.View | ||||
| import com.arialyy.annotations.Download | ||||
| import com.arialyy.aria.core.Aria | ||||
| import com.arialyy.aria.core.download.DownloadTask | ||||
| import com.arialyy.simple.R | ||||
| import com.arialyy.simple.base.BaseActivity | ||||
| 
 | ||||
| /** | ||||
|  * Created by lyy on 2017/10/23. | ||||
|  */ | ||||
| class KotlinDownloadActivity : AppCompatActivity() { | ||||
| 
 | ||||
|   private val DOWNLOAD_URL = "http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk" | ||||
| 
 | ||||
|   private val TAG = "KotlinDownloadActivity"; | ||||
| 
 | ||||
|   override fun onCreate(savedInstanceState: Bundle?) { | ||||
|     super.onCreate(savedInstanceState) | ||||
|     setContentView(setLayoutId()) | ||||
|   } | ||||
| 
 | ||||
|   fun setLayoutId(): Int { | ||||
|     return R.layout.activity_single | ||||
|   } | ||||
| 
 | ||||
|   fun init(savedInstanceState: Bundle?) { | ||||
|     title = "单任务下载" | ||||
| //    val target = Aria.download(this).load(DOWNLOAD_URL) | ||||
| //    binding.progress = target.getPercent() | ||||
| //    if (target.getTaskState() == IEntity.STATE_STOP) { | ||||
| //      mStart.setText("恢复") | ||||
| //      mStart.setTextColor(resources.getColor(android.R.color.holo_blue_light)) | ||||
| //      setBtState(true) | ||||
| //    } else if (target.isDownloading()) { | ||||
| //      setBtState(false) | ||||
| //package com.arialyy.simple.download | ||||
| // | ||||
| //import android.os.Bundle | ||||
| //import android.os.Environment | ||||
| //import android.support.v7.app.AppCompatActivity | ||||
| //import android.util.Log | ||||
| //import android.view.View | ||||
| //import com.arialyy.annotations.Download | ||||
| //import com.arialyy.aria.core.Aria | ||||
| //import com.arialyy.aria.core.download.DownloadTask | ||||
| //import com.arialyy.simple.R | ||||
| //import com.arialyy.simple.base.BaseActivity | ||||
| // | ||||
| ///** | ||||
| // * Created by lyy on 2017/10/23. | ||||
| // */ | ||||
| //class KotlinDownloadActivity : AppCompatActivity() { | ||||
| // | ||||
| //  private val DOWNLOAD_URL = "http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk" | ||||
| // | ||||
| //  private val TAG = "KotlinDownloadActivity"; | ||||
| // | ||||
| //  override fun onCreate(savedInstanceState: Bundle?) { | ||||
| //    super.onCreate(savedInstanceState) | ||||
| //    setContentView(setLayoutId()) | ||||
| //  } | ||||
| // | ||||
| //  fun setLayoutId(): Int { | ||||
| //    return R.layout.activity_single | ||||
| //  } | ||||
| // | ||||
| //  fun init(savedInstanceState: Bundle?) { | ||||
| //    title = "单任务下载" | ||||
| ////    val target = Aria.download(this).load(DOWNLOAD_URL) | ||||
| ////    binding.progress = target.getPercent() | ||||
| ////    if (target.getTaskState() == IEntity.STATE_STOP) { | ||||
| ////      mStart.setText("恢复") | ||||
| ////      mStart.setTextColor(resources.getColor(android.R.color.holo_blue_light)) | ||||
| ////      setBtState(true) | ||||
| ////    } else if (target.isDownloading()) { | ||||
| ////      setBtState(false) | ||||
| ////    } | ||||
| ////    binding.fileSize = target.getConvertFileSize() | ||||
| //    Aria.get(this).downloadConfig.maxTaskNum = 2 | ||||
| //    Aria.download(this).register() | ||||
| //  } | ||||
| // | ||||
| //  @Download.onTaskRunning | ||||
| //  protected fun running(task: DownloadTask) { | ||||
| //    Log.d(TAG, task.percent.toString() + "") | ||||
| ////    val len = task.fileSize | ||||
| ////    if (len == 0L) { | ||||
| ////      binding.progress = 0 | ||||
| ////    } else { | ||||
| ////      binding.progress = task.percent | ||||
| ////    } | ||||
| ////    binding.speed = task.convertSpeed | ||||
| //  } | ||||
| // | ||||
| //  fun onClick(view: View) { | ||||
| //    when (view.id) { | ||||
| //      R.id.start -> startD() | ||||
| //      R.id.stop -> Aria.download(this).load(DOWNLOAD_URL).stop() | ||||
| //      R.id.cancel -> Aria.download(this).load(DOWNLOAD_URL).cancel() | ||||
| //    } | ||||
| //    binding.fileSize = target.getConvertFileSize() | ||||
|     Aria.get(this).downloadConfig.maxTaskNum = 2 | ||||
|     Aria.download(this).register() | ||||
|   } | ||||
| 
 | ||||
|   @Download.onTaskRunning | ||||
|   protected fun running(task: DownloadTask) { | ||||
|     Log.d(TAG, task.percent.toString() + "") | ||||
| //    val len = task.fileSize | ||||
| //    if (len == 0L) { | ||||
| //      binding.progress = 0 | ||||
| //    } else { | ||||
| //      binding.progress = task.percent | ||||
| //    } | ||||
| //    binding.speed = task.convertSpeed | ||||
|   } | ||||
| 
 | ||||
|   fun onClick(view: View) { | ||||
|     when (view.id) { | ||||
|       R.id.start -> startD() | ||||
|       R.id.stop -> Aria.download(this).load(DOWNLOAD_URL).stop() | ||||
|       R.id.cancel -> Aria.download(this).load(DOWNLOAD_URL).cancel() | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   private fun startD() { | ||||
|     Aria.download(this) | ||||
|         .load(DOWNLOAD_URL) | ||||
|         .addHeader("groupName", "value") | ||||
|         .setDownloadPath(Environment.getExternalStorageDirectory().path + "/hhhhhhhh.apk") | ||||
|         .start() | ||||
|   } | ||||
| } | ||||
| //  } | ||||
| // | ||||
| //  private fun startD() { | ||||
| //    Aria.download(this) | ||||
| //        .load(DOWNLOAD_URL) | ||||
| //        .addHeader("groupName", "value") | ||||
| //        .setDownloadPath(Environment.getExternalStorageDirectory().path + "/hhhhhhhh.apk") | ||||
| //        .start() | ||||
| //  } | ||||
| //} | ||||
					Loading…
					
					
				
		Reference in new issue