| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- package eVVM.apk.common;
- import android.graphics.drawable.Drawable;
- import android.os.Bundle;
- import android.support.annotation.DrawableRes;
- import android.support.annotation.NonNull;
- import android.support.annotation.Nullable;
- import android.support.annotation.StringRes;
- import android.util.Log;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import com.hjq.bar.TitleBar;
- import com.hjq.toast.ToastUtils;
- import butterknife.ButterKnife;
- import butterknife.Unbinder;
- import eVVM.apk.helper.DebugUtils;
- import eVVM.apk.other.EventBusManager;
- import eVVM.apk.other.StatusManager;
- public abstract class MyLazyFragment<A extends MyActivity> extends UILazyFragment<A> {
- private Unbinder mButterKnife; // View注解
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View view = super.onCreateView(inflater, container, savedInstanceState);
- mButterKnife = ButterKnife.bind(this, view);
- return view;
- }
- @Override
- protected void initFragment() {
- super.initFragment();
- EventBusManager.register(this);
- }
- @Override
- public void onDestroy() {
- super.onDestroy();
- if (mButterKnife != null) {
- mButterKnife.unbind();
- }
- EventBusManager.unregister(this);
- }
- @Nullable
- public TitleBar getTitleBar() {
- if (getTitleId() > 0 && findViewById(getTitleId()) instanceof TitleBar) {
- return findViewById(getTitleId());
- }
- return null;
- }
- /**
- * 显示吐司
- */
- public void toast(CharSequence s) {
- ToastUtils.show(s);
- }
- public void toast(int id) {
- ToastUtils.show(id);
- }
- public void toast(Object object) {
- ToastUtils.show(object);
- }
- /**
- * 打印日志
- */
- public void log(Object object) {
- if (DebugUtils.isDebug(getBindingActivity())) {
- Log.v(getClass().getSimpleName(), object != null ? object.toString() : "null");
- }
- }
- @Override
- public void onResume() {
- super.onResume();
- //UmengClient.onResume(this);
- }
- @Override
- public void onPause() {
- // UmengClient.onPause(this);
- super.onPause();
- }
- private final StatusManager mStatusManager = new StatusManager();
- /**
- * 显示加载中
- */
- public void showLoading() {
- mStatusManager.showLoading(getBindingActivity());
- }
- /**
- * 显示加载完成
- */
- public void showComplete() {
- mStatusManager.showComplete();
- }
- /**
- * 显示空提示
- */
- public void showEmpty() {
- mStatusManager.showEmpty(getView());
- }
- /**
- * 显示错误提示
- */
- public void showError() {
- mStatusManager.showError(getView());
- }
- /**
- * 显示自定义提示
- */
- public void showLayout(@DrawableRes int iconId, @StringRes int textId) {
- mStatusManager.showLayout(getView(), iconId, textId);
- }
- public void showLayout(Drawable drawable, CharSequence hint) {
- mStatusManager.showLayout(getView(), drawable, hint);
- }
- }
|