Skip to content

Commit fd86dea

Browse files
committed
新增点击升级后自动隐藏对话框
上传服务器代码
1 parent 69bf02b commit fd86dea

File tree

8 files changed

+47
-8
lines changed

8 files changed

+47
-8
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
```gradle
4646
dependencies {
47-
compile 'com.qianwen:update-app:3.2.6'
47+
compile 'com.qianwen:update-app:3.2.7'
4848
}
4949
```
5050

@@ -77,6 +77,8 @@ dependencies {
7777
.setUpdateUrl("https://raw.githubusercontent.com/WVector/AppUpdateDemo/master/json/json.txt")
7878
//添加自定义参数
7979
.setParams(params)
80+
//设置点击升级后,消失对话框
81+
.hideDialogOnDownloading(true)
8082
//设置头部
8183
.setTopPic(R.mipmap.top_5)
8284
//设置主题色
@@ -177,7 +179,9 @@ dependencies {
177179

178180
```
179181

180-
3, 服务器app后台管理界面(下次放出服务器的代码)
182+
3, 服务器app后台管理界面
183+
184+
[点击下载后台代码](https://raw.githubusercontent.com/WVector/AppUpdateDemo/master/web/AppVersionManger.rar)
181185

182186
<img src="https://raw.githubusercontent.com/WVector/AppUpdateDemo/master/image/example_04.png?raw=true" width="1000">
183187

app/src/main/java/com/vector/appupdatedemo/MainActivity.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ public void updateApp4(View view) {
224224
.setUpdateUrl("https://raw.githubusercontent.com/WVector/AppUpdateDemo/master/json/json.txt")
225225
//添加自定义参数
226226
.setParams(params)
227+
//设置点击升级后,消失对话框
228+
.hideDialogOnDownloading(true)
227229
//设置头部
228230
.setTopPic(R.mipmap.top_8)
229231
//设置主题色
@@ -253,11 +255,11 @@ protected UpdateAppBean parseJson(String json) {
253255
.setTargetSize(jsonObject.optString("target_size"))
254256
//更新内容 测试更新内容过多
255257
.setUpdateLog("1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
256-
"1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
257-
"1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
258-
"1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
259-
"1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
260-
"1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。")
258+
"\n1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
259+
"\n1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
260+
"\n1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
261+
"\n1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
262+
"\n1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。")
261263
//是否强制更新
262264
.setConstraint(false);
263265
//设置md5

app/src/main/res/layout/activity_main.xml

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
android:visibility="gone"
6464
/>
6565

66+
<ProgressBar
67+
android:layout_width="wrap_content"
68+
android:layout_height="wrap_content"
69+
android:layout_gravity="center"
70+
android:visibility="gone"/>
71+
6672
<LinearLayout
6773
android:layout_width="match_parent"
6874
android:layout_height="match_parent"

update-app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ publish {
4141
userOrg = 'qianwen'//bintray.com用户名
4242
groupId = 'com.qianwen'//jcenter上的路径
4343
artifactId = 'update-app'//项目名称
44-
publishVersion = '3.2.6'//版本号
44+
publishVersion = '3.2.7'//版本号
4545
desc = 'App update tools'
4646
website = 'https://github.com/WVector/AppUpdateDemo'
4747
}

update-app/src/main/java/com/vector/update_app/DialogActivity.java

+4
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ private void installApp() {
222222
onBackPressed();
223223
} else {
224224
downloadApp();
225+
if (mUpdateApp.isHideDialog()) {
226+
onBackPressed();
227+
}
228+
225229
}
226230
}
227231

update-app/src/main/java/com/vector/update_app/UpdateAppBean.java

+10
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ public class UpdateAppBean implements Serializable {
4343
private HttpManager httpManager;
4444
//目标地址,内部使用
4545
private String targetPath;
46+
private boolean mHideDialog;
47+
48+
//是否隐藏对话框下载进度条,内部使用
49+
public boolean isHideDialog() {
50+
return mHideDialog;
51+
}
52+
53+
public void setHideDialog(boolean hideDialog) {
54+
mHideDialog = hideDialog;
55+
}
4656

4757
public boolean isUpdate() {
4858
return !TextUtils.isEmpty(this.update) && "Yes".equals(this.update);

update-app/src/main/java/com/vector/update_app/UpdateAppManager.java

+13
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class UpdateAppManager {
3636
private UpdateAppBean mUpdateApp;
3737
private String mTargetPath;
3838
private boolean isPost;
39+
private boolean mHideDialog;
3940
//自定义参数
4041

4142
private UpdateAppManager(Builder builder) {
@@ -50,6 +51,7 @@ private UpdateAppManager(Builder builder) {
5051
mTargetPath = builder.getTargetPath();
5152
isPost = builder.isPost();
5253
mParams = builder.getParams();
54+
mHideDialog = builder.isHideDialog();
5355
}
5456

5557
/**
@@ -71,6 +73,7 @@ public void showDialog() {
7173
Intent updateIntent = new Intent(mActivity, DialogActivity.class);
7274
mUpdateApp.setTargetPath(mTargetPath);
7375
mUpdateApp.setHttpManager(mHttpManager);
76+
mUpdateApp.setHideDialog(mHideDialog);
7477
updateIntent.putExtra(INTENT_KEY, mUpdateApp);
7578
if (mThemeColor != 0) {
7679
updateIntent.putExtra(THEME_KEY, mThemeColor);
@@ -192,6 +195,8 @@ public static class Builder {
192195

193196
//自定义参数
194197
private Map<String, String> params;
198+
//是否隐藏对话框下载进度条
199+
private boolean mHideDialog;
195200

196201
public Map<String, String> getParams() {
197202
return params;
@@ -297,6 +302,14 @@ public UpdateAppManager build() {
297302
return new UpdateAppManager(this);
298303
}
299304

305+
public Builder hideDialogOnDownloading(boolean b) {
306+
mHideDialog = b;
307+
return this;
308+
}
309+
310+
public boolean isHideDialog() {
311+
return mHideDialog;
312+
}
300313
}
301314

302315
}

web/AppVersionManger.rar

12.9 MB
Binary file not shown.

0 commit comments

Comments
 (0)