Show the bar chart detail after hiding it.
In a previous commit I made the bar chart detail text GONE when no text was provided to avoid a crash. But I forgot to mark it visible when text is passed afterwards. This fixes that bug. Test: Create bar chart with an empty detail text, set some text, and then see the detail text. Test: atest com.android.settingslib.widget.BarChartPreferenceTest Change-Id: I4a352245c3dc7b02ab3d1de21c348f2d431e95cf
This commit is contained in:
@@ -168,6 +168,7 @@ public class BarChartPreference extends Preference {
|
||||
if (mDetailsId == 0) {
|
||||
detailsView.setVisibility(View.GONE);
|
||||
} else {
|
||||
detailsView.setVisibility(View.VISIBLE);
|
||||
detailsView.setText(mDetailsId);
|
||||
detailsView.setOnClickListener(mDetailsOnClickListener);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,20 @@ public class BarChartPreferenceTest {
|
||||
assertThat(mDetailsView.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onBindViewHolder_notSetDetailsRes_barChartDetailsViewIsGoneThenReappears() {
|
||||
// We don't call BarChartPreference#setBarChartDetails yet.
|
||||
mPreference.onBindViewHolder(mHolder);
|
||||
|
||||
assertThat(mDetailsView.getVisibility()).isEqualTo(View.GONE);
|
||||
|
||||
mPreference.setBarChartDetails(R.string.debug_app);
|
||||
mPreference.onBindViewHolder(mHolder);
|
||||
|
||||
assertThat(mDetailsView.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(mDetailsView.getText()).isEqualTo(mContext.getText(R.string.debug_app));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setBarChartDetailsRes_setDetailsRes_showInBarChartDetails() {
|
||||
mPreference.setBarChartDetails(R.string.debug_app);
|
||||
|
||||
Reference in New Issue
Block a user