From 35c37fdf519d141423e10b08b408df12b0a9229d Mon Sep 17 00:00:00 2001 From: lijia Date: Thu, 12 Oct 2023 15:36:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/alert/UpAppAlert.java | 67 ++++++++++--------- .../ui/home/HomeFragment.java | 8 +-- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/alert/UpAppAlert.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/alert/UpAppAlert.java index 646e1e0..95d6372 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/alert/UpAppAlert.java +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/alert/UpAppAlert.java @@ -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); }); } }) diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/home/HomeFragment.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/home/HomeFragment.java index 5691688..57f132f 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/home/HomeFragment.java +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/home/HomeFragment.java @@ -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();