Skip to content

Commit

Permalink
Dokit库接入
Browse files Browse the repository at this point in the history
  • Loading branch information
running-libo committed Apr 27, 2021
1 parent fd13cf6 commit 6281808
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 43 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.didi.dokit'

android {
compileSdkVersion 30
defaultConfig {
applicationId "com.bytedance.tiktok"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
versionCode 10
versionName "2.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -30,6 +31,41 @@ android {
}
}

dokitExt {
//通用设置
comm {
//地图经纬度开关
gpsSwitch true
//网络开关
networkSwitch true
//大图开关
bigImgSwitch true
//webView js 抓包
webViewSwitch true
}

slowMethod {
//调用栈模式配置 对应gradle.properties中DOKIT_METHOD_STRATEGY=0
stackMethod {
//默认值为 5ms 小于该值的函数在调用栈中不显示
thresholdTime 10
//调用栈函数入口 千万不要用我默认的配置 如果有特殊需求修改成项目中自己的入口 假如不需要可以去掉该字段
enterMethods = ["com.didichuxing.doraemondemo.MainDebugActivity.test1"]
//黑名单 粒度最小到类 暂不支持到方法 千万不要用我默认的配置 如果有特殊需求修改成项目中自己的入口 假如不需要可以去掉该字段
methodBlacklist = ["com.facebook.drawee.backends.pipeline.Fresco"]
}
//普通模式配置 对应gradle.properties中DOKIT_METHOD_STRATEGY=1
normalMethod {
//默认值为 500ms 小于该值的函数在运行时不会在控制台中被打印
thresholdTime 500
//需要针对函数插装的包名 千万不要用我默认的配置 如果有特殊需求修改成项目中自己的项目包名 假如不需要可以去掉该字段
packageNames = ["com.didichuxing.doraemondemo"]
//不需要针对函数插装的包名&类名 千万不要用我默认的配置 如果有特殊需求修改成项目中自己的项目包名 假如不需要可以去掉该字段
methodBlacklist = ["com.didichuxing.doraemondemo.dokit"]
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
Expand Down Expand Up @@ -58,11 +94,11 @@ dependencies {
implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

// implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
// implementation 'androidx.lifecycle:lifecycle-viewmodel:2.0.0'
// implementation 'androidx.lifecycle:lifecycle-livedata:2.0.0'
// implementation 'me.tatarka.bindingcollectionadapter2:bindingcollectionadapter:3.2.0'
// implementation 'me.tatarka.bindingcollectionadapter2:bindingcollectionadapter-recyclerview:3.2.0'
debugImplementation 'com.didichuxing.doraemonkit:dokitx:3.3.5'
releaseImplementation 'com.didichuxing.doraemonkit:dokitx-no-op:3.3.5'

// debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.5'

}
repositories {
mavenCentral()
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/bytedance/tiktok/application/App.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bytedance.tiktok.application

import android.app.Application
import com.didichuxing.doraemonkit.DoraemonKit

/**
* create by libo
Expand All @@ -10,5 +11,7 @@ import android.app.Application
class App : Application() {
override fun onCreate() {
super.onCreate()

DoraemonKit.install(this, "pId")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.util.*
* create on 2020/5/19
* description 公共viewPageradapter
*/
class CommPagerAdapter(fm: FragmentManager?, private val items: ArrayList<out Fragment>, private val mTitles: Array<String>) : FragmentStatePagerAdapter(fm) {
class CommPagerAdapter(fm: FragmentManager?, private val items: ArrayList<out Fragment>, private val mTitles: Array<String>) : FragmentStatePagerAdapter(fm!!) {
override fun getCount(): Int {
return if (items.size == 0) 0 else items.size
}
Expand Down

This file was deleted.

2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ buildscript {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

classpath 'com.didichuxing.doraemonkit:dokitx-plugin:3.3.5'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
17 changes: 17 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,20 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

// dokit全局配置
// 插件开关
DOKIT_PLUGIN_SWITCH=true
// DOKIT读取三方库会和booster冲突 如果你的项目中也集成了booster 建议将开关改成false
DOKIT_THIRD_LIB_SWITCH=true
// 插件日志
DOKIT_LOG_SWITCH=true
// 自定义Webview的全限定名 主要是作用于h5 js抓包和数据mock
DOKIT_WEBVIEW_CLASS_NAME=com/didichuxing/doraemonkit/widget/webview/MyWebView
// dokit 慢函数开关
DOKIT_METHOD_SWITCH=true
// dokit 函数调用栈层级
DOKIT_METHOD_STACK_LEVEL=4
// 0:默认模式 打印函数调用栈 需添加指定入口 默认为application onCreate 和attachBaseContext
// 1:普通模式 运行时打印某个函数的耗时 全局业务代码函数插入
DOKIT_METHOD_STRATEGY=0

0 comments on commit 6281808

Please sign in to comment.