修改BUG

This commit is contained in:
2025-08-08 10:31:50 +08:00
parent 38337c63a5
commit 4f09ec38c1
126 changed files with 4166 additions and 711 deletions

View File

@@ -14,6 +14,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.TextView;
@@ -36,7 +37,7 @@ public class EMqttService extends Service {
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null && intent.hasExtra("mqttBean")) {
MqttBean mqttBean = (MqttBean) intent.getSerializableExtra("mqttBean");
showPiaoPingMessage(mqttBean);
showPiaoPingMessage(mqttBean);//全局飘屏
}
return START_NOT_STICKY;
}
@@ -55,28 +56,37 @@ public class EMqttService extends Service {
}
public void showPiaoPingMessage(MqttBean mqttBean) {
int screenWidth = getResources().getDisplayMetrics().widthPixels;
int screenHeight = getResources().getDisplayMetrics().heightPixels;
//
// WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
// WindowManager.LayoutParams.MATCH_PARENT,
// 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);
//
// // 设置 Gravity 为左上角
// layoutParams.gravity = Gravity.TOP | Gravity.START;
//
// // Y 轴随机位置
// layoutParams.y = (int) ((Math.random() * (screenHeight - 200)));
//
// // 初始 X 设为负值,确保 View 在屏幕左侧外
// layoutParams.x = -screenWidth;
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
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);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
// 设置 Gravity 为左上角
layoutParams.gravity = Gravity.TOP | Gravity.START;
// 设置随机 Y 轴位置
layoutParams.topMargin = (int) (Math.random() * (screenHeight - 200));
// Y 轴随机位置
layoutParams.y = (int) ((Math.random() * (screenHeight - 200)));
// 初始 X 设为负值,确保 View 在屏幕左侧外
layoutParams.x = -screenWidth;
piaoPingView = LayoutInflater.from(this).inflate(R.layout.item_piaoping, null);
TextView textView = piaoPingView.findViewById(R.id.tv_name);