Skip to content

Commit

Permalink
新增点击升级后自动隐藏对话框
Browse files Browse the repository at this point in the history
上传服务器代码
  • Loading branch information
WVector committed Jul 13, 2017
1 parent 69bf02b commit fd86dea
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 8 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

```gradle
dependencies {
compile 'com.qianwen:update-app:3.2.6'
compile 'com.qianwen:update-app:3.2.7'
}
```

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

```

3, 服务器app后台管理界面(下次放出服务器的代码)
3, 服务器app后台管理界面

[点击下载后台代码](https://raw.githubusercontent.com/WVector/AppUpdateDemo/master/web/AppVersionManger.rar)

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

Expand Down
12 changes: 7 additions & 5 deletions app/src/main/java/com/vector/appupdatedemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ public void updateApp4(View view) {
.setUpdateUrl("https://raw.githubusercontent.com/WVector/AppUpdateDemo/master/json/json.txt")
//添加自定义参数
.setParams(params)
//设置点击升级后,消失对话框
.hideDialogOnDownloading(true)
//设置头部
.setTopPic(R.mipmap.top_8)
//设置主题色
Expand Down Expand Up @@ -253,11 +255,11 @@ protected UpdateAppBean parseJson(String json) {
.setTargetSize(jsonObject.optString("target_size"))
//更新内容 测试更新内容过多
.setUpdateLog("1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
"1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
"1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
"1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
"1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
"1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。")
"\n1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
"\n1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
"\n1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
"\n1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。" +
"\n1,添加删除信用卡接口\n2,添加vip认证\n3,区分自定义消费,一个小时不限制。\n4,添加放弃任务接口,小时内不生成。\n5,消费任务手动生成。")
//是否强制更新
.setConstraint(false);
//设置md5
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
android:visibility="gone"
/>

<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion update-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ publish {
userOrg = 'qianwen'//bintray.com用户名
groupId = 'com.qianwen'//jcenter上的路径
artifactId = 'update-app'//项目名称
publishVersion = '3.2.6'//版本号
publishVersion = '3.2.7'//版本号
desc = 'App update tools'
website = 'https://github.com/WVector/AppUpdateDemo'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ private void installApp() {
onBackPressed();
} else {
downloadApp();
if (mUpdateApp.isHideDialog()) {
onBackPressed();
}

}
}

Expand Down
10 changes: 10 additions & 0 deletions update-app/src/main/java/com/vector/update_app/UpdateAppBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ public class UpdateAppBean implements Serializable {
private HttpManager httpManager;
//目标地址,内部使用
private String targetPath;
private boolean mHideDialog;

//是否隐藏对话框下载进度条,内部使用
public boolean isHideDialog() {
return mHideDialog;
}

public void setHideDialog(boolean hideDialog) {
mHideDialog = hideDialog;
}

public boolean isUpdate() {
return !TextUtils.isEmpty(this.update) && "Yes".equals(this.update);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class UpdateAppManager {
private UpdateAppBean mUpdateApp;
private String mTargetPath;
private boolean isPost;
private boolean mHideDialog;
//自定义参数

private UpdateAppManager(Builder builder) {
Expand All @@ -50,6 +51,7 @@ private UpdateAppManager(Builder builder) {
mTargetPath = builder.getTargetPath();
isPost = builder.isPost();
mParams = builder.getParams();
mHideDialog = builder.isHideDialog();
}

/**
Expand All @@ -71,6 +73,7 @@ public void showDialog() {
Intent updateIntent = new Intent(mActivity, DialogActivity.class);
mUpdateApp.setTargetPath(mTargetPath);
mUpdateApp.setHttpManager(mHttpManager);
mUpdateApp.setHideDialog(mHideDialog);
updateIntent.putExtra(INTENT_KEY, mUpdateApp);
if (mThemeColor != 0) {
updateIntent.putExtra(THEME_KEY, mThemeColor);
Expand Down Expand Up @@ -192,6 +195,8 @@ public static class Builder {

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

public Map<String, String> getParams() {
return params;
Expand Down Expand Up @@ -297,6 +302,14 @@ public UpdateAppManager build() {
return new UpdateAppManager(this);
}

public Builder hideDialogOnDownloading(boolean b) {
mHideDialog = b;
return this;
}

public boolean isHideDialog() {
return mHideDialog;
}
}

}
Binary file added web/AppVersionManger.rar
Binary file not shown.

0 comments on commit fd86dea

Please sign in to comment.