Commit 18e6e79e authored by jianglx's avatar jianglx

新版 版本检测完成,修改版本检测升级逻辑

parent 25086179
...@@ -42,6 +42,7 @@ import com.ruiwenliu.wrapper.bean.UpdateTokenBean; ...@@ -42,6 +42,7 @@ import com.ruiwenliu.wrapper.bean.UpdateTokenBean;
import com.ruiwenliu.wrapper.receiver.NetWorkReceiver; import com.ruiwenliu.wrapper.receiver.NetWorkReceiver;
import com.ruiwenliu.wrapper.statusbar.StatusBarUtil; import com.ruiwenliu.wrapper.statusbar.StatusBarUtil;
import com.ruiwenliu.wrapper.util.UtilsManager; import com.ruiwenliu.wrapper.util.UtilsManager;
import com.ruiwenliu.wrapper.util.glide.GlideApp;
import com.ruiwenliu.wrapper.util.listener.SwitchFragment; import com.ruiwenliu.wrapper.util.listener.SwitchFragment;
import com.ruiwenliu.wrapper.weight.CustomScrollViewPager; import com.ruiwenliu.wrapper.weight.CustomScrollViewPager;
import com.ruiwenliu.wrapper.weight.TitleView; import com.ruiwenliu.wrapper.weight.TitleView;
...@@ -218,7 +219,6 @@ public class MainActivity extends BaseActivity<CommonPresenter> implements DownL ...@@ -218,7 +219,6 @@ public class MainActivity extends BaseActivity<CommonPresenter> implements DownL
getEffectiveTime(); getEffectiveTime();
getActivityPopup(); getActivityPopup();
checkVersion(); checkVersion();
checkToken(); checkToken();
} }
...@@ -542,7 +542,7 @@ public class MainActivity extends BaseActivity<CommonPresenter> implements DownL ...@@ -542,7 +542,7 @@ public class MainActivity extends BaseActivity<CommonPresenter> implements DownL
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
imLogin(); imLogin();
if (hasGetVersionInfo && versionCheckBean != null && versionCheckBean.getData() != null && versionCheckBean.getData().getIsCompel() == 1 && !TextUtils.isEmpty(versionCheckBean.getData().getDownloadUrl())) if (!DownListenerManager.getInstance().isDown() && hasGetVersionInfo && versionCheckBean != null && versionCheckBean.getData() != null && versionCheckBean.getData().getIsCompel() == 1 && !TextUtils.isEmpty(versionCheckBean.getData().getDownloadUrl()))
checkUpdateInfo(); checkUpdateInfo();
} }
......
...@@ -42,6 +42,7 @@ public class VersionUpdateDialog extends BaseDialog { ...@@ -42,6 +42,7 @@ public class VersionUpdateDialog extends BaseDialog {
private TextView txtContent; private TextView txtContent;
private TextView tv_version_name; private TextView tv_version_name;
private ImageView imgClose; private ImageView imgClose;
// private ImageView ivHeader ;
private DownloadListener mListener; private DownloadListener mListener;
private UpdateForceDialog forceDialog; private UpdateForceDialog forceDialog;
...@@ -82,6 +83,18 @@ public class VersionUpdateDialog extends BaseDialog { ...@@ -82,6 +83,18 @@ public class VersionUpdateDialog extends BaseDialog {
this.txtContent = layout.findViewById(R.id.txt_content); this.txtContent = layout.findViewById(R.id.txt_content);
this.btn_update = layout.findViewById(R.id.btn_update); this.btn_update = layout.findViewById(R.id.btn_update);
this.imgClose = layout.findViewById(R.id.img_close); this.imgClose = layout.findViewById(R.id.img_close);
// ivHeader = layout.findViewById(R.id.iv_header) ;
// TransformationUtils utils = new TransformationUtils(ivHeader);
//
// GlideApp.with(mContext)
// .asBitmap()
// .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
// .load(R.drawable.icon_member_dialog_top)
// .apply(RequestOptions
// .bitmapTransform(new RoundedCorners(12)).override(ivHeader.getWidth(), ivHeader.getHeight()))
// .into(utils);
this.btn_update.setOnClickListener(view -> { this.btn_update.setOnClickListener(view -> {
if (mListener != null) { if (mListener != null) {
mListener.download(); mListener.download();
......
package com.rv.version.util;
import android.graphics.Bitmap;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.bumptech.glide.request.target.ImageViewTarget;
public class TransformationUtils extends ImageViewTarget<Bitmap> {
private ImageView target;
public TransformationUtils(ImageView target) {
super(target);
this.target = target;
}
@Override
protected void setResource(Bitmap resource) {
target.setImageBitmap(resource);
if (resource == null) return;
//获取原图的宽高
int width = resource.getWidth();
int height = resource.getHeight();
//获取imageView的宽
int imageViewWidth = target.getWidth();
//计算缩放比例
float sy = (float) (imageViewWidth * 0.1) / (float) (width * 0.1);
//计算图片等比例放大后的高
int imageViewHeight = (int) (height * sy);
ViewGroup.LayoutParams params = target.getLayoutParams();
params.height = imageViewHeight;
target.setLayoutParams(params);
}
}
\ No newline at end of file
...@@ -10,17 +10,12 @@ ...@@ -10,17 +10,12 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/size_30" android:layout_marginLeft="@dimen/size_30"
android:layout_marginRight="@dimen/size_30" android:layout_marginRight="@dimen/size_30"
android:background="@drawable/dialog_content_bg" android:background="@drawable/bg_version"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical"> android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/dialog_img_height"
android:scaleType="centerCrop"
android:src="@drawable/icon_dialog_top" />
<TextView <TextView
android:layout_marginTop="@dimen/dialog_img_height"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
...@@ -34,7 +29,7 @@ ...@@ -34,7 +29,7 @@
android:id="@+id/tv_version_name" android:id="@+id/tv_version_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_5" android:layout_marginTop="@dimen/size_3"
android:gravity="center" android:gravity="center"
android:textColor="#171413" android:textColor="#171413"
android:textSize="@dimen/sp_14" /> android:textSize="@dimen/sp_14" />
...@@ -42,12 +37,13 @@ ...@@ -42,12 +37,13 @@
<TextView <TextView
android:id="@+id/txt_content" android:id="@+id/txt_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_weight="1"
android:layout_height="0dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:gravity="left" android:gravity="left"
android:lineSpacingMultiplier="1.5" android:paddingLeft="33dp"
android:paddingLeft="13dp" android:paddingRight="33dp"
android:paddingRight="13dp" android:singleLine="false"
android:textColor="#666666" android:textColor="#666666"
android:textSize="@dimen/sp_12" /> android:textSize="@dimen/sp_12" />
...@@ -55,12 +51,13 @@ ...@@ -55,12 +51,13 @@
android:id="@+id/btn_update" android:id="@+id/btn_update"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/size_40" android:layout_height="@dimen/size_40"
android:layout_marginLeft="13sp" android:layout_marginLeft="13dp"
android:layout_marginTop="13sp" android:layout_marginRight="13dp"
android:layout_marginRight="13sp" android:layout_marginTop="13dp"
android:layout_marginBottom="13sp" android:layout_marginBottom="13dp"
android:background="@drawable/bg_version_btn" android:background="@drawable/bg_version_btn"
android:gravity="center" android:gravity="center"
android:layout_gravity="bottom"
android:text="立即更新" android:text="立即更新"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/sp_16" /> android:textSize="@dimen/sp_16" />
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<dimen name="dialog_width">160dp</dimen> <dimen name="dialog_width">160dp</dimen>
<dimen name="dialog_img_height">55dp</dimen> <dimen name="dialog_img_height">90dp</dimen>
</resources> </resources>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<dimen name="dialog_width">213.33dp</dimen> <dimen name="dialog_width">213.33dp</dimen>
<dimen name="dialog_img_height">73.33dp</dimen> <!--<dimen name="dialog_img_height">73.33dp</dimen>-->
<dimen name="dialog_img_height">120dp</dimen>
</resources> </resources>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<dimen name="dialog_width">320dp</dimen> <dimen name="dialog_width">320dp</dimen>
<dimen name="dialog_img_height">110dp</dimen> <dimen name="dialog_img_height">150dp</dimen>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment