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