添加线程选择接口

pull/2/head
AriaLyy 8 years ago
parent bd94e7dd27
commit 1893460627
  1. 1
      .gradle/2.10/taskArtifacts/cache.properties
  2. BIN
      .gradle/2.10/taskArtifacts/cache.properties.lock
  3. BIN
      .gradle/2.10/taskArtifacts/fileHashes.bin
  4. BIN
      .gradle/2.10/taskArtifacts/fileSnapshots.bin
  5. BIN
      .gradle/2.10/taskArtifacts/outputFileStates.bin
  6. BIN
      .gradle/2.10/taskArtifacts/taskArtifacts.bin
  7. BIN
      .gradle/2.10/tasks/_absadapter_compileDebugAndroidTestJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin
  8. BIN
      .gradle/2.10/tasks/_absadapter_compileDebugAndroidTestJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock
  9. BIN
      .gradle/2.10/tasks/_absadapter_compileDebugAndroidTestJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin
  10. BIN
      .gradle/2.10/tasks/_absadapter_compileDebugAndroidTestJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock
  11. BIN
      .gradle/2.10/tasks/_absadapter_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin
  12. BIN
      .gradle/2.10/tasks/_absadapter_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock
  13. BIN
      .gradle/2.10/tasks/_absadapter_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin
  14. BIN
      .gradle/2.10/tasks/_absadapter_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock
  15. BIN
      .gradle/2.10/tasks/_absadapter_compileDebugUnitTestJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin
  16. BIN
      .gradle/2.10/tasks/_absadapter_compileDebugUnitTestJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock
  17. BIN
      .gradle/2.10/tasks/_absadapter_compileDebugUnitTestJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin
  18. BIN
      .gradle/2.10/tasks/_absadapter_compileDebugUnitTestJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock
  19. BIN
      .gradle/2.10/tasks/_absadapter_compileReleaseJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin
  20. BIN
      .gradle/2.10/tasks/_absadapter_compileReleaseJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock
  21. BIN
      .gradle/2.10/tasks/_absadapter_compileReleaseJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin
  22. BIN
      .gradle/2.10/tasks/_absadapter_compileReleaseJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock
  23. BIN
      .gradle/2.10/tasks/_app_compileDebugAndroidTestJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin
  24. BIN
      .gradle/2.10/tasks/_app_compileDebugAndroidTestJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock
  25. BIN
      .gradle/2.10/tasks/_app_compileDebugAndroidTestJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin
  26. BIN
      .gradle/2.10/tasks/_app_compileDebugAndroidTestJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock
  27. BIN
      .gradle/2.10/tasks/_app_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin
  28. BIN
      .gradle/2.10/tasks/_app_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock
  29. BIN
      .gradle/2.10/tasks/_app_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin
  30. BIN
      .gradle/2.10/tasks/_app_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock
  31. BIN
      .gradle/2.10/tasks/_app_compileDebugUnitTestJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin
  32. BIN
      .gradle/2.10/tasks/_app_compileDebugUnitTestJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock
  33. BIN
      .gradle/2.10/tasks/_app_compileDebugUnitTestJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin
  34. BIN
      .gradle/2.10/tasks/_app_compileDebugUnitTestJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock
  35. 231
      .idea/codeStyleSettings.xml
  36. 3
      .idea/gradle.xml
  37. 29
      app/src/main/java/com/arialyy/simple/activity/MainActivity.java
  38. 2
      app/src/main/java/com/arialyy/simple/activity/MultiTaskActivity.java
  39. 5
      app/src/main/java/com/arialyy/simple/base/BaseDialog.java
  40. 9
      app/src/main/java/com/arialyy/simple/dialog/DownloadNumDialog.java
  41. 48
      app/src/main/res/layout/dialog_download_num.xml
  42. 2
      downloadutil/build.gradle

@ -1 +0,0 @@
#Thu Jun 02 19:55:15 CST 2016

@ -1,231 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value>
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="android" withSubpackages="true" static="false" />
<emptyLine />
<package name="com" withSubpackages="true" static="false" />
<emptyLine />
<package name="junit" withSubpackages="true" static="false" />
<emptyLine />
<package name="net" withSubpackages="true" static="false" />
<emptyLine />
<package name="org" withSubpackages="true" static="false" />
<emptyLine />
<package name="java" withSubpackages="true" static="false" />
<emptyLine />
<package name="javax" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="true" />
<emptyLine />
</value>
</option>
<option name="RIGHT_MARGIN" value="100" />
<AndroidXmlCodeStyleSettings>
<option name="USE_CUSTOM_SETTINGS" value="true" />
</AndroidXmlCodeStyleSettings>
<Objective-C-extensions>
<option name="GENERATE_INSTANCE_VARIABLES_FOR_PROPERTIES" value="ASK" />
<option name="RELEASE_STYLE" value="IVAR" />
<option name="TYPE_QUALIFIERS_PLACEMENT" value="BEFORE" />
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" />
<pair source="c" header="h" />
</extensions>
</Objective-C-extensions>
<XML>
<option name="XML_KEEP_LINE_BREAKS" value="false" />
<option name="XML_ALIGN_ATTRIBUTES" value="false" />
<option name="XML_SPACE_INSIDE_EMPTY_TAG" value="true" />
</XML>
<codeStyleSettings language="XML">
<option name="FORCE_REARRANGE_MODE" value="1" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_width</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_height</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_.*</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:width</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:height</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</value>
</option>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="SquareAndroid" />
</component>
</project>

