Android调试抽屉
使用调试抽屉加快开发速度
特性
DeviceModule - 有关你的设备的通用信息
BuildModule - 应用程序生成信息
SettingsModule - 开开开发人员,电池,默认设置,开放应用信息和可以能直接卸载应用程序
NetworkModule - 启用/禁用 Wifi,移动或者蓝牙
OkHttpModule,OkHttp3Module - 关于http客户端的通用信息( 需要额外的依赖关系)
PicassoModule - 映像下载和缓存统计( 需要额外的依赖关系)
GlideModule - 映像下载和缓存统计( 需要额外的依赖关系)
ScalpelModule - 在你的应用程序( 需要额外的依赖项) 下发现层的工具。 感谢 ebabel 贡献。
LocationModule - 公共位置信息( 需要额外的依赖关系)
TimberModule - 具有共享功能( 需要额外的依赖项)的日志查看器。 感谢 AntonyGolovin 贡献。
ActionsModule - 任何依赖于上下文的操作( ButtonAction,SwitchAction,SpinnerAction )
FpsModule - 使用编舞来测量 FPS ( 需要额外的依赖)
LogsModule - Logcat和OkHttp网络调用拦截器( 需要额外的依赖项)。 片尾 Sloy
NetworkQualityModule - 网络调用的错误/延迟速率管理( 需要额外的依赖项)。 片尾 Sloy
待办事项获取屏幕截图功能
欢迎你给我们推荐模块 !
启动
添加Gradle依赖项:DebugDrawerdependencies {
debugImplementation 'io.palaima.debugdrawer:debugdrawer:0.8.0' releaseImplementation 'io.palaima.debugdrawer:debugdrawer-no-op:0.8.0'}DebugViewdependencies {
debugImplementation 'io.palaima.debugdrawer:debugdrawer-view:0.8.0' releaseImplementation 'io.palaima.debugdrawer:debugdrawer-view-no-op:0.8.0'}
BuildModule,DeviceModule,SettingsModule,NetworkModuledependencies {
implementation 'io.palaima.debugdrawer:debugdrawer-commons:0.8.0'}
ActionsModule - ButtonAction,SwitchAction,SpinnerActiondependencies {
implementation 'io.palaima.debugdrawer:debugdrawer-actions:0.8.0'}
需要 OkHttpModule,OkHttp3ModuleOkHttp 库dependencies {
implementation 'io.palaima.debugdrawer:debugdrawer-okhttp:0.8.0' implementation 'io.palaima.debugdrawer:debugdrawer-okhttp3:0.8.0'}
PicassoModule库要求dependencies {
implementation 'io.palaima.debugdrawer:debugdrawer-picasso:0.8.0'}
需要 GlideModule滑翔库dependencies {
implementation 'io.palaima.debugdrawer:debugdrawer-glide:0.8.0'}
ScalpelModule手术刀库要求库dependencies {
implementation 'io.palaima.debugdrawer:debugdrawer-scalpel:0.8.0'}
LocationModuledependencies {
implementation 'io.palaima.debugdrawer:debugdrawer-location:0.8.0'}
需要 TimberModule木材库dependencies {
implementation 'io.palaima.debugdrawer:debugdrawer-timber:0.8.0'}
FpsModuleTakt库要求dependencies {
implementation 'io.palaima.debugdrawer:debugdrawer-fps:0.8.0'}
LogsModuleLynx & 卡盘库要求dependencies {
implementation 'io.palaima.debugdrawer:debugdrawer-logs:0.8.0'}
需要 NetworkQualityModuleOkHttp 库dependencies {
implementation 'io.palaima.debugdrawer:debugdrawer-network-quality:0.8.0'}
把所有
1在 Activity 中初始化
你可以根据需要使用 DebugDrawer 或者 DebugView示例使用 DebugDrawer ( 用于 DebugView 初始化检查DebugViewActivity )privateDebugDrawer debugDrawer;
@Overrideprotectedvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//...SwitchAction switchAction =newSwitchAction("Test switch", newSwitchAction.Listener() {
@OverridepublicvoidonCheckedChanged(booleanvalue) {
Toast.makeText(MainActivity.this, "Switch checked", Toast.LENGTH_LONG).show();
}
});
ButtonAction buttonAction =newButtonAction("Test button", newButtonAction.Listener() {
@OverridepublicvoidonClick() {
Toast.makeText(MainActivity.this, "Button clicked", Toast.LENGTH_LONG).show();
}
});
SpinnerAction spinnerAction =newSpinnerAction<>(
Arrays.asList("First", "Second", "Third"),
newSpinnerAction.OnItemSelectedListener() {
@OverridepublicvoidonItemSelected(Stringvalue) {
Toast.makeText(MainActivity.this, "Spinner item selected - "+ value, Toast.LENGTH_LONG).show();
}
}
);
debugDrawer =newDebugDrawer.Builder(this)
. modules(
newActionsModule(switchAction, buttonAction, spinnerAction),
newFpsModule(Takt.stock(getApplication())),
newLocationModule(this),
newScalpelModule(this),
newTimberModule(),
newOkHttp3Module(okHttpClient),
newPicassoModule(picasso),
newGlideModule(Glide.get(getContext())),
newDeviceModule(this),
newBuildModule(this),
newNetworkModule(this),
newSettingsModule(this)
).build();
}
2.TimberModule
不要忘记在应用程序类中生成需要的日志树。 TimberModule 中存储在 LumberYard 类中的树。
应用程序类示例:publicclassDebugDrawerApplicationextendsApplication {
@OverridepublicvoidonCreate() {
super.onCreate();
LumberYard lumberYard =LumberYard.getInstance(this);
lumberYard.cleanUp();
Timber.plant(lumberYard.tree());
Timber.plant(newTimber.DebugTree());
}
}
创建和发布你自己的模块
添加 implementation 'io.palaima.debugdrawer:debugdrawer-base:0.8.0' 你的依赖关系
模块必须实现 DebugModule 接口或者扩展 DebugModuleAdapter 如果你不需要生命周期钩子publicinterfaceDebugModule {
/*** Creates module view*/@NonNullViewonCreateView(@NonNullLayoutInflaterinflater, @NonNullViewGroupparent);
/*** Override this method if you need to refresh* some information when drawer is opened*/voidonOpened();
/*** Override this method if you need to stop* some actions when drawer is closed*/voidonClosed();
/*** Override this method if you need to start* some processes*/voidonResume();
/*** Override this method if you need to do* some clean up*/voidonPause();
/*** Override this method if you need to start* some processes that would be killed when* onStop() is called* E.g. register receivers*/voidonStart();
/*** Override this method if you need to do* some clean up when activity goes to foreground.* E.g. unregister receivers*/voidonStop();
}
示例
你可以克隆该项目并自己编译它。
想要贡献欢迎? !
请求请求fork的repo 并从 dev 创建分支。
如果你已经更改了 api,请更新文档。
确保代码 lints。
必要时更改 README.md
编码风格打开大括号以显示在与代码相同的行上
所有变量必须是 camelCase
所有资源必须具有 dd_ 前缀
由
Credits
许可证Copyright 2016 Mantas Palaima.
Licensed under the Apache License, Version 2.0 (the"License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an"AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.