|
36 | 36 | import zblibrary.demo.activity.ScanActivity; |
37 | 37 | import zuo.biao.library.base.BaseActivity; |
38 | 38 | import zuo.biao.library.interfaces.OnBottomDragListener; |
| 39 | +import zuo.biao.library.manager.SystemBarTintManager; |
39 | 40 | import zuo.biao.library.ui.AlertDialog; |
40 | 41 | import zuo.biao.library.ui.AlertDialog.OnDialogButtonClickListener; |
41 | 42 | import zuo.biao.library.ui.BottomMenuWindow; |
@@ -119,6 +120,23 @@ public void initView() {//必须调用 |
119 | 120 | svDemoMain = findView(R.id.svDemoMain); |
120 | 121 | } |
121 | 122 |
|
| 123 | + /**设置沉浸状态栏和导航栏颜色 |
| 124 | + * @param position |
| 125 | + */ |
| 126 | + private void setTintColor(int position) { |
| 127 | + if (position < 0) { |
| 128 | + position = 0; |
| 129 | + } else if (position >= TOPBAR_COLOR_RESIDS.length) { |
| 130 | + position = TOPBAR_COLOR_RESIDS.length - 1; |
| 131 | + } |
| 132 | + |
| 133 | + rlDemoMainTopbar.setBackgroundResource(TOPBAR_COLOR_RESIDS[position]); |
| 134 | + |
| 135 | + SystemBarTintManager tintManager = new SystemBarTintManager(this); |
| 136 | + tintManager.setStatusBarTintEnabled(true); |
| 137 | + tintManager.setStatusBarTintResource(TOPBAR_COLOR_RESIDS[position]);//状态背景色,可传drawable资源 |
| 138 | + } |
| 139 | + |
122 | 140 | /**显示列表选择弹窗 |
123 | 141 | */ |
124 | 142 | private void showItemDialog() { |
@@ -270,16 +288,14 @@ public void onDialogItemClick(int requestCode, int position, String item) { |
270 | 288 | } |
271 | 289 | switch (requestCode) { |
272 | 290 | case DIALOG_SET_TOPBAR: |
273 | | - if (position >= TOPBAR_COLOR_RESIDS.length) { |
274 | | - position = TOPBAR_COLOR_RESIDS.length - 1; |
275 | | - } |
276 | | - rlDemoMainTopbar.setBackgroundResource(TOPBAR_COLOR_RESIDS[position]); |
| 291 | + setTintColor(position); |
277 | 292 | break; |
278 | 293 | default: |
279 | 294 | break; |
280 | 295 | } |
281 | 296 | } |
282 | 297 |
|
| 298 | + |
283 | 299 | @Override |
284 | 300 | public void onDragBottom(boolean rightToLeft) { |
285 | 301 | if (rightToLeft) { |
@@ -499,9 +515,9 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { |
499 | 515 | break; |
500 | 516 | case REQUEST_TO_BOTTOM_MENU: |
501 | 517 | if (data != null) { |
502 | | - int selectedPosition = data.getIntExtra(BottomMenuWindow.RESULT_ITEM_ID, -1); |
503 | | - if (selectedPosition >= 0 && selectedPosition < TOPBAR_COLOR_RESIDS.length) { |
504 | | - rlDemoMainTopbar.setBackgroundResource(TOPBAR_COLOR_RESIDS[selectedPosition]); |
| 518 | + int position = data.getIntExtra(BottomMenuWindow.RESULT_ITEM_ID, -1); |
| 519 | + if (position >= 0) { |
| 520 | + setTintColor(position); |
505 | 521 | } |
506 | 522 | } |
507 | 523 | break; |
|
0 commit comments