Skip to content

Commit

Permalink
fix(YouTube - Seekbar components): Prevent color preference crash on …
Browse files Browse the repository at this point in the history
…some devices

- Fix potential IllegalStateException when creating color input layout
- Add type-safe view group handling

Co-Authored-By: Francesco Marastoni <[email protected]>
  • Loading branch information
anddea and Francesco146 committed Jan 31, 2025
1 parent 580a834 commit fb3bff1
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ private LinearLayout createColorInputLayout(Context context) {

// Get the EditText from the parent class.
EditText editText = getEditText();
// Remove the EditText from its current parent if it exists
ViewParent parent = editText.getParent();
if (parent instanceof ViewGroup) {
((ViewGroup) parent).removeView(editText);
}
// Set the initial text of the EditText to the current color in hexadecimal format.
editText.setText(String.format("#%06X", currentColor));
// Add a TextWatcher to the EditText to update the color preview in real-time.
Expand Down

0 comments on commit fb3bff1

Please sign in to comment.