bug fix
This commit is contained in:
@ -13,7 +13,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<!--android:name=".activity.SimpleTestActivity"-->
|
||||
<!--android:name=".activity.SingleTaskActivity"-->
|
||||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
@ -24,6 +24,9 @@
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".activity.SingleTaskActivity"/>
|
||||
<activity android:name=".activity.MultiTaskActivity"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
@ -1,90 +1,38 @@
|
||||
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 com.arialyy.downloadutil.core.DownloadManager;
|
||||
import com.arialyy.downloadutil.entity.DownloadEntity;
|
||||
import com.arialyy.frame.util.show.L;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import butterknife.Bind;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.adapter.DownloadAdapter;
|
||||
import com.arialyy.simple.base.BaseActivity;
|
||||
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> {
|
||||
@Bind(R.id.list) RecyclerView mList;
|
||||
DownloadAdapter mAdapter;
|
||||
@Bind(R.id.toolbar) Toolbar mBar;
|
||||
|
||||
@Override protected int setLayoutId() {
|
||||
return R.layout.activity_main;
|
||||
}
|
||||
|
||||
@Override protected void init(Bundle savedInstanceState) {
|
||||
super.init(savedInstanceState);
|
||||
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);
|
||||
@Override protected int setLayoutId() {
|
||||
return R.layout.activity_main;
|
||||
}
|
||||
|
||||
@Override protected void init(Bundle savedInstanceState) {
|
||||
super.init(savedInstanceState);
|
||||
setSupportActionBar(mBar);
|
||||
mBar.setTitle("多线程多任务下载");
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.single_task:
|
||||
startActivity(new Intent(this, SingleTaskActivity.class));
|
||||
break;
|
||||
case R.id.multi_task:
|
||||
startActivity(new Intent(this, MultiTaskActivity.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ 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.databinding.ActivitySingleBinding;
|
||||
import com.arialyy.simple.module.DownloadModule;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
|
||||
import butterknife.Bind;
|
||||
|
||||
public class SimpleTestActivity extends BaseActivity<ActivitySimpleBinding> {
|
||||
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;
|
||||
@ -56,28 +56,28 @@ public class SimpleTestActivity extends BaseActivity<ActivitySimpleBinding> {
|
||||
setBtState(false);
|
||||
break;
|
||||
case DOWNLOAD_FAILE:
|
||||
Toast.makeText(SimpleTestActivity.this, "下载失败", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(SingleTaskActivity.this, "下载失败", Toast.LENGTH_SHORT).show();
|
||||
setBtState(true);
|
||||
break;
|
||||
case DOWNLOAD_STOP:
|
||||
Toast.makeText(SimpleTestActivity.this, "暂停下载", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(SingleTaskActivity.this, "暂停下载", Toast.LENGTH_SHORT).show();
|
||||
mStart.setText("恢复");
|
||||
setBtState(true);
|
||||
break;
|
||||
case DOWNLOAD_CANCEL:
|
||||
mPb.setProgress(0);
|
||||
Toast.makeText(SimpleTestActivity.this, "取消下载", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(SingleTaskActivity.this, "取消下载", Toast.LENGTH_SHORT).show();
|
||||
mStart.setText("开始");
|
||||
setBtState(true);
|
||||
break;
|
||||
case DOWNLOAD_RESUME:
|
||||
Toast.makeText(SimpleTestActivity.this,
|
||||
Toast.makeText(SingleTaskActivity.this,
|
||||
"恢复下载,恢复位置 ==> " + Util.formatFileSize((Long) msg.obj),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
setBtState(false);
|
||||
break;
|
||||
case DOWNLOAD_COMPLETE:
|
||||
Toast.makeText(SimpleTestActivity.this, "下载完成", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(SingleTaskActivity.this, "下载完成", Toast.LENGTH_SHORT).show();
|
||||
mStart.setText("重新开始?");
|
||||
mCancel.setEnabled(false);
|
||||
setBtState(true);
|
||||
@ -157,14 +157,14 @@ public class SimpleTestActivity extends BaseActivity<ActivitySimpleBinding> {
|
||||
}
|
||||
|
||||
@Override protected int setLayoutId() {
|
||||
return R.layout.activity_simple;
|
||||
return R.layout.activity_single;
|
||||
}
|
||||
|
||||
@Override protected void init(Bundle savedInstanceState) {
|
||||
super.init(savedInstanceState);
|
||||
setSupportActionBar(toolbar);
|
||||
toolbar.setTitle("单任务下载");
|
||||
init();
|
||||
|
||||
}
|
||||
|
||||
private void init() {
|
@ -3,7 +3,6 @@ package com.arialyy.simple.module;
|
||||
import android.content.Context;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Environment;
|
||||
|
||||
import com.arialyy.downloadutil.core.DownloadManager;
|
||||
import com.arialyy.downloadutil.entity.DownloadEntity;
|
||||
import com.arialyy.downloadutil.util.Util;
|
||||
@ -11,7 +10,6 @@ import com.arialyy.frame.util.AndroidUtils;
|
||||
import com.arialyy.frame.util.StringUtil;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.base.BaseModule;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -20,65 +18,94 @@ import java.util.List;
|
||||
* Created by Lyy on 2016/9/27.
|
||||
*/
|
||||
public class DownloadModule extends BaseModule {
|
||||
public DownloadModule(Context context) {
|
||||
super(context);
|
||||
}
|
||||
public DownloadModule(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置下载数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<DownloadEntity> getDownloadData() {
|
||||
List<DownloadEntity> list = DownloadEntity.findAllData(DownloadEntity.class);
|
||||
if (list == null) {
|
||||
list = createNewDownload();
|
||||
/**
|
||||
* 设置下载数据
|
||||
*/
|
||||
public List<DownloadEntity> getDownloadData() {
|
||||
List<DownloadEntity> list = DownloadEntity.findAllData(DownloadEntity.class);
|
||||
List<DownloadEntity> newDownload = createNewDownload();
|
||||
if (list == null) {
|
||||
list = newDownload;
|
||||
} else {
|
||||
list = filter(list, newDownload);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤任务
|
||||
*
|
||||
* @param sqlEntity 数据库的下载实体
|
||||
* @param createdEntity 通过下载链接生成的下载实体
|
||||
*/
|
||||
private List<DownloadEntity> filter(List<DownloadEntity> sqlEntity,
|
||||
List<DownloadEntity> createdEntity) {
|
||||
List<DownloadEntity> list = new ArrayList<>();
|
||||
list.addAll(sqlEntity);
|
||||
for (DownloadEntity cEntity : createdEntity) {
|
||||
int count = 0;
|
||||
for (DownloadEntity sEntity : sqlEntity) {
|
||||
if (cEntity.getDownloadUrl().equals(sEntity.getDownloadUrl())) {
|
||||
break;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<DownloadEntity> createNewDownload() {
|
||||
List<DownloadEntity> list = new ArrayList<>();
|
||||
String[] urls = getContext().getResources()
|
||||
.getStringArray(R.array.test_apk_download_url);
|
||||
for (String url : urls) {
|
||||
String fileName = Util.keyToHashCode(url) + ".apk";
|
||||
DownloadEntity entity = new DownloadEntity();
|
||||
entity.setDownloadUrl(url);
|
||||
entity.setDownloadPath(getDownloadPath(url));
|
||||
entity.setFileName(fileName);
|
||||
list.add(entity);
|
||||
count++;
|
||||
if (count == sqlEntity.size()) {
|
||||
list.add(cEntity);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载广播过滤器
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IntentFilter getDownloadFilter() {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addDataScheme(getContext().getPackageName());
|
||||
filter.addAction(DownloadManager.ACTION_PRE);
|
||||
filter.addAction(DownloadManager.ACTION_RESUME);
|
||||
filter.addAction(DownloadManager.ACTION_START);
|
||||
filter.addAction(DownloadManager.ACTION_RUNNING);
|
||||
filter.addAction(DownloadManager.ACTION_STOP);
|
||||
filter.addAction(DownloadManager.ACTION_CANCEL);
|
||||
filter.addAction(DownloadManager.ACTION_COMPLETE);
|
||||
filter.addAction(DownloadManager.ACTION_FAIL);
|
||||
return filter;
|
||||
/**
|
||||
* 创建下载列表
|
||||
*/
|
||||
private List<DownloadEntity> createNewDownload() {
|
||||
List<DownloadEntity> list = new ArrayList<>();
|
||||
String[] urls = getContext().getResources().getStringArray(R.array.test_apk_download_url);
|
||||
for (String url : urls) {
|
||||
String fileName = Util.keyToHashCode(url) + ".apk";
|
||||
DownloadEntity entity = new DownloadEntity();
|
||||
entity.setDownloadUrl(url);
|
||||
entity.setDownloadPath(getDownloadPath(url));
|
||||
entity.setFileName(fileName);
|
||||
list.add(entity);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private String getDownloadPath(String url) {
|
||||
String path = Environment.getExternalStorageDirectory()
|
||||
.getPath() + "/" + AndroidUtils.getAppName(getContext()) + "downloads/" + StringUtil
|
||||
.keyToHashKey(url) + ".apk";
|
||||
File file = new File(path);
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
return path;
|
||||
/**
|
||||
* 下载广播过滤器
|
||||
*/
|
||||
public IntentFilter getDownloadFilter() {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addDataScheme(getContext().getPackageName());
|
||||
filter.addAction(DownloadManager.ACTION_PRE);
|
||||
filter.addAction(DownloadManager.ACTION_RESUME);
|
||||
filter.addAction(DownloadManager.ACTION_START);
|
||||
filter.addAction(DownloadManager.ACTION_RUNNING);
|
||||
filter.addAction(DownloadManager.ACTION_STOP);
|
||||
filter.addAction(DownloadManager.ACTION_CANCEL);
|
||||
filter.addAction(DownloadManager.ACTION_COMPLETE);
|
||||
filter.addAction(DownloadManager.ACTION_FAIL);
|
||||
return filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置下载队列
|
||||
*/
|
||||
private String getDownloadPath(String url) {
|
||||
String path =
|
||||
Environment.getExternalStorageDirectory().getPath() + "/" + AndroidUtils.getAppName(
|
||||
getContext()) + "downloads/" + StringUtil.keyToHashKey(url) + ".apk";
|
||||
File file = new File(path);
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<layout 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_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="onClick"
|
||||
android:text="单任务下载"
|
||||
style="?buttonBarButtonStyle"
|
||||
/>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/multi_task"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="onClick"
|
||||
android:text="多任务下载"
|
||||
style="?buttonBarButtonStyle"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
|
21
app/src/main/res/layout/activity_multi.xml
Normal file
21
app/src/main/res/layout/activity_multi.xml
Normal file
@ -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>
|
@ -2,13 +2,12 @@
|
||||
<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"
|
||||
tools:context="com.arialyy.simple.activity.SingleTaskActivity"
|
||||
>
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
@ -17,17 +16,11 @@
|
||||
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"
|
||||
/>
|
||||
<include layout="@layout/layout_bar"/>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_simple"/>
|
||||
<include layout="@layout/content_single"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
@ -5,8 +5,8 @@
|
||||
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"
|
||||
tools:context="com.arialyy.simple.activity.SingleTaskActivity"
|
||||
tools:showIn="@layout/activity_single"
|
||||
>
|
||||
|
||||
<ProgressBar
|
10
app/src/main/res/layout/layout_bar.xml
Normal file
10
app/src/main/res/layout/layout_bar.xml
Normal file
@ -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"
|
||||
/>
|
@ -9,4 +9,20 @@
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</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>
|
||||
|
@ -6,6 +6,8 @@
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
|
Reference in New Issue
Block a user