Skip to content

Commit 69bf02b

Browse files
committed
修复更新内容过多,界面显示不正常的问题
1 parent ef44d4c commit 69bf02b

File tree

6 files changed

+76
-12
lines changed

6 files changed

+76
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
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.5'
47+
compile 'com.qianwen:update-app:3.2.6'
4848
}
4949
```
5050

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,15 @@ protected UpdateAppBean parseJson(String json) {
251251
.setApkFileUrl(jsonObject.optString("apk_file_url"))
252252
//大小
253253
.setTargetSize(jsonObject.optString("target_size"))
254-
//更新内容
255-
.setUpdateLog(jsonObject.optString("update_log"))
254+
//更新内容 测试更新内容过多
255+
.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,消费任务手动生成。")
256261
//是否强制更新
257-
.setConstraint(true);
262+
.setConstraint(false);
258263
//设置md5
259264
// .setNewMd5(jsonObject.optString("new_md5ddfdfdf"));
260265
} catch (JSONException e) {

update-app/build.gradle

Lines changed: 1 addition & 1 deletion
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.5'//版本号
44+
publishVersion = '3.2.6'//版本号
4545
desc = 'App update tools'
4646
website = 'https://github.com/WVector/AppUpdateDemo'
4747
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ private void installApp() {
206206
if (!TextUtils.isEmpty(mUpdateApp.getNewMd5())
207207
&& appFile.exists()
208208
&& Md5Util.getFileMD5(appFile).equalsIgnoreCase(mUpdateApp.getNewMd5())) {
209-
210-
211209
Uri fileUri = FileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".fileProvider", appFile);
212210
Intent intent = new Intent(Intent.ACTION_VIEW);
213211
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.vector.update_app.view;
2+
3+
import android.app.Activity;
4+
import android.content.Context;
5+
import android.util.AttributeSet;
6+
import android.util.DisplayMetrics;
7+
import android.view.Display;
8+
import android.widget.ScrollView;
9+
10+
/**
11+
* Created by Vector
12+
* on 2017/7/13 0013.
13+
*/
14+
15+
public class AutoScrollView extends ScrollView {
16+
private Context mContext;
17+
18+
public AutoScrollView(Context context) {
19+
super(context);
20+
init(context);
21+
}
22+
23+
public AutoScrollView(Context context, AttributeSet attrs) {
24+
super(context, attrs);
25+
init(context);
26+
27+
}
28+
29+
public AutoScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
30+
super(context, attrs, defStyleAttr);
31+
init(context);
32+
}
33+
34+
private void init(Context context) {
35+
mContext = context;
36+
}
37+
38+
@Override
39+
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
40+
try {
41+
//最大高度显示为屏幕内容高度的一半
42+
Display display = ((Activity) mContext).getWindowManager().getDefaultDisplay();
43+
DisplayMetrics d = new DisplayMetrics();
44+
display.getMetrics(d);
45+
//此处是关键,设置控件高度不能超过屏幕高度一半(在此替换成自己需要的高度)
46+
heightMeasureSpec = MeasureSpec.makeMeasureSpec(d.heightPixels / 3, MeasureSpec.AT_MOST);
47+
48+
} catch (Exception e) {
49+
e.printStackTrace();
50+
}
51+
//重新计算控件高、宽
52+
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
53+
}
54+
}

update-app/src/main/res/layout/lib_update_app_dialog.xml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,22 @@
3434
android:textColor="@android:color/black"
3535
android:textSize="15sp"/>
3636

37-
<TextView
38-
android:id="@+id/tv_update_info"
37+
<com.vector.update_app.view.AutoScrollView
3938
android:layout_width="match_parent"
4039
android:layout_height="wrap_content"
4140
android:paddingBottom="10dp"
4241
android:paddingTop="10dp"
43-
android:text="1,xxxxxxxx\n2,ooooooooo"
44-
android:textColor="#666"
45-
android:textSize="14sp"/>
42+
android:scrollbars="none">
43+
44+
<TextView
45+
android:id="@+id/tv_update_info"
46+
android:layout_width="match_parent"
47+
android:layout_height="wrap_content"
48+
android:text="1,xxxxxxxx\n2,ooooooooo"
49+
android:textColor="#666"
50+
android:textSize="14sp"/>
51+
</com.vector.update_app.view.AutoScrollView>
52+
4653

4754
<Button
4855
android:id="@+id/btn_ok"

0 commit comments

Comments
 (0)