cn.loveapple.client.android.util.ComponentUtil.java Source code

Java tutorial

Introduction

Here is the source code for cn.loveapple.client.android.util.ComponentUtil.java

Source

/*
 * $HeadURL$
 * $Author$
 * $Revision$
 * $Date$
 *
 * ====================================================================
 *
 * Copyright (C) 2008 by loveapple.cn
 *
 * All copyright notices regarding loveapple and loveapple CoreLib
 * MUST remain intact in the scripts, documents and source code.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public 
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * Correspondence and Marketing Questions can be sent to:
 * info at loveapple
 *
 * @author: loveapple
 */
package cn.loveapple.client.android.util;

import org.apache.commons.lang.ArrayUtils;

import android.app.Activity;
import android.view.View;

/**
 * 
 * @author $Author$
 * @version $Revision$
 * @date $Date$
 * @id $Id$
 *
 */
public class ComponentUtil {
    /**
     * {@linkplain Activity}??/??{@linkplain View}?
     * 
     * @param target{@linkplain Activity}
     * @param visibleList
     * @param invisibleList
     * @param gonList
     */
    public static void setVisibilityList(Activity target, View[] visibleList, View[] invisibleList,
            View[] goneList) {
        if (ArrayUtils.isNotEmpty(visibleList)) {
            for (View v : visibleList) {
                if (v == null) {
                    continue;
                }
                v.setVisibility(View.VISIBLE);
            }
        }
        if (ArrayUtils.isNotEmpty(invisibleList)) {
            for (View v : invisibleList) {
                if (v == null) {
                    continue;
                }
                v.setVisibility(View.INVISIBLE);
            }
        }
        if (ArrayUtils.isNotEmpty(goneList)) {
            for (View v : goneList) {
                if (v == null) {
                    continue;
                }
                v.setVisibility(View.GONE);
            }
        }
    }

    /**
     * {@linkplain Activity}???({@linkplain View#GONE})?{@linkplain View}?
     * 
     * @see #setVisibilityList(Activity, int[], int[], int[])
     * @param target{@linkplain Activity}
     * @param gonList
     */
    public static void setGoneList(Activity target, View... goneList) {
        setVisibilityList(target, null, null, goneList);
    }

    /**
     * {@linkplain Activity}??({@linkplain View#VISIBLE})?{@linkplain View}?
     * @see #setVisibilityList(Activity, int[], int[], int[])
     * @param target
     * @param visibleList
     */
    public static void setVisibleList(Activity target, View... visibleList) {
        setVisibilityList(target, visibleList, null, null);
    }

    /**
     * {@linkplain Activity}???({@linkplain View#INVISIBLE})?{@linkplain View}?
     * @param target
     * @param invisibleList
     */
    public static void setInvisibleList(Activity target, View... invisibleList) {
        setVisibilityList(target, null, invisibleList, null);
    }

}