Skip to content

Commit

Permalink
Add a few checks to avoid crashing
Browse files Browse the repository at this point in the history
Signed-off-by: DrDisagree <[email protected]>
  • Loading branch information
Mahmud0808 committed Sep 4, 2024
1 parent 4d1fdf8 commit 242a82d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,9 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
addView(mQsIconsContainer)
}

mQuickStatusBarHeader!!.addView(
mQsHeaderContainer,
-1
)

(mQsHeaderContainer.parent as? ViewGroup)?.removeView(mQsHeaderContainer)
mQuickStatusBarHeader!!.addView(mQsHeaderContainer, -1)

handleOldHeaderView(param)

Expand Down Expand Up @@ -395,7 +394,7 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
"switchToParent",
view,
parent,
index,
index.coerceAtMost(parent.childCount),
tag
)

Expand Down Expand Up @@ -450,7 +449,10 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
mQsHeaderContainerShadeParent.indexOfChild(mQsHeaderContainerShade) != index
) {
mQsHeaderContainerShadeParent?.removeView(mQsHeaderContainerShade)
parent.addView(mQsHeaderContainerShade, index)
parent.addView(
mQsHeaderContainerShade,
index.coerceAtMost(parent.childCount)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,8 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
orientation = LinearLayout.VERTICAL
}

mQuickStatusBarHeader!!.addView(
mQsHeaderContainer,
-1
)
(mQsHeaderContainer.parent as? ViewGroup)?.removeView(mQsHeaderContainer)
mQuickStatusBarHeader!!.addView(mQsHeaderContainer, -1)

val relativeLayout = RelativeLayout(mContext).apply {
layoutParams = RelativeLayout.LayoutParams(
Expand Down Expand Up @@ -562,7 +560,7 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
"switchToParent",
view,
parent,
index,
index.coerceAtMost(parent.childCount),
tag
)

Expand Down Expand Up @@ -621,7 +619,7 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
}
}

param.args[2] = (param.args[2] as Int) + 1
param.args[2] = ((param.args[2] as Int) + 1).coerceAtMost(parent.childCount)
}
}
)
Expand Down

0 comments on commit 242a82d

Please sign in to comment.