Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AriaLyy committed Dec 20, 2018
1 parent f596715 commit 4df35a4
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Aria/build.gradle
Expand Up @@ -26,8 +26,8 @@ dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile project(':AriaAnnotations')
// compile 'com.arialyy.aria:aria-ftp-plug:1.0.4'
compile 'com.arialyy.aria:aria-ftp-plug:1.0.4'

compile project(':AriaFtpPlug')
// compile project(':AriaFtpPlug')
}
apply from: 'bintray-release.gradle'
11 changes: 11 additions & 0 deletions Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java
Expand Up @@ -113,10 +113,21 @@ public void startElement(String uri, String localName, String qName, Attributes
case "logLevel":
loadLogLevel(value);
break;
case "netCheck":
loadNetCheck(value);
break;
}
}
}

private void loadNetCheck(String value) {
boolean b = checkBoolean(value), temp = false;
if (b) {
temp = Boolean.valueOf(value);
}
mAppConfig.netCheck = temp;
}

private void loadUseBroadcast(String value) {
boolean b = checkBoolean(value), temp = false;

Expand Down
Expand Up @@ -34,8 +34,7 @@
import com.arialyy.aria.util.CommonUtil;

/**
* Created by lyy on 2016/8/22.
* 下载命令
* Created by lyy on 2016/8/22. 下载命令
*/
public abstract class AbsNormalCmd<T extends AbsTaskEntity> extends AbsCmd<T> {
/**
Expand Down Expand Up @@ -84,7 +83,7 @@ public abstract class AbsNormalCmd<T extends AbsTaskEntity> extends AbsCmd<T> {
*/
void sendWaitState() {
if (tempTask != null) {
sendWaitState(tempTask);
sendWaitState(tempTask);
}
}

Expand Down
Expand Up @@ -36,14 +36,14 @@ public interface ISchedulers<Task extends AbsTask> extends Handler.Callback {
String TASK_TYPE = "ARIA_TASK_TYPE";

/**
* 广播接收器中通过TASK_STATE字段获取任务状态 普通任务的有:
* </br>
* {@link #NO_SUPPORT_BREAK_POINT}、{@link #PRE}、{@link #POST_PRE}、{@link #START}、{@link
* #STOP}、{@link #FAIL}、{@link #CANCEL}、{@link #COMPLETE}、{@link #RUNNING}、{@link #RESUME}、{@link
* #WAIT}
* </br>
* 子任务的有:{@link #SUB_PRE}、{@link #SUB_START}、{@link #SUB_STOP}、{@link #SUB_CANCEL}、{@link
* #SUB_FAIL}、{@link #SUB_RUNNING}、{@link #SUB_COMPLETE}
* 广播接收器中通过TASK_STATE字段获取任务状态
*
* 普通任务的有: {@link #NO_SUPPORT_BREAK_POINT}、{@link #PRE}、{@link
* #POST_PRE}、{@link #START}、{@link #STOP}、{@link #FAIL}、{@link #CANCEL}、{@link #COMPLETE}、{@link
* #RUNNING}、{@link #RESUME}、{@link #WAIT}
*
* 子任务的有:{@link #SUB_PRE}、{@link #SUB_START}、{@link
* #SUB_STOP}、{@link #SUB_CANCEL}、{@link #SUB_FAIL}、{@link #SUB_RUNNING}、{@link #SUB_COMPLETE}
*/
String TASK_STATE = "ARIA_TASK_STATE";

Expand Down
4 changes: 4 additions & 0 deletions Aria/src/main/java/com/arialyy/aria/util/NetUtils.java
Expand Up @@ -22,6 +22,7 @@
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.arialyy.aria.core.Aria;

/**
* 跟网络相关的工具类
Expand Down Expand Up @@ -54,6 +55,9 @@ public class NetUtils {
* @return {@code true} 网络已连接、{@code false}网络未连接
*/
public static boolean isConnected(Context context) {
if (!Aria.get(context).getAppConfig().isNetCheck()){
return true;
}
ConnectivityManager cm =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Expand Up @@ -20,7 +20,7 @@
<!--android:name=".download.group.DownloadGroupActivity"-->
<!--android:name=".MainActivity"-->
<activity
android:name=".upload.FtpUploadActivity"
android:name=".download.SingleTaskActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/assets/aria_config.xml
Expand Up @@ -6,6 +6,8 @@
<useAriaCrashHandler value="true"/>
<!--设置Aria的日志级别,{@link ALog#LOG_LEVEL_VERBOSE}-->
<logLevel value="2"/>
<!-- 是否检查网络 -->
<netCheck value="false"/>
</app>


Expand Down
Expand Up @@ -41,7 +41,14 @@ public class BaseApplication extends Application {
if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
StrictMode.setThreadPolicy(
new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
StrictMode.VmPolicy policy = new StrictMode.VmPolicy.Builder()
//.detectLeakedSqlLiteObjects()
//.detectLeakedClosableObjects()
.detectAll()
.penaltyDeath()
.penaltyLog()
.build();
StrictMode.setVmPolicy(policy);
}

registerReceiver(new ConnectionChangeReceiver(),
Expand Down
Expand Up @@ -32,8 +32,7 @@
import java.io.File;

/**
* Created by lyy on 2017/7/28.
* Ftp 文件上传demo
* Created by lyy on 2017/7/28. Ftp 文件上传demo
*/
public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
private final String FILE_PATH = "/mnt/sdcard/AriaPrj.rar";
Expand Down
22 changes: 16 additions & 6 deletions aria/src/main/java/com/arialyy/aria/core/Configuration.java
Expand Up @@ -27,9 +27,9 @@
import java.io.Serializable;

/**
* Created by lyy on 2016/12/8. 信息配置
* Created by lyy on 2016/12/8. 信息配置 kotlin 方式有bug,不能将public去掉
*/
final class Configuration {
public final class Configuration {
private static final String TAG = "Configuration";
private static final String DOWNLOAD_CONFIG_FILE = "/Aria/AriaDownload.cfg";
private static final String UPLOAD_CONFIG_FILE = "/Aria/AriaUpload.cfg";
Expand Down Expand Up @@ -207,9 +207,7 @@ abstract static class BaseTaskConfig extends BaseConfig implements Serializable
int maxSpeed = 0;

/**
* 是否使用广播
* 除非无法使用注解,否则不建议使用广播来接受任务
* {@code true} 使用广播,{@code false} 不适用广播
* 是否使用广播 除非无法使用注解,否则不建议使用广播来接受任务 {@code true} 使用广播,{@code false} 不适用广播
*/
boolean useBroadcast = false;

Expand Down Expand Up @@ -479,7 +477,19 @@ public static class AppConfig extends BaseConfig {
*/
int logLevel;

private AppConfig() {
/**
* 是否检查网络,{@code true}检查网络
*/
boolean netCheck = true;

public boolean isNetCheck() {
return netCheck;
}

public AppConfig setNetCheck(boolean netCheck) {
this.netCheck = netCheck;
save();
return this;
}

public AppConfig setLogLevel(int level) {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -39,7 +39,7 @@ task clean(type: Delete) {
ext {
userOrg = 'arialyy'
groupId = 'com.arialyy.aria'
publishVersion = '3.5.2'
publishVersion = '3.5.3_dev_1'
// publishVersion = '1.0.4' //FTP插件
repoName='maven'
desc = 'android 下载框架'
Expand Down

0 comments on commit 4df35a4

Please sign in to comment.