// Path: app/src/main/java/com/tsy/leanote/MyApplication.java
// public class MyApplication extends Application {
// 
//     private static MyApplication mMyApplication;
//     private Context mContext;
//     protected MyOkHttp mMyOkHttp;
//     private DaoSession mDaoSession;
//     private UserInfo mUserInfo;         //当前用户
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
// 
//         //内存泄露分析初始化
//         if(BuildConfig.DEBUG) {
//             if (LeakCanary.isInAnalyzerProcess(this)) {
//                 // This process is dedicated to LeakCanary for heap analysis.
//                 // You should not init your app in this process.
//                 return;
//             }
//             LeakCanary.install(this);
//         }
// 
//         //umeng统计初始化
//         if(!TextUtils.isEmpty(BuildConfig.UMENG_APPKEY)) {
//             MobclickAgent.setScenarioType(getApplicationContext(), MobclickAgent.EScenarioType.E_UM_NORMAL);
//             UMConfigure.init(this, BuildConfig.UMENG_APPKEY, "github", UMConfigure.DEVICE_TYPE_PHONE, null);
//         }
// 
//         mMyApplication = this;
//         mContext = getApplicationContext();
// 
//         //数据库初始化
//         DBHelper devOpenHelper = new DBHelper(getApplicationContext(), "leanote.db");
//         DaoMaster daoMaster = new DaoMaster(devOpenHelper.getWritableDb());
//         mDaoSession = daoMaster.newSession();
// 
//         //loading初始化
//         LoadSir.beginBuilder()
//                 .addCallback(new ErrorCallback())
//                 .addCallback(new EmptyCallback())
//                 .addCallback(new LoadingCallback())
//                 .commit();
//     }
// 
//     private void initMyOkHttp() {
//         if(BuildConfig.DEBUG) {
//             //自定义OkHttp
//             HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
//             logging.setLevel(HttpLoggingInterceptor.Level.BODY);
// 
//             OkHttpClient okHttpClient = new OkHttpClient.Builder()
//                     .addInterceptor(logging)            //设置开启log
//                     .build();
//             mMyOkHttp = new MyOkHttp(okHttpClient);
//         } else {
//             mMyOkHttp = new MyOkHttp();
//         }
//     }
// 
//     /**
//      * myokhttp
//      * @return
//      */
//     public MyOkHttp getMyOkHttp() {
//         if(mMyOkHttp == null) {
//             initMyOkHttp();
//         }
// 
//         return mMyOkHttp;
//     }
// 
//     /**
//      * 获取全局Application
//      * @return
//      */
//     public static synchronized MyApplication getInstance() {
//         return mMyApplication;
//     }
// 
//     /**
//      * 获取ApplicationContext
//      * @return
//      */
//     public Context getContext() {
//         return mContext;
//     }
// 
//     /**
//      * 获取dao session
//      * @return
//      */
//     public DaoSession getDaoSession() {
//         return mDaoSession;
//     }
// 
//     public UserInfo getUserInfo() {
//         return mUserInfo;
//     }
// 
//     public void setUserInfo(UserInfo userInfo) {
//         mUserInfo = userInfo;
//     }
// }


