mobile/android/base/home/BookmarkFolderView.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/home/BookmarkFolderView.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +package org.mozilla.gecko.home;
    1.10 +
    1.11 +import org.mozilla.gecko.R;
    1.12 +
    1.13 +import android.content.Context;
    1.14 +import android.util.AttributeSet;
    1.15 +import android.widget.TextView;
    1.16 +
    1.17 +public class BookmarkFolderView extends TextView {
    1.18 +    private static final int[] STATE_OPEN = { R.attr.state_open };
    1.19 +
    1.20 +    private boolean mIsOpen = false;
    1.21 +
    1.22 +    public BookmarkFolderView(Context context) {
    1.23 +        super(context);
    1.24 +    }
    1.25 +
    1.26 +    public BookmarkFolderView(Context context, AttributeSet attrs) {
    1.27 +        super(context, attrs);
    1.28 +    }
    1.29 +
    1.30 +    public BookmarkFolderView(Context context, AttributeSet attrs, int defStyle) {
    1.31 +        super(context, attrs, defStyle);
    1.32 +    }
    1.33 +
    1.34 +    @Override
    1.35 +    public int[] onCreateDrawableState(int extraSpace) {
    1.36 +        final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
    1.37 +
    1.38 +        if (mIsOpen) {
    1.39 +            mergeDrawableStates(drawableState, STATE_OPEN);
    1.40 +        }
    1.41 +
    1.42 +        return drawableState;
    1.43 +    }
    1.44 +
    1.45 +    public void open() {
    1.46 +        if (!mIsOpen) {
    1.47 +            mIsOpen = true;
    1.48 +            refreshDrawableState();
    1.49 +        }
    1.50 +    }
    1.51 +
    1.52 +    public void close() {
    1.53 +        if (mIsOpen) {
    1.54 +            mIsOpen = false;
    1.55 +            refreshDrawableState();
    1.56 +        }
    1.57 +    }
    1.58 +}

mercurial