OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 package org.chromium.chrome.browser.widget; | |
6 | |
7 import android.content.Context; | |
8 import android.util.AttributeSet; | |
9 import android.widget.GridView; | |
10 | |
11 /** | |
12 * This class is a customized GridView which draws items in multiple lines autom atically | |
13 */ | |
14 public class DynamicHeightGridView extends GridView { | |
gogerald1
2017/05/30 19:36:48
name it ExpandableGridView looks make more sense,
Hwanseung Lee
2017/05/31 14:34:36
Done.
| |
15 /** Constructor for when the gridview is inflated from XML. */ | |
16 public DynamicHeightGridView(Context context, AttributeSet attrs) { | |
17 super(context, attrs); | |
18 } | |
19 | |
20 /** Constructor for when the gridview is inflated from XML. */ | |
21 public DynamicHeightGridView(Context context) { | |
gogerald1
2017/05/30 19:36:48
I guess you no need this and the below constructor
Hwanseung Lee
2017/05/31 14:34:36
Done.
| |
22 super(context); | |
23 } | |
24 | |
25 /** Constructor for when the gridview is inflated from XML. */ | |
26 public DynamicHeightGridView(Context context, AttributeSet attrs, int defSty le) { | |
27 super(context, attrs, defStyle); | |
28 } | |
29 | |
30 @Override | |
31 public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | |
32 int heightSpec; | |
33 if (getLayoutParams().height == LayoutParams.WRAP_CONTENT) { | |
34 heightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, Mea sureSpec.AT_MOST); | |
gogerald1
2017/05/30 19:36:48
View.MEASURED_SIZE_MASK looks make more sense here
Hwanseung Lee
2017/05/31 14:34:36
Done.
| |
35 } else { | |
36 heightSpec = heightMeasureSpec; | |
37 } | |
38 | |
39 super.onMeasure(widthMeasureSpec, heightSpec); | |
40 } | |
41 } | |
OLD | NEW |