|
1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- |
|
2 * This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 package org.mozilla.gecko.home; |
|
7 |
|
8 import org.mozilla.gecko.R; |
|
9 |
|
10 import android.content.Context; |
|
11 import android.util.AttributeSet; |
|
12 import android.widget.TextView; |
|
13 |
|
14 public class BookmarkFolderView extends TextView { |
|
15 private static final int[] STATE_OPEN = { R.attr.state_open }; |
|
16 |
|
17 private boolean mIsOpen = false; |
|
18 |
|
19 public BookmarkFolderView(Context context) { |
|
20 super(context); |
|
21 } |
|
22 |
|
23 public BookmarkFolderView(Context context, AttributeSet attrs) { |
|
24 super(context, attrs); |
|
25 } |
|
26 |
|
27 public BookmarkFolderView(Context context, AttributeSet attrs, int defStyle) { |
|
28 super(context, attrs, defStyle); |
|
29 } |
|
30 |
|
31 @Override |
|
32 public int[] onCreateDrawableState(int extraSpace) { |
|
33 final int[] drawableState = super.onCreateDrawableState(extraSpace + 1); |
|
34 |
|
35 if (mIsOpen) { |
|
36 mergeDrawableStates(drawableState, STATE_OPEN); |
|
37 } |
|
38 |
|
39 return drawableState; |
|
40 } |
|
41 |
|
42 public void open() { |
|
43 if (!mIsOpen) { |
|
44 mIsOpen = true; |
|
45 refreshDrawableState(); |
|
46 } |
|
47 } |
|
48 |
|
49 public void close() { |
|
50 if (mIsOpen) { |
|
51 mIsOpen = false; |
|
52 refreshDrawableState(); |
|
53 } |
|
54 } |
|
55 } |