continue to extract attachment code out to AttachmentView

This commit is contained in:
Jesse Vincent 2011-01-06 16:56:37 +00:00
parent 19c5324316
commit 39ef6584a8
2 changed files with 24 additions and 31 deletions

View File

@ -1484,30 +1484,6 @@ public class MessageView extends K9Activity implements OnClickListener
mListener); mListener);
} }
private void onDownloadAttachment(AttachmentView attachment)
{
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
{
/*
* Abort early if there's no place to save the attachment. We don't want to spend
* the time downloading it and then abort.
*/
Toast.makeText(this,
getString(R.string.message_view_status_attachment_not_saved),
Toast.LENGTH_SHORT).show();
return;
}
if (mMessage != null)
{
mController.loadAttachment(
mAccount,
mMessage,
attachment.part,
new Object[] {true, attachment},
mListener);
}
}
private void onShowPictures() private void onShowPictures()
{ {
// TODO: Download attachments that are used as inline image // TODO: Download attachments that are used as inline image
@ -1571,7 +1547,7 @@ public class MessageView extends K9Activity implements OnClickListener
onPrevious(); onPrevious();
break; break;
case R.id.download: case R.id.download:
onDownloadAttachment((AttachmentView) view); ((AttachmentView)view).saveFile();
break; break;
case R.id.show_pictures: case R.id.show_pictures:
onShowPictures(); onShowPictures();
@ -1974,7 +1950,7 @@ public class MessageView extends K9Activity implements OnClickListener
AttachmentView attachment = (AttachmentView) params[1]; AttachmentView attachment = (AttachmentView) params[1];
if (download) if (download)
{ {
attachment.saveFile(); attachment.writeFile();
} }
else else

View File

@ -185,13 +185,10 @@ public class AttachmentView extends FrameLayout
private void onSaveButtonClicked() private void onSaveButtonClicked()
{ {
if (mMessage != null) saveFile();
{
mController.loadAttachment( mAccount, mMessage, part, new Object[] { true, this }, mListener);
}
} }
public void saveFile () public void writeFile ()
{ {
try try
{ {
@ -212,6 +209,26 @@ public class AttachmentView extends FrameLayout
} }
} }
public void saveFile()
{
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
{
/*
* Abort early if there's no place to save the attachment. We don't want to spend
* the time downloading it and then abort.
*/
Toast.makeText(mContext,
mContext.getString(R.string.message_view_status_attachment_not_saved),
Toast.LENGTH_SHORT).show();
return;
}
if (mMessage != null)
{
mController.loadAttachment( mAccount, mMessage, part, new Object[] {true, this}, mListener);
}
}
public void showFile() public void showFile()
{ {
Uri uri = AttachmentProvider.getAttachmentUri( mAccount, part.getAttachmentId()); Uri uri = AttachmentProvider.getAttachmentUri( mAccount, part.getAttachmentId());