Make UidReverseComparator a top-level class

This commit is contained in:
cketti 2016-01-07 01:28:51 +01:00
parent 75121d85fe
commit 89321cf6eb
3 changed files with 35 additions and 30 deletions

View file

@ -7,7 +7,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
@ -134,34 +133,6 @@ public class MessagingController implements Runnable {
private static final String PENDING_COMMAND_MARK_ALL_AS_READ = "com.fsck.k9.MessagingController.markAllAsRead";
private static final String PENDING_COMMAND_EXPUNGE = "com.fsck.k9.MessagingController.expunge";
public static class UidReverseComparator implements Comparator<Message> {
@Override
public int compare(Message messageLeft, Message messageRight) {
Integer uidLeft, uidRight;
try {
uidLeft = Integer.parseInt(messageLeft.getUid());
} catch (NullPointerException | NumberFormatException e) {
uidLeft = null;
}
try {
uidRight = Integer.parseInt(messageRight.getUid());
} catch (NullPointerException | NumberFormatException e) {
uidRight = null;
}
if (uidLeft == null && uidRight == null) {
return 0;
} else if (uidLeft == null) {
return 1;
} else if (uidRight == null) {
return -1;
}
// reverse order
return uidRight.compareTo(uidLeft);
}
}
/**
* Maximum number of unsynced messages to store at once
*/

View file

@ -0,0 +1,35 @@
package com.fsck.k9.controller;
import java.util.Comparator;
import com.fsck.k9.mail.Message;
class UidReverseComparator implements Comparator<Message> {
@Override
public int compare(Message messageLeft, Message messageRight) {
Integer uidLeft, uidRight;
try {
uidLeft = Integer.parseInt(messageLeft.getUid());
} catch (NullPointerException | NumberFormatException e) {
uidLeft = null;
}
try {
uidRight = Integer.parseInt(messageRight.getUid());
} catch (NullPointerException | NumberFormatException e) {
uidRight = null;
}
if (uidLeft == null && uidRight == null) {
return 0;
} else if (uidLeft == null) {
return 1;
} else if (uidRight == null) {
return -1;
}
// reverse order
return uidRight.compareTo(uidLeft);
}
}

View file

@ -3,7 +3,6 @@ package com.fsck.k9.controller;
import android.support.annotation.NonNull;
import com.fsck.k9.controller.MessagingController.UidReverseComparator;
import com.fsck.k9.mail.Message;
import org.junit.Before;
import org.junit.Test;