content: package com.aishang5wpj.juhenews.app;
  
  import android.content.Context;
  import android.os.Bundle;
  import android.text.TextUtils;
  import android.view.MotionEvent;
  import android.view.View;
  import android.view.inputmethod.InputMethodManager;
  import android.widget.EditText;
  import android.widget.Toast;
  
  import me.imid.swipebacklayout.lib.SwipeBackLayout;
  import me.imid.swipebacklayout.lib.app.SwipeBackActivity;
  
  public abstract class BaseActivity extends SwipeBackActivity implements IInit {
      private SwipeBackLayout mSwipeBackLayout;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          mSwipeBackLayout = getSwipeBackLayout();
          mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);
      }
  
      protected void disableSwipeback() {
          mSwipeBackLayout.setEdgeTrackingEnabled(0);
      }
  
      @Override
      protected void onPostCreate(Bundle savedInstanceState) {
          super.onPostCreate(savedInstanceState);
  
          if (this instanceof IInit) {
              IInit iInit = this;
              iInit.onInitViews();
              iInit.onInitListeners();
              iInit.onInitData();
          }
      }
  
      protected void t(String msg) {
          if (!TextUtils.isEmpty(msg)) {
              Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
          }
      }
  
      @Override
      public boolean dispatchTouchEvent(MotionEvent ev) {
          if (ev.getAction() == MotionEvent.ACTION_DOWN) {
              View v = getCurrentFocus();
              if (isShouldHideInput(v, ev)) {
  
                  InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                  if (imm != null) {
                      imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                  }
              }
              return super.dispatchTouchEvent(ev);
          }
          // 必不可少，否则所有的组件都不会有TouchEvent了
          if (getWindow().superDispatchTouchEvent(ev)) {
              return true;
          }
          return onTouchEvent(ev);
      }
  
      public boolean isShouldHideInput(View v, MotionEvent event) {
          if (v != null && (v instanceof EditText)) {
              int[] leftTop = {0, 0};
              // 获取输入框当前的location位置
              v.getLocationInWindow(leftTop);
              int left = leftTop[0];
              int top = leftTop[1];
              int bottom = top + v.getHeight();
              int right = left + v.getWidth();
              if (event.getX() > left && event.getX() < right && event.getY() > top && event.getY() < bottom) {
                  // 点击的是输入框区域，保留点击EditText的事件
                  return false;
              } else {
                  return true;
              }
          }
          return false;
      }
  
      protected boolean checkOk(EditText... editTexts) {
  
          for (EditText editText : editTexts) {
              if (TextUtils.isEmpty(editText.getText().toString())) {
                  return false;
              }
          }
          return true;
      }
  }
  