ExpandableView.java revision ae44128776410abd11bd06ae700db9cc4606a773
1be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi/*
2be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi * Copyright (C) 2014 The Android Open Source Project
3be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi *
4be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi * Licensed under the Apache License, Version 2.0 (the "License");
5be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi * you may not use this file except in compliance with the License.
6be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi * You may obtain a copy of the License at
7be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi *
8be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi *      http://www.apache.org/licenses/LICENSE-2.0
9be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi *
10be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi * Unless required by applicable law or agreed to in writing, software
11be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi * distributed under the License is distributed on an "AS IS" BASIS,
12be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi * See the License for the specific language governing permissions and
14be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi * limitations under the License
15be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi */
16be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
17be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggipackage com.android.systemui.statusbar;
18be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
19be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggiimport android.content.Context;
20be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggiimport android.util.AttributeSet;
2100ebdfe8ba98c05a767660de2ed7c9a19fb49d74Jorim Jaggiimport android.view.MotionEvent;
22be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggiimport android.view.View;
23c9c00ae2fa5fb787e9f12705f8cd8de445ecde4bSelim Cinekimport android.view.ViewGroup;
2424d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinekimport android.widget.FrameLayout;
2524d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinekimport com.android.systemui.R;
2624d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek
2724d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinekimport java.util.ArrayList;
28be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
29be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi/**
30be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi * An abstract view for expandable views.
31be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi */
3224d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinekpublic abstract class ExpandableView extends FrameLayout {
3324d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek
3424d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek    private final int mMaxNotificationHeight;
35be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
36be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    private OnHeightChangedListener mOnHeightChangedListener;
37be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    protected int mActualHeight;
38be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    protected int mClipTopAmount;
39be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    private boolean mActualHeightInitialized;
4024d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek    private ArrayList<View> mMatchParentViews = new ArrayList<View>();
41be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
42be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    public ExpandableView(Context context, AttributeSet attrs) {
43be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi        super(context, attrs);
4424d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        mMaxNotificationHeight = getResources().getDimensionPixelSize(
4524d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek                R.dimen.notification_max_height);
46be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    }
47be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
48be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    @Override
4924d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
5024d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        int ownMaxHeight = mMaxNotificationHeight;
5124d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        int heightMode = MeasureSpec.getMode(heightMeasureSpec);
5224d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        boolean hasFixedHeight = heightMode == MeasureSpec.EXACTLY;
5324d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        boolean isHeightLimited = heightMode == MeasureSpec.AT_MOST;
5424d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        if (hasFixedHeight || isHeightLimited) {
5524d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek            int size = MeasureSpec.getSize(heightMeasureSpec);
5624d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek            ownMaxHeight = Math.min(ownMaxHeight, size);
5724d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        }
5824d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        int newHeightSpec = MeasureSpec.makeMeasureSpec(ownMaxHeight, MeasureSpec.AT_MOST);
5924d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        int maxChildHeight = 0;
6024d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        int childCount = getChildCount();
6124d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        for (int i = 0; i < childCount; i++) {
62c9c00ae2fa5fb787e9f12705f8cd8de445ecde4bSelim Cinek            View child = getChildAt(i);
6324d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek            int childHeightSpec = newHeightSpec;
6424d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek            ViewGroup.LayoutParams layoutParams = child.getLayoutParams();
6524d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek            if (layoutParams.height != ViewGroup.LayoutParams.MATCH_PARENT) {
6624d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek                if (layoutParams.height >= 0) {
6724d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek                    // An actual height is set
6824d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek                    childHeightSpec = layoutParams.height > ownMaxHeight
6924d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek                        ? MeasureSpec.makeMeasureSpec(ownMaxHeight, MeasureSpec.EXACTLY)
7024d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek                        : MeasureSpec.makeMeasureSpec(layoutParams.height, MeasureSpec.EXACTLY);
7124d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek                }
72b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi                child.measure(
73b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi                        getChildMeasureSpec(widthMeasureSpec, 0 /* padding */, layoutParams.width),
74b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi                        childHeightSpec);
7524d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek                int childHeight = child.getMeasuredHeight();
7624d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek                maxChildHeight = Math.max(maxChildHeight, childHeight);
7724d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek            } else {
7824d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek                mMatchParentViews.add(child);
7924d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek            }
8024d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        }
8124d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        int ownHeight = hasFixedHeight ? ownMaxHeight : maxChildHeight;
8224d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        newHeightSpec = MeasureSpec.makeMeasureSpec(ownHeight, MeasureSpec.EXACTLY);
8324d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        for (View child : mMatchParentViews) {
84b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi            child.measure(getChildMeasureSpec(
85b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi                    widthMeasureSpec, 0 /* padding */, child.getLayoutParams().width),
86b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi                    newHeightSpec);
87c9c00ae2fa5fb787e9f12705f8cd8de445ecde4bSelim Cinek        }
8824d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        mMatchParentViews.clear();
8924d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        int width = MeasureSpec.getSize(widthMeasureSpec);
9024d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        setMeasuredDimension(width, ownHeight);
9124d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek    }
9224d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek
9324d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek    @Override
9424d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
9524d7cfa4d6a3331708bb7b37f551b4f534b02f7cSelim Cinek        super.onLayout(changed, left, top, right, bottom);
96be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi        if (!mActualHeightInitialized && mActualHeight == 0) {
973c3c3fc38c474924629aa591c98d6dc190ed4e83Jorim Jaggi            setActualHeight(getInitialHeight());
98be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi        }
99be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    }
100be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
101c27437b7fd04e682ae2abdf0727a99bf5c6e409dSelim Cinek    protected int getInitialHeight() {
102c27437b7fd04e682ae2abdf0727a99bf5c6e409dSelim Cinek        return getHeight();
103c27437b7fd04e682ae2abdf0727a99bf5c6e409dSelim Cinek    }
104c27437b7fd04e682ae2abdf0727a99bf5c6e409dSelim Cinek
10500ebdfe8ba98c05a767660de2ed7c9a19fb49d74Jorim Jaggi    @Override
10600ebdfe8ba98c05a767660de2ed7c9a19fb49d74Jorim Jaggi    public boolean dispatchTouchEvent(MotionEvent ev) {
10700ebdfe8ba98c05a767660de2ed7c9a19fb49d74Jorim Jaggi        if (filterMotionEvent(ev)) {
10800ebdfe8ba98c05a767660de2ed7c9a19fb49d74Jorim Jaggi            return super.dispatchTouchEvent(ev);
10900ebdfe8ba98c05a767660de2ed7c9a19fb49d74Jorim Jaggi        }
11000ebdfe8ba98c05a767660de2ed7c9a19fb49d74Jorim Jaggi        return false;
11100ebdfe8ba98c05a767660de2ed7c9a19fb49d74Jorim Jaggi    }
11200ebdfe8ba98c05a767660de2ed7c9a19fb49d74Jorim Jaggi
11300ebdfe8ba98c05a767660de2ed7c9a19fb49d74Jorim Jaggi    private boolean filterMotionEvent(MotionEvent event) {
11400ebdfe8ba98c05a767660de2ed7c9a19fb49d74Jorim Jaggi        return event.getActionMasked() != MotionEvent.ACTION_DOWN
11500ebdfe8ba98c05a767660de2ed7c9a19fb49d74Jorim Jaggi                || event.getY() > mClipTopAmount && event.getY() < mActualHeight;
11600ebdfe8ba98c05a767660de2ed7c9a19fb49d74Jorim Jaggi    }
11700ebdfe8ba98c05a767660de2ed7c9a19fb49d74Jorim Jaggi
118be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    /**
119be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     * Sets the actual height of this notification. This is different than the laid out
120be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     * {@link View#getHeight()}, as we want to avoid layouting during scrolling and expanding.
121d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi     *
122d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi     * @param actualHeight The height of this notification.
123d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi     * @param notifyListeners Whether the listener should be informed about the change.
124be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     */
125d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi    public void setActualHeight(int actualHeight, boolean notifyListeners) {
1262580a976ec93a01ed00fae51364ad872bc591d95Jorim Jaggi        mActualHeightInitialized = true;
127be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi        mActualHeight = actualHeight;
128d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi        if (notifyListeners) {
129d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi            notifyHeightChanged();
130d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi        }
131d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi    }
132d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi
133d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi    public void setActualHeight(int actualHeight) {
134d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi        setActualHeight(actualHeight, true);
135be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    }
136be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
137be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    /**
138be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     * See {@link #setActualHeight}.
139be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     *
1409cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi     * @return The current actual height of this notification.
141be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     */
142be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    public int getActualHeight() {
143be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi        return mActualHeight;
144be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    }
145be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
146be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    /**
147be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     * @return The maximum height of this notification.
148be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     */
1494222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi    public int getMaxHeight() {
1504222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi        return getHeight();
1514222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi    }
1524222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi
1534222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi    /**
1544222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi     * @return The minimum height of this notification.
1554222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi     */
1564222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi    public int getMinHeight() {
1574222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi        return getHeight();
1584222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi    }
159be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
160be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    /**
161d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi     * Sets the notification as dimmed. The default implementation does nothing.
162d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi     *
163d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi     * @param dimmed Whether the notification should be dimmed.
164d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi     * @param fade Whether an animation should be played to change the state.
165d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi     */
166d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi    public void setDimmed(boolean dimmed, boolean fade) {
167d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi    }
168d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi
169d552d9d8e964c102e6832610be46cf2c041e8829Jorim Jaggi    /**
170bf370992508c55d1f2493923bdc1834a0710e4baJohn Spurlock     * Sets the notification as dark. The default implementation does nothing.
171bf370992508c55d1f2493923bdc1834a0710e4baJohn Spurlock     *
172bf370992508c55d1f2493923bdc1834a0710e4baJohn Spurlock     * @param dark Whether the notification should be dark.
173bf370992508c55d1f2493923bdc1834a0710e4baJohn Spurlock     * @param fade Whether an animation should be played to change the state.
174bf370992508c55d1f2493923bdc1834a0710e4baJohn Spurlock     */
175bf370992508c55d1f2493923bdc1834a0710e4baJohn Spurlock    public void setDark(boolean dark, boolean fade) {
176bf370992508c55d1f2493923bdc1834a0710e4baJohn Spurlock    }
177bf370992508c55d1f2493923bdc1834a0710e4baJohn Spurlock
178bf370992508c55d1f2493923bdc1834a0710e4baJohn Spurlock    /**
179ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi     * See {@link #setHideSensitive}. This is a variant which notifies this view in advance about
180ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi     * the upcoming state of hiding sensitive notifications. It gets called at the very beginning
181ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi     * of a stack scroller update such that the updated intrinsic height (which is dependent on
182ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi     * whether private or public layout is showing) gets taken into account into all layout
183ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi     * calculations.
184ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi     */
185ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi    public void setHideSensitiveForIntrinsicHeight(boolean hideSensitive) {
186ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi    }
187ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi
188ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi    /**
189ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi     * Sets whether the notification should hide its private contents if it is sensitive.
190ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi     */
191ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi    public void setHideSensitive(boolean hideSensitive, boolean animated, long delay,
192ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi            long duration) {
193ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi    }
194ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi
195ae44128776410abd11bd06ae700db9cc4606a773Jorim Jaggi    /**
1969cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi     * @return The desired notification height.
1979cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi     */
1989cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi    public int getIntrinsicHeight() {
199a5eaa6034dd48fab0f5a232c09ebed35f359963eSelim Cinek        return getHeight();
2009cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi    }
2019cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi
2029cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi    /**
203be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     * Sets the amount this view should be clipped from the top. This is used when an expanded
204be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     * notification is scrolling in the top or bottom stack.
205be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     *
206be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     * @param clipTopAmount The amount of pixels this view should be clipped from top.
207be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     */
208be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    public void setClipTopAmount(int clipTopAmount) {
209be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi        mClipTopAmount = clipTopAmount;
210be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    }
211be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
212eb973565f3efc6417ca35363e4d6c642947775d8Selim Cinek    public int getClipTopAmount() {
213eb973565f3efc6417ca35363e4d6c642947775d8Selim Cinek        return mClipTopAmount;
214eb973565f3efc6417ca35363e4d6c642947775d8Selim Cinek    }
215eb973565f3efc6417ca35363e4d6c642947775d8Selim Cinek
216be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    public void setOnHeightChangedListener(OnHeightChangedListener listener) {
217be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi        mOnHeightChangedListener = listener;
218be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    }
219be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
220be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    /**
2214222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi     * @return Whether we can expand this views content.
222be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     */
2234222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi    public boolean isContentExpandable() {
2244222d9a7fb87d73e1443ec1a2de9782b05741af6Jorim Jaggi        return false;
225be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    }
226be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi
2279cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi    public void notifyHeightChanged() {
2289cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi        if (mOnHeightChangedListener != null) {
2299cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi            mOnHeightChangedListener.onHeightChanged(this);
2309cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi        }
2319cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi    }
2329cbadd3c08a7d7dd3412743dd04aecb16c5a1595Jorim Jaggi
233c27437b7fd04e682ae2abdf0727a99bf5c6e409dSelim Cinek    public boolean isTransparent() {
234c27437b7fd04e682ae2abdf0727a99bf5c6e409dSelim Cinek        return false;
235c27437b7fd04e682ae2abdf0727a99bf5c6e409dSelim Cinek    }
236c27437b7fd04e682ae2abdf0727a99bf5c6e409dSelim Cinek
237be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    /**
2388efa6dde2b4f2cdbf046b87b7366404c3cc46219Selim Cinek     * Perform a remove animation on this view.
2398efa6dde2b4f2cdbf046b87b7366404c3cc46219Selim Cinek     *
24060d07c597c3f996deb3f2743466fe5279ca15e8dJorim Jaggi     * @param duration The duration of the remove animation.
2418efa6dde2b4f2cdbf046b87b7366404c3cc46219Selim Cinek     * @param translationDirection The direction value from [-1 ... 1] indicating in which the
2428efa6dde2b4f2cdbf046b87b7366404c3cc46219Selim Cinek     *                             animation should be performed. A value of -1 means that The
2438efa6dde2b4f2cdbf046b87b7366404c3cc46219Selim Cinek     *                             remove animation should be performed upwards,
2448efa6dde2b4f2cdbf046b87b7366404c3cc46219Selim Cinek     *                             such that the  child appears to be going away to the top. 1
2458efa6dde2b4f2cdbf046b87b7366404c3cc46219Selim Cinek     *                             Should mean the opposite.
2468efa6dde2b4f2cdbf046b87b7366404c3cc46219Selim Cinek     * @param onFinishedRunnable A runnable which should be run when the animation is finished.
2478efa6dde2b4f2cdbf046b87b7366404c3cc46219Selim Cinek     */
24860d07c597c3f996deb3f2743466fe5279ca15e8dJorim Jaggi    public abstract void performRemoveAnimation(long duration, float translationDirection,
2498efa6dde2b4f2cdbf046b87b7366404c3cc46219Selim Cinek            Runnable onFinishedRunnable);
2508efa6dde2b4f2cdbf046b87b7366404c3cc46219Selim Cinek
25160d07c597c3f996deb3f2743466fe5279ca15e8dJorim Jaggi    public abstract void performAddAnimation(long delay, long duration);
2528efa6dde2b4f2cdbf046b87b7366404c3cc46219Selim Cinek
253f54090e9bb23e9ed1b4d9e500d856f80d2fbe775Selim Cinek    public abstract void setScrimAmount(float scrimAmount);
254f54090e9bb23e9ed1b4d9e500d856f80d2fbe775Selim Cinek
2553d2b94bf8e32640e57573ebb17911b1db9440231Selim Cinek    public void setBelowSpeedBump(boolean below) {
2563d2b94bf8e32640e57573ebb17911b1db9440231Selim Cinek    }
2573d2b94bf8e32640e57573ebb17911b1db9440231Selim Cinek
2588efa6dde2b4f2cdbf046b87b7366404c3cc46219Selim Cinek    /**
259be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     * A listener notifying when {@link #getActualHeight} changes.
260be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi     */
261be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    public interface OnHeightChangedListener {
26230c305ce6283ce1380ad91ef0d221696b32d5a6bJorim Jaggi
26330c305ce6283ce1380ad91ef0d221696b32d5a6bJorim Jaggi        /**
26430c305ce6283ce1380ad91ef0d221696b32d5a6bJorim Jaggi         * @param view the view for which the height changed, or {@code null} if just the top
26530c305ce6283ce1380ad91ef0d221696b32d5a6bJorim Jaggi         *             padding or the padding between the elements changed
26630c305ce6283ce1380ad91ef0d221696b32d5a6bJorim Jaggi         */
267be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi        void onHeightChanged(ExpandableView view);
268be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi    }
269be565dfc1c17b7ddafa9753851b8f82849fd3f42Jorim Jaggi}
270