From 89d2cf834011908bec4c8ea65737a099fe58026e Mon Sep 17 00:00:00 2001 From: David Piggott Date: Mon, 14 Feb 2011 11:17:14 +0000 Subject: [PATCH] Tidy up incorrect indentation resulting from Eclipse misconfiguration --- .../apps/mytracks/ImportAllTracks.java | 158 +++++++++--------- .../apps/mytracks/util/MyTracksUtils.java | 62 +++---- 2 files changed, 110 insertions(+), 110 deletions(-) diff --git a/MyTracks/src/com/google/android/apps/mytracks/ImportAllTracks.java b/MyTracks/src/com/google/android/apps/mytracks/ImportAllTracks.java index be62d7041..d8139ccc1 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/ImportAllTracks.java +++ b/MyTracks/src/com/google/android/apps/mytracks/ImportAllTracks.java @@ -91,19 +91,19 @@ public class ImportAllTracks { wakeLock.release(); Log.i(MyTracksConstants.TAG, "ImportAllTracks: Releasing wake lock."); } - - Log.i(MyTracksConstants.TAG, "ImportAllTracks: Done"); - AlertDialog.Builder builder = new AlertDialog.Builder(activity); - if (gpxFileCandidateCount == 0) { - builder.setMessage(activity.getString(R.string.import_empty, - MyTracksConstants.SDCARD_TOP_DIR)); - } else { - builder.setMessage(activity.getString(R.string.import_done, - importSuccessCount, gpxFileCandidateCount, - MyTracksConstants.SDCARD_TOP_DIR)); - } - builder.setPositiveButton(R.string.ok, null); - builder.show(); + + Log.i(MyTracksConstants.TAG, "ImportAllTracks: Done"); + AlertDialog.Builder builder = new AlertDialog.Builder(activity); + if (gpxFileCandidateCount == 0) { + builder.setMessage(activity.getString(R.string.import_empty, + MyTracksConstants.SDCARD_TOP_DIR)); + } else { + builder.setMessage(activity.getString(R.string.import_done, + importSuccessCount, gpxFileCandidateCount, + MyTracksConstants.SDCARD_TOP_DIR)); + } + builder.setPositiveButton(R.string.ok, null); + builder.show(); } private void makeProgressDialog(final int trackCount) { @@ -121,72 +121,72 @@ public class ImportAllTracks { * Actually import the tracks. * This should be called after the wake locks have been acquired. */ - private void importAll() { - MyTracksProviderUtils providerUtils = MyTracksProviderUtils.Factory - .get(activity); - LinkedList gpxFiles = new LinkedList(); - File[] gpxFileCandidates = new File("/sdcard/" - + MyTracksConstants.SDCARD_TOP_DIR + "/gpx").listFiles(); - if (gpxFileCandidates != null) { - for (File file : gpxFileCandidates) { - if (!file.isDirectory() && file.getName().endsWith(".gpx")) { - gpxFiles.add(file); - } - } - } - gpxFileCandidateCount = gpxFiles.size(); + private void importAll() { + MyTracksProviderUtils providerUtils = MyTracksProviderUtils.Factory + .get(activity); + LinkedList gpxFiles = new LinkedList(); + File[] gpxFileCandidates = new File("/sdcard/" + + MyTracksConstants.SDCARD_TOP_DIR + "/gpx").listFiles(); + if (gpxFileCandidates != null) { + for (File file : gpxFileCandidates) { + if (!file.isDirectory() && file.getName().endsWith(".gpx")) { + gpxFiles.add(file); + } + } + } + gpxFileCandidateCount = gpxFiles.size(); - if (gpxFileCandidateCount != 0) { - Log.i(MyTracksConstants.TAG, "ImportAllTracks: Importing: " - + gpxFileCandidateCount + " tracks."); - activity.runOnUiThread(new Runnable() { - public void run() { - makeProgressDialog(gpxFileCandidateCount); - } - }); + if (gpxFileCandidateCount != 0) { + Log.i(MyTracksConstants.TAG, "ImportAllTracks: Importing: " + + gpxFileCandidateCount + " tracks."); + activity.runOnUiThread(new Runnable() { + public void run() { + makeProgressDialog(gpxFileCandidateCount); + } + }); - Iterator gpxFilesIterator = gpxFiles.iterator(); - File currentFile; - int currentFileNumber = 0; - while (gpxFilesIterator.hasNext()) { - currentFile = gpxFilesIterator.next(); - final int status = currentFileNumber; - activity.runOnUiThread(new Runnable() { - public void run() { - synchronized (this) { - if (progress == null) { - return; - } - progress.setProgress(status); - } - } - }); - if (importFile(currentFile, providerUtils)) { - importSuccessCount++; - } - currentFileNumber++; - } - if (progress != null) { - synchronized (this) { - progress.dismiss(); - progress = null; - } - } - } - } - - private boolean importFile(File gpxFile, MyTracksProviderUtils providerUtils) { - Log.i(MyTracksConstants.TAG, "ImportAllTracks: importing: " - + gpxFile.getName()); - try { - GpxImporter.importGPXFile(new FileInputStream(gpxFile), providerUtils); - return true; - } catch (Exception e) { - Log.w("", e); - Toast.makeText(activity, - activity.getString(R.string.import_error) + " " + gpxFile.getName(), - Toast.LENGTH_LONG).show(); - return false; - } - } + Iterator gpxFilesIterator = gpxFiles.iterator(); + File currentFile; + int currentFileNumber = 0; + while (gpxFilesIterator.hasNext()) { + currentFile = gpxFilesIterator.next(); + final int status = currentFileNumber; + activity.runOnUiThread(new Runnable() { + public void run() { + synchronized (this) { + if (progress == null) { + return; + } + progress.setProgress(status); + } + } + }); + if (importFile(currentFile, providerUtils)) { + importSuccessCount++; + } + currentFileNumber++; + } + if (progress != null) { + synchronized (this) { + progress.dismiss(); + progress = null; + } + } + } + } + + private boolean importFile(File gpxFile, MyTracksProviderUtils providerUtils) { + Log.i(MyTracksConstants.TAG, "ImportAllTracks: importing: " + + gpxFile.getName()); + try { + GpxImporter.importGPXFile(new FileInputStream(gpxFile), providerUtils); + return true; + } catch (Exception e) { + Log.w("", e); + Toast.makeText(activity, + activity.getString(R.string.import_error) + " " + gpxFile.getName(), + Toast.LENGTH_LONG).show(); + return false; + } + } } diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/MyTracksUtils.java b/MyTracks/src/com/google/android/apps/mytracks/util/MyTracksUtils.java index 0a7e0d5b0..59ba09b3d 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/MyTracksUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/MyTracksUtils.java @@ -294,37 +294,37 @@ public class MyTracksUtils { * Tries to acquire a partial wake lock if not already acquired. Logs errors * and gives up trying in case the wake lock cannot be acquired. */ - public static WakeLock acquireWakeLock(Activity activity, WakeLock wakeLock) { - Log.i(MyTracksConstants.TAG, "MyTracksUtils: Acquiring wake lock."); - try { - PowerManager pm = (PowerManager) activity - .getSystemService(Context.POWER_SERVICE); - if (pm == null) { - Log.e(MyTracksConstants.TAG, "MyTracksUtils: Power manager not found!"); - return wakeLock; - } - if (wakeLock == null) { - wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, - MyTracksConstants.TAG); - if (wakeLock == null) { - Log.e(MyTracksConstants.TAG, - "MyTracksUtils: Could not create wake lock (null)."); - } - return wakeLock; - } - if (!wakeLock.isHeld()) { - wakeLock.acquire(); - if (!wakeLock.isHeld()) { - Log.e(MyTracksConstants.TAG, - "MyTracksUtils: Could not acquire wake lock."); - } - } - } catch (RuntimeException e) { - Log.e(MyTracksConstants.TAG, - "MyTracksUtils: Caught unexpected exception: " + e.getMessage(), e); - } - return wakeLock; - } + public static WakeLock acquireWakeLock(Activity activity, WakeLock wakeLock) { + Log.i(MyTracksConstants.TAG, "MyTracksUtils: Acquiring wake lock."); + try { + PowerManager pm = (PowerManager) activity + .getSystemService(Context.POWER_SERVICE); + if (pm == null) { + Log.e(MyTracksConstants.TAG, "MyTracksUtils: Power manager not found!"); + return wakeLock; + } + if (wakeLock == null) { + wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, + MyTracksConstants.TAG); + if (wakeLock == null) { + Log.e(MyTracksConstants.TAG, + "MyTracksUtils: Could not create wake lock (null)."); + } + return wakeLock; + } + if (!wakeLock.isHeld()) { + wakeLock.acquire(); + if (!wakeLock.isHeld()) { + Log.e(MyTracksConstants.TAG, + "MyTracksUtils: Could not acquire wake lock."); + } + } + } catch (RuntimeException e) { + Log.e(MyTracksConstants.TAG, + "MyTracksUtils: Caught unexpected exception: " + e.getMessage(), e); + } + return wakeLock; + } /** * This is a utility class w/ only static members.