Remove unused method parameters

This commit is contained in:
cketti 2022-02-24 19:56:50 +01:00
parent e59f57f602
commit 4bed7a595b
13 changed files with 38 additions and 53 deletions

View file

@ -419,7 +419,7 @@ public class MessagingController {
// Collecting statistics of the search result
MessageRetrievalListener<LocalMessage> retrievalListener = new MessageRetrievalListener<LocalMessage>() {
@Override
public void messageFinished(LocalMessage message, int number, int ofTotal) {
public void messageFinished(LocalMessage message) {
if (!isMessageSuppressed(message)) {
List<LocalMessage> messages = new ArrayList<>();

View file

@ -399,7 +399,6 @@ public class LocalStore {
@Override
public Void doDbWork(final SQLiteDatabase db) {
Cursor cursor = null;
int i = 0;
try {
cursor = db.rawQuery(queryString + " LIMIT 10", placeHolders);
@ -409,9 +408,8 @@ public class LocalStore {
messages.add(message);
if (listener != null) {
listener.messageFinished(message, i, -1);
listener.messageFinished(message);
}
i++;
}
cursor.close();
cursor = db.rawQuery(queryString + " LIMIT -1 OFFSET 10", placeHolders);
@ -422,9 +420,8 @@ public class LocalStore {
messages.add(message);
if (listener != null) {
listener.messageFinished(message, i, -1);
listener.messageFinished(message);
}
i++;
}
} catch (Exception e) {
Timber.d(e, "Got an exception");

View file

@ -201,7 +201,7 @@ public class MessagingControllerTest extends K9RobolectricTest {
controller.searchLocalMessagesSynchronous(search, listener);
verify(localStore).searchForMessages(messageRetrievalListenerCaptor.capture(), eq(search));
messageRetrievalListenerCaptor.getValue().messageFinished(localMessage, 1, 1);
messageRetrievalListenerCaptor.getValue().messageFinished(localMessage);
verify(listener).listLocalMessagesAddMessages(eq(account),
eq((String) null), eq(Collections.singletonList(localMessage)));
}

View file

@ -483,7 +483,7 @@ internal class ImapSync(
unsyncedMessages,
fetchProfile,
object : MessageRetrievalListener<ImapMessage> {
override fun messageFinished(message: ImapMessage, number: Int, ofTotal: Int) {
override fun messageFinished(message: ImapMessage) {
try {
if (message.isSet(Flag.DELETED)) {
Timber.v(
@ -533,7 +533,7 @@ internal class ImapSync(
smallMessages,
fetchProfile,
object : MessageRetrievalListener<ImapMessage> {
override fun messageFinished(message: ImapMessage, number: Int, ofTotal: Int) {
override fun messageFinished(message: ImapMessage) {
try {
// Store the updated message locally
backendFolder.saveMessage(message, MessageDownloadState.FULL)

View file

@ -97,7 +97,7 @@ class TestImapFolder(override val serverId: String) : ImapFolder {
) {
if (messages.isEmpty()) return
messages.forEachIndexed { index, imapMessage ->
for (imapMessage in messages) {
val uid = imapMessage.uid.toLong()
val flags = messageFlags[uid].orEmpty().toSet()
@ -109,7 +109,7 @@ class TestImapFolder(override val serverId: String) : ImapFolder {
}
imapMessage.body = storedMessage.body
listener?.messageFinished(imapMessage, index, messages.size)
listener?.messageFinished(imapMessage)
}
}

View file

@ -419,7 +419,7 @@ class Pop3Sync {
remoteFolder.fetch(unsyncedMessages, fp,
new MessageRetrievalListener<Pop3Message>() {
@Override
public void messageFinished(Pop3Message message, int number, int ofTotal) {
public void messageFinished(Pop3Message message) {
try {
if (message.isSet(Flag.DELETED) || message.olderThan(earliestDate)) {
if (message.isSet(Flag.DELETED)) {
@ -467,7 +467,7 @@ class Pop3Sync {
remoteFolder.fetch(smallMessages,
fp, new MessageRetrievalListener<Pop3Message>() {
@Override
public void messageFinished(final Pop3Message message, int number, int ofTotal) {
public void messageFinished(final Pop3Message message) {
try {
// Store the updated message locally

View file

@ -405,7 +405,7 @@ class WebDavSync {
remoteFolder.fetch(unsyncedMessages, fp,
new MessageRetrievalListener<WebDavMessage>() {
@Override
public void messageFinished(WebDavMessage message, int number, int ofTotal) {
public void messageFinished(WebDavMessage message) {
try {
if (message.isSet(Flag.DELETED) || message.olderThan(earliestDate)) {
if (message.isSet(Flag.DELETED)) {
@ -453,7 +453,7 @@ class WebDavSync {
remoteFolder.fetch(smallMessages,
fp, new MessageRetrievalListener<WebDavMessage>() {
@Override
public void messageFinished(final WebDavMessage message, int number, int ofTotal) {
public void messageFinished(final WebDavMessage message) {
try {
// Store the updated message locally

View file

@ -3,5 +3,5 @@ package com.fsck.k9.mail;
public interface MessageRetrievalListener<T extends Message> {
void messageFinished(T message, int number, int ofTotal);
void messageFinished(T message);
}

View file

@ -502,11 +502,10 @@ internal class RealImapFolder(
// crazy adding stuff at the top.
val uids = searchResponse.numbers.sortedDescending()
val count = uids.size
return uids.mapIndexed { index, uidLong ->
return uids.map { uidLong ->
val uid = uidLong.toString()
val message = ImapMessage(uid)
listener?.messageFinished(message, index, count)
listener?.messageFinished(message)
message
}
@ -571,7 +570,6 @@ internal class RealImapFolder(
val command = String.format("UID FETCH %s (%s)", commaSeparatedUids, spaceSeparatedFetchFields)
connection!!.sendCommand(command, false)
var messageNumber = 0
var callback: ImapResponseCallback? = null
if (fetchProfile.contains(FetchProfile.Item.BODY) ||
fetchProfile.contains(FetchProfile.Item.BODY_SANE)
@ -612,7 +610,7 @@ internal class RealImapFolder(
}
}
listener?.messageFinished(message, messageNumber, messageMap.size)
listener?.messageFinished(message)
} else {
handleUntaggedResponse(response)
}
@ -647,7 +645,6 @@ internal class RealImapFolder(
val command = String.format("UID FETCH %s (UID %s)", message.uid, fetch)
connection!!.sendCommand(command, false)
var messageNumber = 0
val callback: ImapResponseCallback = FetchPartCallback(part, bodyFactory)
var response: ImapResponse
@ -687,7 +684,7 @@ internal class RealImapFolder(
}
}
listener?.messageFinished(message, messageNumber, 1)
listener?.messageFinished(message)
} else {
handleUntaggedResponse(response)
}

View file

@ -475,7 +475,7 @@ class RealImapFolderTest {
val messages = folder.getMessages(1, 10, null, listener)
verify(listener).messageFinished(messages[0], 0, 1)
verify(listener).messageFinished(messages[0])
verifyNoMoreInteractions(listener)
}
@ -562,7 +562,7 @@ class RealImapFolderTest {
val messages = folder.getMessages(setOf(1L), true, listener)
verify(listener).messageFinished(messages[0], 0, 1)
verify(listener).messageFinished(messages[0])
verifyNoMoreInteractions(listener)
}

View file

@ -120,7 +120,6 @@ public class Pop3Folder {
throw new MessagingException("getMessages", ioe);
}
List<Pop3Message> messages = new ArrayList<>();
int i = 0;
for (int msgNum = start; msgNum <= end; msgNum++) {
Pop3Message message = msgNumToMsgMap.get(msgNum);
if (message == null) {
@ -135,7 +134,7 @@ public class Pop3Folder {
messages.add(message);
if (listener != null) {
listener.messageFinished(message, i++, (end - start) + 1);
listener.messageFinished(message);
}
}
return messages;
@ -314,8 +313,7 @@ public class Pop3Folder {
} catch (IOException ioe) {
throw new MessagingException("fetch", ioe);
}
for (int i = 0, count = messages.size(); i < count; i++) {
Pop3Message pop3Message = messages.get(i);
for (Pop3Message pop3Message : messages) {
try {
if (fp.contains(FetchProfile.Item.BODY)) {
fetchBody(pop3Message, -1);
@ -337,7 +335,7 @@ public class Pop3Folder {
pop3Message.setBody(null);
}
if (listener != null && !(fp.contains(FetchProfile.Item.ENVELOPE) && fp.size() == 1)) {
listener.messageFinished(pop3Message, i, count);
listener.messageFinished(pop3Message);
}
} catch (IOException ioe) {
throw new MessagingException("Unable to fetch message", ioe);
@ -361,8 +359,7 @@ public class Pop3Folder {
* In extreme cases we'll do a command per message instead of a bulk request
* to hopefully save some time and bandwidth.
*/
for (int i = 0, count = messages.size(); i < count; i++) {
Pop3Message message = messages.get(i);
for (Pop3Message message : messages) {
String response = connection.executeSimpleCommand(
String.format(Locale.US, LIST_COMMAND + " %d",
uidToMsgNumMap.get(message.getUid())));
@ -371,7 +368,7 @@ public class Pop3Folder {
int msgSize = Integer.parseInt(listParts[2]);
message.setSize(msgSize);
if (listener != null) {
listener.messageFinished(message, i, count);
listener.messageFinished(message);
}
}
} else {
@ -393,7 +390,7 @@ public class Pop3Folder {
if (pop3Message != null && msgUidIndex.contains(pop3Message.getUid())) {
pop3Message.setSize(msgSize);
if (listener != null) {
listener.messageFinished(pop3Message, i, count);
listener.messageFinished(pop3Message);
}
i++;
}

View file

@ -207,7 +207,6 @@ public class WebDavFolder {
List<WebDavMessage> messages = new ArrayList<>();
String[] uids;
Map<String, String> headers = new HashMap<>();
int uidsLength;
String messageBody;
int prevStart = start;
@ -232,15 +231,14 @@ public class WebDavFolder {
DataSet dataset = store.processRequest(this.mFolderUrl, "SEARCH", messageBody, headers);
uids = dataset.getUids();
Map<String, String> uidToUrl = dataset.getUidToUrl();
uidsLength = uids.length;
for (int i = 0; i < uidsLength; i++) {
WebDavMessage message = new WebDavMessage(uids[i], this);
message.setUrl(uidToUrl.get(uids[i]));
for (String uid : uids) {
WebDavMessage message = new WebDavMessage(uid, this);
message.setUrl(uidToUrl.get(uid));
messages.add(message);
if (listener != null) {
listener.messageFinished(message, i, uidsLength);
listener.messageFinished(message);
}
}
@ -306,8 +304,7 @@ public class WebDavFolder {
/**
* We can't hand off to processRequest() since we need the stream to parse.
*/
for (int i = 0, count = messages.size(); i < count; i++) {
WebDavMessage wdMessage = messages.get(i);
for (WebDavMessage wdMessage : messages) {
int statusCode = 0;
/**
@ -398,7 +395,7 @@ public class WebDavFolder {
}
if (listener != null) {
listener.messageFinished(wdMessage, i, count);
listener.messageFinished(wdMessage);
}
}
}
@ -504,10 +501,7 @@ public class WebDavFolder {
Map<String, ParsedMessageEnvelope> envelopes = dataset.getMessageEnvelopes();
int count = messages.size();
for (int i = messages.size() - 1; i >= 0; i--) {
WebDavMessage message = messages.get(i);
for (WebDavMessage message : messages) {
ParsedMessageEnvelope envelope = envelopes.get(message.getUid());
if (envelope != null) {
message.setNewHeaders(envelope);
@ -517,7 +511,7 @@ public class WebDavFolder {
}
if (listener != null) {
listener.messageFinished(messages.get(i), i, count);
listener.messageFinished(message);
}
}
}

View file

@ -221,7 +221,7 @@ public class WebDavFolderTest {
FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.BODY_SANE);
folder.fetch(messages, profile, listener, MAX_DOWNLOAD_SIZE);
verify(listener, times(25)).messageFinished(any(WebDavMessage.class), anyInt(), eq(25));
verify(listener, times(25)).messageFinished(any(WebDavMessage.class));
}
@Test
@ -251,7 +251,7 @@ public class WebDavFolderTest {
profile.add(FetchProfile.Item.FLAGS);
profile.add(FetchProfile.Item.BODY);
folder.fetch(messages, profile, listener, MAX_DOWNLOAD_SIZE);
verify(listener, times(25)).messageFinished(any(WebDavMessage.class), anyInt(), anyInt());
verify(listener, times(25)).messageFinished(any(WebDavMessage.class));
}
private void setupStoreForMessageFetching() {
@ -291,7 +291,7 @@ public class WebDavFolderTest {
FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.BODY_SANE);
folder.fetch(messages, profile, listener, MAX_DOWNLOAD_SIZE);
verify(listener, times(25)).messageFinished(any(WebDavMessage.class), anyInt(), eq(25));
verify(listener, times(25)).messageFinished(any(WebDavMessage.class));
}
@Test
@ -321,7 +321,7 @@ public class WebDavFolderTest {
FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.BODY_SANE);
folder.fetch(messages, profile, listener, MAX_DOWNLOAD_SIZE);
verify(listener, times(25)).messageFinished(any(WebDavMessage.class), anyInt(), eq(25));
verify(listener, times(25)).messageFinished(any(WebDavMessage.class));
}
@Test
@ -387,7 +387,7 @@ public class WebDavFolderTest {
folder.getMessages(messageStart, messageEnd, listener);
verify(listener, times(5)).messageFinished(any(WebDavMessage.class), anyInt(), eq(5));
verify(listener, times(5)).messageFinished(any(WebDavMessage.class));
}
@Test