parent
432b8773b1
commit
312d6e85d5
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,6 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project version="4"> |
||||
<component name="VcsDirectoryMappings"> |
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" /> |
||||
</component> |
||||
</project> |
@ -0,0 +1,94 @@ |
||||
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 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; |
||||
|
||||
import butterknife.Bind; |
||||
|
||||
/** |
||||
* 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); |
||||
} |
||||
} |
@ -0,0 +1,21 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<layout |
||||
xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
> |
||||
|
||||
<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> |
@ -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" |
||||
/> |
Loading…
Reference in new issue