升级优化

This commit is contained in:
lijia 2023-10-12 15:36:18 +08:00
parent c3a3a5cfe6
commit 35c37fdf51
2 changed files with 39 additions and 36 deletions

View File

@ -1,6 +1,9 @@
package com.arpa.hndahesudintocctmsdriver.ui.alert;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
import android.widget.Button;
@ -30,11 +33,11 @@ import java.io.File;
*/
public class UpAppAlert extends CenterPopupView {
private TextView content,vs,tvContent;
private Button tv_cancel,tv_confirm,tvOk;
private TextView content, vs, tvContent;
private Button tv_cancel, tv_confirm, tvOk;
private LinearLayout up_div;
private String url="";
private String body="";
private String url = "";
private String body = "";
private Context con;
private ProgressBar progress_view;
private String version;
@ -42,19 +45,20 @@ public class UpAppAlert extends CenterPopupView {
private LinearLayout force_box;
private ImageButton force_btn;
public UpAppAlert(@NonNull @NotNull Context context, String url, String body,String version,String force) {
public UpAppAlert(@NonNull @NotNull Context context, String url, String body, String version, String force) {
super(context);
con=context;
this.url=url;
this.body=body;
this.version=version;
this.force=force;
con = context;
this.url = url;
this.body = body;
this.version = version;
this.force = force;
}
@Override
protected int getImplLayoutId() {
return R.layout.alert_up_app;
}
public UpAppAlert(@NonNull @NotNull Context context) {
super(context);
@ -63,17 +67,17 @@ public class UpAppAlert extends CenterPopupView {
@Override
protected void onCreate() {
super.onCreate();
content=findViewById(R.id.tv_content);
tv_cancel=findViewById(R.id.tv_cancel);
tv_confirm=findViewById(R.id.tv_confirm);
tvContent=findViewById(R.id.tvContent);
tvOk=findViewById(R.id.tvOk);
up_div=findViewById(R.id.up_div);
progress_view=findViewById(R.id.progress);
content=findViewById(R.id.tv_content);
force_box=findViewById(R.id.force_box);
force_btn=findViewById(R.id.force_btn);
if(force.equals("1")){
content = findViewById(R.id.tv_content);
tv_cancel = findViewById(R.id.tv_cancel);
tv_confirm = findViewById(R.id.tv_confirm);
tvContent = findViewById(R.id.tvContent);
tvOk = findViewById(R.id.tvOk);
up_div = findViewById(R.id.up_div);
progress_view = findViewById(R.id.progress);
content = findViewById(R.id.tv_content);
force_box = findViewById(R.id.force_box);
force_btn = findViewById(R.id.force_btn);
if (force.equals("1")) {
force_box.setVisibility(GONE);
}
force_btn.setOnClickListener(v -> {
@ -81,16 +85,16 @@ public class UpAppAlert extends CenterPopupView {
dismiss();
//detachFromHost();
});
vs=findViewById(R.id.vs);
vs = findViewById(R.id.vs);
content.setText(body);
vs.setText(version);
tv_cancel.setOnClickListener(v -> {
System.exit(1);
});
tv_confirm.setOnClickListener(v -> {
new AppUpdater.Builder()
new AppUpdater.Builder(con)
.setUrl(url)
.build(con)
.build()
.setUpdateCallback(new AppUpdateCallback() {
@Override
public void onStart(String url) {
@ -98,17 +102,18 @@ public class UpAppAlert extends CenterPopupView {
tv_confirm.setVisibility(GONE);
up_div.setVisibility(VISIBLE);
}
@Override
public void onProgress(long progress, long total, boolean isChange) {
// Log.e("progress",progress+"");
// Log.e("total",total+"");
// Log.e("isChange",isChange+"");
float sum=progress;
float max=total;
if(progress>0){
float b=sum/max;
Log.e("百分比",(100*b)+"");
progress_view.setProgress((int) (100*b));
float sum = progress;
float max = total;
if (progress > 0) {
float b = sum / max;
Log.e("百分比", (100 * b) + "");
progress_view.setProgress((int) (100 * b));
}
}
@ -117,7 +122,7 @@ public class UpAppAlert extends CenterPopupView {
tvContent.setText("下载完成,请及时安装!");
tvOk.setVisibility(VISIBLE);
tvOk.setOnClickListener(v1 -> {
AppUtils.installApk(getContext(),file,getContext().getPackageName() + Constants.DEFAULT_FILE_PROVIDER);
AppUtils.installApk(getContext(), file, getContext().getPackageName() + Constants.DEFAULT_FILE_PROVIDER);
});
}
})

View File

@ -7,7 +7,6 @@ import android.graphics.Outline;
import android.location.Location;
import android.os.Bundle;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
@ -146,10 +145,10 @@ public class HomeFragment extends BaseFragment {
MsgUtil.addHdMsgWat(hd, 33);
//新用户注册需弹窗提示注册
if ("0".equals(ub.getData().getRealAuthentication())){
if ("0".equals(ub.getData().getRealAuthentication())) {
new MessageUtils().showSimCenPop(con, "该司机还未认证,未认证无法接单。是否去注册!", () -> {
Intent in=new Intent(con, CertificatesActivity.class);
in.putExtra("index",0);
Intent in = new Intent(con, CertificatesActivity.class);
in.putExtra("index", 0);
startActivity(in);
});
}
@ -545,7 +544,6 @@ public class HomeFragment extends BaseFragment {
ur.getImage(1);
if (UiAuxiliary.isLogin(con)) {
ur.User();
ur.getDriverExpire();