wjc
2023-06-28 975b91521a04e159f45fb34fc7b55afbf455f7f5
app/src/main/java/com/hdl/photovoltaic/base/BaseActivity.java
@@ -9,10 +9,15 @@
import androidx.appcompat.app.AppCompatActivity;
import com.hdl.photovoltaic.R;
import com.hdl.photovoltaic.bean.BaseEventBus;
import com.hdl.photovoltaic.listener.BaseView;
import com.hdl.photovoltaic.other.HdlThreadLogic;
import com.hdl.photovoltaic.utils.AppManagerUtils;
import com.hdl.photovoltaic.widget.LoadingDialog;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
public abstract class BaseActivity extends AppCompatActivity implements BaseView {
@@ -35,6 +40,8 @@
            throw new RuntimeException("getContentView() should be a @LayoutRes or a View");
        }
        onBindView(savedInstanceState);
        //注册EventBus
        registerEventBus();
    }
@@ -87,9 +94,28 @@
        super.onDestroy();
        //隐藏Loading
        hideLoading();
        //注销EventBus
        unregisterEventBus();
    }
    protected void unregisterEventBus() {
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }
    protected void registerEventBus() {
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
    }
    @Subscribe(threadMode = ThreadMode.POSTING)
    public void onEventMessage(BaseEventBus eventBus) {
    }
    /**
     * 显示View
     *