添加base dialog

This commit is contained in:
tongchenfei
2020-06-16 19:18:15 +08:00
parent 5e2103000d
commit bfe990271a
3 changed files with 122 additions and 60 deletions

View File

@@ -12,6 +12,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.module.common.dialog.BaseFloatDialog;
import com.mogo.module.common.utils.CarSeries;
import com.mogo.module.share.R;
import com.mogo.module.share.constant.ShareConstants;
@@ -36,7 +37,7 @@ import java.util.Map;
* 由于和左侧Adas冲突改成了windowManager方式实现这种实现方式的问题是无法监测back键的事件
* @since 2020-01-10
*/
public class LaucherShareDialog implements View.OnClickListener {
public class LaucherShareDialog extends BaseFloatDialog implements View.OnClickListener {
private static final String TAG = "LaucherShareDialog";
private boolean isShown = false;
@@ -60,36 +61,49 @@ public class LaucherShareDialog implements View.OnClickListener {
private WindowManager windowManager;
public LaucherShareDialog(@NonNull Context context) {
// public LaucherShareDialog(@NonNull Context context) {
// this.mContext = context;
// mApis = (IMogoServiceApis) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation(context);
// mAnalytics = mApis.getAnalyticsApi();
// mStatusManager = mApis.getStatusManagerApi();
// }
private View body;
public LaucherShareDialog(Context context) {
super(context);
this.mContext = context;
mApis = (IMogoServiceApis) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation(context);
mAnalytics = mApis.getAnalyticsApi();
mStatusManager = mApis.getStatusManagerApi();
initView();
initListener();
}
private View body;
private void initView() {
Logger.d(TAG, "test-------3");
body = LayoutInflater.from(mContext).inflate(R.layout.launcher_dialog_share_2, null);
body.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
setContentView(R.layout.launcher_dialog_share_2);
// body = LayoutInflater.from(mContext).inflate(R.layout.launcher_dialog_share_2, null);
// body.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// dismiss();
// }
// });
tvBlock = body.findViewById(R.id.tvBlock);
tvTrafficCheck = body.findViewById(R.id.tvTrafficCheck);
tvClosure = body.findViewById(R.id.tvClosure);
tvNeedHelp = body.findViewById(R.id.tvSeekHelp);
tvBlock = findViewById(R.id.tvBlock);
tvTrafficCheck = findViewById(R.id.tvTrafficCheck);
tvClosure = findViewById(R.id.tvClosure);
tvNeedHelp = findViewById(R.id.tvSeekHelp);
tvAccident = body.findViewById(R.id.tvAccident);
tvRealTimeTraffic = body.findViewById(R.id.tvRealTimeTraffic);
tvStagnantWater = body.findViewById(R.id.tvStagnantWater);
tvRoadIcy = body.findViewById(R.id.tvRoadIcy);
tvDenseFog = body.findViewById(R.id.tvDenseFog);
tvConstruction = body.findViewById(R.id.tvConstruction);
tvAccident = findViewById(R.id.tvAccident);
tvRealTimeTraffic = findViewById(R.id.tvRealTimeTraffic);
tvStagnantWater = findViewById(R.id.tvStagnantWater);
tvRoadIcy = findViewById(R.id.tvRoadIcy);
tvDenseFog = findViewById(R.id.tvDenseFog);
tvConstruction = findViewById(R.id.tvConstruction);
}
@@ -220,46 +234,46 @@ public class LaucherShareDialog implements View.OnClickListener {
}
public void show(){
Logger.d(TAG,"使用windowManager实现");
if (!isShown) {
windowManager = (WindowManager) mContext.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
} else {
layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
}
layoutParams.format = PixelFormat.TRANSLUCENT;
layoutParams.gravity = Gravity.START | Gravity.TOP;
// mWindowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
// FLAG_LAYOUT_IN_SCREEN将window放置在整个屏幕之内,无视其他的装饰(比如状态栏) FLAG_NOT_TOUCH_MODAL不阻塞事件传递到后面的窗口
layoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
if (CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X) {
layoutParams.width = 1920;
layoutParams.height = 1080;
}else {
layoutParams.width = WindowUtils.getScreenWidth(mContext);
layoutParams.height = WindowUtils.getScreenHeight(mContext);
}
Logger.d("ShareDialog", "width: " + layoutParams.width + " height: " + layoutParams.height);
//后面变暗区域透明...
layoutParams.dimAmount = 0;
layoutParams.x = 0;
layoutParams.y = 0;
initView();
initListener();
windowManager.addView(body, layoutParams);
isShown = true;
}
}
// public void show(){
// Logger.d(TAG,"使用windowManager实现");
// if (!isShown) {
// windowManager = (WindowManager) mContext.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
// WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// } else {
// layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
// }
// layoutParams.format = PixelFormat.TRANSLUCENT;
// layoutParams.gravity = Gravity.START | Gravity.TOP;
//// mWindowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
// // FLAG_LAYOUT_IN_SCREEN将window放置在整个屏幕之内,无视其他的装饰(比如状态栏) FLAG_NOT_TOUCH_MODAL不阻塞事件传递到后面的窗口
// layoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
// if (CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X) {
// layoutParams.width = 1920;
// layoutParams.height = 1080;
// }else {
// layoutParams.width = WindowUtils.getScreenWidth(mContext);
// layoutParams.height = WindowUtils.getScreenHeight(mContext);
// }
// Logger.d("ShareDialog", "width: " + layoutParams.width + " height: " + layoutParams.height);
// //后面变暗区域透明...
// layoutParams.dimAmount = 0;
// layoutParams.x = 0;
// layoutParams.y = 0;
// initView();
// initListener();
// windowManager.addView(body, layoutParams);
// isShown = true;
// }
// }
public void dismiss(){
if (isShown && windowManager != null && body != null) {
windowManager.removeViewImmediate(body);
windowManager = null;
isShown = false;
}
}
// public void dismiss(){
// if (isShown && windowManager != null && body != null) {
// windowManager.removeViewImmediate(body);
// windowManager = null;
// isShown = false;
// }
// }
}