Change List<? extends Message> to List<WebDavMessage> where appropriate
This commit is contained in:
parent
db7760a9e2
commit
7ac210956a
5 changed files with 18 additions and 23 deletions
|
@ -6,9 +6,9 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fsck.k9.mail.Message;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.store.webdav.WebDavFolder;
|
||||
import com.fsck.k9.mail.store.webdav.WebDavMessage;
|
||||
import com.fsck.k9.mail.store.webdav.WebDavStore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import timber.log.Timber;
|
||||
|
@ -40,7 +40,7 @@ class CommandMoveOrCopyMessages {
|
|||
try {
|
||||
remoteSrcFolder = webDavStore.getFolder(srcFolder);
|
||||
|
||||
List<Message> messages = new ArrayList<>();
|
||||
List<WebDavMessage> messages = new ArrayList<>();
|
||||
|
||||
for (String uid : uids) {
|
||||
messages.add(remoteSrcFolder.getMessage(uid));
|
||||
|
|
|
@ -6,9 +6,9 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import com.fsck.k9.mail.Flag;
|
||||
import com.fsck.k9.mail.Message;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.store.webdav.WebDavFolder;
|
||||
import com.fsck.k9.mail.store.webdav.WebDavMessage;
|
||||
import com.fsck.k9.mail.store.webdav.WebDavStore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -28,7 +28,7 @@ class CommandSetFlag {
|
|||
try {
|
||||
remoteFolder.open();
|
||||
|
||||
List<Message> messages = new ArrayList<>();
|
||||
List<WebDavMessage> messages = new ArrayList<>();
|
||||
for (String uid : messageServerIds) {
|
||||
messages.add(remoteFolder.getMessage(uid));
|
||||
}
|
||||
|
|
|
@ -100,19 +100,19 @@ public class WebDavFolder {
|
|||
this.mIsOpen = true;
|
||||
}
|
||||
|
||||
public Map<String, String> copyMessages(List<? extends Message> messages, WebDavFolder folder)
|
||||
public Map<String, String> copyMessages(List<WebDavMessage> messages, WebDavFolder folder)
|
||||
throws MessagingException {
|
||||
moveOrCopyMessages(messages, folder.getServerId(), false);
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<String, String> moveMessages(List<? extends Message> messages, WebDavFolder folder)
|
||||
public Map<String, String> moveMessages(List<WebDavMessage> messages, WebDavFolder folder)
|
||||
throws MessagingException {
|
||||
moveOrCopyMessages(messages, folder.getServerId(), true);
|
||||
return null;
|
||||
}
|
||||
|
||||
private void moveOrCopyMessages(List<? extends Message> messages, String folderName, boolean isMove)
|
||||
private void moveOrCopyMessages(List<WebDavMessage> messages, String folderName, boolean isMove)
|
||||
throws MessagingException {
|
||||
String[] uids = new String[messages.size()];
|
||||
|
||||
|
@ -126,9 +126,9 @@ public class WebDavFolder {
|
|||
|
||||
for (int i = 0, count = uids.length; i < count; i++) {
|
||||
urls[i] = uidToUrl.get(uids[i]);
|
||||
if (urls[i] == null && messages.get(i) instanceof WebDavMessage) {
|
||||
WebDavMessage wdMessage = (WebDavMessage) messages.get(i);
|
||||
urls[i] = wdMessage.getUrl();
|
||||
if (urls[i] == null) {
|
||||
WebDavMessage message = messages.get(i);
|
||||
urls[i] = message.getUrl();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ public class WebDavFolder {
|
|||
private void fetchFlags(List<WebDavMessage> startMessages, MessageRetrievalListener<WebDavMessage> listener) throws MessagingException {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
String messageBody;
|
||||
List<Message> messages = new ArrayList<>(20);
|
||||
List<WebDavMessage> messages = new ArrayList<>(20);
|
||||
String[] uids;
|
||||
|
||||
if (startMessages == null ||
|
||||
|
@ -458,14 +458,9 @@ public class WebDavFolder {
|
|||
|
||||
Map<String, Boolean> uidToReadStatus = dataset.getUidToRead();
|
||||
|
||||
for (int i = 0, count = messages.size(); i < count; i++) {
|
||||
if (!(messages.get(i) instanceof WebDavMessage)) {
|
||||
throw new MessagingException("WebDavStore fetch called with non-WebDavMessage");
|
||||
}
|
||||
WebDavMessage wdMessage = (WebDavMessage) messages.get(i);
|
||||
|
||||
for (WebDavMessage message : messages) {
|
||||
try {
|
||||
wdMessage.setFlag(Flag.SEEN, uidToReadStatus.get(wdMessage.getUid()));
|
||||
message.setFlag(Flag.SEEN, uidToReadStatus.get(message.getUid()));
|
||||
} catch (NullPointerException e) {
|
||||
Timber.v(e, "Under some weird circumstances, " +
|
||||
"setting the read status when syncing from webdav threw an NPE. Skipping.");
|
||||
|
@ -539,7 +534,7 @@ public class WebDavFolder {
|
|||
}
|
||||
}
|
||||
|
||||
public void setFlags(List<? extends Message> messages, final Set<Flag> flags, boolean value)
|
||||
public void setFlags(List<WebDavMessage> messages, final Set<Flag> flags, boolean value)
|
||||
throws MessagingException {
|
||||
String[] uids = new String[messages.size()];
|
||||
|
||||
|
@ -607,8 +602,8 @@ public class WebDavFolder {
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<? extends Message> appendWebDavMessages(List<? extends Message> messages) throws MessagingException {
|
||||
List<Message> retMessages = new ArrayList<>(messages.size());
|
||||
public List<WebDavMessage> appendWebDavMessages(List<? extends Message> messages) throws MessagingException {
|
||||
List<WebDavMessage> retMessages = new ArrayList<>(messages.size());
|
||||
|
||||
WebDavHttpClient httpclient = store.getHttpClient();
|
||||
|
||||
|
|
|
@ -938,7 +938,7 @@ public class WebDavStore {
|
|||
WebDavFolder tmpFolder = getFolder(storeConfig.getDraftsFolder());
|
||||
try {
|
||||
tmpFolder.open();
|
||||
List<? extends Message> retMessages = tmpFolder.appendWebDavMessages(messages);
|
||||
List<WebDavMessage> retMessages = tmpFolder.appendWebDavMessages(messages);
|
||||
|
||||
tmpFolder.moveMessages(retMessages, getSendSpoolFolder());
|
||||
} finally {
|
||||
|
|
|
@ -513,7 +513,7 @@ public class WebDavFolderTest {
|
|||
String messageUid = "testMessageUid";
|
||||
when(existingMessage.getUid()).thenReturn(messageUid);
|
||||
|
||||
List<? extends Message> response = folder.appendWebDavMessages(existingMessages);
|
||||
List<WebDavMessage> response = folder.appendWebDavMessages(existingMessages);
|
||||
|
||||
assertEquals(1, response.size(), 1);
|
||||
assertEquals(WebDavMessage.class, response.get(0).getClass());
|
||||
|
|
Loading…
Reference in a new issue