0
0
mirror of https://github.com/thunderbird/thunderbird-android.git synced 2024-09-19 19:52:14 +02:00

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

View File

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

View File

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

View File

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

View File

@ -97,7 +97,7 @@ class TestImapFolder(override val serverId: String) : ImapFolder {
) { ) {
if (messages.isEmpty()) return if (messages.isEmpty()) return
messages.forEachIndexed { index, imapMessage -> for (imapMessage in messages) {
val uid = imapMessage.uid.toLong() val uid = imapMessage.uid.toLong()
val flags = messageFlags[uid].orEmpty().toSet() val flags = messageFlags[uid].orEmpty().toSet()
@ -109,7 +109,7 @@ class TestImapFolder(override val serverId: String) : ImapFolder {
} }
imapMessage.body = storedMessage.body 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, remoteFolder.fetch(unsyncedMessages, fp,
new MessageRetrievalListener<Pop3Message>() { new MessageRetrievalListener<Pop3Message>() {
@Override @Override
public void messageFinished(Pop3Message message, int number, int ofTotal) { public void messageFinished(Pop3Message message) {
try { try {
if (message.isSet(Flag.DELETED) || message.olderThan(earliestDate)) { if (message.isSet(Flag.DELETED) || message.olderThan(earliestDate)) {
if (message.isSet(Flag.DELETED)) { if (message.isSet(Flag.DELETED)) {
@ -467,7 +467,7 @@ class Pop3Sync {
remoteFolder.fetch(smallMessages, remoteFolder.fetch(smallMessages,
fp, new MessageRetrievalListener<Pop3Message>() { fp, new MessageRetrievalListener<Pop3Message>() {
@Override @Override
public void messageFinished(final Pop3Message message, int number, int ofTotal) { public void messageFinished(final Pop3Message message) {
try { try {
// Store the updated message locally // Store the updated message locally

View File

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

View File

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

View File

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

View File

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

View File

@ -207,7 +207,6 @@ public class WebDavFolder {
List<WebDavMessage> messages = new ArrayList<>(); List<WebDavMessage> messages = new ArrayList<>();
String[] uids; String[] uids;
Map<String, String> headers = new HashMap<>(); Map<String, String> headers = new HashMap<>();
int uidsLength;
String messageBody; String messageBody;
int prevStart = start; int prevStart = start;
@ -232,15 +231,14 @@ public class WebDavFolder {
DataSet dataset = store.processRequest(this.mFolderUrl, "SEARCH", messageBody, headers); DataSet dataset = store.processRequest(this.mFolderUrl, "SEARCH", messageBody, headers);
uids = dataset.getUids(); uids = dataset.getUids();
Map<String, String> uidToUrl = dataset.getUidToUrl(); Map<String, String> uidToUrl = dataset.getUidToUrl();
uidsLength = uids.length;
for (int i = 0; i < uidsLength; i++) { for (String uid : uids) {
WebDavMessage message = new WebDavMessage(uids[i], this); WebDavMessage message = new WebDavMessage(uid, this);
message.setUrl(uidToUrl.get(uids[i])); message.setUrl(uidToUrl.get(uid));
messages.add(message); messages.add(message);
if (listener != null) { 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. * We can't hand off to processRequest() since we need the stream to parse.
*/ */
for (int i = 0, count = messages.size(); i < count; i++) { for (WebDavMessage wdMessage : messages) {
WebDavMessage wdMessage = messages.get(i);
int statusCode = 0; int statusCode = 0;
/** /**
@ -398,7 +395,7 @@ public class WebDavFolder {
} }
if (listener != null) { if (listener != null) {
listener.messageFinished(wdMessage, i, count); listener.messageFinished(wdMessage);
} }
} }
} }
@ -504,10 +501,7 @@ public class WebDavFolder {
Map<String, ParsedMessageEnvelope> envelopes = dataset.getMessageEnvelopes(); Map<String, ParsedMessageEnvelope> envelopes = dataset.getMessageEnvelopes();
int count = messages.size(); for (WebDavMessage message : messages) {
for (int i = messages.size() - 1; i >= 0; i--) {
WebDavMessage message = messages.get(i);
ParsedMessageEnvelope envelope = envelopes.get(message.getUid()); ParsedMessageEnvelope envelope = envelopes.get(message.getUid());
if (envelope != null) { if (envelope != null) {
message.setNewHeaders(envelope); message.setNewHeaders(envelope);
@ -517,7 +511,7 @@ public class WebDavFolder {
} }
if (listener != null) { 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(); FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.BODY_SANE); profile.add(FetchProfile.Item.BODY_SANE);
folder.fetch(messages, profile, listener, MAX_DOWNLOAD_SIZE); 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 @Test
@ -251,7 +251,7 @@ public class WebDavFolderTest {
profile.add(FetchProfile.Item.FLAGS); profile.add(FetchProfile.Item.FLAGS);
profile.add(FetchProfile.Item.BODY); profile.add(FetchProfile.Item.BODY);
folder.fetch(messages, profile, listener, MAX_DOWNLOAD_SIZE); 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() { private void setupStoreForMessageFetching() {
@ -291,7 +291,7 @@ public class WebDavFolderTest {
FetchProfile profile = new FetchProfile(); FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.BODY_SANE); profile.add(FetchProfile.Item.BODY_SANE);
folder.fetch(messages, profile, listener, MAX_DOWNLOAD_SIZE); 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 @Test
@ -321,7 +321,7 @@ public class WebDavFolderTest {
FetchProfile profile = new FetchProfile(); FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.BODY_SANE); profile.add(FetchProfile.Item.BODY_SANE);
folder.fetch(messages, profile, listener, MAX_DOWNLOAD_SIZE); 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 @Test
@ -387,7 +387,7 @@ public class WebDavFolderTest {
folder.getMessages(messageStart, messageEnd, listener); 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 @Test