Snap for 4764723 from 4ad06ac4ba to qt-release

Change-Id: Ia9aa01f77fd20b00b83ee02ec9bf23381e1afc64
This commit is contained in:
android-build-team Robot
2018-05-05 09:35:10 +00:00
3 changed files with 25 additions and 7 deletions

View File

@@ -146,15 +146,14 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
@Override
public void onSuggestionClosed(Suggestion suggestion) {
final List<Suggestion> list = mDashboardData.getSuggestions();
if (list == null || list.size() == 0) {
if (list == null || list.size() == 0 || !list.remove(suggestion)) {
return;
}
if (list.size() == 1) {
if (list.isEmpty()) {
// The only suggestion is dismissed, and the the empty suggestion container will
// remain as the dashboard item. Need to refresh the dashboard list.
setSuggestions(null);
} else {
list.remove(suggestion);
setSuggestions(list);
}
}

View File

@@ -86,10 +86,13 @@ public class ZenCustomRadioButtonPreference extends TwoTargetPreference
}
final View gear = holder.findViewById(android.R.id.widget_frame);
final View divider = holder.findViewById(R.id.two_target_divider);
if (mOnGearClickListener != null) {
divider.setVisibility(View.VISIBLE);
gear.setVisibility(View.VISIBLE);
gear.setOnClickListener(this);
} else {
divider.setVisibility(View.GONE);
gear.setVisibility(View.GONE);
gear.setOnClickListener(null);
}

View File

@@ -101,7 +101,7 @@ public class DashboardAdapterTest {
}
@Test
public void testSuggestionDismissed_notOnlySuggestion_updateSuggestionOnly() {
public void onSuggestionClosed_notOnlySuggestion_updateSuggestionOnly() {
final DashboardAdapter adapter =
spy(new DashboardAdapter(mContext, null /* savedInstanceState */,
null /* conditions */, null /* suggestionControllerMixin */,
@@ -134,8 +134,8 @@ public class DashboardAdapterTest {
}
@Test
public void testSuggestionDismissed_onlySuggestion_updateDashboardData() {
DashboardAdapter adapter =
public void onSuggestionClosed_onlySuggestion_updateDashboardData() {
final DashboardAdapter adapter =
spy(new DashboardAdapter(mContext, null /* savedInstanceState */,
null /* conditions */, null /* suggestionControllerMixin */,
null /* lifecycle */));
@@ -151,7 +151,23 @@ public class DashboardAdapterTest {
}
@Test
public void testBindSuggestion_shouldSetSuggestionAdapterAndNoCrash() {
public void onSuggestionClosed_notInSuggestionList_shouldNotUpdateSuggestionList() {
final DashboardAdapter adapter =
spy(new DashboardAdapter(mContext, null /* savedInstanceState */,
null /* conditions */, null /* suggestionControllerMixin */,
null /* lifecycle */));
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
adapter.setSuggestions(suggestions);
final DashboardData dashboardData = adapter.mDashboardData;
reset(adapter); // clear interactions tracking
adapter.onSuggestionClosed(mock(Suggestion.class));
verify(adapter, never()).setSuggestions(any());
}
@Test
public void onBindSuggestion_shouldSetSuggestionAdapterAndNoCrash() {
mDashboardAdapter = new DashboardAdapter(mContext, null /* savedInstanceState */,
null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");