作者 liyan

修改BaseFragment2

@@ -43,7 +43,7 @@ abstract class BaseFragment : Fragment() { @@ -43,7 +43,7 @@ abstract class BaseFragment : Fragment() {
43 if (Date().month + 1 == 4 && Date().date == 4) { 43 if (Date().month + 1 == 4 && Date().date == 4) {
44 // initStatusColor(getColor(requireContext(), R.color.colorGray666)) 44 // initStatusColor(getColor(requireContext(), R.color.colorGray666))
45 } else { 45 } else {
46 - initStatusColor(0) 46 +// initStatusColor(0)
47 } 47 }
48 initView() 48 initView()
49 initData() 49 initData()
@@ -58,20 +58,20 @@ abstract class BaseFragment : Fragment() { @@ -58,20 +58,20 @@ abstract class BaseFragment : Fragment() {
58 58
59 59
60 60
61 - private fun initStatusColor(color: Int) {  
62 - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {  
63 -// requireActivity().window.statusBarColor = if (color == 0) ColorUtil.getColor(requireContext()) else color  
64 - }  
65 - if (ColorUtils.calculateLuminance(Color.TRANSPARENT) >= 0.5) {  
66 - // 设置状态栏中字体的颜色为黑色  
67 - requireActivity().window.decorView.systemUiVisibility =  
68 - View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR  
69 - } else {  
70 - // 跟随系统  
71 - requireActivity().window.decorView.systemUiVisibility =  
72 - View.SYSTEM_UI_FLAG_LAYOUT_STABLE  
73 - }  
74 - } 61 +// private fun initStatusColor(color: Int) {
  62 +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  63 +//// requireActivity().window.statusBarColor = if (color == 0) ColorUtil.getColor(requireContext()) else color
  64 +// }
  65 +// if (ColorUtils.calculateLuminance(Color.TRANSPARENT) >= 0.5) {
  66 +// // 设置状态栏中字体的颜色为黑色
  67 +// requireActivity().window.decorView.systemUiVisibility =
  68 +// View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
  69 +// } else {
  70 +// // 跟随系统
  71 +// requireActivity().window.decorView.systemUiVisibility =
  72 +// View.SYSTEM_UI_FLAG_LAYOUT_STABLE
  73 +// }
  74 +// }
75 75
76 override fun onDestroyView() { 76 override fun onDestroyView() {
77 super.onDestroyView() 77 super.onDestroyView()
@@ -36,11 +36,19 @@ import com.youth.banner.indicator.CircleIndicator @@ -36,11 +36,19 @@ import com.youth.banner.indicator.CircleIndicator
36 * auth:张继 36 * auth:张继
37 * des: 37 * des:
38 */ 38 */
39 -class HomeFragment : BaseLifeCycleFragment<MineViewModel,FragmentHomeBinding>(FragmentHomeBinding::inflate) { 39 +class HomeFragment : BaseLifeCycleFragment<MineViewModel,FragmentHomeBinding>(FragmentHomeBinding::inflate){
40 override fun initDataObserver() { 40 override fun initDataObserver() {
41 41
42 } 42 }
43 43
  44 +// override fun initImmersionBar() {
  45 +// ImmersionBar.with(this).statusBarColor(R.color.color_25).statusBarDarkFont(true).init()
  46 +// }
  47 +//
  48 +// override fun immersionBarEnabled(): Boolean {
  49 +// return true
  50 +// }
  51 +
44 } 52 }
45 //class HomeFragment : Fragment() { 53 //class HomeFragment : Fragment() {
46 // override fun onCreateView( 54 // override fun onCreateView(
@@ -15,5 +15,5 @@ class MineFragment :BaseLifeCycleFragment<MineViewModel,FragmentMineBinding>(Fra @@ -15,5 +15,5 @@ class MineFragment :BaseLifeCycleFragment<MineViewModel,FragmentMineBinding>(Fra
15 override fun initDataObserver() { 15 override fun initDataObserver() {
16 16
17 } 17 }
18 - 18 +
19 } 19 }
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 android:layout_height="match_parent" 6 android:layout_height="match_parent"
7 android:orientation="vertical"> 7 android:orientation="vertical">
8 8
  9 +
9 <LinearLayout 10 <LinearLayout
10 android:layout_width="match_parent" 11 android:layout_width="match_parent"
11 android:layout_height="?actionBarSize" 12 android:layout_height="?actionBarSize"
@@ -3,4 +3,4 @@ @@ -3,4 +3,4 @@
3 android:id="@+id/status_bar" 3 android:id="@+id/status_bar"
4 android:layout_width="match_parent" 4 android:layout_width="match_parent"
5 android:layout_height="24dp" 5 android:layout_height="24dp"
6 - android:background="@android:color/transparent" />  
  6 + android:background="@color/color_25" />