| | | | |
| Offset 1, 40 lines modified | Offset 1, 45 lines modified |
| | |
| 1 | package·com.android.car.ui.core; | 1 | package·com.android.car.ui.core; |
| | |
| 2 | import·java.util.Iterator; | 2 | import·java.util.Iterator; |
| 3 | import·com.android.car.ui.utils.CarUiUtils; | |
| 4 | import·androidx.fragment.app.Fragment; | 3 | import·androidx.fragment.app.Fragment; |
| 5 | import·androidx.fragment.app.FragmentActivity; | 4 | import·androidx.fragment.app.FragmentActivity; |
| 6 | import·android.view.View$OnLayoutChangeListener; | 5 | import·android.view.View$OnLayoutChangeListener; |
| | 6 | import·com.android.car.ui.utils.CarUiUtils; |
| | 7 | import·com.android.car.ui.R$id; |
| 7 | import·com.android.car.ui.baselayout.InsetsChangedListener; | 8 | import·com.android.car.ui.baselayout.InsetsChangedListener; |
| 8 | import·com.android.car.ui.baselayout.Insets; | 9 | import·com.android.car.ui.baselayout.Insets; |
| 9 | import·android.view.View; | 10 | import·android.view.View; |
| 10 | import·android.app.Activity; | 11 | import·android.app.Activity; |
| 11 | import·android.view.ViewTreeObserver$OnGlobalLayoutListener; | 12 | import·android.view.ViewTreeObserver$OnGlobalLayoutListener; |
| | |
| 12 | class·BaseLayoutController$InsetsUpdater·implements·ViewTreeObserver$OnGlobalLayoutListener | 13 | public·final·class·BaseLayoutController$InsetsUpdater·implements·ViewTreeObserver$OnGlobalLayoutListener |
| 13 | { | 14 | { |
| 14 | ····private·static·final·String·BOTTOM_INSET_TAG·=·"car_ui_bottom_inset"; | 15 | ····private·static·final·String·BOTTOM_INSET_TAG·=·"car_ui_bottom_inset"; |
| 15 | ····private·static·final·String·LEFT_INSET_TAG·=·"car_ui_left_inset"; | 16 | ····private·static·final·String·LEFT_INSET_TAG·=·"car_ui_left_inset"; |
| 16 | ····private·static·final·String·RIGHT_INSET_TAG·=·"car_ui_right_inset"; | 17 | ····private·static·final·String·RIGHT_INSET_TAG·=·"car_ui_right_inset"; |
| 17 | ····private·static·final·String·TOP_INSET_TAG·=·"car_ui_top_inset"; | 18 | ····private·static·final·String·TOP_INSET_TAG·=·"car_ui_top_inset"; |
| 18 | ····private·final·Activity·mActivity; | 19 | ····private·final·Activity·mActivity; |
| 19 | ····private·final·View·mBottomInsetView; | 20 | ····private·final·View·mBottomInsetView; |
| | 21 | ····private·final·View·mContentView; |
| | 22 | ····private·final·View·mContentViewContainer; |
| 20 | ····private·Insets·mInsets; | 23 | ····private·Insets·mInsets; |
| 21 | ····private·InsetsChangedListener·mInsetsChangedListenerDelegate; | 24 | ····private·InsetsChangedListener·mInsetsChangedListenerDelegate; |
| 22 | ····private·boolean·mInsetsDirty; | 25 | ····private·boolean·mInsetsDirty; |
| 23 | ····private·final·View·mLeftInsetView; | 26 | ····private·final·View·mLeftInsetView; |
| 24 | ····private·final·View·mRightInsetView; | 27 | ····private·final·View·mRightInsetView; |
| 25 | ····private·final·View·mTopInsetView; | 28 | ····private·final·View·mTopInsetView; |
| 26 | ···· | 29 | ···· |
| 27 | ····BaseLayoutController$InsetsUpdater(final·Activity·mActivity,·View·view,·final·View·view2)·{ | 30 | ····public·BaseLayoutController$InsetsUpdater(final·Activity·mActivity,·View·view,·final·View·mContentView)·{ |
| 28 | ········this.mInsetsDirty·=·true; | 31 | ········this.mInsetsDirty·=·true; |
| 29 | ········this.mInsets·=·new·Insets(); | 32 | ········this.mInsets·=·new·Insets(); |
| 30 | ········this.mActivity·=·mActivity; | 33 | ········this.mActivity·=·mActivity; |
| | 34 | ········this.mContentView·=·mContentView; |
| | 35 | ········this.mContentViewContainer·=·CarUiUtils.requireViewByRefId(view,·R$id.car_ui_base_layout_content_container); |
| 31 | ········this.mLeftInsetView·=·view.findViewWithTag((Object)"car_ui_left_inset"); | 36 | ········this.mLeftInsetView·=·view.findViewWithTag((Object)"car_ui_left_inset"); |
| 32 | ········this.mRightInsetView·=·view.findViewWithTag((Object)"car_ui_right_inset"); | 37 | ········this.mRightInsetView·=·view.findViewWithTag((Object)"car_ui_right_inset"); |
| 33 | ········this.mTopInsetView·=·view.findViewWithTag((Object)"car_ui_top_inset"); | 38 | ········this.mTopInsetView·=·view.findViewWithTag((Object)"car_ui_top_inset"); |
| 34 | ········this.mBottomInsetView·=·view.findViewWithTag((Object)"car_ui_bottom_inset"); | 39 | ········this.mBottomInsetView·=·view.findViewWithTag((Object)"car_ui_bottom_inset"); |
| 35 | ········final·-$$Lambda$BaseLayoutController$InsetsUpdater$zzCIB0038f8j1iFmYePHWvmc4w4·-$$Lambda$BaseLayoutController$InsetsUpdater$zzCIB0038f8j1iFmYePHWvmc4w4·=·new·-$$Lambda$BaseLayoutController$InsetsUpdater$zzCIB0038f8j1iFmYePHWvmc4w4(this); | 40 | ········final·-$$Lambda$BaseLayoutController$InsetsUpdater$zzCIB0038f8j1iFmYePHWvmc4w4·-$$Lambda$BaseLayoutController$InsetsUpdater$zzCIB0038f8j1iFmYePHWvmc4w4·=·new·-$$Lambda$BaseLayoutController$InsetsUpdater$zzCIB0038f8j1iFmYePHWvmc4w4(this); |
| 36 | ········view·=·this.mLeftInsetView; | 41 | ········view·=·this.mLeftInsetView; |
| 37 | ········if·(view·!=·null)·{ | 42 | ········if·(view·!=·null)·{ |
| Offset 48, 15 lines modified | Offset 53, 16 lines modified |
| 48 | ········if·(view·!=·null)·{ | 53 | ········if·(view·!=·null)·{ |
| 49 | ············view.addOnLayoutChangeListener((View$OnLayoutChangeListener)-$$Lambda$BaseLayoutController$InsetsUpdater$zzCIB0038f8j1iFmYePHWvmc4w4); | 54 | ············view.addOnLayoutChangeListener((View$OnLayoutChangeListener)-$$Lambda$BaseLayoutController$InsetsUpdater$zzCIB0038f8j1iFmYePHWvmc4w4); |
| 50 | ········} | 55 | ········} |
| 51 | ········view·=·this.mBottomInsetView; | 56 | ········view·=·this.mBottomInsetView; |
| 52 | ········if·(view·!=·null)·{ | 57 | ········if·(view·!=·null)·{ |
| 53 | ············view.addOnLayoutChangeListener((View$OnLayoutChangeListener)-$$Lambda$BaseLayoutController$InsetsUpdater$zzCIB0038f8j1iFmYePHWvmc4w4); | 58 | ············view.addOnLayoutChangeListener((View$OnLayoutChangeListener)-$$Lambda$BaseLayoutController$InsetsUpdater$zzCIB0038f8j1iFmYePHWvmc4w4); |
| 54 | ········} | 59 | ········} |
| 55 | ········view2.addOnLayoutChangeListener((View$OnLayoutChangeListener)-$$Lambda$BaseLayoutController$InsetsUpdater$zzCIB0038f8j1iFmYePHWvmc4w4); | 60 | ········mContentView.addOnLayoutChangeListener((View$OnLayoutChangeListener)-$$Lambda$BaseLayoutController$InsetsUpdater$zzCIB0038f8j1iFmYePHWvmc4w4); |
| | 61 | ········this.mContentViewContainer.addOnLayoutChangeListener((View$OnLayoutChangeListener)-$$Lambda$BaseLayoutController$InsetsUpdater$zzCIB0038f8j1iFmYePHWvmc4w4); |
| 56 | ····} | 62 | ····} |
| 57 | ···· | 63 | ···· |
| 58 | ····private·static·int·getBottomOfView(final·View·view)·{ | 64 | ····private·static·int·getBottomOfView(final·View·view)·{ |
| 59 | ········final·int[]·array·=·new·int[2]; | 65 | ········final·int[]·array·=·new·int[2]; |
| 60 | ········view.getLocationOnScreen(array); | 66 | ········view.getLocationOnScreen(array); |
| 61 | ········return·array[1]·+·view.getHeight(); | 67 | ········return·array[1]·+·view.getHeight(); |
| 62 | ····} | 68 | ····} |
| Offset 104, 62 lines modified | Offset 110, 49 lines modified |
| 104 | ························n2·=·n; | 110 | ························n2·=·n; |
| 105 | ····················} | 111 | ····················} |
| 106 | ················} | 112 | ················} |
| 107 | ············} | 113 | ············} |
| 108 | ············n·=·n2; | 114 | ············n·=·n2; |
| 109 | ········} | 115 | ········} |
| 110 | ········if·(n·==·0)·{ | 116 | ········if·(n·==·0)·{ |
| 111 | ············CarUiUtils.requireViewByRefId(this.mActivity.getWindow().getDecorView(),·16908290).setPadding(mInsets.getLeft(),·mInsets.getTop(),·mInsets.getRight(),·mInsets.getBottom()); | 117 | ············this.mContentView.setPadding(mInsets.getLeft(),·mInsets.getTop(),·mInsets.getRight(),·mInsets.getBottom()); |
| 112 | ········} | 118 | ········} |
| 113 | ····} | 119 | ····} |
| 114 | ···· | 120 | ···· |
| 115 | ····Insets·getInsets()·{ | 121 | ····Insets·getInsets()·{ |
| 116 | ········return·this.mInsets; | 122 | ········return·this.mInsets; |
| 117 | ····} | 123 | ····} |
| 118 | ···· | 124 | ···· |
| 119 | ····void·installListeners()·{ | 125 | ····public·void·installListeners()·{ |
| 120 | ········this.mActivity.getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener((ViewTreeObserver$OnGlobalLayoutListener)this); | 126 | ········this.mContentView.getRootView().getViewTreeObserver().addOnGlobalLayoutListener((ViewTreeObserver$OnGlobalLayoutListener)this); |
| 121 | ····} | 127 | ····} |
| 122 | ···· | 128 | ···· |
| 123 | ····public·void·onGlobalLayout()·{ | 129 | ····public·void·onGlobalLayout()·{ |
| 124 | ········if·(!this.mInsetsDirty)·{ | 130 | ········if·(!this.mInsetsDirty)·{ |
| 125 | ············return; | 131 | ············return; |
| 126 | ········} | 132 | ········} |
| 127 | ········final·View·requireViewByRefId·=·CarUiUtils.requireViewByRefId(this.mActivity.getWindow().getDecorView(),·16908290); | 133 | ········int·max·=·Math.max(0,·getTopOfView(this.mContentViewContainer)·-·getTopOfView(this.mContentView)); |
| | 134 | ········int·max2·=·Math.max(0,·getLeftOfView(this.mContentViewContainer)·-·getLeftOfView(this.mContentView)); |
| | 135 | ········int·max3·=·Math.max(0,·getRightOfView(this.mContentView)·-·getRightOfView(this.mContentViewContainer)); |
| | 136 | ········int·max4·=·Math.max(0,·getBottomOfView(this.mContentView)·-·getBottomOfView(this.mContentViewContainer)); |
| 128 | ········final·View·mTopInsetView·=·this.mTopInsetView; | 137 | ········final·View·mTopInsetView·=·this.mTopInsetView; |
| 129 | ········int·max; | |
| 130 | ········if·(mTopInsetView·!=·null)·{ | 138 | ········if·(mTopInsetView·!=·null)·{ |
| 131 | ············max·=·Math.max(0,·getBottomOfView(mTopInsetView)·-·getTopOfView(requireViewByRefId)); | 139 | ············max·+=·Math.max(0,·getBottomOfView(mTopInsetView)·-·getTopOfView(this.mContentViewContainer)); |
| 132 | ········} | 140 | ········} |
| 133 | ········else·{ | |
| 134 | ············max·=·0; | |
| 135 | ········} | |
| 136 | ········int·max2; | |
| 137 | ········if·(this.mBottomInsetView·!=·null)·{ | 141 | ········if·(this.mBottomInsetView·!=·null)·{ |
| 138 | ············max2·=·Math.max(0,·getBottomOfView(requireViewByRefId)·-·getTopOfView(this.mBottomInsetView)); | 142 | ············max4·+=·Math.max(0,·getBottomOfView(this.mContentViewContainer)·-·getTopOfView(this.mBottomInsetView)); |
| 139 | ········} | |
| 140 | ········else·{ | |
| 141 | ············max2·=·0; | |
| 142 | ········} | 143 | ········} |
| 143 | ········final·View·mLeftInsetView·=·this.mLeftInsetView; | 144 | ········final·View·mLeftInsetView·=·this.mLeftInsetView; |
| 144 | ········int·max3; | |
| 145 | ········if·(mLeftInsetView·!=·null)·{ | 145 | ········if·(mLeftInsetView·!=·null)·{ |
| 146 | ············max3·=·Math.max(0,·getRightOfView(mLeftInsetView)·-·getLeftOfView(requireViewByRefId)); | 146 | ············max2·+=·Math.max(0,·getRightOfView(mLeftInsetView)·-·getLeftOfView(this.mContentViewContainer)); |
| 147 | ········} | |
| 148 | ········else·{ | |
| 149 | ············max3·=·0; | |
| 150 | ········} | 147 | ········} |
| 151 | ········int·max4; | |
| 152 | ········if·(this.mRightInsetView·!=·null)·{ | 148 | ········if·(this.mRightInsetView·!=·null)·{ |
| 153 | ············max4·=·Math.max(0,·getRightOfView(requireViewByRefId)·-·getLeftOfView(this.mRightInsetView)); | 149 | ············max3·+=·Math.max(0,·getRightOfView(this.mContentViewContainer)·-·getLeftOfView(this.mRightInsetView)); |
| 154 | ········} | |
| 155 | ········else·{ | |
| 156 | ············max4·=·0; | |
| 157 | ········} | 150 | ········} |
| 158 | ········final·Insets·mInsets·=·new·Insets(max3,·max,·max4,·max2); | 151 | ········final·Insets·mInsets·=·new·Insets(max2,·max,·max3,·max4); |
| 159 | ········this.mInsetsDirty·=·false; | 152 | ········this.mInsetsDirty·=·false; |
| 160 | ········if·(!mInsets.equals((Object)this.mInsets))·{ | 153 | ········if·(!mInsets.equals((Object)this.mInsets))·{ |
| 161 | ············this.dispatchNewInsets(this.mInsets·=·mInsets); | 154 | ············this.dispatchNewInsets(this.mInsets·=·mInsets); |
| 162 | ········} | 155 | ········} |
| 163 | ····} | 156 | ····} |
| 164 | ···· | 157 | ···· |
| 165 | ····public·void·replaceInsetsChangedListenerWith(final·InsetsChangedListener·mInsetsChangedListenerDelegate)·{ | 158 | ····public·void·replaceInsetsChangedListenerWith(final·InsetsChangedListener·mInsetsChangedListenerDelegate)·{ |