Fix searchbar divider
This commit is contained in:
2 files changed
+21
-1
No files matched your search
@@ -83,6 +83,7 @@ public class SearchBar extends MaterialCardView implements View.OnClickListener,
|
||||
private SearchEditText mEditText;
|
||||
private EasyRecyclerView mListView;
|
||||
private View mListContainer;
|
||||
private View mListHeader;
|
||||
|
||||
private ViewTransition mViewTransition;
|
||||
|
||||
@@ -124,6 +125,7 @@ public class SearchBar extends MaterialCardView implements View.OnClickListener,
|
||||
mEditText = (SearchEditText) ViewUtils.$$(this, R.id.search_edit_text);
|
||||
mListContainer = ViewUtils.$$(this, R.id.list_container);
|
||||
mListView = (EasyRecyclerView) ViewUtils.$$(mListContainer, R.id.search_bar_list);
|
||||
mListHeader = ViewUtils.$$(mListContainer, R.id.list_header);
|
||||
|
||||
mViewTransition = new ViewTransition(mTitleTextView, mEditText);
|
||||
|
||||
@@ -146,12 +148,19 @@ public class SearchBar extends MaterialCardView implements View.OnClickListener,
|
||||
LinearDividerItemDecoration.VERTICAL,
|
||||
AttrResources.getAttrColor(context, R.attr.dividerColor),
|
||||
LayoutUtils.dp2pix(context, 1));
|
||||
decoration.setShowFirstDivider(true);
|
||||
decoration.setShowLastDivider(false);
|
||||
mListView.addItemDecoration(decoration);
|
||||
mListView.setLayoutManager(layoutManager);
|
||||
}
|
||||
|
||||
private void addListHeader() {
|
||||
mListHeader.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
private void removeListHeader() {
|
||||
mListHeader.setVisibility(GONE);
|
||||
}
|
||||
|
||||
private void updateSuggestions() {
|
||||
updateSuggestions(true);
|
||||
}
|
||||
@@ -188,6 +197,11 @@ public class SearchBar extends MaterialCardView implements View.OnClickListener,
|
||||
}
|
||||
|
||||
mSuggestionList = suggestions;
|
||||
if (mSuggestionList.size() == 0) {
|
||||
removeListHeader();
|
||||
} else {
|
||||
addListHeader();
|
||||
}
|
||||
mSuggestionAdapter.notifyDataSetChanged();
|
||||
|
||||
if (scrollToTop) {
|
||||
|
||||
Reference in new issue
Block a user