Example usage for java.util ArrayList iterator

List of usage examples for java.util ArrayList iterator

Introduction

In this page you can find the example usage for java.util ArrayList iterator.

Prototype

public Iterator<E> iterator() 

Source Link

Document

Returns an iterator over the elements in this list in proper sequence.

Usage

From source file:com.ddj.launcher2.InstallShortcutReceiver.java

static void flushInstallQueue(Context context) {
    String spKey = LauncherUtil.getSharedPreferencesKey();
    SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE);
    ArrayList<PendingInstallShortcutInfo> installQueue = getAndClearInstallQueue(sp);
    Iterator<PendingInstallShortcutInfo> iter = installQueue.iterator();
    while (iter.hasNext()) {
        processInstallShortcut(context, iter.next());
    }//from  w  w  w .j  a  va2  s.  c o  m
}

From source file:Main.java

/**
 * Returns an iterator over the children of the given element with
 * the given tag name.// ww w  .jav a  2s .c o  m
 *
 * @param element The parent element
 * @param tagName The name of the desired child
 * @return An interator of children or null if element is null.
 */
public static Iterator getChildrenByTagName(Element element, String tagName) {
    if (element == null)
        return null;
    // getElementsByTagName gives the corresponding elements in the whole
    // descendance. We want only children

    NodeList children = element.getChildNodes();
    ArrayList goodChildren = new ArrayList();
    for (int i = 0; i < children.getLength(); i++) {
        Node currentChild = children.item(i);
        if (currentChild.getNodeType() == Node.ELEMENT_NODE
                && ((Element) currentChild).getTagName().equals(tagName)) {
            goodChildren.add((Element) currentChild);
        }
    }
    return goodChildren.iterator();
}

From source file:de.schaeuffelhut.android.openvpn.Preferences.java

public final static ArrayList<File> listExistingConfigs(Context context) {
    ArrayList<File> configs = listKnownConfigs(context);
    for (Iterator<File> it = configs.iterator(); it.hasNext();)
        if (!it.next().exists())
            it.remove();//from w  ww  .  ja v  a  2s .  co  m
    return configs;
}

From source file:Main.java

public static Iterator getElementsByTagName(Element element, String tag) {
    ArrayList<Element> children = new ArrayList<Element>();
    if (element != null && tag != null) {
        NodeList nodes = element.getElementsByTagName(tag);
        for (int i = 0; i < nodes.getLength(); i++) {
            Node child = nodes.item(i);
            //      System.out.println("Name: " + child.getNodeName() + ", Value: " + child.getFirstChild().getNodeValue());
            children.add((Element) child);
        }//from   ww w .  j  a va  2s .  c  o  m
    }
    return children.iterator();
}

From source file:com.joysee.portal.launcher.InstallShortcutReceiver.java

static void flushInstallQueue(Context context) {
    String spKey = LauncherAppState.getSharedPreferencesKey();
    SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE);
    ArrayList<PendingInstallShortcutInfo> installQueue = getAndClearInstallQueue(sp);
    if (!installQueue.isEmpty()) {
        Iterator<PendingInstallShortcutInfo> iter = installQueue.iterator();
        ArrayList<ItemInfo> addShortcuts = new ArrayList<ItemInfo>();
        int result = INSTALL_SHORTCUT_SUCCESSFUL;
        String duplicateName = "";
        while (iter.hasNext()) {
            final PendingInstallShortcutInfo pendingInfo = iter.next();
            //final Intent data = pendingInfo.data;
            final Intent intent = pendingInfo.launchIntent;
            final String name = pendingInfo.name;
            final boolean exists = LauncherModel.shortcutExists(context, name, intent);
            //final boolean allowDuplicate = data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE, true);

            // TODO-XXX: Disable duplicates for now
            if (!exists /* && allowDuplicate */) {
                // Generate a shortcut info to add into the model
                ShortcutInfo info = getShortcutInfo(context, pendingInfo.data, pendingInfo.launchIntent);
                addShortcuts.add(info);/*from w ww . j a  v  a2s . c o m*/
            }
            /*
            else if (exists && !allowDuplicate) {
            result = INSTALL_SHORTCUT_IS_DUPLICATE;
            duplicateName = name;
            }
            */
        }

        // Notify the user once if we weren't able to place any duplicates
        if (result == INSTALL_SHORTCUT_IS_DUPLICATE) {
            Toast.makeText(context, duplicateName, Toast.LENGTH_SHORT).show();
        }

        // Add the new apps to the model and bind them
        if (!addShortcuts.isEmpty()) {
            LauncherAppState app = LauncherAppState.getInstance();
            app.getModel().addAndBindAddedApps(context, addShortcuts, null);
        }
    }
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static Iterator getElementsByTagName(Element element, String tag) {
    ArrayList<Element> children = new ArrayList<Element>();
    if (element != null && tag != null) {
        NodeList nodes = element.getElementsByTagName(tag);
        for (int i = 0; i < nodes.getLength(); i++) {
            Node child = nodes.item(i);
            //      System.out.println("Name: " + child.getNodeName() + ", Value: " + child.getFirstChild().getNodeValue());
            children.add((Element) child);
        }//  ww  w. j  av  a 2 s  .c  o  m
    }
    return children.iterator();
}

