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