mobile/android/base/widget/TabRow.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     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 file,
     4  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 package org.mozilla.gecko.widget;
     8 import android.content.Context;
     9 import android.util.AttributeSet;
    10 import android.view.View;
    11 import android.widget.Checkable;
    12 import android.widget.LinearLayout;
    14 public class TabRow extends LinearLayout
    15                     implements Checkable {
    16     private static final String LOGTAG = "GeckoTabRow";
    17     private static final int[] STATE_CHECKED = { android.R.attr.state_checked };
    18     private boolean mChecked;
    20     public TabRow(Context context, AttributeSet attrs) {
    21         super(context, attrs);
    22         mChecked = false;
    23     }
    25     @Override
    26     public int[] onCreateDrawableState(int extraSpace) {
    27         final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
    29         if (mChecked)
    30             mergeDrawableStates(drawableState, STATE_CHECKED);
    32         return drawableState;
    33     }
    35     @Override
    36     public boolean isChecked() {
    37         return mChecked;
    38     }
    40     @Override
    41     public void setChecked(boolean checked) {
    42         if (mChecked != checked) {
    43             mChecked = checked;
    44             refreshDrawableState();
    46             int count = getChildCount();
    47             for (int i=0; i < count; i++) {
    48                 final View child = getChildAt(i);
    49                 if (child instanceof Checkable)
    50                     ((Checkable) child).setChecked(checked);
    51             }
    52         }
    53     }
    55     @Override
    56     public void toggle() {
    57         mChecked = !mChecked;
    58     }
    59 }

mercurial