Skip to content

Latest commit

 

History

History
124 lines (109 loc) · 4.82 KB

File metadata and controls

124 lines (109 loc) · 4.82 KB

gradle引入方法

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
        implementation 'com.github.dongyonghui:CommonLib:2.0'
}

初始化

在Application继承BaseApplication,并复写重新登录方法:

    @Override
    public void reLogin() {
        SPEntity spEntity = EasySharedPreferences.load(SPEntity.class);
        spEntity.loginResponseBean = null;
        spEntity.commit();
        //如果重新登录不需要退出所有页面,可删除下面这行
        AppExit();
        Intent intent = new Intent(this, LoginActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }

初始化日志和网络

        //是否启用日志
        EasyLog.Companion.getDEFAULT().setEnable(true);
        
        private void initHttp() {
                //设置请求头
                HttpHeaders headers = getCommonHttpHeaders();
                //设置请求参数
                EasyHttp.getInstance()
                        .debug("GouKu", BuildConfig.DEBUG)
                        .addCommonHeaders(headers)//设置全局公共头
                        .addInterceptor(new MyHeaderTokenInterceptor(headers));//token追加拦截器
        
            }
        
        public HttpHeaders getCommonHttpHeaders() {
            HttpHeaders headers = new HttpHeaders();
            headers.put("User-Agent", SystemInfoUtils.getUserAgent(this));
            headers.put("Gouku-App-Origin", "31");
            headers.put("Content-Type", "application/json;charset=UTF-8");
            return headers;
        }

使用MVP: Activity 继承 BaseMVPActivity Presenter 继承 MVPPresenter 然后在Activity中实例化Presenter

RecyclerView适配器基类: 普通列表适配器继承 BaseQuickRecyclerViewAdapter 分组列表适配器继承 BaseSectionQuickRecyclerViewAdapter

ListView适配器基类: 继承 BaseListViewAdapter

添加权限

  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.CAMERA" />
    

目录索引

点我查看完整使用文档

点我查看完整使用文档

点我查看完整使用文档

点我查看完整使用文档

点我查看完整使用文档

点我查看完整使用文档

点我查看完整使用文档

点我查看完整使用文档

点我查看完整使用文档

点我查看完整使用文档

点我查看完整使用文档

点我查看完整使用文档

点我查看完整使用文档

点我查看完整使用文档

点我查看完整使用文档