From source file:com.concursive.connect.web.modules.wiki.utils.WikiUtils.java

private static Timestamp getLatestModifiedDate(Wiki wiki, Connection db, ArrayList children, Timestamp latest,
        ArrayList scanned) throws SQLException {
    Iterator i = children.iterator();
    while (i.hasNext()) {
        String pageLink = (String) i.next();
        LOG.debug("Checking getLatestModifiedDate: " + pageLink);
        if (!scanned.contains(pageLink)) {
            scanned.add(pageLink);/*  www.j av a 2s  .  co  m*/
            Wiki thisWiki = WikiList.queryBySubject(db, pageLink, wiki.getProjectId());
            if (thisWiki.getId() != -1) {
                if (thisWiki.getModified().after(latest)) {
                    latest = thisWiki.getModified();
                }
                latest = getLatestModifiedDate(thisWiki, db, getPageLinks(thisWiki), latest, scanned);
            }
        }
    }
    return latest;
}

From source file:cc.flydev.launcher.InstallShortcutReceiver.java

static void flushInstallQueue(Context context) {
    String spKey = LauncherAppState.getSharedPreferencesKey();
    SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE);
    ArrayList<PendingInstallShortcutInfo> installQueue = getAndClearInstallQueue(sp);
    if (!installQueue.isEmpty()) {
        Iterator<PendingInstallShortcutInfo> iter = installQueue.iterator();
        ArrayList<ItemInfo> addShortcuts = new ArrayList<ItemInfo>();
        int result = INSTALL_SHORTCUT_SUCCESSFUL;
        String duplicateName = "";
        while (iter.hasNext()) {
            final PendingInstallShortcutInfo pendingInfo = iter.next();
            //final Intent data = pendingInfo.data;
            final Intent intent = pendingInfo.launchIntent;
            final String name = pendingInfo.name;
            final boolean exists = LauncherModel.shortcutExists(context, name, intent);
            //final boolean allowDuplicate = data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE, true);

            // TODO-XXX: Disable duplicates for now
            if (!exists /* && allowDuplicate */) {
                // Generate a shortcut info to add into the model
                ShortcutInfo info = getShortcutInfo(context, pendingInfo.data, pendingInfo.launchIntent);
                addShortcuts.add(info);//from  w  w w. j  a va  2s .  c  om
            }
            /*
            else if (exists && !allowDuplicate) {
            result = INSTALL_SHORTCUT_IS_DUPLICATE;
            duplicateName = name;
            }
            */
        }

        // Notify the user once if we weren't able to place any duplicates
        if (result == INSTALL_SHORTCUT_IS_DUPLICATE) {
            Toast.makeText(context, context.getString(R.string.shortcut_duplicate, duplicateName),
                    Toast.LENGTH_SHORT).show();
        }

        // Add the new apps to the model and bind them
        if (!addShortcuts.isEmpty()) {
            LauncherAppState app = LauncherAppState.getInstance();
            app.getModel().addAndBindAddedApps(context, addShortcuts, null);
        }
    }
}

