|
8 | 8 | import java.io.BufferedReader;
|
9 | 9 | import java.io.File;
|
10 | 10 | import java.io.FileOutputStream;
|
| 11 | +import java.io.IOException; |
11 | 12 | import java.io.InputStreamReader;
|
12 | 13 | import java.util.ArrayList;
|
13 | 14 | import java.util.List;
|
@@ -123,47 +124,42 @@ public void run() {
|
123 | 124 | throw new RuntimeException("Unable to rename staging folder");
|
124 | 125 | }
|
125 | 126 |
|
126 |
| - activity.runOnUiThread(new Runnable() { |
127 |
| - @Override |
128 |
| - public void run() { |
129 |
| - resultListener.onResult(null); |
130 |
| - } |
131 |
| - }); |
| 127 | + activity.runOnUiThread(() -> resultListener.onResult(null)); |
132 | 128 | } catch (final Exception e) {
|
133 | 129 | NLog.INSTANCE.e(EmulatorDebug.LOG_TAG, "Bootstrap error", e);
|
134 |
| - activity.runOnUiThread(new Runnable() { |
135 |
| - @Override |
136 |
| - public void run() { |
137 |
| - try { |
138 |
| - resultListener.onResult(e); |
139 |
| - } catch (RuntimeException e) { |
140 |
| - // Activity already dismissed - ignore. |
141 |
| - } |
| 130 | + activity.runOnUiThread(() -> { |
| 131 | + try { |
| 132 | + resultListener.onResult(e); |
| 133 | + } catch (RuntimeException e1) { |
| 134 | + // Activity already dismissed - ignore. |
142 | 135 | }
|
143 | 136 | });
|
144 | 137 | } finally {
|
145 |
| - activity.runOnUiThread(new Runnable() { |
146 |
| - @Override |
147 |
| - public void run() { |
148 |
| - try { |
149 |
| - progressDialog.dismiss(); |
150 |
| - } catch (RuntimeException e) { |
151 |
| - // Activity already dismissed - ignore. |
152 |
| - } |
| 138 | + activity.runOnUiThread(() -> { |
| 139 | + try { |
| 140 | + progressDialog.dismiss(); |
| 141 | + } catch (RuntimeException e) { |
| 142 | + // Activity already dismissed - ignore. |
153 | 143 | }
|
154 | 144 | });
|
155 | 145 | }
|
156 | 146 | }
|
157 | 147 |
|
158 |
| - private static void deleteFolder(File fileOrDirectory) { |
159 |
| - File[] children = fileOrDirectory.listFiles(); |
160 |
| - if (children != null) { |
161 |
| - for (File child : children) { |
162 |
| - deleteFolder(child); |
| 148 | + private static void deleteFolder(File fileOrDirectory) throws IOException { |
| 149 | + if (fileOrDirectory.getCanonicalPath().equals(fileOrDirectory.getAbsolutePath()) && fileOrDirectory.isDirectory()) { |
| 150 | + File[] children = fileOrDirectory.listFiles(); |
| 151 | + |
| 152 | + if (children != null) { |
| 153 | + for (File child : children) { |
| 154 | + deleteFolder(child); |
| 155 | + } |
163 | 156 | }
|
164 | 157 | }
|
| 158 | + |
165 | 159 | if (!fileOrDirectory.delete()) {
|
166 |
| - throw new RuntimeException("Unable to delete " + (fileOrDirectory.isDirectory() ? "directory " : "file ") + fileOrDirectory.getAbsolutePath()); |
| 160 | + throw new RuntimeException("Unable to delete " |
| 161 | + + (fileOrDirectory.isDirectory() ? "directory " : "file ") |
| 162 | + + fileOrDirectory.getAbsolutePath()); |
167 | 163 | }
|
168 | 164 | }
|
169 | 165 | }
|
0 commit comments