From bd4e7912f1cf1c4a686096ddb361a5dc9159cb70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E5=B0=8F=E6=B1=9F?= <461355754@qq.com> Date: Tue, 12 Aug 2025 15:43:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=9A=90=E7=A7=81=E5=90=8E?= =?UTF-8?q?=E5=86=8D=E8=8E=B7=E5=8F=96=E5=AF=B9=E5=BA=94=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/qxcm/qxlive/LaunchPageActivity.java | 272 +----------------- moduleUtil/build.gradle | 3 +- .../moduleutil/base/CommonAppContext.java | 29 +- .../qxcm/moduleutil/dialog/WebViewDialog.java | 17 -- .../moduleutil/event/RoomGiftRunable.java | 3 +- .../qxcm/moduleutil/http/RetrofitClient.java | 129 +++++---- .../moduleutil/service/FloatingWindow.java | 98 +++++-- .../qxcm/moduleutil/utils/SystemUtils.java | 2 +- 8 files changed, 177 insertions(+), 376 deletions(-) diff --git a/app/src/main/java/com/qxcm/qxlive/LaunchPageActivity.java b/app/src/main/java/com/qxcm/qxlive/LaunchPageActivity.java index 983addf0..8532b34a 100644 --- a/app/src/main/java/com/qxcm/qxlive/LaunchPageActivity.java +++ b/app/src/main/java/com/qxcm/qxlive/LaunchPageActivity.java @@ -7,12 +7,14 @@ import android.os.Handler; import androidx.annotation.Nullable; +import com.qxcm.moduleutil.activity.BaseAppCompatActivity; import com.qxcm.moduleutil.activity.BaseMvpActivity; +import com.qxcm.moduleutil.base.CommonAppContext; import com.qxcm.moduleutil.dialog.PolicyDialog; import com.qxcm.moduleutil.utils.SpUtil; import com.qxcm.qxlive.databinding.ActivityLaunchPageBinding; -public class LaunchPageActivity extends BaseMvpActivity implements LaunchContacter.View { +public class LaunchPageActivity extends BaseAppCompatActivity { private Handler handler; // public PhoneNumberAuthHelper phoneNumberAuthHelper; // private TokenResultListener tokenResultListener; @@ -29,14 +31,9 @@ public class LaunchPageActivity extends BaseMvpActivity= Build.VERSION_CODES.JELLY_BEAN_MR1) { -// if (isFinishing() || isDestroyed()) { -// return; -// } -// } -// if (TextUtils.isEmpty(AppContext.getInstance().getToken()) || TextUtils.isEmpty(AppContext.getInstance().getUser().getTencent_im())) { -// Logger.e("SplashEnd", "ARouters.CODE_LOGIN"); -// if (canOnePass) { -// phoneNumberAuthHelper.setAuthListener(tokenResultListener); -// doOnePass(); -// } else { -// go2Login(); -// } -// } else { -// Logger.e("SplashEnd", "ARouters.MAIN"); -// -// UserBean userBean = CommonAppContext.getInstance().getUser(); -// -//// TUILogin.login(getBaseContext(), CommonAppContext.getInstance().getCurrentEnvironment().getSdkAppId(), "u"+userBean.getUser_id(), userBean.getTencent_im(), new TUICallback() { -//// @Override -//// public void onError(final int code, final String desc) { -//// LogUtils.e("@@@",code,"描述:",desc); -//// } -//// @Override -//// public void onSuccess() { -//// LogUtils.e("@@@","成功"); -//// -//// } -//// }); -// if (userBean.getSex() == 0) { -// Intent intent = new Intent(this, ImproveInfoActivity.class); -// Bundle bundle = new Bundle(); -// bundle.putSerializable("userBean", userBean); -// intent.putExtras(bundle); -// startActivity(intent); -// } else { -// EventBus.getDefault().post(userBean); -// startActivity(new Intent(this, MainActivity.class)); -// } -// finish(); -// } -// } - -// private void doOnePass() { -// AuthUIConfig authUIConfig = new AuthUIConfig.Builder() -// //导航栏 -// .setNavColor(Color.TRANSPARENT) -// .setNavReturnHidden(true) -// .setNavHidden(true) -// .setNavText("") -// .setNavTextColor(Color.BLACK) -// .setWebNavColor(Color.TRANSPARENT) -// .setWebNavTextColor(Color.BLACK) -// .setWebNavReturnImgPath("ic_topbar_back_dark") -// //状态栏区 -// .setStatusBarColor(Color.TRANSPARENT) -// .setLightColor(false) -// .setWebViewStatusBarColor(Color.TRANSPARENT) -// .setStatusBarUIFlag(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) -// //logo区 -// .setLogoImgPath("login_log") -// .setLogoWidth(142) -// .setLogoHeight(142) -// .setLogoOffsetY(54) -// .setLogoHidden(false) -// .setLogoScaleType(ImageView.ScaleType.FIT_XY) -// //Slogan -// .setSloganText("本机号码") -// .setSloganTextColor(Color.parseColor("#A8A8A8")) -// .setSloganTextSize(12) -// .setSloganOffsetY(236) -// //掩码栏 -// .setNumberColor(Color.BLACK) -// .setNumberSize(30) -// .setNumFieldOffsetY(263) -// .setNumberLayoutGravity(Gravity.CENTER_HORIZONTAL) -// //登录按钮 -// .setLogBtnText("本机号码一键登录") -// .setLogBtnWidth(300) -// .setLogBtnHeight(42) -// .setLogBtnOffsetY(325) -// .setLogBtnTextSize(14) -// .setLogBtnTextColor(getResources().getColor(R.color.black)) -// .setLogBtnBackgroundPath("cs") -// //切换到其他方式 -// .setSwitchAccText("其他登录方式") -// .setSwitchAccTextColor(Color.parseColor("#333333")) -// .setSwitchAccTextSize(12) -// .setSwitchOffsetY(390) -// //协议栏 -// .setAppPrivacyOne("《用户协议》", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6") -// .setAppPrivacyTwo("《隐私协议》", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4") -// .setAppPrivacyColor(Color.parseColor("#A8A8A8"), Color.parseColor("#FFBC00")) -// .setPrivacyBefore("登录即代表同意") -// .setPrivacyEnd("并授权获得号码") -// .setPrivacyTextSize(11) -// .setPrivacyAlertContentVerticalMargin(20) -// .setPrivacyMargin(39) -// .setPrivacyState(true) -// .setCheckboxHidden(false) -// .setCheckedImgPath("ic_agreement_selected") -// .setUncheckedImgPath("ic_agreement_unselect") -// .setPrivacyOffsetX(2) -// .setVendorPrivacyPrefix("《") -// .setVendorPrivacySuffix("》") -// //全页面属性 -// .setAuthPageActIn("in_activity", "out_activity") -// .setAuthPageActOut("in_activity", "out_activity") -// .setPageBackgroundPath("log_bj") -// .create(); -// phoneNumberAuthHelper.setAuthUIConfig(authUIConfig); -// phoneNumberAuthHelper.getLoginToken(getApplicationContext(), 5000); -// } - -// private void initQuickLogin() { -// tokenResultListener = new TokenResultListener() { -// @Override -// public void onTokenSuccess(String s) { -// Logger.e("onTokenSuccess", s); -// ThreadUtils.runOnUiThread(new Runnable() { -// @Override -// public void run() { -// TokenRet tokenRet = null; -// try { -// tokenRet = JSON.parseObject(s, TokenRet.class); -// if (tokenRet != null && ("600000").equals(tokenRet.getCode())) { -// phoneNumberAuthHelper.hideLoginLoading(); -// //获取成功 dimiss就去登录、登录成功 -// phoneNumberAuthHelper.quitLoginPage(); -// LogUtils.e("@@@",tokenRet.getToken()); -// MvpPre.oauthLogin(tokenRet.getToken()); -// } -// } catch (Exception e) { -// go2Login(); -// e.printStackTrace(); -// } -// } -// }); -// } -// -// @Override -// public void onTokenFailed(String s) { -// Logger.e("onTokenFailed", s); -// ThreadUtils.runOnUiThread(new Runnable() { -// @Override -// public void run() { -// phoneNumberAuthHelper.hideLoginLoading(); -// phoneNumberAuthHelper.quitLoginPage(); -// go2Login(); -// } -// }); -// } -// }; -// -// try { -// phoneNumberAuthHelper = PhoneNumberAuthHelper.getInstance(getApplicationContext(), null); -// phoneNumberAuthHelper.getReporter().setLoggerEnable(true); -//// phoneNumberAuthHelper.setAuthSDKInfo("6rdWuz058oq5OahdbFiGEybUcdahd12J83L34Uc7MrPIrxtFG+rXiwDvRcqNvjwbClbbmvMrmxKVkIysFByBsl0Qe9kqd2w8T/nhK5G6eXXlk2V9AjYCieIU+jRnjZBB+Cfechr6rCGJ2aeBARIsXcRPW7wm9WFK9euh5T+v6Pyte68yNaNdcYCll3+U4/uCEog7HygCnMIbAU+kqoPdmn2H+51YOHW+VsnsHd4w1+I3f8Tt0xLIXGM4GWnQueZ5GR46GTWiSYMy8dCIh9SPIMRyC91GosVcfGPMJSdcXqc="); -// phoneNumberAuthHelper.setAuthSDKInfo(((AppContext) getApplication()).getCurrentEnvironment().getALI_AUTH_KEY()); -// phoneNumberAuthHelper.checkEnvAvailable(2); -// -// } catch (Throwable ignored) { -// Logger.e("initAuthSDK", ignored); -// } -// } - - private void go2Login() { - startActivity(new Intent(this, PasswordLoginActivity.class)); - finish(); - } @Override protected int getLayoutId() { return R.layout.activity_launch_page; } - @Override - protected LaunchPresenter bindPresenter() { - return new LaunchPresenter(this, this); - } - -// @Override -// public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { -// super.onRequestPermissionsResult(requestCode, permissions, grantResults); -// -// if (requestCode == 1001) { -// LocationProvider provider = LocationServiceFactory.createBestProvider(this); -// provider.getLastKnownLocation(this, new LocationProvider.LocationCallback() { -// @Override -// public void onLocationReceived(double latitude, double longitude, String city) { -// ToastUtils.showShort("当前位置:" + city); -// city1=city; -// } -// -// @Override -// public void onFailed(String errorMessage) { -// ToastUtils.showShort("定位失败"); -// } -// }); -// } -// } @Override diff --git a/moduleUtil/build.gradle b/moduleUtil/build.gradle index 5b11ed51..8a6c9284 100644 --- a/moduleUtil/build.gradle +++ b/moduleUtil/build.gradle @@ -196,8 +196,7 @@ dependencies { api "com.tencent.imsdk:imsdk-plus:latest.release" //悬浮框 api "io.github.petterpx:floatingx:2.3.5" - // system浮窗&&compose时需要导入 https://github.com/Petterpx/FloatingX/ - // 记得AppHelper里调用 enableComposeSupport() +// // system浮窗&&compose时需要导入 https://github.com/Petterpx/FloatingX/ api 'io.github.petterpx:floatingx-compose:2.3.5' api 'com.github.princekin-f:EasyFloat:2.0.4' diff --git a/moduleUtil/src/main/java/com/qxcm/moduleutil/base/CommonAppContext.java b/moduleUtil/src/main/java/com/qxcm/moduleutil/base/CommonAppContext.java index d899f905..78045a18 100644 --- a/moduleUtil/src/main/java/com/qxcm/moduleutil/base/CommonAppContext.java +++ b/moduleUtil/src/main/java/com/qxcm/moduleutil/base/CommonAppContext.java @@ -113,6 +113,11 @@ public class CommonAppContext extends MultiDexApplication { super.onCreate(); sInstance = this; sMainThreadHandler = new Handler(); + + + } + + public void initialization(){ UtilConfig.init(this); registerActivityLifecycleCallbacks(); initWebView(); @@ -129,15 +134,14 @@ public class CommonAppContext extends MultiDexApplication { piaoPingManager.subscribe(); AgoraManager.getInstance(this).init(currentEnvironment.getSwSdkAppId()); MessageListenerSingleton.getInstance(); - CrashReport.initCrashReport(this, "865cfe9555", true);/*bugly初始化*/ - ServiceUtils.startService(MyMqttService.class);/*Mqtt初始化*/ - } -private PiaoPingManager piaoPingManager; + + private PiaoPingManager piaoPingManager; + private void initARouter() { - if(true) { + if (true) { ARouter.openDebug(); ARouter.openLog(); } @@ -228,7 +232,7 @@ private PiaoPingManager piaoPingManager; LogUtils.e("AppContext------->处于前台"); EventBus.getDefault().post(new AppLifecycleEvent(true)); CommonAppConfig.getInstance().setFrontGround(true); - FloatWindowHelper.setFloatWindowVisible(true); +// FloatWindowHelper.setFloatWindowVisible(true); AppLifecycleUtil.onAppFrontGround(); } @@ -252,7 +256,7 @@ private PiaoPingManager piaoPingManager; LogUtils.e("AppContext------->处于后台"); EventBus.getDefault().post(new AppLifecycleEvent(false)); CommonAppConfig.getInstance().setFrontGround(false); - FloatWindowHelper.setFloatWindowVisible(false); +// FloatWindowHelper.setFloatWindowVisible(false); AppLifecycleUtil.onAppBackGround(); } } @@ -324,16 +328,17 @@ private PiaoPingManager piaoPingManager; public void startInitSdk() { UserBean userBean = SpUtil.getUserBean(); - if (userBean != null){ + if (userBean != null) { // 在用户 UI 点击登录的时候调用 - TUILogin.login(getBaseContext(), CommonAppContext.getInstance().getCurrentEnvironment().getSdkAppId(), "u"+userBean.getUser_id(), userBean.getTencent_im(), new TUICallback() { + TUILogin.login(getBaseContext(), CommonAppContext.getInstance().getCurrentEnvironment().getSdkAppId(), "u" + userBean.getUser_id(), userBean.getTencent_im(), new TUICallback() { @Override public void onError(final int code, final String desc) { - LogUtils.e("@@@1",code,"描述:",desc); + LogUtils.e("@@@1", code, "描述:", desc); } + @Override public void onSuccess() { - LogUtils.e("@@@","成功"); + LogUtils.e("@@@", "成功"); } }); @@ -374,6 +379,8 @@ private PiaoPingManager piaoPingManager; piaoPingManager.unsubscribe(); FileUtils.deleteAllInDir(getCacheDir()); FileUtils.deleteAllInDir(getExternalCacheDir()); + AgoraManager.getInstance(getApplicationContext()).destroy(); + } public static boolean isAlipayInstalled(Context context) { diff --git a/moduleUtil/src/main/java/com/qxcm/moduleutil/dialog/WebViewDialog.java b/moduleUtil/src/main/java/com/qxcm/moduleutil/dialog/WebViewDialog.java index cc3ea438..9b99c9f6 100644 --- a/moduleUtil/src/main/java/com/qxcm/moduleutil/dialog/WebViewDialog.java +++ b/moduleUtil/src/main/java/com/qxcm/moduleutil/dialog/WebViewDialog.java @@ -20,18 +20,9 @@ import androidx.annotation.NonNull; import com.alibaba.android.arouter.launcher.ARouter; import com.blankj.utilcode.util.LogUtils; import com.blankj.utilcode.util.ScreenUtils; -import com.blankj.utilcode.util.ToastUtils; import com.qxcm.moduleutil.R; -import com.qxcm.moduleutil.activity.WebViewActivity; -import com.qxcm.moduleutil.adapter.HeavenGiftAdapter; import com.qxcm.moduleutil.base.CommonAppContext; -import com.qxcm.moduleutil.bean.BaseListData; -import com.qxcm.moduleutil.bean.FirstChargeGiftBean; -import com.qxcm.moduleutil.bean.RoonGiftModel; -import com.qxcm.moduleutil.databinding.DialogFirstChargeBinding; import com.qxcm.moduleutil.databinding.WebViewDialogBinding; -import com.qxcm.moduleutil.http.BaseObserver; -import com.qxcm.moduleutil.http.RetrofitClient; import com.qxcm.moduleutil.utils.ARouteConstants; import com.qxcm.moduleutil.widget.dialog.BaseDialog; import com.tencent.imsdk.v2.V2TIMConversation; @@ -41,14 +32,6 @@ import com.tencent.mm.opensdk.openapi.WXAPIFactory; import com.tencent.qcloud.tuicore.TUIConstants; import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIC2CChatActivity; import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIGroupChatActivity; -import com.zhpan.bannerview.indicator.DrawableIndicator; -import com.zhpan.indicator.base.IIndicator; -import com.zhpan.indicator.enums.IndicatorSlideMode; - -import java.util.ArrayList; -import java.util.List; - -import io.reactivex.disposables.Disposable; /** * @Author lxj$ diff --git a/moduleUtil/src/main/java/com/qxcm/moduleutil/event/RoomGiftRunable.java b/moduleUtil/src/main/java/com/qxcm/moduleutil/event/RoomGiftRunable.java index a4fb153b..cce9495e 100644 --- a/moduleUtil/src/main/java/com/qxcm/moduleutil/event/RoomGiftRunable.java +++ b/moduleUtil/src/main/java/com/qxcm/moduleutil/event/RoomGiftRunable.java @@ -9,6 +9,7 @@ import com.blankj.utilcode.util.ServiceUtils; import com.google.gson.Gson; import com.qxcm.moduleutil.base.CommonAppContext; import com.qxcm.moduleutil.service.FloatingWindow; +import com.qxcm.moduleutil.widget.PiaoPingManager; import org.greenrobot.eventbus.EventBus; @@ -41,7 +42,7 @@ public class RoomGiftRunable implements Runnable { mqttCache.add(mqttBean); // 添加新数据 } EventBus.getDefault().post(mqttBean); - new FloatingWindow(CommonAppContext.getInstance(),mqttBean); +// new FloatingWindow(CommonAppContext.getInstance(),mqttBean); } diff --git a/moduleUtil/src/main/java/com/qxcm/moduleutil/http/RetrofitClient.java b/moduleUtil/src/main/java/com/qxcm/moduleutil/http/RetrofitClient.java index 645f21f8..17f45a3e 100644 --- a/moduleUtil/src/main/java/com/qxcm/moduleutil/http/RetrofitClient.java +++ b/moduleUtil/src/main/java/com/qxcm/moduleutil/http/RetrofitClient.java @@ -95,7 +95,9 @@ import java.net.Proxy; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; +import java.security.cert.X509Certificate; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -139,23 +141,26 @@ public class RetrofitClient { } private OkHttpClient provideOkHttpClient() { - Map headers = SystemUtils.getSystemParams(); + Map headers = Collections.emptyMap(); + if (SpUtil.isAgreePolicy()) { + headers = SystemUtils.getSystemParams(); + } SetCookieCache cookieCache = new SetCookieCache(); ClearableCookieJar cookieJar = new PersistentCookieJar(cookieCache, new SharedPrefsCookiePersistor(CommonAppContext.getInstance())); try { X509TrustManager trustAllCert = new X509TrustManager() { @Override - public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) { + public void checkClientTrusted(X509Certificate[] chain, String authType) { } @Override - public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) { + public void checkServerTrusted(X509Certificate[] chain, String authType) { } @Override - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return new java.security.cert.X509Certificate[]{}; + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[]{}; } }; SSLContext sslContext = null; @@ -277,7 +282,7 @@ public class RetrofitClient { } catch (ClassNotFoundException e) { throw new RuntimeException(e); } - com.blankj.utilcode.util.ToastUtils.showShort(string.getMsg()); + ToastUtils.showShort(string.getMsg()); } } } @@ -793,7 +798,7 @@ public class RetrofitClient { @Override public void onFailure(Call>> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -837,7 +842,7 @@ public class RetrofitClient { @Override public void onFailure(Call>> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -958,7 +963,7 @@ public class RetrofitClient { @Override public void onFailure(Call>> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1071,7 +1076,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1089,7 +1094,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1103,7 +1108,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1117,7 +1122,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1132,7 +1137,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1146,7 +1151,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1161,7 +1166,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1175,7 +1180,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1189,7 +1194,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1203,7 +1208,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1244,7 +1249,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1258,7 +1263,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1272,7 +1277,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1286,7 +1291,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1358,7 +1363,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1372,7 +1377,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1386,7 +1391,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1400,7 +1405,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1414,7 +1419,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1428,7 +1433,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1442,7 +1447,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1456,7 +1461,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1486,7 +1491,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1500,7 +1505,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1538,7 +1543,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1552,7 +1557,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1607,7 +1612,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1638,7 +1643,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1652,7 +1657,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1666,7 +1671,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); @@ -1682,7 +1687,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1696,7 +1701,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1711,7 +1716,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1726,7 +1731,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1740,7 +1745,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); if (t.toString().contains("登录失效")) { try { CommonAppContext.getInstance().clearLoginInfo(); @@ -1761,7 +1766,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1775,7 +1780,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1789,7 +1794,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1805,7 +1810,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } else { @@ -1818,7 +1823,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1833,7 +1838,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1847,7 +1852,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1862,7 +1867,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); t.printStackTrace(); } }); @@ -1912,7 +1917,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1926,7 +1931,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1940,7 +1945,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1969,7 +1974,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } else { @@ -1981,7 +1986,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -1997,7 +2002,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -2011,7 +2016,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -2025,7 +2030,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -2039,7 +2044,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - com.blankj.utilcode.util.ToastUtils.showShort(t.toString()); + ToastUtils.showShort(t.toString()); } }); } @@ -2058,7 +2063,7 @@ public class RetrofitClient { } catch (ClassNotFoundException e) { throw new RuntimeException(e); } - com.blankj.utilcode.util.ToastUtils.showShort(string.getMsg()); + ToastUtils.showShort(string.getMsg()); } } diff --git a/moduleUtil/src/main/java/com/qxcm/moduleutil/service/FloatingWindow.java b/moduleUtil/src/main/java/com/qxcm/moduleutil/service/FloatingWindow.java index 8c784ab4..823afe36 100644 --- a/moduleUtil/src/main/java/com/qxcm/moduleutil/service/FloatingWindow.java +++ b/moduleUtil/src/main/java/com/qxcm/moduleutil/service/FloatingWindow.java @@ -30,16 +30,19 @@ public class FloatingWindow { windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); piaoPingView = LayoutInflater.from(context).inflate(R.layout.item_piaoping, null); WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams( - WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT, + WindowManager.LayoutParams.WRAP_CONTENT, + Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY : WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, + PixelFormat.TRANSLUCENT); + TextView textView = piaoPingView.findViewById(R.id.tv_name); textView.setText(mqttBean.getList().getText()); ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), piaoPingView.findViewById(R.id.iv_piaoping)); @@ -47,44 +50,101 @@ public class FloatingWindow { tv_time.setText(mqttBean.getList().getNumber()); windowManager.addView(piaoPingView, layoutParams); +// piaoPingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { +// @Override +// public void onGlobalLayout() { +// piaoPingView.getViewTreeObserver().removeOnGlobalLayoutListener(this); +// +// // 设置锚点为左上角,避免偏移干扰 +// piaoPingView.setPivotX(0); +// piaoPingView.setPivotY(0); +// +// // 启动动画:从左外滑入 -> 右外滑出 +// ObjectAnimator animator = ObjectAnimator.ofFloat( +// piaoPingView, +// "translationX", +// 0f, // 初始偏移为 0(此时 View 在左侧外) +// screenWidth // 向右移动整个屏幕宽度 +// ); +// animator.setDuration(2000); // 整个动画的时长为2秒 +// +// // 强制 GPU 渲染 +// piaoPingView.setLayerType(View.LAYER_TYPE_HARDWARE, null); +// +// // 延迟显示2秒后开始滑出屏幕的动画 +// piaoPingView.postDelayed(new Runnable() { +// @Override +// public void run() { +// animator.start(); +// } +// }, 2000); +// +// animator.addListener(new AnimatorListenerAdapter() { +// @Override +// public void onAnimationEnd(Animator animation) { +// windowManager.removeView(piaoPingView); +// stopSelf(); +// } +// }); +// } +// }); + + piaoPingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { piaoPingView.getViewTreeObserver().removeOnGlobalLayoutListener(this); - // 设置锚点为左上角,避免偏移干扰 + // 获取视图宽度 + int viewWidth = piaoPingView.getWidth(); + + // 设置锚点为左上角 piaoPingView.setPivotX(0); piaoPingView.setPivotY(0); - // 启动动画:从左外滑入 -> 右外滑出 - ObjectAnimator animator = ObjectAnimator.ofFloat( - piaoPingView, - "translationX", - 0f, // 初始偏移为 0(此时 View 在左侧外) - screenWidth // 向右移动整个屏幕宽度 - ); - animator.setDuration(2000); // 整个动画的时长为2秒 - // 强制 GPU 渲染 piaoPingView.setLayerType(View.LAYER_TYPE_HARDWARE, null); - // 延迟显示2秒后开始滑出屏幕的动画 - piaoPingView.postDelayed(new Runnable() { - @Override - public void run() { - animator.start(); - } - }, 2000); + // 创建滑入动画:从左外滑入到屏幕左侧 + ObjectAnimator slideInAnimator = ObjectAnimator.ofFloat( + piaoPingView, + "translationX", + -viewWidth, // 起始位置:屏幕左外 + 0f // 结束位置:屏幕左边缘 + ); + slideInAnimator.setDuration(500); // 滑入动画时长0.5秒 - animator.addListener(new AnimatorListenerAdapter() { + // 创建滑出动画:从当前位置滑出到屏幕右侧外 + ObjectAnimator slideOutAnimator = ObjectAnimator.ofFloat( + piaoPingView, + "translationX", + 0f, // 起始位置:屏幕左边缘 + screenWidth // 结束位置:屏幕右外 + ); + slideOutAnimator.setDuration(500); // 滑出动画时长0.5秒 + + // 设置滑出动画监听器 + slideOutAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { windowManager.removeView(piaoPingView); stopSelf(); } }); + + // 开始执行动画序列 + slideInAnimator.start(); + + // 滑入完成后延迟2秒执行滑出动画 + piaoPingView.postDelayed(new Runnable() { + @Override + public void run() { + slideOutAnimator.start(); + } + }, 2000); } }); + } public void stopSelf(){ diff --git a/moduleUtil/src/main/java/com/qxcm/moduleutil/utils/SystemUtils.java b/moduleUtil/src/main/java/com/qxcm/moduleutil/utils/SystemUtils.java index 76a55760..824cb895 100644 --- a/moduleUtil/src/main/java/com/qxcm/moduleutil/utils/SystemUtils.java +++ b/moduleUtil/src/main/java/com/qxcm/moduleutil/utils/SystemUtils.java @@ -93,7 +93,7 @@ public class SystemUtils { configUtils.setConfigName(system_uuid_key); String system_config_uuid = configUtils.findStringByKey(system_uuid_key); if (system_config_uuid == null) { - system_config_uuid = DeviceUtils.getAndroidID(); +// system_config_uuid = DeviceUtils.getUniqueDeviceId(); configUtils.addOrUpdateText(system_uuid_key, system_config_uuid); } return system_config_uuid;