mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Fixed warnings about unchecked casts by extracting the code to methods and using the @SuppressWarnings annotation on them.
This commit is contained in:
parent
d48ec4892a
commit
365b106753
@ -376,13 +376,19 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
mSelectedContextAccount = Preferences.getPreferences(this).getAccount(accountUuid);
|
||||
}
|
||||
|
||||
if (icicle != null)
|
||||
restoreAccountStats(icicle);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void restoreAccountStats(Bundle icicle)
|
||||
{
|
||||
if (icicle != null)
|
||||
{
|
||||
Map<String, AccountStats> oldStats = (Map<String, AccountStats>)icicle.get(ACCOUNT_STATS);
|
||||
if (oldStats != null)
|
||||
{
|
||||
Map<String, AccountStats> oldStats = (Map<String, AccountStats>)icicle.get(ACCOUNT_STATS);
|
||||
if (oldStats != null)
|
||||
{
|
||||
accountStats.putAll(oldStats);
|
||||
}
|
||||
accountStats.putAll(oldStats);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -348,14 +348,7 @@ public class FolderList extends K9ListActivity
|
||||
private void initializeActivityView()
|
||||
{
|
||||
mAdapter = new FolderListAdapter();
|
||||
|
||||
final Object previousData = getLastNonConfigurationInstance();
|
||||
|
||||
if (previousData != null)
|
||||
{
|
||||
//noinspection unchecked
|
||||
mAdapter.mFolders = (ArrayList<FolderInfoHolder>) previousData;
|
||||
}
|
||||
restorePreviousData();
|
||||
|
||||
setListAdapter(mAdapter);
|
||||
|
||||
@ -363,6 +356,17 @@ public class FolderList extends K9ListActivity
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void restorePreviousData()
|
||||
{
|
||||
final Object previousData = getLastNonConfigurationInstance();
|
||||
|
||||
if (previousData != null)
|
||||
{
|
||||
mAdapter.mFolders = (ArrayList<FolderInfoHolder>) previousData;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override public Object onRetainNonConfigurationInstance()
|
||||
{
|
||||
|
@ -739,13 +739,7 @@ public class MessageList
|
||||
}
|
||||
|
||||
mAdapter = new MessageListAdapter();
|
||||
final Object previousData = getLastNonConfigurationInstance();
|
||||
|
||||
if (previousData != null)
|
||||
{
|
||||
//noinspection unchecked
|
||||
mAdapter.messages.addAll((List<MessageInfoHolder>) previousData);
|
||||
}
|
||||
restorePreviousData();
|
||||
|
||||
if (mFolderName != null)
|
||||
{
|
||||
@ -756,6 +750,17 @@ public class MessageList
|
||||
mListView.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void restorePreviousData()
|
||||
{
|
||||
final Object previousData = getLastNonConfigurationInstance();
|
||||
|
||||
if (previousData != null)
|
||||
{
|
||||
mAdapter.messages.addAll((List<MessageInfoHolder>) previousData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause()
|
||||
{
|
||||
|
@ -493,8 +493,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
||||
Uri uri = intent.getData();
|
||||
if (icicle != null)
|
||||
{
|
||||
mMessageReference = (MessageReference) icicle.getSerializable(EXTRA_MESSAGE_REFERENCE);
|
||||
mMessageReferences = (ArrayList<MessageReference>) icicle.getSerializable(EXTRA_MESSAGE_REFERENCES);
|
||||
restoreMessageReferences(icicle);
|
||||
mPgpData = (PgpData) icicle.getSerializable(STATE_PGP_DATA);
|
||||
updateDecryptLayout();
|
||||
}
|
||||
@ -502,8 +501,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
||||
{
|
||||
if (uri == null)
|
||||
{
|
||||
mMessageReference = (MessageReference) intent.getSerializableExtra(EXTRA_MESSAGE_REFERENCE);
|
||||
mMessageReferences = (ArrayList<MessageReference>) intent.getSerializableExtra(EXTRA_MESSAGE_REFERENCES);
|
||||
restoreMessageReferences(icicle);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -558,6 +556,13 @@ public class MessageView extends K9Activity implements OnClickListener
|
||||
displayMessage(mMessageReference);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void restoreMessageReferences(Bundle icicle)
|
||||
{
|
||||
mMessageReference = (MessageReference) icicle.getSerializable(EXTRA_MESSAGE_REFERENCE);
|
||||
mMessageReferences = (ArrayList<MessageReference>) icicle.getSerializable(EXTRA_MESSAGE_REFERENCES);
|
||||
}
|
||||
|
||||
private void setupButtonViews()
|
||||
{
|
||||
setOnClickListener(R.id.from);
|
||||
|
Loading…
Reference in New Issue
Block a user