Bug 1219393 - Left aligned search icons only when there are less icons than required to fill the search icon bar. r=sebastian

MozReview-Commit-ID: JXBGJuT2bN0
This commit is contained in:
Kevin Lam 2016-09-30 09:56:55 -04:00
Родитель 786c5d0eb6
Коммит 63e52fcef6
1 изменённых файлов: 7 добавлений и 12 удалений

Просмотреть файл

@ -91,25 +91,20 @@ public class SearchEngineBar extends RecyclerView
if (searchEngineCount > 0) {
final int availableWidth = getMeasuredWidth() - mLabelContainerWidth;
final double searchEnginesToDisplay;
if (searchEngineCount * mMinIconContainerWidth <= availableWidth) {
// All search engines fit int: So let's just display all.
searchEnginesToDisplay = searchEngineCount;
mIconContainerWidth = (int) mMinIconContainerWidth;
} else {
// If only (n) search engines fit into the available space then display only (x) search
// engines with (x) picked so that the last search engine will be cut-off (we only display
// half of it) to show the ability to scroll this view.
// If only (n) search engines fit into the available space then display only (x)
// search engines with (x) picked so that the last search engine will be cut-off
// (we only display half of it) to show the ability to scroll this view.
searchEnginesToDisplay = Math.floor((availableWidth / mMinIconContainerWidth) - 0.5) + 0.5;
final double searchEnginesToDisplay = Math.floor((availableWidth / mMinIconContainerWidth) - 0.5) + 0.5;
// Use all available width and spread search engine icons
mIconContainerWidth = (int) (availableWidth / searchEnginesToDisplay);
}
// Use all available width and spread search engine icons
final int availableWidthPerContainer = (int) (availableWidth / searchEnginesToDisplay);
if (availableWidthPerContainer != mIconContainerWidth) {
mIconContainerWidth = availableWidthPerContainer;
}
mAdapter.setIconContainerWidth(mIconContainerWidth);
}
}