Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
23f9e97d
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,发现更多精彩内容 >>
未验证
提交
23f9e97d
编写于
12月 19, 2019
作者:
金
金台
提交者:
GitHub
12月 19, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #355 from xiandanin/master
Android控件检查增加padding和margin信息
上级
7ff74323
7043e55c
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
87 addition
and
44 deletion
+87
-44
Android/doraemonkit-no-op/src/main/java/com/didichuxing/doraemonkit/kit/network/okhttp/DoraemonWeakNetworkInterceptor.java
...it/kit/network/okhttp/DoraemonWeakNetworkInterceptor.java
+1
-2
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/network/okhttp/interceptor/DoraemonWeakNetworkInterceptor.java
...rk/okhttp/interceptor/DoraemonWeakNetworkInterceptor.java
+2
-3
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/viewcheck/ViewCheckInfoDokitView.java
...ing/doraemonkit/kit/viewcheck/ViewCheckInfoDokitView.java
+61
-9
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/weaknetwork/ByteCountBufferedSink.java
...ng/doraemonkit/kit/weaknetwork/ByteCountBufferedSink.java
+1
-2
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/weaknetwork/SpeedLimitRequestBody.java
...ng/doraemonkit/kit/weaknetwork/SpeedLimitRequestBody.java
+1
-2
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/weaknetwork/SpeedLimitResponseBody.java
...g/doraemonkit/kit/weaknetwork/SpeedLimitResponseBody.java
+1
-2
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/weaknetwork/WeakNetworkFragment.java
...xing/doraemonkit/kit/weaknetwork/WeakNetworkFragment.java
+1
-20
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/weaknetwork/WeakNetworkKit.java
...dichuxing/doraemonkit/kit/weaknetwork/WeakNetworkKit.java
+1
-2
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/weaknetwork/WeakNetworkManager.java
...uxing/doraemonkit/kit/weaknetwork/WeakNetworkManager.java
+1
-2
Android/doraemonkit/src/main/res/layout/dk_float_view_check_info.xml
...aemonkit/src/main/res/layout/dk_float_view_check_info.xml
+1
-0
Android/doraemonkit/src/main/res/values-en-rUS/strings.xml
Android/doraemonkit/src/main/res/values-en-rUS/strings.xml
+4
-0
Android/doraemonkit/src/main/res/values-zh-rCN/strings.xml
Android/doraemonkit/src/main/res/values-zh-rCN/strings.xml
+4
-0
Android/doraemonkit/src/main/res/values-zh-rTW/strings.xml
Android/doraemonkit/src/main/res/values-zh-rTW/strings.xml
+4
-0
Android/doraemonkit/src/main/res/values/strings.xml
Android/doraemonkit/src/main/res/values/strings.xml
+4
-0
未找到文件。
Android/doraemonkit-no-op/src/main/java/com/didichuxing/doraemonkit/kit/network/okhttp/DoraemonWeakNetworkInterceptor.java
浏览文件 @
23f9e97d
...
...
@@ -7,8 +7,7 @@ import okhttp3.Request;
import
okhttp3.Response
;
/**
* @author denghaha
* created 2019-05-10 11:56
* Created by xiandanin on 2019-05-10 11:56
*/
public
class
DoraemonWeakNetworkInterceptor
implements
Interceptor
{
...
...
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/network/okhttp/interceptor/DoraemonWeakNetworkInterceptor.java
浏览文件 @
23f9e97d
...
...
@@ -11,9 +11,8 @@ import okhttp3.Response;
/**
* 用于模拟弱网的拦截器
*
* @author denghaha
* created 2019-05-09 16:29
* <p>
* Created by xiandanin on 2019-05-09 16:29
*/
public
class
DoraemonWeakNetworkInterceptor
implements
Interceptor
{
...
...
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/viewcheck/ViewCheckInfoDokitView.java
浏览文件 @
23f9e97d
...
...
@@ -10,6 +10,7 @@ import android.support.v7.app.AppCompatActivity;
import
android.text.TextUtils
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.FrameLayout
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
...
...
@@ -80,11 +81,11 @@ public class ViewCheckInfoDokitView extends AbsDokitView implements ViewCheckDok
@Override
public
void
run
()
{
ViewCheckDokitView
dokitView
=
(
ViewCheckDokitView
)
DokitViewManager
.
getInstance
().
getDokitView
(
getActivity
(),
ViewCheckDokitView
.
class
.
getSimpleName
());
if
(
dokitView
!=
null
)
{
if
(
dokitView
!=
null
)
{
dokitView
.
setViewSelectListener
(
ViewCheckInfoDokitView
.
this
);
}
}
},
200
);
},
200
);
}
...
...
@@ -98,6 +99,15 @@ public class ViewCheckInfoDokitView extends AbsDokitView implements ViewCheckDok
params
.
height
=
DokitViewLayoutParams
.
WRAP_CONTENT
;
}
@Override
public
void
updateViewLayout
(
String
tag
,
boolean
isActivityResume
)
{
super
.
updateViewLayout
(
tag
,
isActivityResume
);
// 由于父类在此方法限制了高度无法自适应,所以重新设成wrap_content以自适应
final
FrameLayout
.
LayoutParams
params
=
getNormalLayoutParams
();
params
.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
;
getRootView
().
setLayoutParams
(
params
);
}
@Override
public
void
onViewSelected
(
View
view
)
{
if
(
view
==
null
)
{
...
...
@@ -111,14 +121,13 @@ public class ViewCheckInfoDokitView extends AbsDokitView implements ViewCheckDok
mId
.
setText
(
idText
);
String
positionText
=
getResources
().
getString
(
R
.
string
.
dk_view_check_info_size
,
view
.
getWidth
(),
view
.
getHeight
());
mPosition
.
setText
(
positionText
);
Drawable
drawable
=
view
.
getBackground
();
String
backgroundColor
=
""
;
if
(
drawable
instanceof
ColorDrawable
)
{
int
colorInt
=
((
ColorDrawable
)
drawable
).
getColor
();
backgroundColor
=
ColorUtil
.
parseColorInt
(
colorInt
);
String
descText
=
getViewExtraInfo
(
view
);
if
(
TextUtils
.
isEmpty
(
descText
))
{
mDesc
.
setVisibility
(
View
.
GONE
);
}
else
{
mDesc
.
setText
(
descText
);
mDesc
.
setVisibility
(
View
.
VISIBLE
);
}
String
descText
=
getResources
().
getString
(
R
.
string
.
dk_view_check_info_desc
,
backgroundColor
);
mDesc
.
setText
(
descText
);
Activity
activity
=
ActivityUtils
.
getTopActivity
();
if
(
activity
!=
null
)
{
String
activityText
=
activity
.
getClass
().
getSimpleName
();
...
...
@@ -136,6 +145,49 @@ public class ViewCheckInfoDokitView extends AbsDokitView implements ViewCheckDok
}
}
private
String
getViewExtraInfo
(
View
v
)
{
StringBuilder
info
=
new
StringBuilder
();
// 背景色
Drawable
drawable
=
v
.
getBackground
();
if
(
drawable
!=
null
)
{
if
(
drawable
instanceof
ColorDrawable
)
{
int
colorInt
=
((
ColorDrawable
)
drawable
).
getColor
();
String
backgroundColor
=
ColorUtil
.
parseColorInt
(
colorInt
);
info
.
append
(
getResources
().
getString
(
R
.
string
.
dk_view_check_info_desc
,
backgroundColor
));
info
.
append
(
"\n"
);
}
}
// padding
if
(
v
.
getPaddingLeft
()
!=
0
&&
v
.
getPaddingTop
()
!=
0
&&
v
.
getPaddingRight
()
!=
0
&&
v
.
getPaddingBottom
()
!=
0
)
{
info
.
append
(
getResources
().
getString
(
R
.
string
.
dk_view_check_info_padding
,
v
.
getPaddingLeft
(),
v
.
getPaddingTop
(),
v
.
getPaddingRight
(),
v
.
getPaddingBottom
()));
info
.
append
(
"\n"
);
}
// margin
final
ViewGroup
.
LayoutParams
layoutParams
=
v
.
getLayoutParams
();
if
(
layoutParams
instanceof
ViewGroup
.
MarginLayoutParams
)
{
final
ViewGroup
.
MarginLayoutParams
mp
=
((
ViewGroup
.
MarginLayoutParams
)
layoutParams
);
if
(
mp
.
leftMargin
!=
0
&&
mp
.
topMargin
!=
0
&&
mp
.
rightMargin
!=
0
&&
mp
.
bottomMargin
!=
0
)
{
info
.
append
(
getResources
().
getString
(
R
.
string
.
dk_view_check_info_margin
,
mp
.
leftMargin
,
mp
.
topMargin
,
mp
.
rightMargin
,
mp
.
bottomMargin
));
info
.
append
(
"\n"
);
}
}
// TextView信息
if
(
v
instanceof
TextView
)
{
TextView
tv
=
((
TextView
)
v
);
String
textColor
=
ColorUtil
.
parseColorInt
(
tv
.
getCurrentTextColor
());
info
.
append
(
getResources
().
getString
(
R
.
string
.
dk_view_check_info_text_color
,
textColor
));
info
.
append
(
"\n"
);
info
.
append
(
getResources
().
getString
(
R
.
string
.
dk_view_check_info_text_size
,
(
int
)
tv
.
getTextSize
()));
info
.
append
(
"\n"
);
}
// 删除最后一个换行
if
(!
TextUtils
.
isEmpty
(
info
))
{
info
.
deleteCharAt
(
info
.
length
()
-
1
);
}
return
info
.
toString
();
}
private
void
setTextAndVisible
(
TextView
textView
,
String
text
)
{
if
(
TextUtils
.
isEmpty
(
text
))
{
textView
.
setVisibility
(
View
.
GONE
);
...
...
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/weaknetwork/ByteCountBufferedSink.java
浏览文件 @
23f9e97d
...
...
@@ -18,8 +18,7 @@ import okio.Timeout;
/**
* 可以设置每次写入大小的BufferedSink
*
* @author denghaha
* created 2019-05-10 16:07
* Created by xiandanin on 2019-05-10 16:07
*/
public
class
ByteCountBufferedSink
implements
BufferedSink
{
private
final
long
mByteCount
;
...
...
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/weaknetwork/SpeedLimitRequestBody.java
浏览文件 @
23f9e97d
...
...
@@ -12,8 +12,7 @@ import okio.ForwardingSink;
import
okio.Sink
;
/**
* @author denghaha
* created 2019-05-09 18:35
* Created by xiandanin on 2019-05-09 18:35
*/
public
class
SpeedLimitRequestBody
extends
RequestBody
{
private
long
mSpeedByte
;
//b/s
...
...
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/weaknetwork/SpeedLimitResponseBody.java
浏览文件 @
23f9e97d
...
...
@@ -13,8 +13,7 @@ import okio.Okio;
import
okio.Source
;
/**
* @author denghaha
* created 2019-05-09 18:35
* Created by xiandanin on 2019-05-09 18:35
*/
public
class
SpeedLimitResponseBody
extends
ResponseBody
{
//b/s
...
...
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/weaknetwork/WeakNetworkFragment.java
浏览文件 @
23f9e97d
...
...
@@ -22,8 +22,7 @@ import com.didichuxing.doraemonkit.ui.widget.titlebar.HomeTitleBar;
/**
* 模拟弱网
*
* @author denghaha
* created 2019/5/7 19:10
* Created by xiandanin on 2019/5/7 19:10
*/
public
class
WeakNetworkFragment
extends
BaseFragment
implements
TextWatcher
{
private
SettingItemAdapter
mSettingItemAdapter
;
...
...
@@ -173,22 +172,4 @@ public class WeakNetworkFragment extends BaseFragment implements TextWatcher {
}
static
class
SimpleTextWatcher
implements
TextWatcher
{
@Override
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{
}
@Override
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
int
count
)
{
}
@Override
public
void
afterTextChanged
(
Editable
s
)
{
}
}
}
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/weaknetwork/WeakNetworkKit.java
浏览文件 @
23f9e97d
...
...
@@ -10,8 +10,7 @@ import com.didichuxing.doraemonkit.kit.Category;
/**
* 模拟弱网
*
* @author denghaha
* created 2019/5/7 19:05
* Created by xiandanin on 2019/5/7 19:05
*/
public
class
WeakNetworkKit
extends
AbstractKit
{
@Override
...
...
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/weaknetwork/WeakNetworkManager.java
浏览文件 @
23f9e97d
...
...
@@ -14,8 +14,7 @@ import okhttp3.Response;
import
okhttp3.ResponseBody
;
/**
* @author denghaha
* created 2019-05-09 16:30
* Created by xiandanin on 2019-05-09 16:30
*/
public
class
WeakNetworkManager
{
public
static
final
int
TYPE_OFF_NETWORK
=
0
;
...
...
Android/doraemonkit/src/main/res/layout/dk_float_view_check_info.xml
浏览文件 @
23f9e97d
...
...
@@ -40,6 +40,7 @@
android:layout_below=
"@id/position"
android:layout_alignLeft=
"@id/position"
android:layout_marginBottom=
"6dp"
android:lineSpacingExtra=
"7dp"
android:gravity=
"left"
/>
<TextView
...
...
Android/doraemonkit/src/main/res/values-en-rUS/strings.xml
浏览文件 @
23f9e97d
...
...
@@ -165,6 +165,10 @@
<string
name=
"dk_gps_location_change_toast"
>
Location changed: %1$s, %2$s
</string>
<string
name=
"dk_view_check_info_size"
>
View Size:width%1$d,height%2$d
</string>
<string
name=
"dk_view_check_info_desc"
>
View Background:%1$s
</string>
<string
name=
"dk_view_check_info_padding"
>
View Padding:%1$d, %2$d, %3$d, %4$d
</string>
<string
name=
"dk_view_check_info_margin"
>
View Margin:%1$d, %2$d, %3$d, %4$d
</string>
<string
name=
"dk_view_check_info_text_color"
>
Text Color:%1$s
</string>
<string
name=
"dk_view_check_info_text_size"
>
Text Size:%1$d
</string>
<string
name=
"dk_view_check_info_id"
>
View ID:%1$s
</string>
<string
name=
"dk_view_check_info_class"
>
View Class:%1$s
</string>
<string
name=
"dk_view_check_info_activity"
>
Current Activity:%1$s
</string>
...
...
Android/doraemonkit/src/main/res/values-zh-rCN/strings.xml
浏览文件 @
23f9e97d
...
...
@@ -165,6 +165,10 @@
<string
name=
"dk_float_permission_toast"
>
哆啦A梦需要打开悬浮窗权限才能正常使用
</string>
<string
name=
"dk_gps_location_change_toast"
>
地址变为: %1$s, %2$s
</string>
<string
name=
"dk_view_check_info_desc"
>
背景颜色:%1$s
</string>
<string
name=
"dk_view_check_info_padding"
>
内边距:%1$d, %2$d, %3$d, %4$d
</string>
<string
name=
"dk_view_check_info_margin"
>
外边距:%1$d, %2$d, %3$d, %4$d
</string>
<string
name=
"dk_view_check_info_text_color"
>
文字颜色:%1$s
</string>
<string
name=
"dk_view_check_info_text_size"
>
文字大小:%1$d
</string>
<string
name=
"dk_view_check_info_size"
>
控件尺寸:宽%1$d,高%2$d
</string>
<string
name=
"dk_view_check_info_id"
>
控件ID:%1$s
</string>
<string
name=
"dk_view_check_info_class"
>
控件类型:%1$s
</string>
...
...
Android/doraemonkit/src/main/res/values-zh-rTW/strings.xml
浏览文件 @
23f9e97d
...
...
@@ -164,6 +164,10 @@
<string
name=
"dk_float_permission_toast"
>
哆啦A夢需要打開懸浮視窗權限才能正常使用
</string>
<string
name=
"dk_gps_location_change_toast"
>
地址變為: %1$s, %2$s
</string>
<string
name=
"dk_view_check_info_desc"
>
背景顏色:%1$s
</string>
<string
name=
"dk_view_check_info_padding"
>
內邊距:%1$d, %2$d, %3$d, %4$d
</string>
<string
name=
"dk_view_check_info_margin"
>
外邊距:%1$d, %2$d, %3$d, %4$d
</string>
<string
name=
"dk_view_check_info_text_color"
>
文字顏色:%1$s
</string>
<string
name=
"dk_view_check_info_text_size"
>
文字大小:%1$d
</string>
<string
name=
"dk_view_check_info_size"
>
View 尺寸:寬%1$d,高%2$d
</string>
<string
name=
"dk_view_check_info_id"
>
View ID:%1$s
</string>
<string
name=
"dk_view_check_info_class"
>
View 類別:%1$s
</string>
...
...
Android/doraemonkit/src/main/res/values/strings.xml
浏览文件 @
23f9e97d
...
...
@@ -159,6 +159,10 @@
<string
name=
"dk_view_check_info_id"
>
控件ID:%1$s
</string>
<string
name=
"dk_view_check_info_size"
>
控件尺寸:宽%1$d,高%2$d
</string>
<string
name=
"dk_view_check_info_desc"
>
背景颜色:%1$s
</string>
<string
name=
"dk_view_check_info_padding"
>
内边距:%1$d, %2$d, %3$d, %4$d
</string>
<string
name=
"dk_view_check_info_margin"
>
外边距:%1$d, %2$d, %3$d, %4$d
</string>
<string
name=
"dk_view_check_info_text_color"
>
文字颜色:%1$s
</string>
<string
name=
"dk_view_check_info_text_size"
>
文字大小:%1$d
</string>
<string
name=
"dk_view_check_info_activity"
>
当前Activity:%1$s
</string>
<string
name=
"dk_view_check_info_fragment"
>
可见Fragments:%1$s
</string>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录