content: package com.mindorks.snaphelperexample.ui.base;
  
  import android.annotation.TargetApi;
  import android.app.ProgressDialog;
  import android.content.pm.PackageManager;
  import android.os.Build;
  import android.support.v7.app.AppCompatActivity;
  
  import com.mindorks.snaphelperexample.utils.DialogUtils;
  
  /**
   * Created by amitshekhar on 13/01/17.
   */
  
  public abstract class BaseActivity extends AppCompatActivity implements MvpView {
  
      private ProgressDialog progressDialog;
  
      @TargetApi(Build.VERSION_CODES.M)
      public void requestPermissionsSafely(String[] permissions, int requestCode) {
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
              requestPermissions(permissions, requestCode);
          }
      }
  
      @TargetApi(Build.VERSION_CODES.M)
      public boolean hasPermission(String permission) {
          return Build.VERSION.SDK_INT < Build.VERSION_CODES.M ||
                  checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED;
      }
  
      @Override
      public void showLoading() {
          hideLoading();
          progressDialog = DialogUtils.showLoadingDialog(this);
      }
  
      @Override
      public void hideLoading() {
          if (progressDialog != null && progressDialog.isShowing()) {
              progressDialog.cancel();
          }
      }
  
  }
  