Exemplo n.º 1
0
 private void processFile(File file) throws IOException {
   String fileEx = FileUtility.getFileExtension(file);
   Data data;
   if (fileEx.equals(".jpg") || fileEx.equals(".jpeg")) {
     Metadata meta = null;
     Date[] dates = null;
     try {
       meta = ImageMetadataReader.readMetadata(file);
       dates = PhotoUtility.getData(meta);
     } catch (ImageProcessingException e) {
     } catch (TagNotFound e) {
     } finally {
       if (meta != null && dates != null) data = new Data(file, dates[0], ImageType.JPG, false);
       else data = new Data(file, new Date(file.lastModified()), ImageType.JPG, true);
     }
   } else
     data =
         new Data(
             file,
             new Date(file.lastModified()),
             ImageType.valueOf(fileEx.substring(1).toUpperCase()),
             true);
   notifyFileCountObservers(CountType.SINGEL, ++count);
   notifyImageObservers(data);
 }
Exemplo n.º 2
0
 @Override
 public void run() {
   notifyFileCountObservers(CountType.TOTAL, FileUtility.fileCount(file, FILTER));
   try {
     ArrayList<File> files = new ArrayList<File>();
     files.add(file);
     while (!stop && !files.isEmpty()) {
       File file = files.remove(0);
       if (file.isDirectory()) files.addAll(Arrays.asList(file.listFiles(FILTER)));
       else processFile(file);
     }
     if (interuptCallerThread != null)
       synchronized (interuptCallerThread) {
         interuptCallerThread.notify();
       }
   } catch (IOException e) {
     e.printStackTrace();
   }
 }