修改隐私后再获取对应的方式

This commit is contained in:
2025-08-12 15:43:36 +08:00
parent ecb7f4b396
commit bd4e7912f1
8 changed files with 177 additions and 376 deletions

View File

@@ -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) {

View File

@@ -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$

View File

@@ -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);
}

View File

@@ -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<String, String> headers = SystemUtils.getSystemParams();
Map<String, String> 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<BaseModel<List<MyRoomBean>>> 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<BaseModel<List<TopRoom>>> 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<BaseModel<List<MyCpRoom>>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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<BaseModel<String>> 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());
}
}

View File

@@ -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(){

View File

@@ -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;