mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-30 13:12:25 -05:00
replace constant lookups of the MessagingController instance with a locally cached one
This commit is contained in:
parent
299c057cd4
commit
ed60cdfa5a
@ -136,6 +136,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
private static final int PREVIOUS = 1;
|
private static final int PREVIOUS = 1;
|
||||||
private static final int NEXT = 2;
|
private static final int NEXT = 2;
|
||||||
private int mLastDirection = PREVIOUS;
|
private int mLastDirection = PREVIOUS;
|
||||||
|
private MessagingController mController = MessagingController.getInstance(getApplication());
|
||||||
private MessageReference mNextMessage = null;
|
private MessageReference mNextMessage = null;
|
||||||
private MessageReference mPreviousMessage = null;
|
private MessageReference mPreviousMessage = null;
|
||||||
private Menu optionsMenu = null;
|
private Menu optionsMenu = null;
|
||||||
@ -1029,7 +1030,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
// start with fresh, empty PGP data
|
// start with fresh, empty PGP data
|
||||||
initializeCrypto(null);
|
initializeCrypto(null);
|
||||||
mTopView.setVisibility(View.VISIBLE);
|
mTopView.setVisibility(View.VISIBLE);
|
||||||
MessagingController.getInstance(getApplication()).loadMessageForView(
|
mController.loadMessageForView(
|
||||||
mAccount,
|
mAccount,
|
||||||
mMessageReference.folderName,
|
mMessageReference.folderName,
|
||||||
mMessageReference.uid,
|
mMessageReference.uid,
|
||||||
@ -1043,7 +1044,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
next.setEnabled(mNextMessage != null);
|
next.setEnabled(mNextMessage != null);
|
||||||
previous.setEnabled(mPreviousMessage != null);
|
previous.setEnabled(mPreviousMessage != null);
|
||||||
// If moving isn't support at all, then all of them must be disabled anyway.
|
// If moving isn't support at all, then all of them must be disabled anyway.
|
||||||
if (MessagingController.getInstance(getApplication()).isMoveCapable(mAccount))
|
if (mController.isMoveCapable(mAccount))
|
||||||
{
|
{
|
||||||
// Only enable the button if the Archive folder is not the current folder and not NONE.
|
// Only enable the button if the Archive folder is not the current folder and not NONE.
|
||||||
mArchive.setEnabled(!mMessageReference.folderName.equals(mAccount.getArchiveFolderName()) &&
|
mArchive.setEnabled(!mMessageReference.folderName.equals(mAccount.getArchiveFolderName()) &&
|
||||||
@ -1225,7 +1226,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
disableButtons();
|
disableButtons();
|
||||||
Message messageToDelete = mMessage;
|
Message messageToDelete = mMessage;
|
||||||
showNextMessageOrReturn();
|
showNextMessageOrReturn();
|
||||||
MessagingController.getInstance(getApplication()).deleteMessages(
|
mController.deleteMessages(
|
||||||
new Message[] {messageToDelete},
|
new Message[] {messageToDelete},
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
@ -1233,11 +1234,11 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
|
|
||||||
private void onRefile(String dstFolder)
|
private void onRefile(String dstFolder)
|
||||||
{
|
{
|
||||||
if (!MessagingController.getInstance(getApplication()).isMoveCapable(mAccount))
|
if (!mController.isMoveCapable(mAccount))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!MessagingController.getInstance(getApplication()).isMoveCapable(mMessage))
|
if (!mController.isMoveCapable(mMessage))
|
||||||
{
|
{
|
||||||
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
|
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
|
||||||
toast.show();
|
toast.show();
|
||||||
@ -1250,7 +1251,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showNextMessageOrReturn();
|
showNextMessageOrReturn();
|
||||||
MessagingController.getInstance(getApplication())
|
mController
|
||||||
.moveMessage(mAccount, srcFolder, messageToMove, dstFolder, null);
|
.moveMessage(mAccount, srcFolder, messageToMove, dstFolder, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1341,7 +1342,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
{
|
{
|
||||||
if (mMessage != null)
|
if (mMessage != null)
|
||||||
{
|
{
|
||||||
MessagingController.getInstance(getApplication()).setFlag(mAccount,
|
mController.setFlag(mAccount,
|
||||||
mMessage.getFolder().getName(), new String[] {mMessage.getUid()}, Flag.FLAGGED, !mMessage.isSet(Flag.FLAGGED));
|
mMessage.getFolder().getName(), new String[] {mMessage.getUid()}, Flag.FLAGGED, !mMessage.isSet(Flag.FLAGGED));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -1358,12 +1359,12 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
|
|
||||||
private void onMove()
|
private void onMove()
|
||||||
{
|
{
|
||||||
if ((!MessagingController.getInstance(getApplication()).isMoveCapable(mAccount))
|
if ((!mController.isMoveCapable(mAccount))
|
||||||
|| (mMessage == null))
|
|| (mMessage == null))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!MessagingController.getInstance(getApplication()).isMoveCapable(mMessage))
|
if (!mController.isMoveCapable(mMessage))
|
||||||
{
|
{
|
||||||
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
|
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
|
||||||
toast.show();
|
toast.show();
|
||||||
@ -1375,12 +1376,12 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
|
|
||||||
private void onCopy()
|
private void onCopy()
|
||||||
{
|
{
|
||||||
if ((!MessagingController.getInstance(getApplication()).isCopyCapable(mAccount))
|
if ((!mController.isCopyCapable(mAccount))
|
||||||
|| (mMessage == null))
|
|| (mMessage == null))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!MessagingController.getInstance(getApplication()).isCopyCapable(mMessage))
|
if (!mController.isCopyCapable(mMessage))
|
||||||
{
|
{
|
||||||
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
|
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
|
||||||
toast.show();
|
toast.show();
|
||||||
@ -1463,11 +1464,11 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
case ACTIVITY_CHOOSE_FOLDER_MOVE:
|
case ACTIVITY_CHOOSE_FOLDER_MOVE:
|
||||||
Message messageToMove = mMessage;
|
Message messageToMove = mMessage;
|
||||||
showNextMessageOrReturn();
|
showNextMessageOrReturn();
|
||||||
MessagingController.getInstance(getApplication()).moveMessage(mAccount,
|
mController.moveMessage(mAccount,
|
||||||
srcFolderName, messageToMove, destFolderName, null);
|
srcFolderName, messageToMove, destFolderName, null);
|
||||||
break;
|
break;
|
||||||
case ACTIVITY_CHOOSE_FOLDER_COPY:
|
case ACTIVITY_CHOOSE_FOLDER_COPY:
|
||||||
MessagingController.getInstance(getApplication()).copyMessage(mAccount,
|
mController.copyMessage(mAccount,
|
||||||
srcFolderName, mMessage, destFolderName, null);
|
srcFolderName, mMessage, destFolderName, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1480,7 +1481,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
{
|
{
|
||||||
if (mMessage != null)
|
if (mMessage != null)
|
||||||
{
|
{
|
||||||
MessagingController.getInstance(getApplication()).sendAlternate(this, mAccount, mMessage);
|
mController.sendAlternate(this, mAccount, mMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1524,7 +1525,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
{
|
{
|
||||||
if (mMessage != null)
|
if (mMessage != null)
|
||||||
{
|
{
|
||||||
MessagingController.getInstance(getApplication()).setFlag(
|
mController.setFlag(
|
||||||
mAccount,
|
mAccount,
|
||||||
mMessageReference.folderName,
|
mMessageReference.folderName,
|
||||||
new String[] { mMessage.getUid() },
|
new String[] { mMessage.getUid() },
|
||||||
@ -1550,7 +1551,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mDownloadRemainder.setEnabled(false);
|
mDownloadRemainder.setEnabled(false);
|
||||||
MessagingController.getInstance(getApplication()).loadMessageForViewRemote(
|
mController.loadMessageForViewRemote(
|
||||||
mAccount,
|
mAccount,
|
||||||
mMessageReference.folderName,
|
mMessageReference.folderName,
|
||||||
mMessageReference.uid,
|
mMessageReference.uid,
|
||||||
@ -1572,7 +1573,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
}
|
}
|
||||||
if (mMessage != null)
|
if (mMessage != null)
|
||||||
{
|
{
|
||||||
MessagingController.getInstance(getApplication()).loadAttachment(
|
mController.loadAttachment(
|
||||||
mAccount,
|
mAccount,
|
||||||
mMessage,
|
mMessage,
|
||||||
attachment.part,
|
attachment.part,
|
||||||
@ -1732,11 +1733,11 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
getMenuInflater().inflate(R.menu.message_view_option, menu);
|
getMenuInflater().inflate(R.menu.message_view_option, menu);
|
||||||
optionsMenu = menu;
|
optionsMenu = menu;
|
||||||
prepareMenuItems();
|
prepareMenuItems();
|
||||||
if (!MessagingController.getInstance(getApplication()).isCopyCapable(mAccount))
|
if (!mController.isCopyCapable(mAccount))
|
||||||
{
|
{
|
||||||
menu.findItem(R.id.copy).setVisible(false);
|
menu.findItem(R.id.copy).setVisible(false);
|
||||||
}
|
}
|
||||||
if (!MessagingController.getInstance(getApplication()).isMoveCapable(mAccount))
|
if (!mController.isMoveCapable(mAccount))
|
||||||
{
|
{
|
||||||
menu.findItem(R.id.move).setVisible(false);
|
menu.findItem(R.id.move).setVisible(false);
|
||||||
menu.findItem(R.id.archive).setVisible(false);
|
menu.findItem(R.id.archive).setVisible(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user