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 ef44d4c commit 69bf02b
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 12 deletions.
2 changes: 1 addition & 1 deletion 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.5'
compile 'com.qianwen:update-app:3.2.6'
}
```

Expand Down
11 changes: 8 additions & 3 deletions app/src/main/java/com/vector/appupdatedemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,15 @@ protected UpdateAppBean parseJson(String json) {
.setApkFileUrl(jsonObject.optString("apk_file_url"))
//大小
.setTargetSize(jsonObject.optString("target_size"))
//更新内容
.setUpdateLog(jsonObject.optString("update_log"))
//更新内容 测试更新内容过多
.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,消费任务手动生成。")
//是否强制更新
.setConstraint(true);
.setConstraint(false);
//设置md5
// .setNewMd5(jsonObject.optString("new_md5ddfdfdf"));
} catch (JSONException e) {
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.5'//版本号
publishVersion = '3.2.6'//版本号
desc = 'App update tools'
website = 'https://github.com/WVector/AppUpdateDemo'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ private void installApp() {
if (!TextUtils.isEmpty(mUpdateApp.getNewMd5())
&& appFile.exists()
&& Md5Util.getFileMD5(appFile).equalsIgnoreCase(mUpdateApp.getNewMd5())) {


Uri fileUri = FileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".fileProvider", appFile);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.vector.update_app.view;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.Display;
import android.widget.ScrollView;

/**
* Created by Vector
* on 2017/7/13 0013.
*/

public class AutoScrollView extends ScrollView {
private Context mContext;

public AutoScrollView(Context context) {
super(context);
init(context);
}

public AutoScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);

}

public AutoScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}

private void init(Context context) {
mContext = context;
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
try {
//最大高度显示为屏幕内容高度的一半
Display display = ((Activity) mContext).getWindowManager().getDefaultDisplay();
DisplayMetrics d = new DisplayMetrics();
display.getMetrics(d);
//此处是关键,设置控件高度不能超过屏幕高度一半(在此替换成自己需要的高度)
heightMeasureSpec = MeasureSpec.makeMeasureSpec(d.heightPixels / 3, MeasureSpec.AT_MOST);

} catch (Exception e) {
e.printStackTrace();
}
//重新计算控件高、宽
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
17 changes: 12 additions & 5 deletions update-app/src/main/res/layout/lib_update_app_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,22 @@
android:textColor="@android:color/black"
android:textSize="15sp"/>

<TextView
android:id="@+id/tv_update_info"
<com.vector.update_app.view.AutoScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="1,xxxxxxxx\n2,ooooooooo"
android:textColor="#666"
android:textSize="14sp"/>
android:scrollbars="none">

<TextView
android:id="@+id/tv_update_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1,xxxxxxxx\n2,ooooooooo"
android:textColor="#666"
android:textSize="14sp"/>
</com.vector.update_app.view.AutoScrollView>


<Button
android:id="@+id/btn_ok"
Expand Down

0 comments on commit 69bf02b

Please sign in to comment.