Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
e90814cd
D
DoraemonKit
项目概览
DiDi
/
DoraemonKit
12 个月 前同步成功
通知
166
Star
19623
Fork
3062
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DoraemonKit
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e90814cd
编写于
1月 04, 2021
作者:
金
金台
提交者:
GitHub
1月 04, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #719 from xiandanin/thirdlib
第三方库信息列表支持实时搜索、排序
上级
f4bf46ae
03ac903f
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
91 addition
and
56 deletion
+91
-56
Android/java/buildSrc/src/main/kotlin/com/didichuxing/doraemonkit/plugin/DoKitPlugin.kt
.../kotlin/com/didichuxing/doraemonkit/plugin/DoKitPlugin.kt
+2
-2
Android/java/buildSrc/src/main/kotlin/com/didichuxing/doraemonkit/plugin/ThirdLibInfo.kt
...kotlin/com/didichuxing/doraemonkit/plugin/ThirdLibInfo.kt
+1
-1
Android/java/buildSrc/src/main/kotlin/com/didichuxing/doraemonkit/plugin/classtransformer/CommTransformer.kt
...ng/doraemonkit/plugin/classtransformer/CommTransformer.kt
+2
-2
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/sysinfo/ThirdLibInfoFragment.java
...chuxing/doraemonkit/kit/sysinfo/ThirdLibInfoFragment.java
+48
-39
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/sysinfo/ThirdLibInfoItemAdapter.java
...xing/doraemonkit/kit/sysinfo/ThirdLibInfoItemAdapter.java
+2
-1
Android/java/doraemonkit/src/main/res/layout/dk_fragment_third_lib_info.xml
...monkit/src/main/res/layout/dk_fragment_third_lib_info.xml
+23
-10
Android/java/doraemonkit/src/main/res/layout/dk_fragment_weak_network.xml
...aemonkit/src/main/res/layout/dk_fragment_weak_network.xml
+1
-1
Android/java/doraemonkit/src/main/res/values-en-rUS/strings.xml
...d/java/doraemonkit/src/main/res/values-en-rUS/strings.xml
+3
-0
Android/java/doraemonkit/src/main/res/values-zh-rCN/strings.xml
...d/java/doraemonkit/src/main/res/values-zh-rCN/strings.xml
+3
-0
Android/java/doraemonkit/src/main/res/values-zh-rTW/strings.xml
...d/java/doraemonkit/src/main/res/values-zh-rTW/strings.xml
+3
-0
Android/java/doraemonkit/src/main/res/values/strings.xml
Android/java/doraemonkit/src/main/res/values/strings.xml
+3
-0
未找到文件。
Android/java/buildSrc/src/main/kotlin/com/didichuxing/doraemonkit/plugin/DoKitPlugin.kt
浏览文件 @
e90814cd
...
...
@@ -14,7 +14,6 @@ import com.didiglobal.booster.gradle.getProperty
import
org.gradle.api.Plugin
import
org.gradle.api.Project
import
org.gradle.api.artifacts.result.ResolvedArtifactResult
import
org.gradle.api.invocation.Gradle
/**
* ================================================
...
...
@@ -149,7 +148,8 @@ class DoKitPlugin : Plugin<Project> {
val
thirdLibInfo
=
ThirdLibInfo
(
fileName
,
DoKitPluginUtil
.
fileSize
(
artifactResult
.
file
,
2
)
artifactResult
.
file
.
length
(),
artifactResult
.
variant
.
displayName
)
DoKitExtUtil
.
THIRD_LIB_INFOS
.
add
(
thirdLibInfo
)
}
...
...
Android/java/buildSrc/src/main/kotlin/com/didichuxing/doraemonkit/plugin/ThirdLibInfo.kt
浏览文件 @
e90814cd
...
...
@@ -9,4 +9,4 @@ package com.didichuxing.doraemonkit.plugin
* 修订历史:
* ================================================
*/
data class
ThirdLibInfo
(
val
name
:
String
,
val
fileSize
:
String
?
=
"0kb"
)
\ No newline at end of file
data class
ThirdLibInfo
(
val
name
:
String
,
val
fileSize
:
Long
,
val
variant
:
String
)
\ No newline at end of file
Android/java/buildSrc/src/main/kotlin/com/didichuxing/doraemonkit/plugin/classtransformer/CommTransformer.kt
浏览文件 @
e90814cd
...
...
@@ -407,8 +407,8 @@ class CommTransformer : ClassTransformer {
for
(
thirdLibInfo
in
DoKitExtUtil
.
THIRD_LIB_INFOS
)
{
add
(
VarInsnNode
(
ALOAD
,
0
))
add
(
LdcInsnNode
(
thirdLibInfo
.
name
))
add
(
LdcInsnNode
(
thirdLibInfo
.
fileSize
))
add
(
LdcInsnNode
(
thirdLibInfo
.
variant
))
add
(
LdcInsnNode
(
thirdLibInfo
.
fileSize
.
toString
()
))
add
(
MethodInsnNode
(
...
...
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/sysinfo/ThirdLibInfoFragment.java
浏览文件 @
e90814cd
package
com.didichuxing.doraemonkit.kit.sysinfo
;
import
android.Manifest
;
import
android.annotation.TargetApi
;
import
android.content.pm.PackageInfo
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.text.Editable
;
import
android.text.TextWatcher
;
import
android.view.View
;
import
android.widget.EditText
;
import
android.widget.TextView
;
import
android.widget.RadioButton
;
import
android.widget.RadioGroup
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.blankj.utilcode.util.AppUtils
;
import
com.blankj.utilcode.util.NetworkUtils
;
import
com.blankj.utilcode.util.PhoneUtils
;
import
com.blankj.utilcode.util.ToastUtils
;
import
com.didichuxing.doraemonkit.R
;
import
com.didichuxing.doraemonkit.aop.DokitThirdLibInfo
;
import
com.didichuxing.doraemonkit.kit.core.BaseFragment
;
import
com.didichuxing.doraemonkit.okhttp_api.OkHttpWrap
;
import
com.didichuxing.doraemonkit.util.DeviceUtils
;
import
com.didichuxing.doraemonkit.util.ExecutorUtil
;
import
com.didichuxing.doraemonkit.util.PermissionUtil
;
import
com.didichuxing.doraemonkit.util.UIUtils
;
import
com.didichuxing.doraemonkit.widget.recyclerview.DividerItemDecoration
;
import
com.didichuxing.doraemonkit.widget.titlebar.HomeTitleBar
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.BiConsumer
;
/**
* 第三方库信息
...
...
@@ -47,6 +35,7 @@ public class ThirdLibInfoFragment extends BaseFragment {
private
RecyclerView
mInfoList
;
private
ThirdLibInfoItemAdapter
mInfoItemAdapter
;
private
EditText
mEditText
;
private
RadioGroup
mSortGroup
;
@Override
protected
int
onRequestLayout
()
{
...
...
@@ -75,17 +64,26 @@ public class ThirdLibInfoFragment extends BaseFragment {
}
});
mEditText
=
findViewById
(
R
.
id
.
edittext
);
TextView
mTvSearch
=
findViewById
(
R
.
id
.
tv_search
);
mTvSearch
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
mEditText
.
addTextChangedListener
(
new
TextWatcher
()
{
@Override
public
void
onClick
(
View
v
)
{
String
keyWords
=
mEditText
.
getText
().
toString
().
trim
();
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{
}
@Override
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
int
count
)
{
String
keyWords
=
s
.
toString
().
trim
();
if
(
keyWords
.
isEmpty
())
{
initData
();
}
else
{
notifyThirdKeyWordsLibInfos
(
keyWords
);
}
}
@Override
public
void
afterTextChanged
(
Editable
s
)
{
}
});
LinearLayoutManager
layoutManager
=
new
LinearLayoutManager
(
getContext
());
...
...
@@ -96,6 +94,14 @@ public class ThirdLibInfoFragment extends BaseFragment {
decoration
.
setDrawable
(
getResources
().
getDrawable
(
R
.
drawable
.
dk_divider
));
mInfoList
.
addItemDecoration
(
decoration
);
mSortGroup
=
findViewById
(
R
.
id
.
sort_option
);
mSortGroup
.
setOnCheckedChangeListener
(
new
RadioGroup
.
OnCheckedChangeListener
()
{
@Override
public
void
onCheckedChanged
(
RadioGroup
group
,
int
checkedId
)
{
mInfoItemAdapter
.
setData
(
sortSysInfoItems
(
null
));
}
});
if
(
DokitThirdLibInfo
.
THIRD_LIB_INFOS
==
null
||
DokitThirdLibInfo
.
THIRD_LIB_INFOS
.
isEmpty
())
{
ToastUtils
.
showShort
(
"检查gradle.properties中的DOKIT_THIRD_LIB_SWITCH值是否为true"
);
}
...
...
@@ -105,7 +111,7 @@ public class ThirdLibInfoFragment extends BaseFragment {
private
void
initData
()
{
List
<
SysInfoItem
>
sysInfoItems
=
new
ArrayList
<>();
addThirdLibInfos
(
sysInfoItems
);
mInfoItemAdapter
.
setData
(
s
ysInfoItems
);
mInfoItemAdapter
.
setData
(
s
ortSysInfoItems
(
sysInfoItems
)
);
}
//添加所有三方库信息
...
...
@@ -113,34 +119,37 @@ public class ThirdLibInfoFragment extends BaseFragment {
for
(
Map
.
Entry
<
String
,
String
>
entry
:
DokitThirdLibInfo
.
THIRD_LIB_INFOS
.
entrySet
())
{
sysInfoItems
.
add
(
new
SysInfoItem
(
entry
.
getKey
(),
entry
.
getValue
()));
}
Collections
.
sort
(
sysInfoItems
,
new
Comparator
<
SysInfoItem
>()
{
@Override
public
int
compare
(
SysInfoItem
o1
,
SysInfoItem
o2
)
{
return
o1
.
name
.
compareToIgnoreCase
(
o2
.
name
);
}
});
}
private
List
<
SysInfoItem
>
sortSysInfoItems
(
List
<
SysInfoItem
>
sysInfoItems
)
{
List
<
SysInfoItem
>
data
=
sysInfoItems
==
null
?
mInfoItemAdapter
.
getData
()
:
sysInfoItems
;
if
(
mSortGroup
.
getCheckedRadioButtonId
()
==
R
.
id
.
sort_size
)
{
Collections
.
sort
(
data
,
new
Comparator
<
SysInfoItem
>()
{
@Override
public
int
compare
(
SysInfoItem
o1
,
SysInfoItem
o2
)
{
return
(
int
)
(
Long
.
parseLong
(
o2
.
value
)
-
Long
.
parseLong
(
o1
.
value
));
}
});
}
else
{
Collections
.
sort
(
data
,
new
Comparator
<
SysInfoItem
>()
{
@Override
public
int
compare
(
SysInfoItem
o1
,
SysInfoItem
o2
)
{
return
o1
.
name
.
compareToIgnoreCase
(
o2
.
name
);
}
});
}
return
data
;
}
//添加所有三方库信息
private
void
notifyThirdKeyWordsLibInfos
(
String
keyWords
)
{
List
<
SysInfoItem
>
sysInfoItems
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
String
>
entry
:
DokitThirdLibInfo
.
THIRD_LIB_INFOS
.
entrySet
())
{
if
(
entry
.
getKey
().
startsWith
(
keyWords
)
||
entry
.
getKey
().
contains
(
keyWords
))
{
if
(
entry
.
getKey
().
toLowerCase
().
startsWith
(
keyWords
.
toLowerCase
())
||
entry
.
getKey
().
toLowerCase
().
contains
(
keyWords
.
toLowerCase
()
))
{
sysInfoItems
.
add
(
new
SysInfoItem
(
entry
.
getKey
(),
entry
.
getValue
()));
}
}
Collections
.
sort
(
sysInfoItems
,
new
Comparator
<
SysInfoItem
>()
{
@Override
public
int
compare
(
SysInfoItem
o1
,
SysInfoItem
o2
)
{
return
o1
.
name
.
compareToIgnoreCase
(
o2
.
name
);
}
});
mInfoItemAdapter
.
setData
(
sysInfoItems
);
mInfoItemAdapter
.
setData
(
sortSysInfoItems
(
sysInfoItems
));
}
...
...
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/sysinfo/ThirdLibInfoItemAdapter.java
浏览文件 @
e90814cd
package
com.didichuxing.doraemonkit.kit.sysinfo
;
import
android.content.Context
;
import
android.text.format.Formatter
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -68,7 +69,7 @@ public class ThirdLibInfoItemAdapter extends AbsRecyclerAdapter<AbsViewBinder<Sy
@Override
public
void
bind
(
final
SysInfoItem
sysInfoItem
)
{
mTvName
.
setText
(
sysInfoItem
.
name
);
mTvSize
.
setText
(
sysInfoItem
.
value
);
mTvSize
.
setText
(
Formatter
.
formatFileSize
(
itemView
.
getContext
(),
Long
.
parseLong
(
sysInfoItem
.
value
))
);
}
}
...
...
Android/java/doraemonkit/src/main/res/layout/dk_fragment_third_lib_info.xml
浏览文件 @
e90814cd
...
...
@@ -21,24 +21,36 @@
android:layout_marginLeft=
"16dp"
android:layout_marginRight=
"16dp"
>
<TextView
android:id=
"@+id/tv_search"
android:layout_width=
"wrap_content"
android:layout_height=
"36dp"
<RadioGroup
android:layout_alignParentRight=
"true"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"8dp"
android:gravity=
"center"
android:text=
"@string/dk_mock_search"
android:textColor=
"@color/dk_color_337CC4"
android:textSize=
"14sp"
/>
android:layout_centerVertical=
"true"
android:id=
"@+id/sort_option"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<RadioButton
android:checked=
"true"
android:id=
"@+id/sort_name"
style=
"@style/DK.RadioButton.Left"
android:layout_weight=
"1"
android:text=
"@string/dk_third_sort_name"
/>
<RadioButton
android:id=
"@+id/sort_size"
style=
"@style/DK.RadioButton.Right"
android:layout_weight=
"1"
android:text=
"@string/dk_third_sort_size"
/>
</RadioGroup>
<androidx.cardview.widget.CardView
android:id=
"@+id/cardview"
android:layout_width=
"match_parent"
android:layout_height=
"36dp"
android:layout_margin=
"5dp"
android:layout_toLeftOf=
"@id/
tv_search
"
android:layout_toLeftOf=
"@id/
sort_option
"
app:cardBackgroundColor=
"@color/dk_color_FFFFFF"
app:cardCornerRadius=
"4dp"
app:cardElevation=
"3dp"
...
...
@@ -48,6 +60,7 @@
app:contentPaddingTop=
"5dp"
>
<EditText
android:singleLine=
"true"
android:id=
"@+id/edittext"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
...
...
Android/java/doraemonkit/src/main/res/layout/dk_fragment_weak_network.xml
浏览文件 @
e90814cd
...
...
@@ -35,7 +35,7 @@
android:paddingRight=
"@dimen/dk_dp_15"
android:visibility=
"gone"
tools:visibility=
"visible"
>
<!-- r
e
dioGroup-->
<!-- r
a
dioGroup-->
<RadioGroup
android:id=
"@+id/weak_network_option"
android:layout_width=
"match_parent"
...
...
Android/java/doraemonkit/src/main/res/values-en-rUS/strings.xml
浏览文件 @
e90814cd
...
...
@@ -133,6 +133,9 @@
<string
name=
"dk_item_block_goto_list"
>
View Block History
</string>
<string
name=
"dk_item_block_mock"
>
Mock Block
</string>
<string
name=
"dk_third_sort_name"
>
By Name
</string>
<string
name=
"dk_third_sort_size"
>
By Size
</string>
<string
name=
"dk_block_class_has_blocked"
>
blocked %s ms
</string>
<string
name=
"dk_block_notification_message"
>
Click for more details
</string>
...
...
Android/java/doraemonkit/src/main/res/values-zh-rCN/strings.xml
浏览文件 @
e90814cd
...
...
@@ -135,6 +135,9 @@
<string
name=
"dk_item_block_goto_list"
>
查看卡顿记录
</string>
<string
name=
"dk_item_block_mock"
>
模拟卡顿
</string>
<string
name=
"dk_third_sort_name"
>
按名称
</string>
<string
name=
"dk_third_sort_size"
>
按大小
</string>
<string
name=
"dk_block_class_has_blocked"
>
blocked %s ms
</string>
<string
name=
"dk_block_notification_message"
>
Click for more details
</string>
...
...
Android/java/doraemonkit/src/main/res/values-zh-rTW/strings.xml
浏览文件 @
e90814cd
...
...
@@ -133,6 +133,9 @@
<string
name=
"dk_item_block_goto_list"
>
查看 ANR 紀錄
</string>
<string
name=
"dk_item_block_mock"
>
模擬 ANR
</string>
<string
name=
"dk_third_sort_name"
>
按名稱
</string>
<string
name=
"dk_third_sort_size"
>
按大小
</string>
<string
name=
"dk_block_class_has_blocked"
>
blocked %s ms
</string>
<string
name=
"dk_block_notification_message"
>
Click for more details
</string>
...
...
Android/java/doraemonkit/src/main/res/values/strings.xml
浏览文件 @
e90814cd
...
...
@@ -149,6 +149,9 @@
<string
name=
"dk_block_class_has_blocked"
>
blocked %s ms
</string>
<string
name=
"dk_block_notification_message"
>
Click for more details
</string>
<string
name=
"dk_third_sort_name"
>
按名称
</string>
<string
name=
"dk_third_sort_size"
>
按大小
</string>
<string
name=
"dk_crash_capture_tips"
>
DoraemonKit正在为您记录Crash
</string>
<string
name=
"dk_crash_capture_no_record"
>
暂无crash记录
</string>
<string
name=
"dk_crash_capture_switch"
>
Crash日志收集开关
</string>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录