code cleanup - use lambdas
This commit is contained in:
parent
aca9b3ff65
commit
5d1fc92e44
1 changed files with 9 additions and 25 deletions
|
@ -89,23 +89,16 @@ public class MaintenancePlugin extends PluginBase {
|
||||||
ctx.startActivity(emailIntent);
|
ctx.startActivity(emailIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo replace this with a call on startup of the application, specifically to remove
|
||||||
|
// unnecessary garbage from the log exports
|
||||||
public void deleteLogs() {
|
public void deleteLogs() {
|
||||||
String logDirectory = LoggerUtils.getLogDirectory();
|
String logDirectory = LoggerUtils.getLogDirectory();
|
||||||
File logDir = new File(logDirectory);
|
File logDir = new File(logDirectory);
|
||||||
|
|
||||||
File[] files = logDir.listFiles(new FilenameFilter() {
|
File[] files = logDir.listFiles((file, name) -> name.startsWith("AndroidAPS")
|
||||||
@Override
|
&& name.endsWith(".zip"));
|
||||||
public boolean accept(File file, String name) {
|
|
||||||
return name.startsWith("AndroidAPS")
|
|
||||||
&& name.endsWith(".zip");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Arrays.sort(files, new Comparator<File>() {
|
Arrays.sort(files, (f1, f2) -> f1.getName().compareTo(f2.getName()));
|
||||||
public int compare(File f1, File f2) {
|
|
||||||
return f1.getName().compareTo(f2.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
List<File> delFiles = Arrays.asList(files);
|
List<File> delFiles = Arrays.asList(files);
|
||||||
int amount = SP.getInt("key_logshipper_amount", 2);
|
int amount = SP.getInt("key_logshipper_amount", 2);
|
||||||
|
@ -145,20 +138,11 @@ public class MaintenancePlugin extends PluginBase {
|
||||||
LOG.debug("getting {} logs from directory {}", amount, directory);
|
LOG.debug("getting {} logs from directory {}", amount, directory);
|
||||||
File logDir = new File(directory);
|
File logDir = new File(directory);
|
||||||
|
|
||||||
File[] files = logDir.listFiles(new FilenameFilter() {
|
File[] files = logDir.listFiles((file, name) -> name.startsWith("AndroidAPS")
|
||||||
@Override
|
&& (name.endsWith(".log")
|
||||||
public boolean accept(File file, String name) {
|
|| (name.endsWith(".zip") && !name.endsWith(LoggerUtils.SUFFIX))));
|
||||||
return name.startsWith("AndroidAPS")
|
|
||||||
&& (name.endsWith(".log")
|
|
||||||
|| (name.endsWith(".zip") && !name.endsWith(LoggerUtils.SUFFIX)));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Arrays.sort(files, new Comparator<File>() {
|
Arrays.sort(files, (f1, f2) -> f2.getName().compareTo(f1.getName()));
|
||||||
public int compare(File f1, File f2) {
|
|
||||||
return f2.getName().compareTo(f1.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
List<File> result = Arrays.asList(files);
|
List<File> result = Arrays.asList(files);
|
||||||
int toIndex = amount++;
|
int toIndex = amount++;
|
||||||
|
|
Loading…
Reference in a new issue