commit
4a589e947c
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,229 @@ |
|||||||
|
<?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_LEGACY_SETTINGS_IMPORTED" 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="Aria" /> |
||||||
|
</component> |
||||||
|
</project> |
@ -0,0 +1,3 @@ |
|||||||
|
<component name="ProjectDictionaryState"> |
||||||
|
<dictionary name="AriaL" /> |
||||||
|
</component> |
@ -1,29 +1,32 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
package="com.arialyy.simple"> |
package="com.arialyy.simple"> |
||||||
|
|
||||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> |
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> |
||||||
<uses-permission android:name="android.permission.INTERNET"/> |
<uses-permission android:name="android.permission.INTERNET"/> |
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> |
||||||
|
|
||||||
<application |
<application |
||||||
android:name=".base.BaseApplication" |
android:name=".base.BaseApplication" |
||||||
android:allowBackup="true" |
android:allowBackup="true" |
||||||
android:icon="@mipmap/ic_launcher" |
android:icon="@mipmap/ic_launcher" |
||||||
|
android:label="@string/app_name" |
||||||
|
android:supportsRtl="true" |
||||||
|
android:theme="@style/AppTheme"> |
||||||
|
<!--android:name=".activity.SingleTaskActivity"--> |
||||||
|
<activity |
||||||
|
android:name=".activity.MainActivity" |
||||||
android:label="@string/app_name" |
android:label="@string/app_name" |
||||||
android:supportsRtl="true" |
android:theme="@style/AppTheme.NoActionBar"> |
||||||
android:theme="@style/AppTheme"> |
<intent-filter> |
||||||
<!--android:name=".activity.SimpleTestActivity"--> |
<action android:name="android.intent.action.MAIN"/> |
||||||
<activity |
|
||||||
android:name=".activity.MainActivity" |
|
||||||
android:label="@string/app_name" |
|
||||||
android:theme="@style/AppTheme.NoActionBar"> |
|
||||||
<intent-filter> |
|
||||||
<action android:name="android.intent.action.MAIN"/> |
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER"/> |
<category android:name="android.intent.category.LAUNCHER"/> |
||||||
</intent-filter> |
</intent-filter> |
||||||
</activity> |
</activity> |
||||||
</application> |
|
||||||
|
<activity android:name=".activity.SingleTaskActivity"/> |
||||||
|
<activity android:name=".activity.MultiTaskActivity"/> |
||||||
|
</application> |
||||||
|
|
||||||
</manifest> |
</manifest> |
||||||
|
@ -1,90 +1,38 @@ |
|||||||
package com.arialyy.simple.activity; |
package com.arialyy.simple.activity; |
||||||
|
|
||||||
import android.content.BroadcastReceiver; |
|
||||||
import android.content.Context; |
|
||||||
import android.content.Intent; |
import android.content.Intent; |
||||||
import android.os.Bundle; |
import android.os.Bundle; |
||||||
import android.support.v7.widget.LinearLayoutManager; |
import android.support.v7.widget.Toolbar; |
||||||
import android.support.v7.widget.RecyclerView; |
import android.view.View; |
||||||
|
import butterknife.Bind; |
||||||
import com.arialyy.downloadutil.core.DownloadManager; |
|
||||||
import com.arialyy.downloadutil.entity.DownloadEntity; |
|
||||||
import com.arialyy.frame.util.show.L; |
|
||||||
import com.arialyy.simple.R; |
import com.arialyy.simple.R; |
||||||
import com.arialyy.simple.adapter.DownloadAdapter; |
|
||||||
import com.arialyy.simple.base.BaseActivity; |
import com.arialyy.simple.base.BaseActivity; |
||||||
import com.arialyy.simple.databinding.ActivityMainBinding; |
import com.arialyy.simple.databinding.ActivityMainBinding; |
||||||
import com.arialyy.simple.module.DownloadModule; |
|
||||||
|
|
||||||
import butterknife.Bind; |
|
||||||
|
|
||||||
/** |
/** |
||||||
* Created by Lyy on 2016/9/27. |
* Created by Lyy on 2016/10/13. |
||||||
*/ |
*/ |
||||||
public class MainActivity extends BaseActivity<ActivityMainBinding> { |
public class MainActivity extends BaseActivity<ActivityMainBinding> { |
||||||
@Bind(R.id.list) RecyclerView mList; |
@Bind(R.id.toolbar) Toolbar mBar; |
||||||
DownloadAdapter mAdapter; |
|
||||||
|
@Override protected int setLayoutId() { |
||||||
@Override protected int setLayoutId() { |
return R.layout.activity_main; |
||||||
return R.layout.activity_main; |
} |
||||||
} |
|
||||||
|
@Override protected void init(Bundle savedInstanceState) { |
||||||
@Override protected void init(Bundle savedInstanceState) { |
super.init(savedInstanceState); |
||||||
super.init(savedInstanceState); |
setSupportActionBar(mBar); |
||||||
mAdapter = new DownloadAdapter(this, getModule(DownloadModule.class).getDownloadData()); |
mBar.setTitle("多线程多任务下载"); |
||||||
mList.setLayoutManager(new LinearLayoutManager(this)); |
} |
||||||
mList.setAdapter(mAdapter); |
|
||||||
} |
public void onClick(View view) { |
||||||
|
switch (view.getId()) { |
||||||
|
case R.id.single_task: |
||||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() { |
startActivity(new Intent(this, SingleTaskActivity.class)); |
||||||
long len = 0; |
break; |
||||||
|
case R.id.multi_task: |
||||||
@Override public void onReceive(Context context, Intent intent) { |
startActivity(new Intent(this, MultiTaskActivity.class)); |
||||||
String action = intent.getAction(); |
break; |
||||||
DownloadEntity entity = intent.getParcelableExtra(DownloadManager.ENTITY); |
|
||||||
switch (action) { |
|
||||||
case DownloadManager.ACTION_PRE: |
|
||||||
len = entity.getFileSize(); |
|
||||||
L.d(TAG, "download pre"); |
|
||||||
break; |
|
||||||
case DownloadManager.ACTION_START: |
|
||||||
L.d(TAG, "download start"); |
|
||||||
break; |
|
||||||
case DownloadManager.ACTION_RESUME: |
|
||||||
L.d(TAG, "download resume"); |
|
||||||
long location = intent.getLongExtra(DownloadManager.CURRENT_LOCATION, 1); |
|
||||||
mAdapter.updateState(entity); |
|
||||||
break; |
|
||||||
case DownloadManager.ACTION_RUNNING: |
|
||||||
long current = intent.getLongExtra(DownloadManager.CURRENT_LOCATION, 0); |
|
||||||
mAdapter.setProgress(entity.getDownloadUrl(), current); |
|
||||||
break; |
|
||||||
case DownloadManager.ACTION_STOP: |
|
||||||
L.d(TAG, "download stop"); |
|
||||||
mAdapter.updateState(entity); |
|
||||||
break; |
|
||||||
case DownloadManager.ACTION_COMPLETE: |
|
||||||
L.d(TAG, "download complete"); |
|
||||||
mAdapter.updateState(entity); |
|
||||||
break; |
|
||||||
case DownloadManager.ACTION_CANCEL: |
|
||||||
L.d(TAG, "download cancel"); |
|
||||||
break; |
|
||||||
case DownloadManager.ACTION_FAIL: |
|
||||||
L.d(TAG, "download fail"); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
@Override protected void onResume() { |
|
||||||
super.onResume(); |
|
||||||
registerReceiver(mReceiver, getModule(DownloadModule.class).getDownloadFilter()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override protected void onDestroy() { |
|
||||||
super.onDestroy(); |
|
||||||
unregisterReceiver(mReceiver); |
|
||||||
} |
} |
||||||
|
} |
||||||
} |
} |
||||||
|
@ -0,0 +1,91 @@ |
|||||||
|
package com.arialyy.simple.activity; |
||||||
|
|
||||||
|
import android.content.BroadcastReceiver; |
||||||
|
import android.content.Context; |
||||||
|
import android.content.Intent; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.support.v7.widget.LinearLayoutManager; |
||||||
|
import android.support.v7.widget.RecyclerView; |
||||||
|
import android.support.v7.widget.Toolbar; |
||||||
|
import butterknife.Bind; |
||||||
|
import com.arialyy.downloadutil.core.DownloadManager; |
||||||
|
import com.arialyy.downloadutil.entity.DownloadEntity; |
||||||
|
import com.arialyy.frame.util.show.L; |
||||||
|
import com.arialyy.simple.R; |
||||||
|
import com.arialyy.simple.adapter.DownloadAdapter; |
||||||
|
import com.arialyy.simple.base.BaseActivity; |
||||||
|
import com.arialyy.simple.databinding.ActivityMultiBinding; |
||||||
|
import com.arialyy.simple.module.DownloadModule; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by Lyy on 2016/9/27. |
||||||
|
*/ |
||||||
|
public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> { |
||||||
|
@Bind(R.id.list) RecyclerView mList; |
||||||
|
@Bind(R.id.toolbar) Toolbar mBar; |
||||||
|
DownloadAdapter mAdapter; |
||||||
|
|
||||||
|
@Override protected int setLayoutId() { |
||||||
|
return R.layout.activity_multi; |
||||||
|
} |
||||||
|
|
||||||
|
@Override protected void init(Bundle savedInstanceState) { |
||||||
|
super.init(savedInstanceState); |
||||||
|
setSupportActionBar(mBar); |
||||||
|
mBar.setTitle("多任务下载"); |
||||||
|
mAdapter = new DownloadAdapter(this, getModule(DownloadModule.class).getDownloadData()); |
||||||
|
mList.setLayoutManager(new LinearLayoutManager(this)); |
||||||
|
mList.setAdapter(mAdapter); |
||||||
|
} |
||||||
|
|
||||||
|
private BroadcastReceiver mReceiver = new BroadcastReceiver() { |
||||||
|
long len = 0; |
||||||
|
|
||||||
|
@Override public void onReceive(Context context, Intent intent) { |
||||||
|
String action = intent.getAction(); |
||||||
|
DownloadEntity entity = intent.getParcelableExtra(DownloadManager.ENTITY); |
||||||
|
switch (action) { |
||||||
|
case DownloadManager.ACTION_PRE: |
||||||
|
len = entity.getFileSize(); |
||||||
|
L.d(TAG, "download pre"); |
||||||
|
break; |
||||||
|
case DownloadManager.ACTION_START: |
||||||
|
L.d(TAG, "download start"); |
||||||
|
break; |
||||||
|
case DownloadManager.ACTION_RESUME: |
||||||
|
L.d(TAG, "download resume"); |
||||||
|
long location = intent.getLongExtra(DownloadManager.CURRENT_LOCATION, 1); |
||||||
|
mAdapter.updateState(entity); |
||||||
|
break; |
||||||
|
case DownloadManager.ACTION_RUNNING: |
||||||
|
long current = intent.getLongExtra(DownloadManager.CURRENT_LOCATION, 0); |
||||||
|
mAdapter.setProgress(entity.getDownloadUrl(), current); |
||||||
|
break; |
||||||
|
case DownloadManager.ACTION_STOP: |
||||||
|
L.d(TAG, "download stop"); |
||||||
|
mAdapter.updateState(entity); |
||||||
|
break; |
||||||
|
case DownloadManager.ACTION_COMPLETE: |
||||||
|
L.d(TAG, "download complete"); |
||||||
|
mAdapter.updateState(entity); |
||||||
|
break; |
||||||
|
case DownloadManager.ACTION_CANCEL: |
||||||
|
L.d(TAG, "download cancel"); |
||||||
|
break; |
||||||
|
case DownloadManager.ACTION_FAIL: |
||||||
|
L.d(TAG, "download fail"); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
@Override protected void onResume() { |
||||||
|
super.onResume(); |
||||||
|
registerReceiver(mReceiver, getModule(DownloadModule.class).getDownloadFilter()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override protected void onDestroy() { |
||||||
|
super.onDestroy(); |
||||||
|
unregisterReceiver(mReceiver); |
||||||
|
} |
||||||
|
} |
@ -1,248 +0,0 @@ |
|||||||
package com.arialyy.simple.activity; |
|
||||||
|
|
||||||
import android.content.BroadcastReceiver; |
|
||||||
import android.content.Context; |
|
||||||
import android.content.Intent; |
|
||||||
import android.os.Bundle; |
|
||||||
import android.os.Environment; |
|
||||||
import android.os.Handler; |
|
||||||
import android.os.Message; |
|
||||||
import android.support.v7.widget.Toolbar; |
|
||||||
import android.view.View; |
|
||||||
import android.widget.Button; |
|
||||||
import android.widget.ProgressBar; |
|
||||||
import android.widget.TextView; |
|
||||||
import android.widget.Toast; |
|
||||||
|
|
||||||
import com.arialyy.downloadutil.core.DownloadManager; |
|
||||||
import com.arialyy.downloadutil.core.command.CommandFactory; |
|
||||||
import com.arialyy.downloadutil.core.command.IDownloadCommand; |
|
||||||
import com.arialyy.downloadutil.entity.DownloadEntity; |
|
||||||
import com.arialyy.downloadutil.orm.DbEntity; |
|
||||||
import com.arialyy.downloadutil.util.Util; |
|
||||||
import com.arialyy.frame.util.show.L; |
|
||||||
import com.arialyy.simple.R; |
|
||||||
import com.arialyy.simple.base.BaseActivity; |
|
||||||
import com.arialyy.simple.databinding.ActivitySimpleBinding; |
|
||||||
import com.arialyy.simple.module.DownloadModule; |
|
||||||
|
|
||||||
import java.util.ArrayList; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
import butterknife.Bind; |
|
||||||
|
|
||||||
public class SimpleTestActivity extends BaseActivity<ActivitySimpleBinding> { |
|
||||||
private static final int DOWNLOAD_PRE = 0x01; |
|
||||||
private static final int DOWNLOAD_STOP = 0x02; |
|
||||||
private static final int DOWNLOAD_FAILE = 0x03; |
|
||||||
private static final int DOWNLOAD_CANCEL = 0x04; |
|
||||||
private static final int DOWNLOAD_RESUME = 0x05; |
|
||||||
private static final int DOWNLOAD_COMPLETE = 0x06; |
|
||||||
private ProgressBar mPb; |
|
||||||
private String mDownloadUrl = "http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk"; |
|
||||||
private Button mStart, mStop, mCancel; |
|
||||||
private TextView mSize; |
|
||||||
@Bind(R.id.toolbar) Toolbar toolbar; |
|
||||||
private CommandFactory mFactory; |
|
||||||
private DownloadManager mManager; |
|
||||||
private DownloadEntity mEntity; |
|
||||||
|
|
||||||
private Handler mUpdateHandler = new Handler() { |
|
||||||
@Override public void handleMessage(Message msg) { |
|
||||||
super.handleMessage(msg); |
|
||||||
switch (msg.what) { |
|
||||||
case DOWNLOAD_PRE: |
|
||||||
mSize.setText(Util.formatFileSize((Long) msg.obj)); |
|
||||||
setBtState(false); |
|
||||||
break; |
|
||||||
case DOWNLOAD_FAILE: |
|
||||||
Toast.makeText(SimpleTestActivity.this, "下载失败", Toast.LENGTH_SHORT).show(); |
|
||||||
setBtState(true); |
|
||||||
break; |
|
||||||
case DOWNLOAD_STOP: |
|
||||||
Toast.makeText(SimpleTestActivity.this, "暂停下载", Toast.LENGTH_SHORT).show(); |
|
||||||
mStart.setText("恢复"); |
|
||||||
setBtState(true); |
|
||||||
break; |
|
||||||
case DOWNLOAD_CANCEL: |
|
||||||
mPb.setProgress(0); |
|
||||||
Toast.makeText(SimpleTestActivity.this, "取消下载", Toast.LENGTH_SHORT).show(); |
|
||||||
mStart.setText("开始"); |
|
||||||
setBtState(true); |
|
||||||
break; |
|
||||||
case DOWNLOAD_RESUME: |
|
||||||
Toast.makeText(SimpleTestActivity.this, |
|
||||||
"恢复下载,恢复位置 ==> " + Util.formatFileSize((Long) msg.obj), |
|
||||||
Toast.LENGTH_SHORT).show(); |
|
||||||
setBtState(false); |
|
||||||
break; |
|
||||||
case DOWNLOAD_COMPLETE: |
|
||||||
Toast.makeText(SimpleTestActivity.this, "下载完成", Toast.LENGTH_SHORT).show(); |
|
||||||
mStart.setText("重新开始?"); |
|
||||||
mCancel.setEnabled(false); |
|
||||||
setBtState(true); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
/** |
|
||||||
* 设置start 和 stop 按钮状态 |
|
||||||
* |
|
||||||
* @param state |
|
||||||
*/ |
|
||||||
private void setBtState(boolean state) { |
|
||||||
mStart.setEnabled(state); |
|
||||||
mStop.setEnabled(!state); |
|
||||||
} |
|
||||||
|
|
||||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() { |
|
||||||
long len = 0; |
|
||||||
|
|
||||||
@Override public void onReceive(Context context, Intent intent) { |
|
||||||
String action = intent.getAction(); |
|
||||||
switch (action) { |
|
||||||
case DownloadManager.ACTION_PRE: |
|
||||||
DownloadEntity entity = intent.getParcelableExtra(DownloadManager.ENTITY); |
|
||||||
len = entity.getFileSize(); |
|
||||||
L.d(TAG, "download pre"); |
|
||||||
mUpdateHandler.obtainMessage(DOWNLOAD_PRE, len).sendToTarget(); |
|
||||||
break; |
|
||||||
case DownloadManager.ACTION_START: |
|
||||||
L.d(TAG, "download start"); |
|
||||||
break; |
|
||||||
case DownloadManager.ACTION_RESUME: |
|
||||||
L.d(TAG, "download resume"); |
|
||||||
long location = intent.getLongExtra(DownloadManager.CURRENT_LOCATION, 1); |
|
||||||
mUpdateHandler.obtainMessage(DOWNLOAD_RESUME, location).sendToTarget(); |
|
||||||
break; |
|
||||||
case DownloadManager.ACTION_RUNNING: |
|
||||||
long current = intent.getLongExtra(DownloadManager.CURRENT_LOCATION, 0); |
|
||||||
if (len == 0) { |
|
||||||
mPb.setProgress(0); |
|
||||||
} else { |
|
||||||
mPb.setProgress((int) ((current * 100) / len)); |
|
||||||
} |
|
||||||
break; |
|
||||||
case DownloadManager.ACTION_STOP: |
|
||||||
L.d(TAG, "download stop"); |
|
||||||
mUpdateHandler.sendEmptyMessage(DOWNLOAD_STOP); |
|
||||||
break; |
|
||||||
case DownloadManager.ACTION_COMPLETE: |
|
||||||
mUpdateHandler.sendEmptyMessage(DOWNLOAD_COMPLETE); |
|
||||||
break; |
|
||||||
case DownloadManager.ACTION_CANCEL: |
|
||||||
mUpdateHandler.sendEmptyMessage(DOWNLOAD_CANCEL); |
|
||||||
break; |
|
||||||
case DownloadManager.ACTION_FAIL: |
|
||||||
mUpdateHandler.sendEmptyMessage(DOWNLOAD_FAILE); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
@Override protected void onCreate(Bundle savedInstanceState) { |
|
||||||
super.onCreate(savedInstanceState); |
|
||||||
init(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override protected void onResume() { |
|
||||||
super.onResume(); |
|
||||||
registerReceiver(mReceiver, getModule(DownloadModule.class).getDownloadFilter()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override protected void onDestroy() { |
|
||||||
super.onDestroy(); |
|
||||||
unregisterReceiver(mReceiver); |
|
||||||
} |
|
||||||
|
|
||||||
@Override protected int setLayoutId() { |
|
||||||
return R.layout.activity_simple; |
|
||||||
} |
|
||||||
|
|
||||||
@Override protected void init(Bundle savedInstanceState) { |
|
||||||
super.init(savedInstanceState); |
|
||||||
setSupportActionBar(toolbar); |
|
||||||
init(); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
private void init() { |
|
||||||
mPb = (ProgressBar) findViewById(R.id.progressBar); |
|
||||||
mStart = (Button) findViewById(R.id.start); |
|
||||||
mStop = (Button) findViewById(R.id.stop); |
|
||||||
mCancel = (Button) findViewById(R.id.cancel); |
|
||||||
mSize = (TextView) findViewById(R.id.size); |
|
||||||
mFactory = CommandFactory.getInstance(); |
|
||||||
mManager = DownloadManager.getInstance(); |
|
||||||
mEntity = DbEntity.findData(DownloadEntity.class, new String[]{"downloadUrl"}, |
|
||||||
new String[]{mDownloadUrl}); |
|
||||||
if (mEntity != null) { |
|
||||||
mPb.setProgress((int) ((mEntity.getCurrentProgress() * 100) / mEntity.getFileSize())); |
|
||||||
mSize.setText(Util.formatFileSize(mEntity.getFileSize())); |
|
||||||
if (mEntity.getState() == DownloadEntity.STATE_DOWNLOAD_ING) { |
|
||||||
setBtState(false); |
|
||||||
} else if (mEntity.isDownloadComplete()) { |
|
||||||
mStart.setText("重新开始?"); |
|
||||||
setBtState(true); |
|
||||||
} |
|
||||||
} else { |
|
||||||
mEntity = new DownloadEntity(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void onClick(View view) { |
|
||||||
switch (view.getId()) { |
|
||||||
case R.id.start: |
|
||||||
start(); |
|
||||||
// if (PermissionManager.getInstance()
|
|
||||||
// .checkPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
|
||||||
// start();
|
|
||||||
// } else {
|
|
||||||
// PermissionManager.getInstance()
|
|
||||||
// .requestPermission(this, new OnPermissionCallback() {
|
|
||||||
// @Override public void onSuccess(String... permissions) {
|
|
||||||
// start();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override public void onFail(String... permissions) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
|
||||||
// }
|
|
||||||
break; |
|
||||||
case R.id.stop: |
|
||||||
stop(); |
|
||||||
break; |
|
||||||
case R.id.cancel: |
|
||||||
cancel(); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private void start() { |
|
||||||
mEntity.setFileName("test.apk"); |
|
||||||
mEntity.setDownloadUrl(mDownloadUrl); |
|
||||||
mEntity.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk"); |
|
||||||
List<IDownloadCommand> commands = new ArrayList<>(); |
|
||||||
IDownloadCommand addCommand = mFactory.createCommand(this, mEntity, |
|
||||||
CommandFactory.TASK_CREATE); |
|
||||||
IDownloadCommand startCommand = mFactory.createCommand(this, mEntity, |
|
||||||
CommandFactory.TASK_START); |
|
||||||
commands.add(addCommand); |
|
||||||
commands.add(startCommand); |
|
||||||
mManager.setCommands(commands).exe(); |
|
||||||
} |
|
||||||
|
|
||||||
private void stop() { |
|
||||||
IDownloadCommand stopCommand = mFactory.createCommand(this, mEntity, |
|
||||||
CommandFactory.TASK_STOP); |
|
||||||
mManager.setCommand(stopCommand).exe(); |
|
||||||
} |
|
||||||
|
|
||||||
private void cancel() { |
|
||||||
IDownloadCommand cancelCommand = mFactory.createCommand(this, mEntity, |
|
||||||
CommandFactory.TASK_CANCEL); |
|
||||||
mManager.setCommand(cancelCommand).exe(); |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,241 @@ |
|||||||
|
package com.arialyy.simple.activity; |
||||||
|
|
||||||
|
import android.content.BroadcastReceiver; |
||||||
|
import android.content.Context; |
||||||
|
import android.content.Intent; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.os.Environment; |
||||||
|
import android.os.Handler; |
||||||
|
import android.os.Message; |
||||||
|
import android.support.v7.widget.Toolbar; |
||||||
|
import android.view.View; |
||||||
|
import android.widget.Button; |
||||||
|
import android.widget.ProgressBar; |
||||||
|
import android.widget.TextView; |
||||||
|
import android.widget.Toast; |
||||||
|
import butterknife.Bind; |
||||||
|
import com.arialyy.downloadutil.core.DownloadManager; |
||||||
|
import com.arialyy.downloadutil.core.command.CommandFactory; |
||||||
|
import com.arialyy.downloadutil.core.command.IDownloadCommand; |
||||||
|
import com.arialyy.downloadutil.entity.DownloadEntity; |
||||||
|
import com.arialyy.downloadutil.orm.DbEntity; |
||||||
|
import com.arialyy.downloadutil.util.Util; |
||||||
|
import com.arialyy.frame.util.show.L; |
||||||
|
import com.arialyy.simple.R; |
||||||
|
import com.arialyy.simple.base.BaseActivity; |
||||||
|
import com.arialyy.simple.databinding.ActivitySingleBinding; |
||||||
|
import com.arialyy.simple.module.DownloadModule; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { |
||||||
|
private static final int DOWNLOAD_PRE = 0x01; |
||||||
|
private static final int DOWNLOAD_STOP = 0x02; |
||||||
|
private static final int DOWNLOAD_FAILE = 0x03; |
||||||
|
private static final int DOWNLOAD_CANCEL = 0x04; |
||||||
|
private static final int DOWNLOAD_RESUME = 0x05; |
||||||
|
private static final int DOWNLOAD_COMPLETE = 0x06; |
||||||
|
private ProgressBar mPb; |
||||||
|
private String mDownloadUrl = |
||||||
|
"http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk"; |
||||||
|
private Button mStart, mStop, mCancel; |
||||||
|
private TextView mSize; |
||||||
|
@Bind(R.id.toolbar) Toolbar toolbar; |
||||||
|
private CommandFactory mFactory; |
||||||
|
private DownloadManager mManager; |
||||||
|
private DownloadEntity mEntity; |
||||||
|
|
||||||
|
private Handler mUpdateHandler = new Handler() { |
||||||
|
@Override public void handleMessage(Message msg) { |
||||||
|
super.handleMessage(msg); |
||||||
|
switch (msg.what) { |
||||||
|
case DOWNLOAD_PRE: |
||||||
|
mSize.setText(Util.formatFileSize((Long) msg.obj)); |
||||||
|
setBtState(false); |
||||||
|
break; |
||||||
|
case DOWNLOAD_FAILE: |
||||||
|
Toast.makeText(SingleTaskActivity.this, "下载失败", Toast.LENGTH_SHORT).show(); |
||||||
|
setBtState(true); |
||||||
|
break; |
||||||
|
case DOWNLOAD_STOP: |
||||||
|
Toast.makeText(SingleTaskActivity.this, "暂停下载", Toast.LENGTH_SHORT).show(); |
||||||
|
mStart.setText("恢复"); |
||||||
|
setBtState(true); |
||||||
|
break; |
||||||
|
case DOWNLOAD_CANCEL: |
||||||
|
mPb.setProgress(0); |
||||||
|
Toast.makeText(SingleTaskActivity.this, "取消下载", Toast.LENGTH_SHORT).show(); |
||||||
|
mStart.setText("开始"); |
||||||
|
setBtState(true); |
||||||
|
break; |
||||||
|
case DOWNLOAD_RESUME: |
||||||
|
Toast.makeText(SingleTaskActivity.this, |
||||||
|
"恢复下载,恢复位置 ==> " + Util.formatFileSize((Long) msg.obj), Toast.LENGTH_SHORT).show(); |
||||||
|
setBtState(false); |
||||||
|
break; |
||||||
|
case DOWNLOAD_COMPLETE: |
||||||
|
Toast.makeText(SingleTaskActivity.this, "下载完成", Toast.LENGTH_SHORT).show(); |
||||||
|
mStart.setText("重新开始?"); |
||||||
|
mCancel.setEnabled(false); |
||||||
|
setBtState(true); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置start 和 stop 按钮状态 |
||||||
|
*/ |
||||||
|
private void setBtState(boolean state) { |
||||||
|
mStart.setEnabled(state); |
||||||
|
mStop.setEnabled(!state); |
||||||
|
} |
||||||
|
|
||||||
|
private BroadcastReceiver mReceiver = new BroadcastReceiver() { |
||||||
|
long len = 0; |
||||||
|
|
||||||
|
@Override public void onReceive(Context context, Intent intent) { |
||||||
|
String action = intent.getAction(); |
||||||
|
switch (action) { |
||||||
|
case DownloadManager.ACTION_PRE: |
||||||
|
DownloadEntity entity = intent.getParcelableExtra(DownloadManager.ENTITY); |
||||||
|
len = entity.getFileSize(); |
||||||
|
L.d(TAG, "download pre"); |
||||||
|
mUpdateHandler.obtainMessage(DOWNLOAD_PRE, len).sendToTarget(); |
||||||
|
break; |
||||||
|
case DownloadManager.ACTION_START: |
||||||
|
L.d(TAG, "download start"); |
||||||
|
break; |
||||||
|
case DownloadManager.ACTION_RESUME: |
||||||
|
L.d(TAG, "download resume"); |
||||||
|
long location = intent.getLongExtra(DownloadManager.CURRENT_LOCATION, 1); |
||||||
|
mUpdateHandler.obtainMessage(DOWNLOAD_RESUME, location).sendToTarget(); |
||||||
|
break; |
||||||
|
case DownloadManager.ACTION_RUNNING: |
||||||
|
long current = intent.getLongExtra(DownloadManager.CURRENT_LOCATION, 0); |
||||||
|
if (len == 0) { |
||||||
|
mPb.setProgress(0); |
||||||
|
} else { |
||||||
|
mPb.setProgress((int) ((current * 100) / len)); |
||||||
|
} |
||||||
|
break; |
||||||
|
case DownloadManager.ACTION_STOP: |
||||||
|
L.d(TAG, "download stop"); |
||||||
|
mUpdateHandler.sendEmptyMessage(DOWNLOAD_STOP); |
||||||
|
break; |
||||||
|
case DownloadManager.ACTION_COMPLETE: |
||||||
|
mUpdateHandler.sendEmptyMessage(DOWNLOAD_COMPLETE); |
||||||
|
break; |
||||||
|
case DownloadManager.ACTION_CANCEL: |
||||||
|
mUpdateHandler.sendEmptyMessage(DOWNLOAD_CANCEL); |
||||||
|
break; |
||||||
|
case DownloadManager.ACTION_FAIL: |
||||||
|
mUpdateHandler.sendEmptyMessage(DOWNLOAD_FAILE); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
@Override protected void onCreate(Bundle savedInstanceState) { |
||||||
|
super.onCreate(savedInstanceState); |
||||||
|
init(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override protected void onResume() { |
||||||
|
super.onResume(); |
||||||
|
registerReceiver(mReceiver, getModule(DownloadModule.class).getDownloadFilter()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override protected void onDestroy() { |
||||||
|
super.onDestroy(); |
||||||
|
unregisterReceiver(mReceiver); |
||||||
|
} |
||||||
|
|
||||||
|
@Override protected int setLayoutId() { |
||||||
|
return R.layout.activity_single; |
||||||
|
} |
||||||
|
|
||||||
|
@Override protected void init(Bundle savedInstanceState) { |
||||||
|
super.init(savedInstanceState); |
||||||
|
setSupportActionBar(toolbar); |
||||||
|
toolbar.setTitle("单任务下载"); |
||||||
|
init(); |
||||||
|
} |
||||||
|
|
||||||
|
private void init() { |
||||||
|
mPb = (ProgressBar) findViewById(R.id.progressBar); |
||||||
|
mStart = (Button) findViewById(R.id.start); |
||||||
|
mStop = (Button) findViewById(R.id.stop); |
||||||
|
mCancel = (Button) findViewById(R.id.cancel); |
||||||
|
mSize = (TextView) findViewById(R.id.size); |
||||||
|
mFactory = CommandFactory.getInstance(); |
||||||
|
mManager = DownloadManager.getInstance(); |
||||||
|
mEntity = DbEntity.findData(DownloadEntity.class, new String[] { "downloadUrl" }, |
||||||
|
new String[] { mDownloadUrl }); |
||||||
|
if (mEntity != null) { |
||||||
|
mPb.setProgress((int) ((mEntity.getCurrentProgress() * 100) / mEntity.getFileSize())); |
||||||
|
mSize.setText(Util.formatFileSize(mEntity.getFileSize())); |
||||||
|
if (mEntity.getState() == DownloadEntity.STATE_DOWNLOAD_ING) { |
||||||
|
setBtState(false); |
||||||
|
} else if (mEntity.isDownloadComplete()) { |
||||||
|
mStart.setText("重新开始?"); |
||||||
|
setBtState(true); |
||||||
|
} |
||||||
|
} else { |
||||||
|
mEntity = new DownloadEntity(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void onClick(View view) { |
||||||
|
switch (view.getId()) { |
||||||
|
case R.id.start: |
||||||
|
start(); |
||||||
|
// if (PermissionManager.getInstance()
|
||||||
|
// .checkPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||||
|
// start();
|
||||||
|
// } else {
|
||||||
|
// PermissionManager.getInstance()
|
||||||
|
// .requestPermission(this, new OnPermissionCallback() {
|
||||||
|
// @Override public void onSuccess(String... permissions) {
|
||||||
|
// start();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override public void onFail(String... permissions) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||||
|
// }
|
||||||
|
break; |
||||||
|
case R.id.stop: |
||||||
|
stop(); |
||||||
|
break; |
||||||
|
case R.id.cancel: |
||||||
|
cancel(); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void start() { |
||||||
|
mEntity.setFileName("test.apk"); |
||||||
|
mEntity.setDownloadUrl(mDownloadUrl); |
||||||
|
mEntity.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk"); |
||||||
|
List<IDownloadCommand> commands = new ArrayList<>(); |
||||||
|
IDownloadCommand addCommand = mFactory.createCommand(this, mEntity, CommandFactory.TASK_CREATE); |
||||||
|
IDownloadCommand startCommand = |
||||||
|
mFactory.createCommand(this, mEntity, CommandFactory.TASK_START); |
||||||
|
commands.add(addCommand); |
||||||
|
commands.add(startCommand); |
||||||
|
mManager.setCommands(commands).exe(); |
||||||
|
} |
||||||
|
|
||||||
|
private void stop() { |
||||||
|
IDownloadCommand stopCommand = mFactory.createCommand(this, mEntity, CommandFactory.TASK_STOP); |
||||||
|
mManager.setCommand(stopCommand).exe(); |
||||||
|
} |
||||||
|
|
||||||
|
private void cancel() { |
||||||
|
IDownloadCommand cancelCommand = |
||||||
|
mFactory.createCommand(this, mEntity, CommandFactory.TASK_CANCEL); |
||||||
|
mManager.setCommand(cancelCommand).exe(); |
||||||
|
} |
||||||
|
} |
@ -1,14 +1,13 @@ |
|||||||
package com.arialyy.simple.base; |
package com.arialyy.simple.base; |
||||||
|
|
||||||
import android.content.Context; |
import android.content.Context; |
||||||
|
|
||||||
import com.arialyy.frame.module.AbsModule; |
import com.arialyy.frame.module.AbsModule; |
||||||
|
|
||||||
/** |
/** |
||||||
* Created by Lyy on 2016/9/27. |
* Created by Lyy on 2016/9/27. |
||||||
*/ |
*/ |
||||||
public class BaseModule extends AbsModule { |
public class BaseModule extends AbsModule { |
||||||
public BaseModule(Context context) { |
public BaseModule(Context context) { |
||||||
super(context); |
super(context); |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,18 +1,32 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||||
<layout |
<layout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
xmlns:android="http://schemas.android.com/apk/res/android"> |
> |
||||||
|
|
||||||
<LinearLayout |
<LinearLayout |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:orientation="vertical" |
||||||
|
> |
||||||
|
|
||||||
|
<include layout="@layout/layout_bar"/> |
||||||
|
|
||||||
|
<Button |
||||||
|
android:id="@+id/single_task" |
||||||
android:layout_width="match_parent" |
android:layout_width="match_parent" |
||||||
android:layout_height="match_parent" |
android:layout_height="wrap_content" |
||||||
android:orientation="vertical" |
android:onClick="onClick" |
||||||
> |
android:text="单任务下载" |
||||||
|
style="?buttonBarButtonStyle" |
||||||
|
/> |
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView |
<Button |
||||||
android:id="@+id/list" |
android:id="@+id/multi_task" |
||||||
android:layout_width="match_parent" |
android:layout_width="match_parent" |
||||||
android:layout_height="match_parent" |
android:layout_height="wrap_content" |
||||||
/> |
android:onClick="onClick" |
||||||
|
android:text="多任务下载" |
||||||
|
style="?buttonBarButtonStyle" |
||||||
|
/> |
||||||
|
|
||||||
</LinearLayout> |
</LinearLayout> |
||||||
</layout> |
</layout> |
||||||
|
@ -0,0 +1,20 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<layout |
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
> |
||||||
|
|
||||||
|
<LinearLayout |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:orientation="vertical" |
||||||
|
> |
||||||
|
<include layout="@layout/layout_bar"/> |
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView |
||||||
|
android:id="@+id/list" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
/> |
||||||
|
|
||||||
|
</LinearLayout> |
||||||
|
</layout> |
@ -1,42 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"> |
|
||||||
|
|
||||||
<android.support.design.widget.CoordinatorLayout |
|
||||||
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|
||||||
xmlns:tools="http://schemas.android.com/tools" |
|
||||||
android:layout_width="match_parent" |
|
||||||
android:layout_height="match_parent" |
|
||||||
android:fitsSystemWindows="true" |
|
||||||
tools:context="com.arialyy.simple.activity.SimpleTestActivity" |
|
||||||
> |
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout |
|
||||||
android:layout_width="match_parent" |
|
||||||
android:layout_height="wrap_content" |
|
||||||
android:theme="@style/AppTheme.AppBarOverlay" |
|
||||||
> |
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar |
|
||||||
android:id="@+id/toolbar" |
|
||||||
android:layout_width="match_parent" |
|
||||||
android:layout_height="?attr/actionBarSize" |
|
||||||
android:background="?attr/colorPrimary" |
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay" |
|
||||||
/> |
|
||||||
|
|
||||||
</android.support.design.widget.AppBarLayout> |
|
||||||
|
|
||||||
<include layout="@layout/content_simple"/> |
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton |
|
||||||
android:id="@+id/fab" |
|
||||||
android:layout_width="wrap_content" |
|
||||||
android:layout_height="wrap_content" |
|
||||||
android:layout_gravity="bottom|end" |
|
||||||
android:layout_margin="@dimen/fab_margin" |
|
||||||
android:src="@android:drawable/ic_dialog_email" |
|
||||||
/> |
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout> |
|
||||||
</layout> |
|
@ -0,0 +1,34 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"> |
||||||
|
|
||||||
|
<android.support.design.widget.CoordinatorLayout |
||||||
|
xmlns:tools="http://schemas.android.com/tools" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:fitsSystemWindows="true" |
||||||
|
tools:context="com.arialyy.simple.activity.SingleTaskActivity" |
||||||
|
> |
||||||
|
|
||||||
|
<android.support.design.widget.AppBarLayout |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:theme="@style/AppTheme.AppBarOverlay" |
||||||
|
> |
||||||
|
|
||||||
|
<include layout="@layout/layout_bar"/> |
||||||
|
|
||||||
|
</android.support.design.widget.AppBarLayout> |
||||||
|
|
||||||
|
<include layout="@layout/content_single"/> |
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton |
||||||
|
android:id="@+id/fab" |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_gravity="bottom|end" |
||||||
|
android:layout_margin="@dimen/fab_margin" |
||||||
|
android:src="@android:drawable/ic_dialog_email" |
||||||
|
/> |
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout> |
||||||
|
</layout> |
@ -1,72 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|
||||||
xmlns:tools="http://schemas.android.com/tools" |
|
||||||
android:layout_width="match_parent" |
|
||||||
android:layout_height="match_parent" |
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" |
|
||||||
tools:context="com.arialyy.simple.activity.SimpleTestActivity" |
|
||||||
tools:showIn="@layout/activity_simple" |
|
||||||
> |
|
||||||
|
|
||||||
<ProgressBar |
|
||||||
android:id="@+id/progressBar" |
|
||||||
style="?android:attr/progressBarStyleHorizontal" |
|
||||||
android:layout_width="wrap_content" |
|
||||||
android:layout_height="20dp" |
|
||||||
android:layout_alignParentLeft="true" |
|
||||||
android:layout_alignParentStart="true" |
|
||||||
android:layout_alignParentTop="true" |
|
||||||
android:layout_margin="16dp" |
|
||||||
android:layout_toLeftOf="@+id/size" |
|
||||||
/> |
|
||||||
|
|
||||||
<TextView |
|
||||||
android:id="@+id/size" |
|
||||||
android:layout_width="wrap_content" |
|
||||||
android:layout_height="wrap_content" |
|
||||||
android:layout_alignParentRight="true" |
|
||||||
android:layout_alignTop="@+id/progressBar" |
|
||||||
android:layout_marginRight="16dp" |
|
||||||
android:text="ssss" |
|
||||||
android:textSize="16sp" |
|
||||||
/> |
|
||||||
|
|
||||||
<LinearLayout |
|
||||||
android:layout_width="match_parent" |
|
||||||
android:layout_height="wrap_content" |
|
||||||
android:layout_below="@+id/progressBar" |
|
||||||
android:orientation="horizontal" |
|
||||||
> |
|
||||||
|
|
||||||
<Button |
|
||||||
android:id="@+id/start" |
|
||||||
style="?buttonBarButtonStyle" |
|
||||||
android:layout_width="0dp" |
|
||||||
android:layout_height="wrap_content" |
|
||||||
android:layout_weight="1" |
|
||||||
android:onClick="onClick" |
|
||||||
android:text="开始" |
|
||||||
/> |
|
||||||
|
|
||||||
<Button |
|
||||||
android:id="@+id/stop" |
|
||||||
style="?buttonBarButtonStyle" |
|
||||||
android:layout_width="0dp" |
|
||||||
android:layout_height="wrap_content" |
|
||||||
android:layout_weight="1" |
|
||||||
android:onClick="onClick" |
|
||||||
android:text="暂停" |
|
||||||
/> |
|
||||||
|
|
||||||
<Button |
|
||||||
android:id="@+id/cancel" |
|
||||||
style="?buttonBarButtonStyle" |
|
||||||
android:layout_width="0dp" |
|
||||||
android:layout_height="wrap_content" |
|
||||||
android:layout_weight="1" |
|
||||||
android:onClick="onClick" |
|
||||||
android:text="删除任务" |
|
||||||
/> |
|
||||||
</LinearLayout> |
|
||||||
</RelativeLayout> |
|
@ -0,0 +1,72 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||||
|
xmlns:tools="http://schemas.android.com/tools" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" |
||||||
|
tools:context="com.arialyy.simple.activity.SingleTaskActivity" |
||||||
|
tools:showIn="@layout/activity_single" |
||||||
|
> |
||||||
|
|
||||||
|
<ProgressBar |
||||||
|
android:id="@+id/progressBar" |
||||||
|
style="?android:attr/progressBarStyleHorizontal" |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="20dp" |
||||||
|
android:layout_alignParentLeft="true" |
||||||
|
android:layout_alignParentStart="true" |
||||||
|
android:layout_alignParentTop="true" |
||||||
|
android:layout_margin="16dp" |
||||||
|
android:layout_toLeftOf="@+id/size" |
||||||
|
/> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/size" |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_alignParentRight="true" |
||||||
|
android:layout_alignTop="@+id/progressBar" |
||||||
|
android:layout_marginRight="16dp" |
||||||
|
android:text="ssss" |
||||||
|
android:textSize="16sp" |
||||||
|
/> |
||||||
|
|
||||||
|
<LinearLayout |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_below="@+id/progressBar" |
||||||
|
android:orientation="horizontal" |
||||||
|
> |
||||||
|
|
||||||
|
<Button |
||||||
|
android:id="@+id/start" |
||||||
|
style="?buttonBarButtonStyle" |
||||||
|
android:layout_width="0dp" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_weight="1" |
||||||
|
android:onClick="onClick" |
||||||
|
android:text="开始" |
||||||
|
/> |
||||||
|
|
||||||
|
<Button |
||||||
|
android:id="@+id/stop" |
||||||
|
style="?buttonBarButtonStyle" |
||||||
|
android:layout_width="0dp" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_weight="1" |
||||||
|
android:onClick="onClick" |
||||||
|
android:text="暂停" |
||||||
|
/> |
||||||
|
|
||||||
|
<Button |
||||||
|
android:id="@+id/cancel" |
||||||
|
style="?buttonBarButtonStyle" |
||||||
|
android:layout_width="0dp" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_weight="1" |
||||||
|
android:onClick="onClick" |
||||||
|
android:text="删除任务" |
||||||
|
/> |
||||||
|
</LinearLayout> |
||||||
|
</RelativeLayout> |
@ -1,27 +1,27 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
android:layout_width="match_parent" |
android:layout_width="match_parent" |
||||||
android:layout_height="wrap_content" |
android:layout_height="wrap_content" |
||||||
android:padding="16dp" |
android:padding="16dp" |
||||||
> |
> |
||||||
|
|
||||||
<com.arialyy.simple.widget.HorizontalProgressBarWithNumber |
<com.arialyy.simple.widget.HorizontalProgressBarWithNumber |
||||||
android:id="@+id/progressBar" |
android:id="@+id/progressBar" |
||||||
android:layout_width="match_parent" |
android:layout_width="match_parent" |
||||||
android:layout_height="wrap_content" |
android:layout_height="wrap_content" |
||||||
android:layout_centerVertical="true" |
android:layout_centerVertical="true" |
||||||
android:layout_marginRight="16dp" |
android:layout_marginRight="16dp" |
||||||
android:layout_toLeftOf="@+id/bt" |
android:layout_toLeftOf="@+id/bt" |
||||||
android:max="100" |
android:max="100" |
||||||
/> |
/> |
||||||
|
|
||||||
<Button |
<Button |
||||||
android:id="@+id/bt" |
android:id="@+id/bt" |
||||||
android:layout_width="wrap_content" |
android:layout_width="wrap_content" |
||||||
android:layout_height="wrap_content" |
android:layout_height="wrap_content" |
||||||
android:layout_alignParentRight="true" |
android:layout_alignParentRight="true" |
||||||
android:text="开始" |
android:text="开始" |
||||||
style="?buttonBarButtonStyle" |
style="?buttonBarButtonStyle" |
||||||
/> |
/> |
||||||
|
|
||||||
</RelativeLayout> |
</RelativeLayout> |
@ -0,0 +1,10 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<android.support.v7.widget.Toolbar |
||||||
|
android:id="@+id/toolbar" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="?attr/actionBarSize" |
||||||
|
android:background="?attr/colorPrimary" |
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay" |
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||||
|
/> |
@ -1,10 +1,10 @@ |
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" |
<menu xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||||
xmlns:tools="http://schemas.android.com/tools" |
xmlns:tools="http://schemas.android.com/tools" |
||||||
tools:context="com.example.arial.downloaddemo.com.arialyy.simple.MainActivity"> |
tools:context="com.example.arial.downloaddemo.com.arialyy.simple.MainActivity"> |
||||||
<item |
<item |
||||||
android:id="@+id/action_settings" |
android:id="@+id/action_settings" |
||||||
android:title="@string/action_settings" |
android:title="@string/action_settings" |
||||||
android:orderInCategory="100" |
android:orderInCategory="100" |
||||||
app:showAsAction="never"/> |
app:showAsAction="never"/> |
||||||
</menu> |
</menu> |
||||||
|
@ -1,12 +1,28 @@ |
|||||||
<resources> |
<resources> |
||||||
|
|
||||||
<style name="AppTheme.NoActionBar"> |
<style name="AppTheme.NoActionBar"> |
||||||
<item name="windowActionBar">false</item> |
<item name="windowActionBar">false</item> |
||||||
<item name="windowNoTitle">true</item> |
<item name="windowNoTitle">true</item> |
||||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item> |
<item name="android:windowDrawsSystemBarBackgrounds">true</item> |
||||||
<item name="android:statusBarColor">@android:color/transparent</item> |
<item name="android:statusBarColor">@android:color/transparent</item> |
||||||
<item name="colorPrimary">@color/colorPrimary</item> |
<item name="colorPrimary">@color/colorPrimary</item> |
||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> |
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> |
||||||
<item name="colorAccent">@color/colorAccent</item> |
<item name="colorAccent">@color/colorAccent</item> |
||||||
</style> |
</style> |
||||||
|
|
||||||
|
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> |
||||||
|
<!-- Customize your theme here. --> |
||||||
|
<item name="colorPrimary">@color/colorPrimary</item> |
||||||
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> |
||||||
|
<item name="colorAccent">@color/colorAccent</item> |
||||||
|
<!--设置导航栏内容可用--> |
||||||
|
<!--<item name="android:windowTranslucentNavigation">true</item>--> |
||||||
|
<!--设置状态栏内容可以--> |
||||||
|
<!--<item name="android:windowTranslucentStatus">true</item>--> |
||||||
|
<item name="windowActionBar">false</item> |
||||||
|
<item name="windowNoTitle">true</item> |
||||||
|
<item name="android:windowDrawsSystemBarBackgrounds">true</item> |
||||||
|
<item name="android:statusBarColor">@android:color/transparent</item> |
||||||
|
<item name="android:windowIsTranslucent">true</item> |
||||||
|
</style> |
||||||
</resources> |
</resources> |
||||||
|
@ -1,6 +1,6 @@ |
|||||||
<resources> |
<resources> |
||||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml |
<!-- Example customization of dimensions originally defined in res/values/dimens.xml |
||||||
(such as screen margins) for screens with more than 820dp of available width. This |
(such as screen margins) for screens with more than 820dp of available width. This |
||||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> |
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> |
||||||
<dimen name="activity_horizontal_margin">64dp</dimen> |
<dimen name="activity_horizontal_margin">64dp</dimen> |
||||||
</resources> |
</resources> |
||||||
|
@ -1,16 +1,16 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||||
<resources> |
<resources> |
||||||
<declare-styleable name="HorizontalProgressBarWithNumber"> |
<declare-styleable name="HorizontalProgressBarWithNumber"> |
||||||
<attr name="progress_unreached_color" format="color"/> |
<attr name="progress_unreached_color" format="color"/> |
||||||
<attr name="progress_reached_color" format="color"/> |
<attr name="progress_reached_color" format="color"/> |
||||||
<attr name="progress_reached_bar_height" format="dimension"/> |
<attr name="progress_reached_bar_height" format="dimension"/> |
||||||
<attr name="progress_unreached_bar_height" format="dimension"/> |
<attr name="progress_unreached_bar_height" format="dimension"/> |
||||||
<attr name="progress_text_size" format="dimension"/> |
<attr name="progress_text_size" format="dimension"/> |
||||||
<attr name="progress_text_color" format="color"/> |
<attr name="progress_text_color" format="color"/> |
||||||
<attr name="progress_text_offset" format="dimension"/> |
<attr name="progress_text_offset" format="dimension"/> |
||||||
<attr name="progress_text_visibility" format="enum"> |
<attr name="progress_text_visibility" format="enum"> |
||||||
<enum name="visible" value="0"/> |
<enum name="visible" value="0"/> |
||||||
<enum name="invisible" value="1"/> |
<enum name="invisible" value="1"/> |
||||||
</attr> |
</attr> |
||||||
</declare-styleable> |
</declare-styleable> |
||||||
</resources> |
</resources> |
@ -1,6 +1,6 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||||
<resources> |
<resources> |
||||||
<color name="colorPrimary">#3F51B5</color> |
<color name="colorPrimary">#3F51B5</color> |
||||||
<color name="colorPrimaryDark">#303F9F</color> |
<color name="colorPrimaryDark">#303F9F</color> |
||||||
<color name="colorAccent">#FF4081</color> |
<color name="colorAccent">#FF4081</color> |
||||||
</resources> |
</resources> |
||||||
|
@ -1,6 +1,6 @@ |
|||||||
<resources> |
<resources> |
||||||
<!-- Default screen margins, per the Android Design guidelines. --> |
<!-- Default screen margins, per the Android Design guidelines. --> |
||||||
<dimen name="activity_horizontal_margin">16dp</dimen> |
<dimen name="activity_horizontal_margin">16dp</dimen> |
||||||
<dimen name="activity_vertical_margin">16dp</dimen> |
<dimen name="activity_vertical_margin">16dp</dimen> |
||||||
<dimen name="fab_margin">16dp</dimen> |
<dimen name="fab_margin">16dp</dimen> |
||||||
</resources> |
</resources> |
||||||
|
@ -1,18 +1,18 @@ |
|||||||
<resources> |
<resources> |
||||||
<string name="app_name">DownloadDemo</string> |
<string name="app_name">DownloadDemo</string> |
||||||
<string name="action_settings">Settings</string> |
<string name="action_settings">Settings</string> |
||||||
|
|
||||||
<string-array name="test_apk_download_url"> |
<string-array name="test_apk_download_url"> |
||||||
<item>http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk</item> <!--300M的文件--> |
<item>http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk</item> <!--300M的文件--> |
||||||
<item>http://static.gaoshouyou.com/d/21/e8/61218d78d0e8b79df68dbc18dd484c97.apk</item> |
<item>http://static.gaoshouyou.com/d/21/e8/61218d78d0e8b79df68dbc18dd484c97.apk</item> |
||||||
<item>http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk</item> |
<item>http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk</item> |
||||||
<item>http://static.gaoshouyou.com/d/d4/4f/d6d48db3794fb9ecf47e83c346570881.apk</item> |
<item>http://static.gaoshouyou.com/d/d4/4f/d6d48db3794fb9ecf47e83c346570881.apk</item> |
||||||
<!--<item>http://static.gaoshouyou.com/d/18/cf/ba18113bc6cf56c1c5863e761e717003.apk</item>--> |
<!--<item>http://static.gaoshouyou.com/d/18/cf/ba18113bc6cf56c1c5863e761e717003.apk</item>--> |
||||||
<!--<item>http://static.gaoshouyou.com/d/60/17/2460921367173ea7145f11194a6f2587.apk</item>--> |
<!--<item>http://static.gaoshouyou.com/d/60/17/2460921367173ea7145f11194a6f2587.apk</item>--> |
||||||
<!--<item>http://static.gaoshouyou.com/d/32/e0/1a32123ecbe0ee010d35479df248f90f.apk</item>--> |
<!--<item>http://static.gaoshouyou.com/d/32/e0/1a32123ecbe0ee010d35479df248f90f.apk</item>--> |
||||||
<!--<item>http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk</item>--> |
<!--<item>http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk</item>--> |
||||||
<!--<item>http://static.gaoshouyou.com/d/e6/f5/4de6329f9cf5dc3a1d1e6bbcca0d003c.apk</item>--> |
<!--<item>http://static.gaoshouyou.com/d/e6/f5/4de6329f9cf5dc3a1d1e6bbcca0d003c.apk</item>--> |
||||||
<!--<item>http://static.gaoshouyou.com/d/6e/e5/ff6ecaaf45e532e6d07747af82357472.apk</item>--> |
<!--<item>http://static.gaoshouyou.com/d/6e/e5/ff6ecaaf45e532e6d07747af82357472.apk</item>--> |
||||||
<!--<item>http://static.gaoshouyou.com/d/36/69/2d3699acfa69e9632262442c46516ad8.apk</item>--> |
<!--<item>http://static.gaoshouyou.com/d/36/69/2d3699acfa69e9632262442c46516ad8.apk</item>--> |
||||||
</string-array> |
</string-array> |
||||||
</resources> |
</resources> |
||||||
|
@ -1,23 +1,25 @@ |
|||||||
<resources> |
<resources> |
||||||
|
|
||||||
<!-- Base application theme. --> |
<!-- Base application theme. --> |
||||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> |
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> |
||||||
<!-- Customize your theme here. --> |
<!-- Customize your theme here. --> |
||||||
<item name="colorPrimary">@color/colorPrimary</item> |
<item name="colorPrimary">@color/colorPrimary</item> |
||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> |
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> |
||||||
<item name="colorAccent">@color/colorAccent</item> |
<item name="colorAccent">@color/colorAccent</item> |
||||||
</style> |
<item name="windowActionBar">false</item> |
||||||
|
<item name="windowNoTitle">true</item> |
||||||
|
</style> |
||||||
|
|
||||||
<style name="AppTheme.NoActionBar"> |
<style name="AppTheme.NoActionBar"> |
||||||
<item name="windowActionBar">false</item> |
<item name="windowActionBar">false</item> |
||||||
<item name="windowNoTitle">true</item> |
<item name="windowNoTitle">true</item> |
||||||
<item name="colorPrimary">@color/colorPrimary</item> |
<item name="colorPrimary">@color/colorPrimary</item> |
||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> |
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> |
||||||
<item name="colorAccent">@color/colorAccent</item> |
<item name="colorAccent">@color/colorAccent</item> |
||||||
</style> |
</style> |
||||||
|
|
||||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/> |
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/> |
||||||
|
|
||||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/> |
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/> |
||||||
|
|
||||||
</resources> |
</resources> |
||||||
|
@ -1,14 +0,0 @@ |
|||||||
package com.example.arial.downloaddemo; |
|
||||||
|
|
||||||
import org.junit.Test; |
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals; |
|
||||||
|
|
||||||
/** |
|
||||||
* To work on unit tests, switch the Test Artifact in the Build Variants view. |
|
||||||
*/ |
|
||||||
public class ExampleUnitTest { |
|
||||||
@Test public void addition_isCorrect() throws Exception { |
|
||||||
assertEquals(4, 2 + 2); |
|
||||||
} |
|
||||||
} |
|
@ -1,11 +1,11 @@ |
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
package="com.arialyy.downloadutil"> |
package="com.arialyy.downloadutil"> |
||||||
|
|
||||||
<application |
<application |
||||||
android:allowBackup="true" |
android:allowBackup="true" |
||||||
android:label="@string/app_name" |
android:label="@string/app_name" |
||||||
android:supportsRtl="true"> |
android:supportsRtl="true"> |
||||||
|
|
||||||
</application> |
</application> |
||||||
|
|
||||||
</manifest> |
</manifest> |
||||||
|
@ -1,8 +1,8 @@ |
|||||||
<resources> |
<resources> |
||||||
<string name="app_name">DownloadUtil</string> |
<string name="app_name">DownloadUtil</string> |
||||||
|
|
||||||
<string name="error_entity_null">下载实体不能为空</string> |
<string name="error_entity_null">下载实体不能为空</string> |
||||||
<string name="error_download_url_null">下载链接不能为空</string> |
<string name="error_download_url_null">下载链接不能为空</string> |
||||||
<string name="error_download_path_null">存储地址不能为空</string> |
<string name="error_download_path_null">存储地址不能为空</string> |
||||||
<string name="error_file_name_null">文件名不能为空</string> |
<string name="error_file_name_null">文件名不能为空</string> |
||||||
</resources> |
</resources> |
||||||
|
@ -1,14 +0,0 @@ |
|||||||
package com.arialyy.downloadutil; |
|
||||||
|
|
||||||
import org.junit.Test; |
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals; |
|
||||||
|
|
||||||
/** |
|
||||||
* To work on unit tests, switch the Test Artifact in the Build Variants view. |
|
||||||
*/ |
|
||||||
public class ExampleUnitTest { |
|
||||||
@Test public void addition_isCorrect() throws Exception { |
|
||||||
assertEquals(4, 2 + 2); |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue