makcar/app/src/main/java/com/aros/apron/base/BaseActivity.java

50 lines
1.1 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.aros.apron.base;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.aros.apron.tools.AppManager;
import org.greenrobot.eventbus.EventBus;
public abstract class BaseActivity extends AppCompatActivity {
/**
* activity堆栈管理
*/
protected AppManager appManager = AppManager.getAppManager();
protected String TAG;
protected boolean useEventBus = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
loggerSimpleName();
if (useEventBus()) {
EventBus.getDefault().register(this);
}
appManager.addActivity(this);
}
public abstract boolean useEventBus();
public void loggerSimpleName() {
TAG = getClass().getSimpleName();
// Log.e("Aros","当前界面 "+ TAG);
}
@Override
protected void onDestroy() {
super.onDestroy();
// 从栈中移除activity
appManager.finishActivity(this);
if (useEventBus == true) {
EventBus.getDefault().unregister(this);
}
}
}