parent
9e3f70f59d
commit
1154470759
@ -1,36 +1,41 @@ |
||||
apply plugin: 'com.android.application' |
||||
|
||||
android { |
||||
compileSdkVersion 'Google Inc.:Google APIs:23' |
||||
buildToolsVersion "23.0.2" |
||||
compileSdkVersion 'Google Inc.:Google APIs:23' |
||||
buildToolsVersion "23.0.2" |
||||
|
||||
defaultConfig { |
||||
applicationId "com.example.arial.downloaddemo" |
||||
minSdkVersion 15 |
||||
targetSdkVersion 23 |
||||
versionCode 1 |
||||
versionName "1.0" |
||||
} |
||||
buildTypes { |
||||
release { |
||||
minifyEnabled false |
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
||||
} |
||||
defaultConfig { |
||||
applicationId "com.arialyy.simple" |
||||
minSdkVersion 15 |
||||
targetSdkVersion 23 |
||||
versionCode 1 |
||||
versionName "1.0" |
||||
} |
||||
buildTypes { |
||||
release { |
||||
minifyEnabled false |
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
||||
} |
||||
} |
||||
|
||||
dataBinding { |
||||
enabled = true |
||||
} |
||||
dataBinding { |
||||
enabled = true |
||||
} |
||||
|
||||
packagingOptions { |
||||
exclude 'META-INF/services/javax.annotation.processing.Processor' |
||||
} |
||||
} |
||||
|
||||
dependencies { |
||||
compile fileTree(include: ['*.jar'], dir: 'libs') |
||||
testCompile 'junit:junit:4.12' |
||||
compile 'com.android.support:appcompat-v7:23.+' |
||||
compile 'com.android.support:design:23.+' |
||||
compile 'com.jakewharton:butterknife:7.0.1' |
||||
compile 'com.google.code.gson:gson:2.7' |
||||
compile 'com.squareup.okhttp3:okhttp:3.2.0' |
||||
compile 'com.arialyy.frame:MVVM2:2.2.0' |
||||
compile project(':downloadutil') |
||||
compile fileTree(include: ['*.jar'], dir: 'libs') |
||||
testCompile 'junit:junit:4.12' |
||||
compile 'com.android.support:appcompat-v7:23.+' |
||||
compile 'com.android.support:design:23.+' |
||||
compile 'com.jakewharton:butterknife:7.0.1' |
||||
compile 'com.google.code.gson:gson:2.7' |
||||
compile 'com.squareup.okhttp3:okhttp:3.2.0' |
||||
compile 'com.arialyy.frame:MVVM2:2.2.0' |
||||
compile 'com.arialyy.absadapter:AbsAdapter:1.1.2' |
||||
compile project(':downloadutil') |
||||
} |
||||
|
@ -1,25 +1,28 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||
package="com.example.arial.downloaddemo" > |
||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> |
||||
<uses-permission android:name="android.permission.INTERNET" /> |
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> |
||||
<application |
||||
android:allowBackup="true" |
||||
android:icon="@mipmap/ic_launcher" |
||||
package="com.arialyy.simple"> |
||||
|
||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> |
||||
<uses-permission android:name="android.permission.INTERNET"/> |
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> |
||||
|
||||
<application |
||||
android:name=".base.BaseApplication" |
||||
android:allowBackup="true" |
||||
android:icon="@mipmap/ic_launcher" |
||||
android:label="@string/app_name" |
||||
android:supportsRtl="true" |
||||
android:theme="@style/AppTheme"> |
||||
<activity |
||||
android:name=".activity.SimpleTestActivity" |
||||
android:label="@string/app_name" |
||||
android:supportsRtl="true" |
||||
android:theme="@style/AppTheme" > |
||||
<activity |
||||
android:name=".MainActivity" |
||||
android:label="@string/app_name" |
||||
android:theme="@style/AppTheme.NoActionBar" > |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.MAIN" /> |
||||
android:theme="@style/AppTheme.NoActionBar"> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.MAIN"/> |
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" /> |
||||
</intent-filter> |
||||
</activity> |
||||
</application> |
||||
<category android:name="android.intent.category.LAUNCHER"/> |
||||
</intent-filter> |
||||
</activity> |
||||
</application> |
||||
|
||||
</manifest> |
||||
|
@ -0,0 +1,22 @@ |
||||
package com.arialyy.simple.activity; |
||||
|
||||
import android.support.v7.widget.RecyclerView; |
||||
import butterknife.Bind; |
||||
import com.arialyy.simple.R; |
||||
import com.arialyy.simple.base.BaseActivity; |
||||
import com.arialyy.simple.databinding.ActivityMainBinding; |
||||
|
||||
/** |
||||
* Created by Lyy on 2016/9/27. |
||||
*/ |
||||
public class MainActivity extends BaseActivity<ActivityMainBinding> { |
||||
@Bind(R.id.list) |
||||
RecyclerView mList; |
||||
|
||||
@Override protected int setLayoutId() { |
||||
return R.layout.activity_main; |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,72 @@ |
||||
package com.arialyy.simple.adapter; |
||||
|
||||
import android.content.Context; |
||||
import android.util.SparseArray; |
||||
import android.view.View; |
||||
import android.widget.Button; |
||||
import butterknife.Bind; |
||||
import com.arialyy.absadapter.common.AbsHolder; |
||||
import com.arialyy.absadapter.recycler_view.AbsRVAdapter; |
||||
import com.arialyy.downloadutil.entity.DownloadEntity; |
||||
import com.arialyy.simple.R; |
||||
import com.arialyy.simple.widget.HorizontalProgressBarWithNumber; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Created by Lyy on 2016/9/27. |
||||
* 下载列表适配器 |
||||
*/ |
||||
public class DownloadAdapter extends AbsRVAdapter<DownloadEntity, DownloadAdapter.MyHolder> { |
||||
private static final String TAG = "DownloadAdapter"; |
||||
private Map<String, Long> mProgress = new HashMap<>(); |
||||
private SparseArray<String> mPositions = new SparseArray<>(); |
||||
|
||||
public DownloadAdapter(Context context, List<DownloadEntity> data) { |
||||
super(context, data); |
||||
int i = 0; |
||||
for (DownloadEntity entity : data) { |
||||
mProgress.put(entity.getDownloadUrl(), entity.getCurrentProgress()); |
||||
mPositions.append(i, entity.getDownloadUrl()); |
||||
i++; |
||||
} |
||||
} |
||||
|
||||
@Override protected MyHolder getViewHolder(View convertView, int viewType) { |
||||
return new MyHolder(convertView); |
||||
} |
||||
|
||||
@Override protected int setLayoutId(int type) { |
||||
return R.layout.item_download; |
||||
} |
||||
|
||||
public synchronized void setProgress(String url, long currentPosition) { |
||||
mProgress.put(url, currentPosition); |
||||
notifyItemChanged(indexItem(url)); |
||||
} |
||||
|
||||
private int indexItem(String url) { |
||||
return mPositions.indexOfValue(url); |
||||
} |
||||
|
||||
@Override protected void bindData(MyHolder holder, int position, DownloadEntity item) { |
||||
//holder.progress.setProgress(item.getCurrentProgress());
|
||||
long size = item.getFileSize(); |
||||
int current = 0; |
||||
if (size == 0){ |
||||
current = 0; |
||||
} |
||||
current = (int) (mProgress.get(item.getDownloadUrl()) * 100 / item.getFileSize()); |
||||
holder.progress.setProgress(current); |
||||
} |
||||
|
||||
class MyHolder extends AbsHolder { |
||||
@Bind(R.id.progressBar) HorizontalProgressBarWithNumber progress; |
||||
@Bind(R.id.bt) Button bt; |
||||
|
||||
public MyHolder(View itemView) { |
||||
super(itemView); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,18 @@ |
||||
package com.arialyy.simple.base; |
||||
|
||||
import android.databinding.ViewDataBinding; |
||||
import android.os.Bundle; |
||||
import com.arialyy.frame.core.AbsActivity; |
||||
|
||||
/** |
||||
* Created by Lyy on 2016/9/27. |
||||
*/ |
||||
public abstract class BaseActivity<VB extends ViewDataBinding> extends AbsActivity<VB> { |
||||
@Override protected void dataCallback(int result, Object data) { |
||||
|
||||
} |
||||
|
||||
@Override protected void init(Bundle savedInstanceState) { |
||||
super.init(savedInstanceState); |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
package com.arialyy.simple.base; |
||||
|
||||
import android.app.Application; |
||||
import com.arialyy.frame.core.AbsFrame; |
||||
|
||||
/** |
||||
* Created by Lyy on 2016/9/27. |
||||
*/ |
||||
public class BaseApplication extends Application { |
||||
@Override public void onCreate() { |
||||
super.onCreate(); |
||||
AbsFrame.init(this); |
||||
} |
||||
} |
@ -0,0 +1,13 @@ |
||||
package com.arialyy.simple.base; |
||||
|
||||
import android.content.Context; |
||||
import com.arialyy.frame.module.AbsModule; |
||||
|
||||
/** |
||||
* Created by Lyy on 2016/9/27. |
||||
*/ |
||||
public class BaseModule extends AbsModule{ |
||||
public BaseModule(Context context) { |
||||
super(context); |
||||
} |
||||
} |
@ -0,0 +1,21 @@ |
||||
//package com.arialyy.simple.module;
|
||||
//
|
||||
//import android.content.Context;
|
||||
//import com.arialyy.downloadutil.entity.DownloadEntity;
|
||||
//import com.arialyy.simple.base.BaseModule;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * Created by Lyy on 2016/9/27.
|
||||
// */
|
||||
//public class DownloadModule extends BaseModule{
|
||||
// public DownloadModule(Context context) {
|
||||
// super(context);
|
||||
// }
|
||||
//
|
||||
// public List<DownloadEntity> getDownloadData(){
|
||||
// List<DownloadEntity> list = new ArrayList<>();
|
||||
// DownloadEntity entity
|
||||
// }
|
||||
//}
|
@ -0,0 +1,180 @@ |
||||
package com.arialyy.simple.widget; |
||||
|
||||
import android.content.Context; |
||||
import android.content.res.TypedArray; |
||||
import android.graphics.Canvas; |
||||
import android.graphics.Paint; |
||||
import android.util.AttributeSet; |
||||
import android.util.TypedValue; |
||||
import android.widget.ProgressBar; |
||||
import com.arialyy.simple.R; |
||||
|
||||
public class HorizontalProgressBarWithNumber extends ProgressBar { |
||||
private static final int DEFAULT_TEXT_SIZE = 10; |
||||
private static final int DEFAULT_TEXT_COLOR = 0XFFFC00D1; |
||||
private static final int DEFAULT_COLOR_UNREACHED_COLOR = 0xFFd3d6da; |
||||
private static final int DEFAULT_HEIGHT_REACHED_PROGRESS_BAR = 2; |
||||
private static final int DEFAULT_HEIGHT_UNREACHED_PROGRESS_BAR = 2; |
||||
private static final int DEFAULT_SIZE_TEXT_OFFSET = 10; |
||||
/** |
||||
* painter of all drawing things |
||||
*/ |
||||
protected Paint mPaint = new Paint(); |
||||
/** |
||||
* color of progress number |
||||
*/ |
||||
protected int mTextColor = DEFAULT_TEXT_COLOR; |
||||
/** |
||||
* size of text (sp) |
||||
*/ |
||||
protected int mTextSize = sp2px(DEFAULT_TEXT_SIZE); |
||||
/** |
||||
* offset of draw progress |
||||
*/ |
||||
protected int mTextOffset = dp2px(DEFAULT_SIZE_TEXT_OFFSET); |
||||
/** |
||||
* height of reached progress bar |
||||
*/ |
||||
protected int mReachedProgressBarHeight = dp2px(DEFAULT_HEIGHT_REACHED_PROGRESS_BAR); |
||||
/** |
||||
* color of reached bar |
||||
*/ |
||||
protected int mReachedBarColor = DEFAULT_TEXT_COLOR; |
||||
/** |
||||
* color of unreached bar |
||||
*/ |
||||
protected int mUnReachedBarColor = DEFAULT_COLOR_UNREACHED_COLOR; |
||||
/** |
||||
* height of unreached progress bar |
||||
*/ |
||||
protected int mUnReachedProgressBarHeight = dp2px(DEFAULT_HEIGHT_UNREACHED_PROGRESS_BAR); |
||||
/** |
||||
* view width except padding |
||||
*/ |
||||
protected int mRealWidth; |
||||
protected boolean mIfDrawText = true; |
||||
protected static final int VISIBLE = 0; |
||||
|
||||
public HorizontalProgressBarWithNumber(Context context, AttributeSet attrs) { |
||||
this(context, attrs, 0); |
||||
} |
||||
|
||||
public HorizontalProgressBarWithNumber(Context context, AttributeSet attrs, int defStyle) { |
||||
super(context, attrs, defStyle); |
||||
obtainStyledAttributes(attrs); |
||||
mPaint.setTextSize(mTextSize); |
||||
mPaint.setColor(mTextColor); |
||||
} |
||||
|
||||
@Override protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
||||
int width = MeasureSpec.getSize(widthMeasureSpec); |
||||
int height = measureHeight(heightMeasureSpec); |
||||
setMeasuredDimension(width, height); |
||||
mRealWidth = getMeasuredWidth() - getPaddingRight() - getPaddingLeft(); |
||||
} |
||||
|
||||
private int measureHeight(int measureSpec) { |
||||
int result = 0; |
||||
int specMode = MeasureSpec.getMode(measureSpec); |
||||
int specSize = MeasureSpec.getSize(measureSpec); |
||||
if (specMode == MeasureSpec.EXACTLY) { |
||||
result = specSize; |
||||
} else { |
||||
float textHeight = (mPaint.descent() - mPaint.ascent()); |
||||
result = (int) (getPaddingTop() + getPaddingBottom() + Math.max( |
||||
Math.max(mReachedProgressBarHeight, mUnReachedProgressBarHeight), Math.abs(textHeight))); |
||||
if (specMode == MeasureSpec.AT_MOST) { |
||||
result = Math.min(result, specSize); |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* get the styled attributes |
||||
*/ |
||||
private void obtainStyledAttributes(AttributeSet attrs) { |
||||
// init values from custom attributes
|
||||
final TypedArray attributes = |
||||
getContext().obtainStyledAttributes(attrs, R.styleable.HorizontalProgressBarWithNumber); |
||||
mTextColor = |
||||
attributes.getColor(R.styleable.HorizontalProgressBarWithNumber_progress_text_color, |
||||
DEFAULT_TEXT_COLOR); |
||||
mTextSize = (int) attributes.getDimension( |
||||
R.styleable.HorizontalProgressBarWithNumber_progress_text_size, mTextSize); |
||||
mReachedBarColor = |
||||
attributes.getColor(R.styleable.HorizontalProgressBarWithNumber_progress_reached_color, |
||||
mTextColor); |
||||
mUnReachedBarColor = |
||||
attributes.getColor(R.styleable.HorizontalProgressBarWithNumber_progress_unreached_color, |
||||
DEFAULT_COLOR_UNREACHED_COLOR); |
||||
mReachedProgressBarHeight = (int) attributes.getDimension( |
||||
R.styleable.HorizontalProgressBarWithNumber_progress_reached_bar_height, |
||||
mReachedProgressBarHeight); |
||||
mUnReachedProgressBarHeight = (int) attributes.getDimension( |
||||
R.styleable.HorizontalProgressBarWithNumber_progress_unreached_bar_height, |
||||
mUnReachedProgressBarHeight); |
||||
mTextOffset = (int) attributes.getDimension( |
||||
R.styleable.HorizontalProgressBarWithNumber_progress_text_offset, mTextOffset); |
||||
int textVisible = |
||||
attributes.getInt(R.styleable.HorizontalProgressBarWithNumber_progress_text_visibility, |
||||
VISIBLE); |
||||
if (textVisible != VISIBLE) { |
||||
mIfDrawText = false; |
||||
} |
||||
attributes.recycle(); |
||||
} |
||||
|
||||
@Override protected synchronized void onDraw(Canvas canvas) { |
||||
canvas.save(); |
||||
canvas.translate(getPaddingLeft(), getHeight() / 2); |
||||
boolean noNeedBg = false; |
||||
float radio = getProgress() * 1.0f / getMax(); |
||||
float progressPosX = (int) (mRealWidth * radio); |
||||
String text = getProgress() + "%"; |
||||
// mPaint.getTextBounds(text, 0, text.length(), mTextBound);
|
||||
float textWidth = mPaint.measureText(text); |
||||
float textHeight = (mPaint.descent() + mPaint.ascent()) / 2; |
||||
if (progressPosX + textWidth > mRealWidth) { |
||||
progressPosX = mRealWidth - textWidth; |
||||
noNeedBg = true; |
||||
} |
||||
// draw reached bar
|
||||
float endX = progressPosX - mTextOffset / 2; |
||||
if (endX > 0) { |
||||
mPaint.setColor(mReachedBarColor); |
||||
mPaint.setStrokeWidth(mReachedProgressBarHeight); |
||||
canvas.drawLine(0, 0, endX, 0, mPaint); |
||||
} |
||||
// draw progress bar
|
||||
// measure text bound
|
||||
if (mIfDrawText) { |
||||
mPaint.setColor(mTextColor); |
||||
canvas.drawText(text, progressPosX, -textHeight, mPaint); |
||||
} |
||||
// draw unreached bar
|
||||
if (!noNeedBg) { |
||||
float start = progressPosX + mTextOffset / 2 + textWidth; |
||||
mPaint.setColor(mUnReachedBarColor); |
||||
mPaint.setStrokeWidth(mUnReachedProgressBarHeight); |
||||
canvas.drawLine(start, 0, mRealWidth, 0, mPaint); |
||||
} |
||||
canvas.restore(); |
||||
} |
||||
|
||||
/** |
||||
* dp 2 px |
||||
*/ |
||||
protected int dp2px(int dpVal) { |
||||
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpVal, |
||||
getResources().getDisplayMetrics()); |
||||
} |
||||
|
||||
/** |
||||
* sp 2 px |
||||
*/ |
||||
protected int sp2px(int spVal) { |
||||
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, spVal, |
||||
getResources().getDisplayMetrics()); |
||||
} |
||||
} |
@ -1,35 +1,17 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<android.support.design.widget.CoordinatorLayout |
||||
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" |
||||
android:fitsSystemWindows="true" |
||||
tools:context="com.example.arial.downloaddemo.MainActivity"> |
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
|
||||
<android.support.design.widget.AppBarLayout |
||||
android:layout_height="wrap_content" |
||||
android:layout_width="match_parent" |
||||
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> |
||||
<LinearLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:orientation="vertical" |
||||
> |
||||
|
||||
<include layout="@layout/content_main"/> |
||||
|
||||
<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.v7.widget.RecyclerView |
||||
android:id="@+id/list" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
/> |
||||
|
||||
</android.support.design.widget.CoordinatorLayout> |
||||
</LinearLayout> |
||||
</layout> |
||||
|
@ -0,0 +1,42 @@ |
||||
<?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> |
@ -1,65 +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.example.arial.downloaddemo.MainActivity" |
||||
tools:showIn="@layout/activity_main"> |
||||
|
||||
<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_below="@+id/progressBar" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="horizontal"> |
||||
|
||||
<Button |
||||
android:text="开始" |
||||
android:id="@+id/start" |
||||
style="?buttonBarButtonStyle" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:onClick="onClick" /> |
||||
|
||||
<Button |
||||
android:onClick="onClick" |
||||
android:text="暂停" |
||||
android:id="@+id/stop" |
||||
style="?buttonBarButtonStyle" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" /> |
||||
|
||||
<Button |
||||
android:onClick="onClick" |
||||
android:text="取消" |
||||
android:id="@+id/cancel" |
||||
style="?buttonBarButtonStyle" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" /> |
||||
</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.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_below="@+id/progressBar" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="horizontal" |
||||
> |
||||
|
||||
<Button |
||||
android:text="开始" |
||||
android:id="@+id/start" |
||||
style="?buttonBarButtonStyle" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:onClick="onClick" |
||||
/> |
||||
|
||||
<Button |
||||
android:onClick="onClick" |
||||
android:text="暂停" |
||||
android:id="@+id/stop" |
||||
style="?buttonBarButtonStyle" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
/> |
||||
|
||||
<Button |
||||
android:onClick="onClick" |
||||
android:text="取消" |
||||
android:id="@+id/cancel" |
||||
style="?buttonBarButtonStyle" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
/> |
||||
</LinearLayout> |
||||
</RelativeLayout> |
@ -0,0 +1,27 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:padding="16dp" |
||||
> |
||||
|
||||
<com.arialyy.simple.widget.HorizontalProgressBarWithNumber |
||||
android:id="@+id/progressBar" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_centerVertical="true" |
||||
android:layout_marginRight="16dp" |
||||
android:layout_toLeftOf="@+id/bt" |
||||
android:max="100" |
||||
/> |
||||
|
||||
<Button |
||||
android:id="@+id/bt" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_alignParentRight="true" |
||||
android:text="开始" |
||||
style="?buttonBarButtonStyle" |
||||
/> |
||||
|
||||
</RelativeLayout> |
@ -1,9 +1,10 @@ |
||||
<menu 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" |
||||
tools:context="com.example.arial.downloaddemo.MainActivity" > |
||||
<item android:id="@+id/action_settings" |
||||
android:title="@string/action_settings" |
||||
android:orderInCategory="100" |
||||
app:showAsAction="never" /> |
||||
tools:context="com.example.arial.downloaddemo.com.arialyy.simple.MainActivity"> |
||||
<item |
||||
android:id="@+id/action_settings" |
||||
android:title="@string/action_settings" |
||||
android:orderInCategory="100" |
||||
app:showAsAction="never"/> |
||||
</menu> |
||||
|
@ -1,8 +1,9 @@ |
||||
<resources> |
||||
<style name="AppTheme.NoActionBar"> |
||||
<item name="windowActionBar">false</item> |
||||
<item name="windowNoTitle">true</item> |
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item> |
||||
<item name="android:statusBarColor">@android:color/transparent</item> |
||||
</style> |
||||
|
||||
<style name="AppTheme.NoActionBar"> |
||||
<item name="windowActionBar">false</item> |
||||
<item name="windowNoTitle">true</item> |
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item> |
||||
<item name="android:statusBarColor">@android:color/transparent</item> |
||||
</style> |
||||
</resources> |
||||
|
@ -1,6 +1,6 @@ |
||||
<resources> |
||||
<!-- 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 |
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> |
||||
<dimen name="activity_horizontal_margin">64dp</dimen> |
||||
<!-- 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 |
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> |
||||
<dimen name="activity_horizontal_margin">64dp</dimen> |
||||
</resources> |
||||
|
@ -0,0 +1,16 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<declare-styleable name="HorizontalProgressBarWithNumber"> |
||||
<attr name="progress_unreached_color" format="color" /> |
||||
<attr name="progress_reached_color" format="color" /> |
||||
<attr name="progress_reached_bar_height" format="dimension" /> |
||||
<attr name="progress_unreached_bar_height" format="dimension" /> |
||||
<attr name="progress_text_size" format="dimension" /> |
||||
<attr name="progress_text_color" format="color" /> |
||||
<attr name="progress_text_offset" format="dimension" /> |
||||
<attr name="progress_text_visibility" format="enum"> |
||||
<enum name="visible" value="0" /> |
||||
<enum name="invisible" value="1" /> |
||||
</attr> |
||||
</declare-styleable> |
||||
</resources> |
@ -1,6 +1,6 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<color name="colorPrimary">#3F51B5</color> |
||||
<color name="colorPrimaryDark">#303F9F</color> |
||||
<color name="colorAccent">#FF4081</color> |
||||
<color name="colorPrimary">#3F51B5</color> |
||||
<color name="colorPrimaryDark">#303F9F</color> |
||||
<color name="colorAccent">#FF4081</color> |
||||
</resources> |
||||
|
@ -1,6 +1,6 @@ |
||||
<resources> |
||||
<!-- Default screen margins, per the Android Design guidelines. --> |
||||
<dimen name="activity_horizontal_margin">16dp</dimen> |
||||
<dimen name="activity_vertical_margin">16dp</dimen> |
||||
<dimen name="fab_margin">16dp</dimen> |
||||
<!-- Default screen margins, per the Android Design guidelines. --> |
||||
<dimen name="activity_horizontal_margin">16dp</dimen> |
||||
<dimen name="activity_vertical_margin">16dp</dimen> |
||||
<dimen name="fab_margin">16dp</dimen> |
||||
</resources> |
||||
|
@ -1,4 +1,4 @@ |
||||
<resources> |
||||
<string name="app_name">DownloadDemo</string> |
||||
<string name="action_settings">Settings</string> |
||||
<string name="app_name">DownloadDemo</string> |
||||
<string name="action_settings">Settings</string> |
||||
</resources> |
||||
|
@ -1,17 +1,20 @@ |
||||
<resources> |
||||
|
||||
<!-- Base application theme. --> |
||||
<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> |
||||
</style> |
||||
<style name="AppTheme.NoActionBar"> |
||||
<item name="windowActionBar">false</item> |
||||
<item name="windowNoTitle">true</item> |
||||
</style> |
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> |
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> |
||||
<!-- Base application theme. --> |
||||
<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> |
||||
</style> |
||||
|
||||
<style name="AppTheme.NoActionBar"> |
||||
<item name="windowActionBar">false</item> |
||||
<item name="windowNoTitle">true</item> |
||||
</style> |
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/> |
||||
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/> |
||||
|
||||
</resources> |
||||
|
Loading…
Reference in new issue