Skip to content

Commit

Permalink
PreferenceCategory icon space reserved bug fix fixed again
Browse files Browse the repository at this point in the history
  • Loading branch information
gregkorossy committed Jul 23, 2018
1 parent 7cb5bc9 commit 9f7ce1e
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class PreferenceCategory extends androidx.preference.PreferenceCategory {
protected int color;
protected View itemView;

private static int originalStartPadding = Integer.MIN_VALUE;

public PreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);

Expand Down Expand Up @@ -138,9 +140,16 @@ public void onBindViewHolder(PreferenceViewHolder holder) {
// FIXME PreferenceCategory doesn't respect iconSpaceReserved set to false
// https://issuetracker.google.com/issues/111662669
// https://github.com/Gericop/Android-Support-Preference-V7-Fix/issues/132
ViewGroup parent = (ViewGroup) titleView.getParent();

if (originalStartPadding == Integer.MIN_VALUE) {
originalStartPadding = ViewCompat.getPaddingStart(parent);
}

if (!isIconSpaceReserved()) {
ViewGroup parent = (ViewGroup) titleView.getParent();
ViewCompat.setPaddingRelative(parent, 0, parent.getPaddingTop(), 0, parent.getPaddingBottom());
} else {
ViewCompat.setPaddingRelative(parent, originalStartPadding, parent.getPaddingTop(), 0, parent.getPaddingBottom());
}
}

Expand Down

0 comments on commit 9f7ce1e

Please sign in to comment.