| | |
| | | import com.hdl.photovoltaic.listener.BaseView; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | | import com.hdl.photovoltaic.utils.LocalManageUtil; |
| | | 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; |
| | | |
| | | |
| | | public abstract class BaseActivity extends AppCompatActivity implements BaseView { |
| | |
| | | @Override |
| | | protected void onCreate(@Nullable Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | LocalManageUtil.changeAppLanguage("en", this); |
| | | _mActivity = this; |
| | | Object content = getContentView(); |
| | | //添加Activity到堆栈 |
| | |
| | | throw new RuntimeException("getContentView() should be a @LayoutRes or a View"); |
| | | } |
| | | onBindView(savedInstanceState); |
| | | //注册EventBus |
| | | registerEventBus(); |
| | | |
| | | } |
| | | |
| | |
| | | super.onDestroy(); |
| | | //隐藏Loading |
| | | hideLoading(); |
| | | //注销EventBus |
| | | unregisterEventBus(); |
| | | //移除Activity |
| | | AppManagerUtils.getAppManager().removeActivity(this); |
| | | |
| | | } |
| | | |
| | | 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 |
| | | * |