Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mmm-rain
AndroidUtilCode
提交
8b05af19
A
AndroidUtilCode
项目概览
mmm-rain
/
AndroidUtilCode
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AndroidUtilCode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8b05af19
编写于
7月 23, 2017
作者:
B
Blankj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
see 07/23 log
上级
e7c9ba3b
变更
37
展开全部
隐藏空白更改
内联
并排
Showing
37 changed file
with
691 addition
and
345 deletion
+691
-345
app/src/main/java/com/blankj/androidutilcode/activity/StatusBarAlphaActivity.java
...ankj/androidutilcode/activity/StatusBarAlphaActivity.java
+5
-3
app/src/main/java/com/blankj/androidutilcode/activity/StatusBarColorActivity.java
...ankj/androidutilcode/activity/StatusBarColorActivity.java
+7
-8
app/src/main/java/com/blankj/androidutilcode/activity/StatusBarFragmentActivity.java
...j/androidutilcode/activity/StatusBarFragmentActivity.java
+16
-4
app/src/main/java/com/blankj/androidutilcode/activity/StatusBarImageViewActivity.java
.../androidutilcode/activity/StatusBarImageViewActivity.java
+4
-2
app/src/main/java/com/blankj/androidutilcode/base/BaseBackActivity.java
...ava/com/blankj/androidutilcode/base/BaseBackActivity.java
+0
-2
app/src/main/java/com/blankj/androidutilcode/base/BaseFragment.java
...in/java/com/blankj/androidutilcode/base/BaseFragment.java
+3
-3
app/src/main/java/com/blankj/androidutilcode/fragment/StatusBarAlphaFragment.java
...ankj/androidutilcode/fragment/StatusBarAlphaFragment.java
+51
-3
app/src/main/java/com/blankj/androidutilcode/fragment/StatusBarColorFragment.java
...ankj/androidutilcode/fragment/StatusBarColorFragment.java
+65
-3
app/src/main/java/com/blankj/androidutilcode/fragment/StatusBarImageViewFragment.java
.../androidutilcode/fragment/StatusBarImageViewFragment.java
+49
-3
app/src/main/res/layout/activity_activity.xml
app/src/main/res/layout/activity_activity.xml
+4
-3
app/src/main/res/layout/activity_app.xml
app/src/main/res/layout/activity_app.xml
+4
-3
app/src/main/res/layout/activity_back.xml
app/src/main/res/layout/activity_back.xml
+2
-1
app/src/main/res/layout/activity_bar.xml
app/src/main/res/layout/activity_bar.xml
+4
-3
app/src/main/res/layout/activity_clean.xml
app/src/main/res/layout/activity_clean.xml
+4
-3
app/src/main/res/layout/activity_device.xml
app/src/main/res/layout/activity_device.xml
+4
-3
app/src/main/res/layout/activity_flashlight.xml
app/src/main/res/layout/activity_flashlight.xml
+4
-3
app/src/main/res/layout/activity_keyboard.xml
app/src/main/res/layout/activity_keyboard.xml
+4
-3
app/src/main/res/layout/activity_log.xml
app/src/main/res/layout/activity_log.xml
+4
-3
app/src/main/res/layout/activity_network.xml
app/src/main/res/layout/activity_network.xml
+4
-3
app/src/main/res/layout/activity_permission.xml
app/src/main/res/layout/activity_permission.xml
+4
-3
app/src/main/res/layout/activity_phone.xml
app/src/main/res/layout/activity_phone.xml
+4
-3
app/src/main/res/layout/activity_pinyin.xml
app/src/main/res/layout/activity_pinyin.xml
+4
-3
app/src/main/res/layout/activity_process.xml
app/src/main/res/layout/activity_process.xml
+4
-3
app/src/main/res/layout/activity_sdcard.xml
app/src/main/res/layout/activity_sdcard.xml
+4
-3
app/src/main/res/layout/activity_snackbar.xml
app/src/main/res/layout/activity_snackbar.xml
+4
-3
app/src/main/res/layout/activity_span.xml
app/src/main/res/layout/activity_span.xml
+4
-3
app/src/main/res/layout/activity_status_bar_alpha.xml
app/src/main/res/layout/activity_status_bar_alpha.xml
+40
-0
app/src/main/res/layout/activity_status_bar_color.xml
app/src/main/res/layout/activity_status_bar_color.xml
+9
-5
app/src/main/res/layout/activity_status_bar_image_view.xml
app/src/main/res/layout/activity_status_bar_image_view.xml
+4
-3
app/src/main/res/layout/activity_toast.xml
app/src/main/res/layout/activity_toast.xml
+4
-3
app/src/main/res/layout/dialog_keyboard.xml
app/src/main/res/layout/dialog_keyboard.xml
+4
-3
app/src/main/res/layout/fragment_status_bar_alpha.xml
app/src/main/res/layout/fragment_status_bar_alpha.xml
+17
-7
app/src/main/res/layout/fragment_status_bar_color.xml
app/src/main/res/layout/fragment_status_bar_color.xml
+16
-6
app/src/main/res/layout/fragment_status_bar_image_view.xml
app/src/main/res/layout/fragment_status_bar_image_view.xml
+23
-15
utilcode/src/main/java/com/blankj/utilcode/util/BarUtils.java
...code/src/main/java/com/blankj/utilcode/util/BarUtils.java
+283
-214
utilcode/src/main/java/com/blankj/utilcode/util/FragmentUtils.java
...src/main/java/com/blankj/utilcode/util/FragmentUtils.java
+12
-0
utilcode/src/main/java/com/blankj/utilcode/util/ScreenUtils.java
...e/src/main/java/com/blankj/utilcode/util/ScreenUtils.java
+13
-9
未找到文件。
app/src/main/java/com/blankj/androidutilcode/activity/StatusBarAlphaActivity.java
浏览文件 @
8b05af19
...
...
@@ -31,16 +31,18 @@ public class StatusBarAlphaActivity extends BaseActivity {
@Override
public
int
bindLayout
()
{
return
R
.
layout
.
fragment
_status_bar_alpha
;
return
R
.
layout
.
activity
_status_bar_alpha
;
}
@Override
public
void
initView
(
Bundle
savedInstanceState
,
View
view
)
{
BarUtils
.
setStatusBarAlpha
(
StatusBarAlphaActivity
.
this
,
mAlpha
,
findViewById
(
R
.
id
.
tv_status_alpha
));
findViewById
(
R
.
id
.
btn_set_transparent
).
setOnClickListener
(
this
);
mTvStatusAlpha
=
(
TextView
)
findViewById
(
R
.
id
.
tv_status_alpha
);
sbChangeAlpha
=
(
SeekBar
)
findViewById
(
R
.
id
.
sb_change_alpha
);
sbChangeAlpha
.
setOnSeekBarChangeListener
(
translucentListener
);
sbChangeAlpha
.
setProgress
(
mAlpha
);
mTvStatusAlpha
.
setText
(
String
.
valueOf
(
mAlpha
)
);
}
@Override
...
...
@@ -61,8 +63,8 @@ public class StatusBarAlphaActivity extends BaseActivity {
@Override
public
void
onProgressChanged
(
SeekBar
seekBar
,
int
progress
,
boolean
fromUser
)
{
mAlpha
=
progress
;
BarUtils
.
setStatusBar4Bg
(
StatusBarAlphaActivity
.
this
,
mAlpha
);
mTvStatusAlpha
.
setText
(
String
.
valueOf
(
mAlpha
));
BarUtils
.
setStatusBarAlpha
(
StatusBarAlphaActivity
.
this
,
mAlpha
);
}
@Override
...
...
app/src/main/java/com/blankj/androidutilcode/activity/StatusBarColorActivity.java
浏览文件 @
8b05af19
...
...
@@ -8,7 +8,8 @@ import android.widget.SeekBar;
import
android.widget.TextView
;
import
com.blankj.androidutilcode.R
;
import
com.blankj.androidutilcode.base.BaseBackActivity
;
import
com.blankj.androidutilcode.UtilsApp
;
import
com.blankj.androidutilcode.base.BaseActivity
;
import
com.blankj.utilcode.util.BarUtils
;
import
java.util.Random
;
...
...
@@ -22,7 +23,7 @@ import java.util.Random;
* desc : Bar工具类Demo分支
* </pre>
*/
public
class
StatusBarColorActivity
extends
Base
Back
Activity
{
public
class
StatusBarColorActivity
extends
BaseActivity
{
private
Random
mRandom
;
private
int
mColor
;
...
...
@@ -33,7 +34,7 @@ public class StatusBarColorActivity extends BaseBackActivity {
@Override
public
void
initData
(
Bundle
bundle
)
{
mRandom
=
new
Random
();
mColor
=
ContextCompat
.
getColor
(
this
,
R
.
color
.
colorPrimary
);
mColor
=
ContextCompat
.
getColor
(
UtilsApp
.
getInstance
()
,
R
.
color
.
colorPrimary
);
mAlpha
=
112
;
}
...
...
@@ -44,15 +45,14 @@ public class StatusBarColorActivity extends BaseBackActivity {
@Override
public
void
initView
(
Bundle
savedInstanceState
,
View
view
)
{
getSupportActionBar
().
setTitle
(
getString
(
R
.
string
.
demo_bar
)
);
BarUtils
.
setStatusBarColor
(
StatusBarColorActivity
.
this
,
mColor
,
mAlpha
);
findViewById
(
R
.
id
.
btn_random_color
).
setOnClickListener
(
this
);
findViewById
(
R
.
id
.
btn_set_transparent
).
setOnClickListener
(
this
);
mTvStatusAlpha
=
(
TextView
)
findViewById
(
R
.
id
.
tv_status_alpha
);
sbChangeAlpha
=
(
SeekBar
)
findViewById
(
R
.
id
.
sb_change_alpha
);
sbChangeAlpha
.
setOnSeekBarChangeListener
(
colorListener
);
sbChangeAlpha
.
setProgress
(
mAlpha
);
updateColorBar
();
mTvStatusAlpha
.
setText
(
String
.
valueOf
(
mAlpha
));
}
...
...
@@ -75,7 +75,6 @@ public class StatusBarColorActivity extends BaseBackActivity {
}
private
void
updateColorBar
()
{
mToolbar
.
setBackgroundColor
(
mColor
);
BarUtils
.
setStatusBarColor
(
this
,
mColor
,
mAlpha
);
}
...
...
@@ -83,8 +82,8 @@ public class StatusBarColorActivity extends BaseBackActivity {
@Override
public
void
onProgressChanged
(
SeekBar
seekBar
,
int
progress
,
boolean
fromUser
)
{
mAlpha
=
progress
;
BarUtils
.
setStatusBarColor
(
StatusBarColorActivity
.
this
,
mColor
,
mAlpha
);
mTvStatusAlpha
.
setText
(
String
.
valueOf
(
mAlpha
));
BarUtils
.
setStatusBarColor
(
StatusBarColorActivity
.
this
,
mColor
,
mAlpha
);
}
@Override
...
...
app/src/main/java/com/blankj/androidutilcode/activity/StatusBarFragmentActivity.java
浏览文件 @
8b05af19
...
...
@@ -15,6 +15,7 @@ import com.blankj.androidutilcode.base.BaseActivity;
import
com.blankj.androidutilcode.fragment.StatusBarAlphaFragment
;
import
com.blankj.androidutilcode.fragment.StatusBarColorFragment
;
import
com.blankj.androidutilcode.fragment.StatusBarImageViewFragment
;
import
com.blankj.utilcode.util.BarUtils
;
import
java.util.ArrayList
;
...
...
@@ -28,9 +29,10 @@ import java.util.ArrayList;
*/
public
class
StatusBarFragmentActivity
extends
BaseActivity
{
private
ViewPager
mVpHome
;
private
ViewPager
mVpHome
;
private
BottomNavigationView
navigation
;
private
ArrayList
<
Fragment
>
mFragmentList
=
new
ArrayList
<>();
private
int
[]
itemIds
=
new
int
[]{
R
.
id
.
navigation_color
,
R
.
id
.
navigation_alpha
,
R
.
id
.
navigation_image_view
};
@Override
...
...
@@ -45,12 +47,15 @@ public class StatusBarFragmentActivity extends BaseActivity {
@Override
public
void
initView
(
Bundle
savedInstanceState
,
View
view
)
{
BarUtils
.
initStatusBar4Fragment
(
this
);
mVpHome
=
(
ViewPager
)
findViewById
(
R
.
id
.
vp_home
);
navigation
=
(
BottomNavigationView
)
findViewById
(
R
.
id
.
navigation
);
mFragmentList
.
add
(
new
StatusBarColorFragment
());
mFragmentList
.
add
(
new
StatusBarAlphaFragment
());
mFragmentList
.
add
(
new
StatusBarImageViewFragment
());
mFragmentList
.
add
(
StatusBarColorFragment
.
newInstance
());
mFragmentList
.
add
(
StatusBarAlphaFragment
.
newInstance
());
mFragmentList
.
add
(
StatusBarImageViewFragment
.
newInstance
());
mVpHome
.
setAdapter
(
new
FragmentPagerAdapter
(
getSupportFragmentManager
())
{
@Override
...
...
@@ -73,6 +78,13 @@ public class StatusBarFragmentActivity extends BaseActivity {
@Override
public
void
onPageSelected
(
int
position
)
{
navigation
.
setSelectedItemId
(
itemIds
[
position
]);
if
(
position
==
0
)
{
((
StatusBarColorFragment
)
mFragmentList
.
get
(
0
)).
updateFakeStatusBar
();
}
else
if
(
position
==
1
)
{
((
StatusBarAlphaFragment
)
mFragmentList
.
get
(
1
)).
updateFakeStatusBar
();
}
else
{
((
StatusBarImageViewFragment
)
mFragmentList
.
get
(
2
)).
updateFakeStatusBar
();
}
}
@Override
...
...
app/src/main/java/com/blankj/androidutilcode/activity/StatusBarImageViewActivity.java
浏览文件 @
8b05af19
...
...
@@ -36,11 +36,13 @@ public class StatusBarImageViewActivity extends BaseActivity {
@Override
public
void
initView
(
Bundle
savedInstanceState
,
View
view
)
{
BarUtils
.
setStatusBarAlpha
(
StatusBarImageViewActivity
.
this
,
mAlpha
);
findViewById
(
R
.
id
.
btn_set_transparent
).
setOnClickListener
(
this
);
mTvStatusAlpha
=
(
TextView
)
findViewById
(
R
.
id
.
tv_status_alpha
);
sbChangeAlpha
=
(
SeekBar
)
findViewById
(
R
.
id
.
sb_change_alpha
);
sbChangeAlpha
.
setOnSeekBarChangeListener
(
translucentListener
);
sbChangeAlpha
.
setProgress
(
mAlpha
);
mTvStatusAlpha
.
setText
(
String
.
valueOf
(
mAlpha
)
);
}
@Override
...
...
@@ -61,7 +63,7 @@ public class StatusBarImageViewActivity extends BaseActivity {
@Override
public
void
onProgressChanged
(
SeekBar
seekBar
,
int
progress
,
boolean
fromUser
)
{
mAlpha
=
progress
;
BarUtils
.
setStatusBar
4ImageView
(
StatusBarImageViewActivity
.
this
,
mAlpha
,
null
);
BarUtils
.
setStatusBar
Alpha
(
StatusBarImageViewActivity
.
this
,
mAlpha
);
mTvStatusAlpha
.
setText
(
String
.
valueOf
(
mAlpha
));
}
...
...
app/src/main/java/com/blankj/androidutilcode/base/BaseBackActivity.java
浏览文件 @
8b05af19
package
com.blankj.androidutilcode.base
;
import
android.graphics.Color
;
import
android.support.v7.widget.Toolbar
;
import
android.view.LayoutInflater
;
import
android.view.MenuItem
;
...
...
@@ -34,7 +33,6 @@ public abstract class BaseBackActivity extends BaseActivity {
if
(
getSupportActionBar
()
!=
null
)
{
getSupportActionBar
().
setDisplayHomeAsUpEnabled
(
true
);
}
contentView
.
setBackgroundColor
(
Color
.
WHITE
);
}
@Override
...
...
app/src/main/java/com/blankj/androidutilcode/base/BaseFragment.java
浏览文件 @
8b05af19
...
...
@@ -17,7 +17,7 @@ import android.view.ViewGroup;
* desc : Fragment-v4基类
* </pre>
*/
public
abstract
class
BaseFragment
extends
Fragment
public
abstract
class
BaseFragment
<
T
extends
BaseActivity
>
extends
Fragment
implements
IBaseView
,
View
.
OnClickListener
{
private
static
final
String
TAG
=
"BaseFragment"
;
...
...
@@ -32,7 +32,7 @@ public abstract class BaseFragment extends Fragment
*/
private
long
lastClick
=
0
;
protected
BaseActivity
mActivity
;
protected
T
mActivity
;
@Override
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
...
...
@@ -70,7 +70,7 @@ public abstract class BaseFragment extends Fragment
@Override
public
void
onActivityCreated
(
Bundle
savedInstanceState
)
{
super
.
onActivityCreated
(
savedInstanceState
);
mActivity
=
(
BaseActivity
)
getActivity
();
mActivity
=
(
T
)
getActivity
();
initView
(
savedInstanceState
,
contentView
);
doBusiness
(
mActivity
);
Log
.
d
(
TAG
,
"onActivityCreated: "
);
...
...
app/src/main/java/com/blankj/androidutilcode/fragment/StatusBarAlphaFragment.java
浏览文件 @
8b05af19
...
...
@@ -3,9 +3,13 @@ package com.blankj.androidutilcode.fragment;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.SeekBar
;
import
android.widget.TextView
;
import
com.blankj.androidutilcode.R
;
import
com.blankj.androidutilcode.activity.StatusBarFragmentActivity
;
import
com.blankj.androidutilcode.base.BaseFragment
;
import
com.blankj.utilcode.util.BarUtils
;
/**
* <pre>
...
...
@@ -15,10 +19,22 @@ import com.blankj.androidutilcode.base.BaseFragment;
* desc :
* </pre>
*/
public
class
StatusBarAlphaFragment
extends
BaseFragment
{
public
class
StatusBarAlphaFragment
extends
BaseFragment
<
StatusBarFragmentActivity
>
{
private
int
mAlpha
;
private
TextView
mTvStatusAlpha
;
private
SeekBar
sbChangeAlpha
;
private
View
fakeStatusBar
;
public
static
StatusBarAlphaFragment
newInstance
()
{
return
new
StatusBarAlphaFragment
();
}
@Override
public
void
initData
(
Bundle
bundle
)
{
mAlpha
=
112
;
}
@Override
...
...
@@ -28,7 +44,12 @@ public class StatusBarAlphaFragment extends BaseFragment {
@Override
public
void
initView
(
Bundle
savedInstanceState
,
View
view
)
{
fakeStatusBar
=
view
.
findViewById
(
R
.
id
.
fake_status_bar
);
mTvStatusAlpha
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
tv_status_alpha
);
sbChangeAlpha
=
(
SeekBar
)
view
.
findViewById
(
R
.
id
.
sb_change_alpha
);
view
.
findViewById
(
R
.
id
.
btn_set_transparent
).
setOnClickListener
(
this
);
sbChangeAlpha
.
setOnSeekBarChangeListener
(
translucentListener
);
mTvStatusAlpha
.
setText
(
String
.
valueOf
(
mAlpha
));
}
@Override
...
...
@@ -38,6 +59,33 @@ public class StatusBarAlphaFragment extends BaseFragment {
@Override
public
void
onWidgetClick
(
View
view
)
{
switch
(
view
.
getId
())
{
case
R
.
id
.
btn_set_transparent
:
sbChangeAlpha
.
setProgress
(
0
);
break
;
}
}
private
SeekBar
.
OnSeekBarChangeListener
translucentListener
=
new
SeekBar
.
OnSeekBarChangeListener
()
{
@Override
public
void
onProgressChanged
(
SeekBar
seekBar
,
int
progress
,
boolean
fromUser
)
{
mAlpha
=
progress
;
mTvStatusAlpha
.
setText
(
String
.
valueOf
(
mAlpha
));
updateFakeStatusBar
();
}
@Override
public
void
onStartTrackingTouch
(
SeekBar
seekBar
)
{
}
@Override
public
void
onStopTrackingTouch
(
SeekBar
seekBar
)
{
}
};
public
void
updateFakeStatusBar
()
{
BarUtils
.
setFakeStatusBarAlpha
(
fakeStatusBar
,
mAlpha
);
}
}
app/src/main/java/com/blankj/androidutilcode/fragment/StatusBarColorFragment.java
浏览文件 @
8b05af19
...
...
@@ -2,10 +2,18 @@ package com.blankj.androidutilcode.fragment;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.support.v4.content.ContextCompat
;
import
android.view.View
;
import
android.widget.SeekBar
;
import
android.widget.TextView
;
import
com.blankj.androidutilcode.R
;
import
com.blankj.androidutilcode.UtilsApp
;
import
com.blankj.androidutilcode.activity.StatusBarFragmentActivity
;
import
com.blankj.androidutilcode.base.BaseFragment
;
import
com.blankj.utilcode.util.BarUtils
;
import
java.util.Random
;
/**
* <pre>
...
...
@@ -15,10 +23,25 @@ import com.blankj.androidutilcode.base.BaseFragment;
* desc :
* </pre>
*/
public
class
StatusBarColorFragment
extends
BaseFragment
{
public
class
StatusBarColorFragment
extends
BaseFragment
<
StatusBarFragmentActivity
>
{
private
Random
mRandom
;
private
int
mColor
;
private
int
mAlpha
;
private
TextView
mTvStatusAlpha
;
private
SeekBar
sbChangeAlpha
;
private
View
fakeStatusBar
;
public
static
StatusBarColorFragment
newInstance
()
{
return
new
StatusBarColorFragment
();
}
@Override
public
void
initData
(
Bundle
bundle
)
{
mRandom
=
new
Random
();
mColor
=
ContextCompat
.
getColor
(
UtilsApp
.
getInstance
(),
R
.
color
.
colorPrimary
);
mAlpha
=
112
;
}
@Override
...
...
@@ -28,9 +51,17 @@ public class StatusBarColorFragment extends BaseFragment {
@Override
public
void
initView
(
Bundle
savedInstanceState
,
View
view
)
{
fakeStatusBar
=
view
.
findViewById
(
R
.
id
.
fake_status_bar
);
updateFakeStatusBar
();
view
.
findViewById
(
R
.
id
.
btn_random_color
).
setOnClickListener
(
this
);
view
.
findViewById
(
R
.
id
.
btn_set_transparent
).
setOnClickListener
(
this
);
mTvStatusAlpha
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
tv_status_alpha
);
sbChangeAlpha
=
(
SeekBar
)
view
.
findViewById
(
R
.
id
.
sb_change_alpha
);
sbChangeAlpha
.
setOnSeekBarChangeListener
(
colorListener
);
mTvStatusAlpha
.
setText
(
String
.
valueOf
(
mAlpha
));
}
@Override
public
void
doBusiness
(
Context
context
)
{
...
...
@@ -38,6 +69,37 @@ public class StatusBarColorFragment extends BaseFragment {
@Override
public
void
onWidgetClick
(
View
view
)
{
switch
(
view
.
getId
())
{
case
R
.
id
.
btn_random_color
:
mColor
=
0xff000000
|
mRandom
.
nextInt
(
0xffffff
);
updateFakeStatusBar
();
break
;
case
R
.
id
.
btn_set_transparent
:
sbChangeAlpha
.
setProgress
(
0
);
break
;
}
}
private
SeekBar
.
OnSeekBarChangeListener
colorListener
=
new
SeekBar
.
OnSeekBarChangeListener
()
{
@Override
public
void
onProgressChanged
(
SeekBar
seekBar
,
int
progress
,
boolean
fromUser
)
{
mAlpha
=
progress
;
mTvStatusAlpha
.
setText
(
String
.
valueOf
(
mAlpha
));
updateFakeStatusBar
();
}
@Override
public
void
onStartTrackingTouch
(
SeekBar
seekBar
)
{
}
@Override
public
void
onStopTrackingTouch
(
SeekBar
seekBar
)
{
}
};
public
void
updateFakeStatusBar
()
{
BarUtils
.
setFakeStatusBarColor
(
fakeStatusBar
,
mColor
,
mAlpha
);
}
}
app/src/main/java/com/blankj/androidutilcode/fragment/StatusBarImageViewFragment.java
浏览文件 @
8b05af19
...
...
@@ -3,8 +3,11 @@ package com.blankj.androidutilcode.fragment;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.SeekBar
;
import
android.widget.TextView
;
import
com.blankj.androidutilcode.R
;
import
com.blankj.androidutilcode.activity.StatusBarFragmentActivity
;
import
com.blankj.androidutilcode.base.BaseFragment
;
import
com.blankj.utilcode.util.BarUtils
;
...
...
@@ -16,10 +19,21 @@ import com.blankj.utilcode.util.BarUtils;
* desc :
* </pre>
*/
public
class
StatusBarImageViewFragment
extends
BaseFragment
{
public
class
StatusBarImageViewFragment
extends
BaseFragment
<
StatusBarFragmentActivity
>
{
private
int
mAlpha
;
private
TextView
mTvStatusAlpha
;
private
SeekBar
sbChangeAlpha
;
private
View
fakeStatusBar
;
public
static
StatusBarImageViewFragment
newInstance
()
{
return
new
StatusBarImageViewFragment
();
}
@Override
public
void
initData
(
Bundle
bundle
)
{
mAlpha
=
112
;
}
@Override
...
...
@@ -29,7 +43,12 @@ public class StatusBarImageViewFragment extends BaseFragment {
@Override
public
void
initView
(
Bundle
savedInstanceState
,
View
view
)
{
BarUtils
.
setStatusBar4ImageViewInFragment
(
mActivity
,
null
);
fakeStatusBar
=
view
.
findViewById
(
R
.
id
.
fake_status_bar
);
mTvStatusAlpha
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
tv_status_alpha
);
sbChangeAlpha
=
(
SeekBar
)
view
.
findViewById
(
R
.
id
.
sb_change_alpha
);
view
.
findViewById
(
R
.
id
.
btn_set_transparent
).
setOnClickListener
(
this
);
sbChangeAlpha
.
setOnSeekBarChangeListener
(
translucentListener
);
mTvStatusAlpha
.
setText
(
String
.
valueOf
(
mAlpha
));
}
@Override
...
...
@@ -39,6 +58,33 @@ public class StatusBarImageViewFragment extends BaseFragment {
@Override
public
void
onWidgetClick
(
View
view
)
{
switch
(
view
.
getId
())
{
case
R
.
id
.
btn_set_transparent
:
sbChangeAlpha
.
setProgress
(
0
);
break
;
}
}
private
SeekBar
.
OnSeekBarChangeListener
translucentListener
=
new
SeekBar
.
OnSeekBarChangeListener
()
{
@Override
public
void
onProgressChanged
(
SeekBar
seekBar
,
int
progress
,
boolean
fromUser
)
{
mAlpha
=
progress
;
mTvStatusAlpha
.
setText
(
String
.
valueOf
(
mAlpha
));
updateFakeStatusBar
();
}
@Override
public
void
onStartTrackingTouch
(
SeekBar
seekBar
)
{
}
@Override
public
void
onStopTrackingTouch
(
SeekBar
seekBar
)
{
}
};
public
void
updateFakeStatusBar
()
{
BarUtils
.
setFakeStatusBarAlpha
(
fakeStatusBar
,
mAlpha
);
}
}
app/src/main/res/layout/activity_activity.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_app.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_back.xml
浏览文件 @
8b05af19
...
...
@@ -3,7 +3,8 @@
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
android:background=
"@color/white"
>
<android.support.design.widget.AppBarLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_bar.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_clean.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_device.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_flashlight.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_keyboard.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:id=
"@+id/fragment_container"
...
...
app/src/main/res/layout/activity_log.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_network.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_permission.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_phone.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_pinyin.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_process.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_sdcard.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_snackbar.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_span.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_status_bar_alpha.xml
0 → 100644
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/bg_bar"
>
<LinearLayout
android:id=
"@+id/ll_container"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center_horizontal"
android:orientation=
"vertical"
android:paddingLeft=
"@dimen/spacing_16"
android:paddingRight=
"@dimen/spacing_16"
>
<TextView
android:id=
"@+id/tv_status_alpha"
style=
"@style/TextStyle"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
/>
<SeekBar
android:id=
"@+id/sb_change_alpha"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:max=
"255"
android:padding=
"@dimen/spacing_8"
android:progress=
"112"
/>
<Button
android:id=
"@+id/btn_set_transparent"
style=
"@style/WideBtnStyle"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/status_bar_set_transparent"
/>
</LinearLayout>
</ScrollView>
app/src/main/res/layout/activity_status_bar_color.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center_horizontal"
android:orientation=
"vertical"
android:padding=
"@dimen/spacing_16"
>
android:paddingLeft=
"@dimen/spacing_16"
android:paddingRight=
"@dimen/spacing_16"
>
<TextView
android:id=
"@+id/tv_status_alpha"
...
...
@@ -22,7 +25,8 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:max=
"255"
android:padding=
"@dimen/spacing_8"
/>
android:padding=
"@dimen/spacing_8"
android:progress=
"112"
/>
<Button
android:id=
"@+id/btn_random_color"
...
...
app/src/main/res/layout/activity_status_bar_image_view.xml
浏览文件 @
8b05af19
...
...
@@ -21,8 +21,8 @@
android:layout_height=
"wrap_content"
android:gravity=
"center_horizontal"
android:orientation=
"vertical"
android:padding
=
"@dimen/spacing_16"
>
android:padding
Left=
"@dimen/spacing_16"
android:paddingRight=
"@dimen/spacing_16"
>
<TextView
android:id=
"@+id/tv_status_alpha"
...
...
@@ -36,7 +36,8 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:max=
"255"
android:padding=
"@dimen/spacing_8"
/>
android:padding=
"@dimen/spacing_8"
android:progress=
"112"
/>
<Button
android:id=
"@+id/btn_set_transparent"
...
...
app/src/main/res/layout/activity_toast.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/dialog_keyboard.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/fragment_status_bar_alpha.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/bg_bar"
>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/bg_bar"
android:orientation=
"vertical"
>
<View
android:id=
"@+id/fake_status_bar"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
/>
<LinearLayout
android:id=
"@+id/ll_container"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center_horizontal"
android:orientation=
"vertical"
android:padding=
"@dimen/spacing_16"
>
android:paddingLeft=
"@dimen/spacing_16"
android:paddingRight=
"@dimen/spacing_16"
>
<TextView
android:id=
"@+id/tv_status_alpha"
...
...
@@ -23,7 +32,8 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:max=
"255"
android:padding=
"@dimen/spacing_8"
/>
android:padding=
"@dimen/spacing_8"
android:progress=
"112"
/>
<Button
android:id=
"@+id/btn_set_transparent"
...
...
@@ -33,4 +43,4 @@
android:text=
"@string/status_bar_set_transparent"
/>
</LinearLayout>
</
ScrollView
>
</
LinearLayout
>
app/src/main/res/layout/fragment_status_bar_color.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<View
android:id=
"@+id/fake_status_bar"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
/>
<LinearLayout
android:id=
"@id/ll_container"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center_horizontal"
android:orientation=
"vertical"
android:padding=
"@dimen/spacing_16"
>
android:paddingLeft=
"@dimen/spacing_16"
android:paddingRight=
"@dimen/spacing_16"
>
<TextView
android:id=
"@+id/tv_status_alpha"
...
...
@@ -22,7 +31,8 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:max=
"255"
android:padding=
"@dimen/spacing_8"
/>
android:padding=
"@dimen/spacing_8"
android:progress=
"112"
/>
<Button
android:id=
"@+id/btn_random_color"
...
...
@@ -39,4 +49,4 @@
android:text=
"@string/status_bar_set_transparent"
/>
</LinearLayout>
</
ScrollView
>
</
LinearLayout
>
app/src/main/res/layout/fragment_status_bar_image_view.xml
浏览文件 @
8b05af19
<?xml version="1.0" encoding="utf-8"?>
<
Linear
Layout
<
Frame
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
android:layout_height=
"match_parent"
>
<ImageView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:scaleType=
"centerCrop"
android:src=
"@drawable/lena"
/>
<ScrollView
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white"
>
android:orientation=
"vertical"
>
<ImageView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:scaleType=
"centerCrop"
android:src=
"@drawable/lena"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center_horizontal"
android:orientation=
"vertical"
android:padding=
"@dimen/spacing_16"
>
android:paddingLeft=
"@dimen/spacing_16"
android:paddingRight=
"@dimen/spacing_16"
>
<TextView
android:id=
"@+id/tv_status_alpha"
...
...
@@ -35,7 +35,8 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:max=
"255"
android:padding=
"@dimen/spacing_8"
/>
android:padding=
"@dimen/spacing_8"
android:progress=
"112"
/>
<Button
android:id=
"@+id/btn_set_transparent"
...
...
@@ -45,5 +46,12 @@
android:text=
"@string/status_bar_set_transparent"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
\ No newline at end of file
</LinearLayout>
<View
android:id=
"@+id/fake_status_bar"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
/>
</FrameLayout>
\ No newline at end of file
utilcode/src/main/java/com/blankj/utilcode/util/BarUtils.java
浏览文件 @
8b05af19
此差异已折叠。
点击以展开。
utilcode/src/main/java/com/blankj/utilcode/util/FragmentUtils.java
浏览文件 @
8b05af19
...
...
@@ -233,6 +233,18 @@ public final class FragmentUtils {
}
}
/**
* 替换fragment
*
* @param srcFragment 源fragment
* @param destFragment 目标fragment
* @return 目标fragment
*/
public
static
Fragment
replaceFragment
(
@NonNull
final
Fragment
srcFragment
,
@NonNull
final
Fragment
destFragment
)
{
return
replaceFragment
(
srcFragment
,
destFragment
,
false
);
}
/**
* 替换fragment
*
...
...
utilcode/src/main/java/com/blankj/utilcode/util/ScreenUtils.java
浏览文件 @
8b05af19
...
...
@@ -5,8 +5,10 @@ import android.app.KeyguardManager;
import
android.content.Context
;
import
android.content.pm.ActivityInfo
;
import
android.content.res.Configuration
;
import
android.content.res.Resources
;
import
android.graphics.Bitmap
;
import
android.provider.Settings
;
import
android.support.annotation.NonNull
;
import
android.util.DisplayMetrics
;
import
android.view.Surface
;
import
android.view.View
;
...
...
@@ -53,7 +55,7 @@ public final class ScreenUtils {
*
* @param activity activity
*/
public
static
void
setLandscape
(
final
Activity
activity
)
{
public
static
void
setLandscape
(
@NonNull
final
Activity
activity
)
{
activity
.
setRequestedOrientation
(
ActivityInfo
.
SCREEN_ORIENTATION_LANDSCAPE
);
}
...
...
@@ -62,7 +64,7 @@ public final class ScreenUtils {
*
* @param activity activity
*/
public
static
void
setPortrait
(
final
Activity
activity
)
{
public
static
void
setPortrait
(
@NonNull
final
Activity
activity
)
{
activity
.
setRequestedOrientation
(
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
);
}
...
...
@@ -90,7 +92,7 @@ public final class ScreenUtils {
* @param activity activity
* @return 屏幕旋转角度
*/
public
static
int
getScreenRotation
(
final
Activity
activity
)
{
public
static
int
getScreenRotation
(
@NonNull
final
Activity
activity
)
{
switch
(
activity
.
getWindowManager
().
getDefaultDisplay
().
getRotation
())
{
default
:
case
Surface
.
ROTATION_0
:
...
...
@@ -110,7 +112,7 @@ public final class ScreenUtils {
* @param activity activity
* @return Bitmap
*/
public
static
Bitmap
captureWithStatusBar
(
final
Activity
activity
)
{
public
static
Bitmap
captureWithStatusBar
(
@NonNull
final
Activity
activity
)
{
View
view
=
activity
.
getWindow
().
getDecorView
();
view
.
setDrawingCacheEnabled
(
true
);
view
.
buildDrawingCache
();
...
...
@@ -128,12 +130,14 @@ public final class ScreenUtils {
* @param activity activity
* @return Bitmap
*/
public
static
Bitmap
captureWithoutStatusBar
(
final
Activity
activity
)
{
public
static
Bitmap
captureWithoutStatusBar
(
@NonNull
final
Activity
activity
)
{
View
view
=
activity
.
getWindow
().
getDecorView
();
view
.
setDrawingCacheEnabled
(
true
);
view
.
buildDrawingCache
();
Bitmap
bmp
=
view
.
getDrawingCache
();
int
statusBarHeight
=
BarUtils
.
getStatusBarHeight
(
activity
);
Resources
resources
=
activity
.
getResources
();
int
resourceId
=
resources
.
getIdentifier
(
"status_bar_height"
,
"dimen"
,
"android"
);
int
statusBarHeight
=
resources
.
getDimensionPixelSize
(
resourceId
);
DisplayMetrics
dm
=
new
DisplayMetrics
();
activity
.
getWindowManager
().
getDefaultDisplay
().
getMetrics
(
dm
);
Bitmap
ret
=
Bitmap
.
createBitmap
(
bmp
,
0
,
statusBarHeight
,
dm
.
widthPixels
,
dm
.
heightPixels
-
statusBarHeight
);
...
...
@@ -176,12 +180,12 @@ public final class ScreenUtils {
}
/**
*
Check if the device is a tablet based on screen size
*
判断是否是平板
*
* @return {@code true}:
Yes<br>{@code false}: No
* @return {@code true}:
是<br>{@code false}: 否
*/
public
static
boolean
isTablet
()
{
return
(
Utils
.
getContext
().
getResources
().
getConfiguration
().
screenLayout
return
(
Utils
.
getContext
().
getResources
().
getConfiguration
().
screenLayout
&
Configuration
.
SCREENLAYOUT_SIZE_MASK
)
>=
Configuration
.
SCREENLAYOUT_SIZE_LARGE
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录