Skip to content

Commit 36e538e

Browse files
author
吕发强
committed
调整下载显示进度样式
1 parent 8c90033 commit 36e538e

File tree

7 files changed

+43
-28
lines changed

7 files changed

+43
-28
lines changed

library/src/main/java/com/lvfq/library/utils/LvAppManager.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public void addActivity(Activity activity) {
5252
* 获取当前Activity(堆栈中最后一个压入的)
5353
*/
5454
public Activity currentActivity() {
55+
if (activityStack == null) {
56+
return null;
57+
}
5558
Activity activity = activityStack.lastElement();
5659
return activity;
5760
}
@@ -60,6 +63,9 @@ public Activity currentActivity() {
6063
* 结束当前Activity(堆栈中最后一个压入的)
6164
*/
6265
public void finishActivity() {
66+
if (activityStack == null) {
67+
return;
68+
}
6369
Activity activity = activityStack.lastElement();
6470
finishActivity(activity);
6571
}
@@ -68,7 +74,7 @@ public void finishActivity() {
6874
* 结束指定的Activity
6975
*/
7076
public void finishActivity(Activity activity) {
71-
if (activity != null) {
77+
if (activity != null && activityStack != null) {
7278
activityStack.remove(activity);
7379
activity.finish();
7480
}
@@ -78,6 +84,9 @@ public void finishActivity(Activity activity) {
7884
* 结束指定类名的Activity
7985
*/
8086
public void finishActivity(Class<?> cls) {
87+
if (activityStack == null) {
88+
return;
89+
}
8190
for (Activity activity : activityStack) {
8291
if (activity.getClass().equals(cls)) {
8392
finishActivity(activity);
@@ -89,6 +98,9 @@ public void finishActivity(Class<?> cls) {
8998
* 结束所有Activity
9099
*/
91100
public void finishAllActivity() {
101+
if (activityStack == null) {
102+
return;
103+
}
92104
for (int i = 0, size = activityStack.size(); i < size; i++) {
93105
if (null != activityStack.get(i)) {
94106
activityStack.get(i).finish();
@@ -102,12 +114,15 @@ public void finishAllActivity() {
102114
*/
103115
public void AppExit() {
104116
try {
105-
finishAllActivity();
106-
// ActivityManager activityMgr = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
107-
// activityMgr.restartPackage(context.getPackageName());
117+
if (activityStack != null) {
118+
finishAllActivity();
119+
}
120+
// ActivityManager activityMgr = (ActivityManager) LvUtils.getContext().getSystemService(Context.ACTIVITY_SERVICE);
121+
// activityMgr.restartPackage( LvUtils.getContext().getPackageName());
108122
android.os.Process.killProcess(android.os.Process.myPid());
109123
System.exit(0);
110124
} catch (Exception e) {
125+
e.printStackTrace();
111126
}
112127
}
113128
}

library/src/main/java/com/lvfq/library/utils/LvDownloadDialog.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public class LvDownloadDialog extends AlertDialog implements View.OnClickListene
6161

6262
private boolean isMustUpdate = false; // 是否强制更新
6363
private boolean cancelUpdate = false; // 是否取消下载
64-
private boolean isDownloading = false; // 是否正在下载
6564

6665

6766
private Context context;
@@ -122,7 +121,7 @@ public void setMustUpdate(boolean mustUpdate) {
122121
* 初始化
123122
*
124123
* @param context
125-
* @param downlaodUrl 下载地址
124+
* @param downlaodUrl 下载地址
126125
* @param apkName 安装包名称
127126
* @param isMustUpdate 是否强制更新
128127
* @param scale 宽度比
@@ -149,7 +148,7 @@ public LvDownloadDialog(Context context, String downlaodUrl, String apkName, boo
149148
/**
150149
* @param context
151150
* @param downlaodUrl 下载路径
152-
* @param apkName 安装包名称
151+
* @param apkName 安装包名称
153152
*/
154153
public LvDownloadDialog(Context context, String downlaodUrl, String apkName) {
155154
this(context, downlaodUrl, apkName, false, 0);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<corners android:radius="@dimen/dp_10" />
4+
<solid android:color="@color/color_dd" />
5+
</shape>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<corners android:radius="10dp" />
4+
<solid android:color="#ff0000" />
5+
</shape>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<item android:id="@android:id/progress">
5+
<scale
6+
android:drawable="@drawable/shape_lv_download_progress"
7+
android:scaleWidth="100%" />
8+
</item>
9+
10+
</layer-list>

library/src/main/res/drawable/shape_progress_bg_style.xml

Lines changed: 0 additions & 20 deletions
This file was deleted.

library/src/main/res/layout/dialog_download.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@
3838
style="?android:attr/progressBarStyleHorizontal"
3939
android:layout_width="match_parent"
4040
android:layout_height="@dimen/dp_10"
41+
android:background="@drawable/shape_lv_download_background"
4142
android:max="100"
4243
android:progress="0"
43-
android:progressDrawable="@drawable/shape_progress_bg_style"
44+
android:progressDrawable="@drawable/shape_lv_progress_bg_style"
4445
android:visibility="gone" />
4546
</FrameLayout>
4647

0 commit comments

Comments
 (0)