Clean up MessageViewFragment a bit

This commit is contained in:
cketti 2015-09-07 04:12:55 +02:00
parent 1f16002685
commit bb5d0682c3
2 changed files with 25 additions and 24 deletions

View file

@ -54,6 +54,8 @@ public class MessageTopView extends LinearLayout implements ShowPicturesControll
setShowPicturesButtonListener();
containerViews = (LinearLayout) findViewById(R.id.message_containers);
hideHeaderView();
}
private void setShowPicturesButtonListener() {
@ -129,7 +131,7 @@ public class MessageTopView extends LinearLayout implements ShowPicturesControll
return mHeaderContainer.additionalHeadersVisible();
}
public void resetHeaderView() {
private void hideHeaderView() {
mHeaderContainer.setVisibility(View.GONE);
}

View file

@ -170,14 +170,20 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (savedInstanceState != null) {
mPgpData = (PgpData) savedInstanceState.get(STATE_PGP_DATA);
}
initializePgpData(savedInstanceState);
Bundle arguments = getArguments();
MessageReference messageReference = arguments.getParcelable(ARG_REFERENCE);
displayMessage(messageReference, (mPgpData == null));
displayMessage(messageReference);
}
private void initializePgpData(Bundle savedInstanceState) {
if (savedInstanceState != null) {
mPgpData = (PgpData) savedInstanceState.get(STATE_PGP_DATA);
} else {
mPgpData = new PgpData();
}
}
@Override
@ -186,23 +192,16 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
outState.putSerializable(STATE_PGP_DATA, mPgpData);
}
private void displayMessage(MessageReference ref, boolean resetPgpData) {
mMessageReference = ref;
private void displayMessage(MessageReference messageReference) {
mMessageReference = messageReference;
if (K9.DEBUG) {
Log.d(K9.LOG_TAG, "MessageView displaying message " + mMessageReference);
}
Context appContext = getActivity().getApplicationContext();
Activity activity = getActivity();
Context appContext = activity.getApplicationContext();
mAccount = Preferences.getPreferences(appContext).getAccount(mMessageReference.getAccountUuid());
messageCryptoHelper = new MessageCryptoHelper(getActivity(), mAccount, this);
if (resetPgpData) {
// start with fresh, empty PGP data
mPgpData = new PgpData();
}
// Clear previous message
mMessageView.resetView();
mMessageView.resetHeaderView();
messageCryptoHelper = new MessageCryptoHelper(activity, mAccount, this);
startLoadingMessageFromDatabase();
@ -268,14 +267,14 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
getLoaderManager().initLoader(DECODE_MESSAGE_LOADER_ID, null, decodeMessageLoaderCallback);
}
private void onDecodeMessageFinished(MessageViewInfo messageContainer) {
this.messageViewInfo = messageContainer;
showMessage(messageContainer);
private void onDecodeMessageFinished(MessageViewInfo messageViewInfo) {
this.messageViewInfo = messageViewInfo;
showMessage(messageViewInfo);
}
private void showMessage(MessageViewInfo messageContainer) {
private void showMessage(MessageViewInfo messageViewInfo) {
try {
mMessageView.setMessage(mAccount, messageContainer);
mMessageView.setMessage(mAccount, messageViewInfo);
mMessageView.setShowDownloadButton(mMessage);
} catch (MessagingException e) {
Log.e(K9.LOG_TAG, "Error while trying to display message", e);
@ -747,9 +746,9 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
}
@Override
public void onLoadFinished(Loader<MessageViewInfo> loader, MessageViewInfo messageContainer) {
public void onLoadFinished(Loader<MessageViewInfo> loader, MessageViewInfo messageViewInfo) {
setProgress(false);
onDecodeMessageFinished(messageContainer);
onDecodeMessageFinished(messageViewInfo);
}
@Override