diff options
Diffstat (limited to 'src/com/android/camera/ui/ListMenu.java')
-rw-r--r-- | src/com/android/camera/ui/ListMenu.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/com/android/camera/ui/ListMenu.java b/src/com/android/camera/ui/ListMenu.java index bb21f7e0a..f56200a55 100644 --- a/src/com/android/camera/ui/ListMenu.java +++ b/src/com/android/camera/ui/ListMenu.java @@ -75,18 +75,13 @@ public class ListMenu extends ListView mOffString = context.getString(R.string.setting_off); } - private int getSettingLayoutId(ListPreference pref) { - return R.layout.list_menu_item; - } - @Override public View getView(int position, View convertView, ViewGroup parent) { ListPreference pref = mListItem.get(position); - int viewLayoutId = getSettingLayoutId(pref); ListMenuItem view = (ListMenuItem) convertView; view = (ListMenuItem) - mInflater.inflate(viewLayoutId, parent, false); + mInflater.inflate(R.layout.list_menu_item, parent, false); view.initialize(pref); // no init for restore one view.setSettingChangedListener(ListMenu.this); @@ -112,7 +107,7 @@ public class ListMenu extends ListView } @Override - public void onApplyWindowInsets(Rect insets) { + public void onApplyWindowInsets(Rect insets, int rootWidth, int rootHeight) { if (mHeader == null) { mHeader = new Space(getContext()); addHeaderView(mHeader); @@ -122,8 +117,10 @@ public class ListMenu extends ListView setFooterDividersEnabled(false); } - adjustViewHeight(mHeader, insets.top); - adjustViewHeight(mFooter, insets.bottom); + boolean largerThanRoot = + getPreCalculatedHeight() - insets.top - insets.bottom > rootHeight; + adjustViewHeight(mHeader, largerThanRoot ? insets.top : 0); + adjustViewHeight(mFooter, largerThanRoot ? insets.bottom : 0); } private void adjustViewHeight(View view, int height) { @@ -241,6 +238,12 @@ public class ListMenu extends ListView } + private int getPreCalculatedHeight() { + int count = getAdapter().getCount(); + return count * (int) getContext().getResources().getDimension(R.dimen.setting_row_height) + + (count - 1) * getDividerHeight(); + } + public void reloadPreference() { int count = getChildCount(); for (int i = 0; i < count; i++) { |