Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 1 | package org.sflphone.views;
|
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 2 |
|
| 3 | import android.content.Context;
|
| 4 | import android.util.AttributeSet;
|
| 5 | import android.widget.GridView;
|
| 6 |
|
Alexandre Lision | febae14 | 2013-07-18 09:58:52 -0400 | [diff] [blame] | 7 |
|
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 8 | public 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 | }
|