blob: 85a1e3afd1be0a49c6d2d7eb54bd645cc4f9f217 [file] [log] [blame]
alisiond295ec22013-05-17 10:12:13 -04001package com.savoirfairelinux.sflphone.views;
2
3import android.content.Context;
4import android.util.AttributeSet;
5import android.widget.GridView;
6
Alexandre Lisionfebae142013-07-18 09:58:52 -04007
alisiond295ec22013-05-17 10:12:13 -04008public class TACGridView extends GridView {
9
10 public TACGridView(Context context, AttributeSet attrs, int defStyle) {
11 super(context, attrs, defStyle);
12
13 }
14
15 public TACGridView(Context context, AttributeSet attrs) {
16 super(context, attrs);
17 }
18
19 public TACGridView(Context context) {
20 super(context);
21 }
22
23 boolean expanded = false;
24
25 public boolean isExpanded() {
26 return expanded;
27 }
28
29 public void setExpanded(boolean expanded) {
30 this.expanded = expanded;
31 }
32
33 @Override
34 public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
35 if (isExpanded()) {
36 // Calculate entire height by providing a very large height hint.
37 // But do not use the highest 2 bits of this integer; those are
38 // reserved for the MeasureSpec mode.
39 int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
40 super.onMeasure(widthMeasureSpec, expandSpec);
41
42 android.view.ViewGroup.LayoutParams params = getLayoutParams();
43 params.height = getMeasuredHeight();
44 } else {
45 super.onMeasure(widthMeasureSpec, heightMeasureSpec);
46 }
47 }
48
49}