1 Star 0 Fork 224

Hami小熊 / DoraemonKit

forked from DiDi-opensource / DoraemonKit 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
android_en_guide.md 2.41 KB
一键复制 编辑 原始数据 按行查看 历史
jackjintai 提交于 2019-11-14 10:42 . modify:

Document

1. Dependency

dependencies {
	...
    debugImplementation 'com.didichuxing.doraemonkit:doraemonkit:2.0.1'
    releaseImplementation 'com.didichuxing.doraemonkit:doraemonkit-no-op:2.0.1'
    ...
}

Please use the latest release

2. Install

Install DoraemonKit in Application::onCreate().

@Override
public void onCreate() {
	...
    DoraemonKit.install(application)
     
    // for web container debug, optional
    DoraemonKit.setWebDoorCallback(new WebDoorManager.WebDoorCallback() {
    @Override
    public void overrideUrlLoading(Context context, String s) {
        // use your web container open the link
    }
    ...
} 

3. Network Monitor(Optional)

Add a dependency in build.gradle in root of host project as following.

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    dependencies {
        ...
        classpath 'com.github.franticn:gradle_plugin_android_aspectjx:2.0.6'
        ...
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

Apply plugin in application module of build.gradle

...
apply plugin: 'android-aspectjx'
dependencies {
	...
    debugImplementation 'com.didichuxing.doraemonkit:doraemonkit-aop:2.0.1'
    ...
}

4. Custom Component(Optional)

Define a class implement the interface IKit,the interface describe a component in DoraemonKit panel.

An environment switch component can be defined as following.

public class EnvSwitchKit implements IKit {
    @Override
    public int getCategory() {
        return Category.BIZ;
    }
 
    @Override
    public int getName() {
        return R.string.bh_env_switch;
    }
 
    @Override
    public int getIcon() {
        return R.drawable.bh_roadbit;
    }
 
    @Override
    public void onClick(Context context) {
        DebugService service = ServiceManager.getInstance().getService(context, DebugService.class);
        PageManager.getInstance().startFragment(service.getContainer(), EnvSwitchFragment.class);
    }
 
    @Override
    public void onAppInit(Context context) {
    
    }
}

Register the environment switch component when DoraemonKit installed.

@Override
public void onCreate() {
    kits.add(new EnvSwitchKit());
    DoraemonKit.install(application, kits);
    ...
}
Java
1
https://gitee.com/lamproot/DoraemonKit.git
git@gitee.com:lamproot/DoraemonKit.git
lamproot
DoraemonKit
DoraemonKit
master

搜索帮助