From source file:com.llf.android.launcher3.InstallShortcutReceiver.java

static void flushInstallQueue(Context context) {
    String spKey = LauncherAppState.getSharedPreferencesKey();
    SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE);
    ArrayList<PendingInstallShortcutInfo> installQueue = getAndClearInstallQueue(sp);
    if (!installQueue.isEmpty()) {
        Iterator<PendingInstallShortcutInfo> iter = installQueue.iterator();
        ArrayList<ItemInfo> addShortcuts = new ArrayList<ItemInfo>();
        int result = INSTALL_SHORTCUT_SUCCESSFUL;
        String duplicateName = "";
        while (iter.hasNext()) {
            final PendingInstallShortcutInfo pendingInfo = iter.next();
            // final Intent data = pendingInfo.data;
            final Intent intent = pendingInfo.launchIntent;
            final String name = pendingInfo.name;
            final boolean exists = LauncherModel.shortcutExists(context, name, intent);
            // final boolean allowDuplicate =
            // data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE,
            // true);

            // TODO-XXX: Disable duplicates for now
            if (!exists /* && allowDuplicate */) {
                // Generate a shortcut info to add into the model
                ShortcutInfo info = getShortcutInfo(context, pendingInfo.data, pendingInfo.launchIntent);
                addShortcuts.add(info);/*  w w  w .j av  a  2 s. c o  m*/
            }
            /*
             * else if (exists && !allowDuplicate) { result =
             * INSTALL_SHORTCUT_IS_DUPLICATE; duplicateName = name; }
             */
        }

        // Notify the user once if we weren't able to place any duplicates
        if (result == INSTALL_SHORTCUT_IS_DUPLICATE) {
            Toast.makeText(context, context.getString(R.string.shortcut_duplicate, duplicateName),
                    Toast.LENGTH_SHORT).show();
        }

        // Add the new apps to the model and bind them
        if (!addShortcuts.isEmpty()) {
            LauncherAppState app = LauncherAppState.getInstance();
            app.getModel().addAndBindAddedApps(context, addShortcuts, null);
        }
    }
}

From source file:com.aidy.launcher3.ui.receiver.InstallShortcutReceiver.java

public static void flushInstallQueue(Context context) {
    String spKey = LauncherAppState.getSharedPreferencesKey();
    SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE);
    ArrayList<PendingInstallShortcutInfo> installQueue = getAndClearInstallQueue(sp);
    if (!installQueue.isEmpty()) {
        Iterator<PendingInstallShortcutInfo> iter = installQueue.iterator();
        ArrayList<ItemInfoBean> addShortcuts = new ArrayList<ItemInfoBean>();
        int result = INSTALL_SHORTCUT_SUCCESSFUL;
        String duplicateName = "";
        while (iter.hasNext()) {
            final PendingInstallShortcutInfo pendingInfo = iter.next();
            // final Intent data = pendingInfo.data;
            final Intent intent = pendingInfo.launchIntent;
            final String name = pendingInfo.name;
            final boolean exists = LauncherModel.shortcutExists(context, name, intent);
            // final boolean allowDuplicate =
            // data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE,
            // true);

            // TODO-XXX: Disable duplicates for now
            if (!exists /* && allowDuplicate */) {
                // Generate a shortcut info to add into the model
                ShortcutInfo info = getShortcutInfo(context, pendingInfo.data, pendingInfo.launchIntent);
                addShortcuts.add(info);/* w  w w. ja v a2 s  .co  m*/
            }
            /*
             * else if (exists && !allowDuplicate) { result =
             * INSTALL_SHORTCUT_IS_DUPLICATE; duplicateName = name; }
             */
        }

        // Notify the user once if we weren't able to place any duplicates
        if (result == INSTALL_SHORTCUT_IS_DUPLICATE) {
            Toast.makeText(context, context.getString(R.string.shortcut_duplicate, duplicateName),
                    Toast.LENGTH_SHORT).show();
        }

        // Add the new apps to the model and bind them
        if (!addShortcuts.isEmpty()) {
            LauncherAppState app = LauncherAppState.getInstance();
            app.getModel().addAndBindAddedApps(context, addShortcuts, null);
        }
    }
}