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