Skip to content

Commit

Permalink
Divider reset bugfix (issue #34)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregkorossy committed Jul 29, 2016
1 parent 627d854 commit e787c10
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public EditTextPreferenceDialogFragmentCompat() {
public static EditTextPreferenceDialogFragmentCompat newInstance(String key) {
EditTextPreferenceDialogFragmentCompat fragment = new EditTextPreferenceDialogFragmentCompat();
Bundle b = new Bundle(1);
b.putString("key", key);
b.putString(ARG_KEY, key);
fragment.setArguments(b);
return fragment;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ protected void setDividerPreferences(@DividerPrefFlags @DividerPrefBase final in
}

void applyDividerPreference(final RecyclerView recyclerView, @DividerPrefFlags @DividerPrefBase final int flags) {
boolean decoratorRecreateNeeded = flags != divPrefFlags || divPrefInvalid;

divPrefFlags = flags;
divPrefInvalid = false;

Expand Down Expand Up @@ -173,6 +175,11 @@ void applyDividerPreference(final RecyclerView recyclerView, @DividerPrefFlags @
divPrefFlags = DIVIDER_PREFERENCE_BETWEEN;
}

if (divItemDecoration != null && decoratorRecreateNeeded) {
recyclerView.removeItemDecoration(divItemDecoration);
divItemDecoration = null;
}

if (divItemDecoration == null) {
divItemDecoration = new DividerItemDecoration(getDividerDrawable());
recyclerView.addItemDecoration(divItemDecoration);
Expand Down Expand Up @@ -201,6 +208,13 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
setDividerPreferences(divPrefFlags);
}

@Override
public void onDestroyView() {
super.onDestroyView();

divPrefInvalid = true;
}

@Override
public void setDivider(Drawable divider) {
super.setDivider(divider);
Expand Down

0 comments on commit e787c10

Please sign in to comment.