get Normal Views - Android User Interface

Android examples for User Interface:View Property

Description

get Normal 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
 *///from   w ww. jav a 2  s. c o m
//package com.java2s;

import android.view.View;

public class Main {
    private static final View getNormalViews(View[] views) {
        final View[] decorViews = new View[views.length];
        int i = 0;
        View view;

        for (int j = 0; j < views.length; j++) {
            view = views[j];
            if (view.getClass()
                    .getName()
                    .equals("com.android.internal.policy.impl.PhoneWindow$DecorView")) {
                decorViews[i] = view;
                i++;
            }
        }
        return getContainerViews(decorViews);
    }

    private static final View getContainerViews(View[] views) {
        View container = null;
        long drawingTime = 0;
        View view;

        for (int i = 0; i < views.length; i++) {
            view = views[i];
            if (view != null && view.isShown() && view.hasWindowFocus()
                    && view.getDrawingTime() > drawingTime) {
                container = view;
                drawingTime = view.getDrawingTime();
            }
        }
        return container;
    }
}

Related Tutorials