Removes invisible Views - Android User Interface

Android examples for User Interface:View Hide Show

Description

Removes invisible Views

Demo Code

/* Athrun - Android automation testing Framework.
 Copyright (C) 2010-2012 TaoBao UI AutoMan Team

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This program 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 General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., HuaXing road, Hangzhou,China. 
 Email:taichan@taobao.com,shidun@taobao.com,bingyang.djj@taobao.com
 *//* w w w  . ja va 2  s . c  o  m*/
//package com.java2s;

import java.util.ArrayList;

import android.view.View;

public class Main {
    /**
     * Removes invisible {@code View}s
     * 
     * @param viewList
     *            an {@code ArrayList} with {@code View}s that is being checked
     *            for invisible {@code View}s.
     * @return a filtered {@code ArrayList} with no invisible {@code View}s.
     */
    public static <T extends View> ArrayList<T> removeInvisibleViews(
            ArrayList<T> viewList) {
        ArrayList<T> tmpViewList = new ArrayList<T>(viewList.size());
        for (T view : viewList) {
            if (view != null && view.getVisibility() != View.GONE
                    && view.getVisibility() != View.INVISIBLE) {
                tmpViewList.add(view);
            }
        }
        return tmpViewList;
    }
}

Related Tutorials