@ -3,8 +3,9 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="D:\Android Studio\gradle\gradle-2.14.1" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />

@ -1,10 +1,15 @@
package com.arialyy.simple.activity;
import android.Manifest;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import butterknife.Bind;
import com.arialyy.frame.permission.OnPermissionCallback;
import com.arialyy.frame.permission.PermissionManager;
import com.arialyy.frame.util.show.T;
import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity;
import com.arialyy.simple.databinding.ActivityMainBinding;
@ -14,6 +19,8 @@ import com.arialyy.simple.databinding.ActivityMainBinding;
*/
public class MainActivity extends BaseActivity<ActivityMainBinding> {
@Bind(R.id.toolbar) Toolbar mBar;
@Bind(R.id.single_task) Button mSigleBt;
@Bind(R.id.multi_task) Button mMultiBt;
@Override protected int setLayoutId() {
return R.layout.activity_main;
@ -23,6 +30,28 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> {
super.init(savedInstanceState);
setSupportActionBar(mBar);
mBar.setTitle("多线程多任务下载");
boolean hasPermission = PermissionManager.getInstance()
.checkPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (hasPermission) {
setEnable(true);
} else {
setEnable(false);
PermissionManager.getInstance().requestPermission(this, new OnPermissionCallback() {
@Override public void onSuccess(String... permissions) {
setEnable(true);
}
@Override public void onFail(String... permissions) {
T.showShort(MainActivity.this, "没有文件读写权限");
setEnable(false);
}
}, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
}
private void setEnable(boolean enable) {
mSigleBt.setEnabled(enable);
mMultiBt.setEnabled(enable);
}
public void onClick(View view) {

@ -90,7 +90,7 @@ public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> {
};
public void onClick(View view){
DownloadNumDialog dialog = new DownloadNumDialog();
DownloadNumDialog dialog = new DownloadNumDialog(this);
dialog.show(getSupportFragmentManager(), "download_num");
}

@ -8,6 +8,11 @@ import com.arialyy.frame.core.AbsDialogFragment;
* Created by AriaLyy@outlook.com on 2016/11/14.
*/
public abstract class BaseDialog<VB extends ViewDataBinding> extends AbsDialogFragment<VB>{
protected BaseDialog(Object obj){
super(obj);
}
@Override protected void init(Bundle savedInstanceState) {
}

@ -1,5 +1,6 @@
package com.arialyy.simple.dialog;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
@ -14,11 +15,16 @@ import com.arialyy.simple.databinding.DialogDownloadNumBinding;
* Created by AriaLyy@outlook.com on 2016/11/14.
* 设置下载数量对话框
*/
public class DownloadNumDialog extends BaseDialog<DialogDownloadNumBinding> implements RadioGroup.OnCheckedChangeListener{
@SuppressLint("ValidFragment") public class DownloadNumDialog
extends BaseDialog<DialogDownloadNumBinding> implements RadioGroup.OnCheckedChangeListener {
public static final int RESULT_CODE = 1001;
@Bind(R.id.cancel) Button mCancel;
@Bind(R.id.rg) RadioGroup mRg;
public DownloadNumDialog(Object obj) {
super(obj);
}
@Override protected int setLayoutId() {
return R.layout.dialog_download_num;
}
@ -41,6 +47,7 @@ public class DownloadNumDialog extends BaseDialog<DialogDownloadNumBinding> impl
RadioButton rb = (RadioButton) group.getChildAt(checkedId);
if (rb.isChecked()) {
getSimplerModule().onDialog(RESULT_CODE, rb.getTag());
dismiss();
}
}
}

@ -1,83 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:minWidth="300dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:textColor="@color/colorPrimary"
android:textSize="16sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="10dp"
android:text="设置下载数"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/colorPrimary"
android:textSize="16sp"
/>
<View
android:background="@color/black"
android:layout_width="match_parent"
android:layout_height="1dp"/>
android:layout_height="1dp"
android:background="@color/black"
/>
<RadioGroup
android:id="@+id/rg"
android:padding="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp"
>
<RadioButton
android:tag="2"
android:text="下载线程数:2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layoutDirection="rtl"
android:tag="2"
android:text="下载线程数:2"
android:textAlignment="textStart"
android:layout_gravity="start"
/>
<RadioButton
android:tag="3"
android:text="下载线程数:3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layoutDirection="rtl"
android:tag="3"
android:text="下载线程数:3"
android:textAlignment="textStart"
android:layout_gravity="start"
/>
<RadioButton
android:tag="4"
android:text="下载线程数:4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layoutDirection="rtl"
android:tag="4"
android:text="下载线程数:4"
android:textAlignment="textStart"
android:layout_gravity="start"
/>
</RadioGroup>
<View
android:background="@color/black"
android:layout_width="match_parent"
android:layout_height="1dp"/>
android:layout_height="1dp"
android:background="@color/black"
/>
<Button
android:id="@+id/cancel"
android:text="取消"
style="?buttonBarButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="取消"
style="?buttonBarButtonStyle"
/>
</LinearLayout>

@ -23,4 +23,4 @@ dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
}
apply from: 'jcenter.gradle'
//apply from: 'jcenter.gradle'
Loading…
Cancel
Save