From cbddf975d3a52e34b9b9773789e2ff3a4954c4a8 Mon Sep 17 00:00:00 2001 From: Iain Billett Date: Wed, 25 Jul 2012 17:43:54 +0100 Subject: [PATCH] Added methods to check if a file has a thumbnail. Change-Id: I362ff20d8768be1dffbf857e442fbc30822079a7 --- .../src/org/libreoffice/ui/FileUtilities.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/FileUtilities.java b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/FileUtilities.java index df440e51f65f..71e67c1df3fc 100644 --- a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/FileUtilities.java +++ b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/FileUtilities.java @@ -194,6 +194,24 @@ public class FileUtilities { } return; } + + static boolean hasThumbnail(File file) + { + String filename = file.getName(); + if( lookupExtension( filename ) == DOC ) // only do this for docs for now + { + // Will need another method to check if Thumb is up-to-date - or extend this one? + if( new File( file.getParent() , getThumbnailName( file ) ).isFile() ) + return true; + return false; // If it's a document with no thumb + } + return true; + } + + static String getThumbnailName( File file ) + { + return "." + file.getName().split("[.]")[0] + ".png" ; + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */