OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.ntp; | 5 package org.chromium.chrome.browser.ntp; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.util.AttributeSet; | 8 import android.util.AttributeSet; |
9 import android.view.View; | 9 import android.view.View; |
10 import android.widget.ExpandableListView; | 10 import android.widget.ExpandableListView; |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 @Override | 32 @Override |
33 protected void onFinishInflate() { | 33 protected void onFinishInflate() { |
34 super.onFinishInflate(); | 34 super.onFinishInflate(); |
35 float density = getResources().getDisplayMetrics().density; | 35 float density = getResources().getDisplayMetrics().density; |
36 mMaxListViewWidth = Math.round(MAX_LIST_VIEW_WIDTH_DP * density); | 36 mMaxListViewWidth = Math.round(MAX_LIST_VIEW_WIDTH_DP * density); |
37 } | 37 } |
38 | 38 |
39 @Override | 39 @Override |
40 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | 40 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
41 if (!DeviceFormFactor.isTablet(getContext())) { | 41 if (!DeviceFormFactor.isTablet()) { |
42 super.onMeasure(widthMeasureSpec, heightMeasureSpec); | 42 super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
43 return; | 43 return; |
44 } | 44 } |
45 | 45 |
46 // Increase padding if needed to ensure children are no wider than mMaxL
istViewWidth. | 46 // Increase padding if needed to ensure children are no wider than mMaxL
istViewWidth. |
47 int childWidth = MeasureSpec.getSize(widthMeasureSpec); | 47 int childWidth = MeasureSpec.getSize(widthMeasureSpec); |
48 int excessWidth = childWidth - mMaxListViewWidth; | 48 int excessWidth = childWidth - mMaxListViewWidth; |
49 int horizontalPadding = 0; | 49 int horizontalPadding = 0; |
50 if (excessWidth > 0) { | 50 if (excessWidth > 0) { |
51 horizontalPadding += excessWidth / 2; | 51 horizontalPadding += excessWidth / 2; |
(...skipping 11 matching lines...) Expand all Loading... |
63 } | 63 } |
64 | 64 |
65 @Override | 65 @Override |
66 protected void onDetachedFromWindow() { | 66 protected void onDetachedFromWindow() { |
67 mSavedListPosition = getFirstVisiblePosition(); | 67 mSavedListPosition = getFirstVisiblePosition(); |
68 View v = getChildAt(0); | 68 View v = getChildAt(0); |
69 mSavedListTop = (v == null) ? 0 : v.getTop(); | 69 mSavedListTop = (v == null) ? 0 : v.getTop(); |
70 super.onDetachedFromWindow(); | 70 super.onDetachedFromWindow(); |
71 } | 71 } |
72 } | 72 } |
OLD | NEW |