From 1f3acf4c29f367e40a3f589b51176ed24e28948f Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期二, 02 九月 2025 17:54:42 +0800
Subject: [PATCH] 2025年09月02日17:54:39
---
app/src/main/java/com/hdl/photovoltaic/base/BaseFragment.java | 151 ++++++++++++++++----------------------------------
1 files changed, 49 insertions(+), 102 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/base/BaseFragment.java b/app/src/main/java/com/hdl/photovoltaic/base/BaseFragment.java
index 5598bea..8eee042 100644
--- a/app/src/main/java/com/hdl/photovoltaic/base/BaseFragment.java
+++ b/app/src/main/java/com/hdl/photovoltaic/base/BaseFragment.java
@@ -3,11 +3,9 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.WindowManager;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
@@ -16,9 +14,16 @@
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Lifecycle;
+import com.hdl.photovoltaic.R;
import com.hdl.photovoltaic.listener.BaseView;
+import com.hdl.photovoltaic.other.HdlThreadLogic;
+import com.hdl.photovoltaic.widget.LoadingDialog;
+import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
+
import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
import java.util.Locale;
@@ -27,9 +32,7 @@
private boolean isFirst = true;
protected FragmentActivity _mActivity;
protected View mContainerView;
-// private LoadingDialog loadingDialog;
-// private LoadingDialog loadingGetDataDialog;
-// private DeviceLoadingDialog deviceLoadingDialog;
+ private LoadingDialog loadingDialog;
@Override
public void onAttach(@NonNull Context context) {
@@ -46,7 +49,7 @@
view = inflater.inflate((int) getContentView(), container, false);
} else if (getContentView() instanceof View) {
view = (View) getContentView();
- FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
+ ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
view.setLayoutParams(layoutParams);
} else {
view = null;
@@ -58,6 +61,7 @@
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
+ view.setClickable(true);
view.postDelayed(new Runnable() {
@Override
public void run() {
@@ -90,7 +94,8 @@
protected void onLazyInitView(Bundle savedInstanceState) {
onBindView(savedInstanceState);
-// registerEventBus();
+ //娉ㄥ唽EventBus
+ registerEventBus();
}
@@ -99,7 +104,10 @@
super.onDestroyView();
_mActivity = null;
isFirst = true;
-// unregisterEventBus();
+ //闅愯棌Loading
+ hideLoading();
+ //娉ㄩ攢EventBus
+ unregisterEventBus();
}
@@ -115,10 +123,15 @@
}
}
-// @Subscribe(threadMode = ThreadMode.MAIN)
-// public void onEventMessage(BaseEvent event) {
-//
-// }
+ /**
+ * 鏀跺埌EventBUs閫氱煡
+ *
+ * @param eventBus 鏁版嵁
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onEventMessage(BaseEventBus eventBus) {
+
+ }
/**
* 鏄剧ずView
@@ -154,118 +167,52 @@
}
}
- /* *//**
+
+ /**
* 鑾峰彇LoadingDialog
*
- * @return
- *//*
+ * @return LoadingDialog
+ */
protected LoadingDialog getLoadingDialog() {
if (loadingDialog == null && _mActivity != null) {
- loadingDialog = new LoadingDialog(_mActivity, R.style.loading_dialog);
+ loadingDialog = new LoadingDialog(_mActivity, R.style.Custom_Dialog);
}
return loadingDialog;
}
- public LoadingDialog getLoadingGetDataDialog() {
- if (loadingGetDataDialog == null && _mActivity != null) {
- loadingGetDataDialog = new LoadingDialog(_mActivity, R.style.loading_dialog);
- }
- return loadingGetDataDialog;
- }
-
-
- *//**
- * 鑾峰彇DeviceLoadingDialog
- *
- * @return
- *//*
- protected DeviceLoadingDialog getDeviceLoadingDialog() {
- if (deviceLoadingDialog == null && _mActivity != null) {
- deviceLoadingDialog = new DeviceLoadingDialog(_mActivity, R.style.loading_dialog);
- }
- return deviceLoadingDialog;
- }
-
- *//**
+ /**
* 寮�濮婰oading
- *//*
- public void showLoading() {
+ */
+ protected void showLoading() {
+ getLoadingDialog().setText("");
getLoadingDialog().start();
}
- *//**
+ /**
* 寮�濮婰oading
- *//*
- public void showDeviceLoading() {
- getDeviceLoadingDialog().start();
- }
-
-
- *//**
- * 寮�濮婰oading
- *//*
+ *
+ * @param mes 鑷畾涔夋枃鏈�
+ */
protected void showLoading(String mes) {
getLoadingDialog().start();
getLoadingDialog().setText(mes);
}
-
- *//**
- * 寮�濮婰oading
- *//*
- protected void showGetDataLoading(String mes) {
- getLoadingGetDataDialog().startTouchNotGone();
- getLoadingGetDataDialog().setText(mes);
- }
-
-
- *//**
- * 寮�濮婰oading
- *//*
- protected void showDeviceLoading(String mes) {
- getDeviceLoadingDialog().start();
- getDeviceLoadingDialog().setText(mes);
- }
-
- *//**
- * 鍋滄闅愯棌Loading
- *//*
- protected void hideLoading() {
- if (loadingDialog != null && loadingDialog.isShowing()) {
- loadingDialog.stop();
- }
- }
-
- *//**
- * 鍋滄闅愯棌Loading
- *//*
- protected void hideGetDataLoading() {
- if (loadingGetDataDialog != null && loadingGetDataDialog.isShowing()) {
- loadingGetDataDialog.stop();
- }
- }
-
- */
-
/**
* 鍋滄闅愯棌Loading
- *//*
- protected void hideDeviceLoading() {
- if (deviceLoadingDialog != null && deviceLoadingDialog.isShowing()) {
- deviceLoadingDialog.stop();
- }
- }*/
-
- //鐢ㄤ簬popwindow鏄剧ず闅愯棌鏃跺�欒儗鏅殑棰滆壊鏇存崲
- protected void backgroundAlpha(float bgAlpha) {
- if (_mActivity != null) {
- WindowManager.LayoutParams lp = _mActivity.getWindow().getAttributes();
- _mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
- lp.alpha = bgAlpha; //0.0-1.0
- _mActivity.getWindow().setAttributes(lp);
- }
+ */
+ protected void hideLoading() {
+ HdlThreadLogic.runMainThread(new Runnable() {
+ @Override
+ public void run() {
+ if (loadingDialog != null && loadingDialog.isShowing()) {
+ loadingDialog.stop();
+ }
+ }
+ }, null, null);
}
+
public static boolean isZh(Context context) {
Locale locale = context.getResources().getConfiguration().locale;
String language = locale.getLanguage();
--
Gitblit v1.8.0