import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import com.tsy.leanote.MyApplication;
import com.tsy.leanote.R;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import pub.devrel.easypermissions.AppSettingsDialog;
import pub.devrel.easypermissions.EasyPermissions;
    protected void performCodeWithPermission(@NonNull String rationale,
                                             final int requestCode, @NonNull String[] perms, @NonNull BaseActivity.PermissionCallback callback) {
        if (EasyPermissions.hasPermissions(getActivity(), perms)) {
            callback.hasPermission(Arrays.asList(perms));
        } else {
            if(mPermissonCallbacks == null) {
                mPermissonCallbacks = new HashMap<>();
            }
            mPermissonCallbacks.put(requestCode, callback);

            if(mPermissions == null) {
                mPermissions = new HashMap<>();
            }
            mPermissions.put(requestCode, perms);

            EasyPermissions.requestPermissions(this, rationale, requestCode, perms);
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
    }

    @Override
    public void onPermissionsGranted(int requestCode, List<String> perms) {
        if(mPermissonCallbacks == null || !mPermissonCallbacks.containsKey(requestCode)) {
            return;
        }
// Path: app/src/main/java/com/tsy/leanote/MyApplication.java
// public class MyApplication extends Application {
// 
//     private static MyApplication mMyApplication;
//     private Context mContext;
//     protected MyOkHttp mMyOkHttp;
//     private DaoSession mDaoSession;
//     private UserInfo mUserInfo;         //当前用户
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
// 
//         //内存泄露分析初始化
//         if(BuildConfig.DEBUG) {
//             if (LeakCanary.isInAnalyzerProcess(this)) {
//                 // This process is dedicated to LeakCanary for heap analysis.
//                 // You should not init your app in this process.
//                 return;
//             }
//             LeakCanary.install(this);
//         }
// 
//         //umeng统计初始化
//         if(!TextUtils.isEmpty(BuildConfig.UMENG_APPKEY)) {
//             MobclickAgent.setScenarioType(getApplicationContext(), MobclickAgent.EScenarioType.E_UM_NORMAL);
//             UMConfigure.init(this, BuildConfig.UMENG_APPKEY, "github", UMConfigure.DEVICE_TYPE_PHONE, null);
//         }
// 
//         mMyApplication = this;
//         mContext = getApplicationContext();
// 
//         //数据库初始化
//         DBHelper devOpenHelper = new DBHelper(getApplicationContext(), "leanote.db");
//         DaoMaster daoMaster = new DaoMaster(devOpenHelper.getWritableDb());
//         mDaoSession = daoMaster.newSession();
// 
//         //loading初始化
//         LoadSir.beginBuilder()
//                 .addCallback(new ErrorCallback())
//                 .addCallback(new EmptyCallback())
//                 .addCallback(new LoadingCallback())
//                 .commit();
//     }
// 
//     private void initMyOkHttp() {
//         if(BuildConfig.DEBUG) {
//             //自定义OkHttp
//             HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
//             logging.setLevel(HttpLoggingInterceptor.Level.BODY);
// 
//             OkHttpClient okHttpClient = new OkHttpClient.Builder()
//                     .addInterceptor(logging)            //设置开启log
//                     .build();
//             mMyOkHttp = new MyOkHttp(okHttpClient);
//         } else {
//             mMyOkHttp = new MyOkHttp();
//         }
//     }
// 
//     /**
//      * myokhttp
//      * @return
//      */
//     public MyOkHttp getMyOkHttp() {
//         if(mMyOkHttp == null) {
//             initMyOkHttp();
//         }
// 
//         return mMyOkHttp;
//     }
// 
//     /**
//      * 获取全局Application
//      * @return
//      */
//     public static synchronized MyApplication getInstance() {
//         return mMyApplication;
//     }
// 
//     /**
//      * 获取ApplicationContext
//      * @return
//      */
//     public Context getContext() {
//         return mContext;
//     }
// 
//     /**
//      * 获取dao session
//      * @return
//      */
//     public DaoSession getDaoSession() {
//         return mDaoSession;
//     }
// 
//     public UserInfo getUserInfo() {
//         return mUserInfo;
//     }
// 
//     public void setUserInfo(UserInfo userInfo) {
//         mUserInfo = userInfo;
//     }
// }


// Path: app/src/main/java/com/tsy/leanote/base/BaseFragment.java
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import com.tsy.leanote.MyApplication;
import com.tsy.leanote.R;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import pub.devrel.easypermissions.AppSettingsDialog;
import pub.devrel.easypermissions.EasyPermissions;

    protected void performCodeWithPermission(@NonNull String rationale,
                                             final int requestCode, @NonNull String[] perms, @NonNull BaseActivity.PermissionCallback callback) {
        if (EasyPermissions.hasPermissions(getActivity(), perms)) {
            callback.hasPermission(Arrays.asList(perms));
        } else {
            if(mPermissonCallbacks == null) {
                mPermissonCallbacks = new HashMap<>();
            }
            mPermissonCallbacks.put(requestCode, callback);

            if(mPermissions == null) {
                mPermissions = new HashMap<>();
            }
            mPermissions.put(requestCode, perms);

            EasyPermissions.requestPermissions(this, rationale, requestCode, perms);
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
    }

    @Override
    public void onPermissionsGranted(int requestCode, List<String> perms) {
        if(mPermissonCallbacks == null || !mPermissonCallbacks.containsKey(requestCode)) {
            return;
        }
        if(mPermissions == null || !mPermissions.containsKey(requestCode)) {