src/main/java/de/blau/android/photos/PhotoIndex.java
/**
     * Recursively scan directories and add images to index
     * 
     * @param db database containing the index
     * @param dir directory we are starting with
     * @param lastScan date we last scanned this directory tree
     */
Recursively scan directories and add images to index

@param db database containing the index
@param dir directory we are starting with
@param lastScan date we last scanned this directory tree
Recursively scan directories and add images to index @param db database containing the index @param dir directory we are starting with @param lastScan date we last scanned this directory tree
private void scanDir(@NonNull SQLiteDatabase db, @NonNull String dir, long lastScan) {
        File indir = new File(dir);
        boolean needsReindex = false;
        if (indir.lastModified() >= lastScan) { 
            Log.d(DEBUG_TAG, "deleteing refs for reindex");
            try {
                db.delete(PHOTOS_TABLE, URI_WHERE, new String[] { indir.getAbsolutePath() });
            } catch (SQLiteException sqex) {
                Log.d(DEBUG_TAG, sqex.toString());
                ACRAHelper.nocrashReport(sqex, sqex.getMessage());
            }
            needsReindex = true;
        }
        File[] list = indir.listFiles();
        if (list == null) {
            return;
        }
        for (File f : list) {
            if (NOVESPUCCI.equals(f.getName())) {
                return;
            }
        }
        for (File f : list) {
            if (f.isDirectory()) {
                scanDir(db, f.getAbsolutePath(), lastScan);
            }
            if (needsReindex && f.getName().toLowerCase(Locale.US).endsWith(Paths.FILE_EXTENSION_IMAGE)) {
                addPhoto(db, indir, f);
            }
        }
    }
private void scanDir ( @ NonNull SQLiteDatabase db , @ NonNull String dir , long lastScan ) { File indir = new File ( dir ) ; boolean needsReindex = false ; if ( indir . lastModified ( ) >= lastScan ) { Log . d ( DEBUG_TAG , "deleteing refs for reindex" ) ; try { db . delete ( PHOTOS_TABLE , URI_WHERE , new String [ ] { indir . getAbsolutePath ( ) } ) ; } catch ( SQLiteException sqex ) { Log . d ( DEBUG_TAG , sqex . toString ( ) ) ; ACRAHelper . nocrashReport ( sqex , sqex . getMessage ( ) ) ; } needsReindex = true ; } File [ ] list = indir . listFiles ( ) ; if ( list == null ) { return ; } for ( File f : list ) { if ( NOVESPUCCI . equals ( f . getName ( ) ) ) { return ; } } for ( File f : list ) { if ( f . isDirectory ( ) ) { scanDir ( db , f . getAbsolutePath ( ) , lastScan ) ; } if ( needsReindex && f . getName ( ) . toLowerCase ( Locale . US ) . endsWith ( Paths . FILE_EXTENSION_IMAGE ) ) { addPhoto ( db , indir , f ) ; } } }
Recursively scan directories and add images to index
Recursively scan directories and add images to index
// directory was modified // remove all entries // now process // check if we shouldn't process this directory, not the most efficient way likely // recursive decent