Code example for Queue

Methods: isEmpty, offer

0
            createMediaScanner(); 
        } 
        if (isConnected()) { 
            mediaScanner.scanFile(file.getAbsolutePath(), type);
        } else { 
            waitScans.offer(new FileInfo(file, type));
        } 
    } 
     
    /** 
     *  Disconnects from the media scanner. 
     */ 
    public void disconnect() { 
        if (mediaScanner == null) {
            return; 
        } 
        if (!mediaScanner.isConnected()) {
            return; 
        } 
        mediaScanner.disconnect();
    } 
     
    void createMediaScanner() { 
        mediaScanner = new MediaScannerConnection(context, 
                new MediaScannerClient()); 
        mediaScanner.connect();
    } 
     
    /** 
     *  Returns true if the connection to media scanner is established and 
     *  the queue of the scans, which came while connecting, is empty. 
     */ 
    boolean isConnected() { 
        if (mediaScanner == null) {
            return false; 
        } 
        if (!mediaScanner.isConnected()) {
            return false; 
        } 
        return waitScans.isEmpty();
    } 
     
    static private class FileInfo { 
        public File path;
        public String type;