mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
Fix NullPointerException when the user clicks on a "new mail"
notification. Resolves Issue 1001
This commit is contained in:
parent
81fd4749cc
commit
e1c686d40d
@ -318,6 +318,10 @@ public class FolderList extends K9ListActivity
|
|||||||
initialFolder = null;
|
initialFolder = null;
|
||||||
mStartup = false;
|
mStartup = false;
|
||||||
savedFolderName = savedInstanceState.getString(STATE_CURRENT_FOLDER);
|
savedFolderName = savedInstanceState.getString(STATE_CURRENT_FOLDER);
|
||||||
|
if (savedFolderName != null)
|
||||||
|
{
|
||||||
|
mSelectedContextFolder = mAdapter.getFolder(savedFolderName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mStartup
|
if (mStartup
|
||||||
@ -328,51 +332,59 @@ public class FolderList extends K9ListActivity
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
|
||||||
|
|
||||||
mListView = getListView();
|
initializeActivityView();
|
||||||
mListView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_INSET);
|
|
||||||
mListView.setLongClickable(true);
|
|
||||||
mListView.setFastScrollEnabled(true);
|
|
||||||
mListView.setScrollingCacheEnabled(true);
|
|
||||||
mListView.setOnItemClickListener(new OnItemClickListener()
|
|
||||||
{
|
|
||||||
public void onItemClick(AdapterView parent, View v, int itemPosition, long id)
|
|
||||||
{
|
|
||||||
MessageList.actionHandleFolder(FolderList.this, mAccount, ((FolderInfoHolder)mAdapter.getItem(id)).name, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
registerForContextMenu(mListView);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We manually save and restore the list's state because our adapter is
|
|
||||||
* slow.
|
|
||||||
*/
|
|
||||||
mListView.setSaveEnabled(false);
|
|
||||||
|
|
||||||
mInflater = getLayoutInflater();
|
|
||||||
|
|
||||||
mAdapter = new FolderListAdapter();
|
|
||||||
|
|
||||||
final Object previousData = getLastNonConfigurationInstance();
|
|
||||||
|
|
||||||
if (previousData != null)
|
|
||||||
{
|
|
||||||
//noinspection unchecked
|
|
||||||
mAdapter.mFolders = (ArrayList<FolderInfoHolder>) previousData;
|
|
||||||
}
|
|
||||||
|
|
||||||
setListAdapter(mAdapter);
|
|
||||||
|
|
||||||
setTitle(mAccount.getDescription());
|
|
||||||
|
|
||||||
if (savedFolderName != null)
|
|
||||||
{
|
|
||||||
mSelectedContextFolder = mAdapter.getFolder(savedFolderName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* There are two times when we might need to initialize the activity view
|
||||||
|
* onCreate
|
||||||
|
* OR
|
||||||
|
* onResume if the initial onCreate opened a folder directly
|
||||||
|
*/
|
||||||
|
private void initializeActivityView()
|
||||||
|
{
|
||||||
|
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||||
|
|
||||||
|
mListView = getListView();
|
||||||
|
mListView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_INSET);
|
||||||
|
mListView.setLongClickable(true);
|
||||||
|
mListView.setFastScrollEnabled(true);
|
||||||
|
mListView.setScrollingCacheEnabled(true);
|
||||||
|
mListView.setOnItemClickListener(new OnItemClickListener()
|
||||||
|
{
|
||||||
|
public void onItemClick(AdapterView parent, View v, int itemPosition, long id)
|
||||||
|
{
|
||||||
|
MessageList.actionHandleFolder(FolderList.this, mAccount, ((FolderInfoHolder)mAdapter.getItem(id)).name, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
registerForContextMenu(mListView);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We manually save and restore the list's state because our adapter is
|
||||||
|
* slow.
|
||||||
|
*/
|
||||||
|
mListView.setSaveEnabled(true);
|
||||||
|
|
||||||
|
mInflater = getLayoutInflater();
|
||||||
|
|
||||||
|
mAdapter = new FolderListAdapter();
|
||||||
|
|
||||||
|
final Object previousData = getLastNonConfigurationInstance();
|
||||||
|
|
||||||
|
if (previousData != null)
|
||||||
|
{
|
||||||
|
//noinspection unchecked
|
||||||
|
mAdapter.mFolders = (ArrayList<FolderInfoHolder>) previousData;
|
||||||
|
}
|
||||||
|
|
||||||
|
setListAdapter(mAdapter);
|
||||||
|
|
||||||
|
setTitle(mAccount.getDescription());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override public Object onRetainNonConfigurationInstance()
|
@Override public Object onRetainNonConfigurationInstance()
|
||||||
{
|
{
|
||||||
return mAdapter.mFolders;
|
return mAdapter.mFolders;
|
||||||
@ -393,6 +405,9 @@ public class FolderList extends K9ListActivity
|
|||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
if (mAdapter == null)
|
||||||
|
initializeActivityView();
|
||||||
|
|
||||||
MessagingController.getInstance(getApplication()).addListener(mAdapter.mListener);
|
MessagingController.getInstance(getApplication()).addListener(mAdapter.mListener);
|
||||||
mAccount.refresh(Preferences.getPreferences(this));
|
mAccount.refresh(Preferences.getPreferences(this));
|
||||||
MessagingController.getInstance(getApplication()).getAccountUnreadCount(this, mAccount, mAdapter.mListener);
|
MessagingController.getInstance(getApplication()).getAccountUnreadCount(this, mAccount, mAdapter.mListener);
|
||||||
|
Loading…
Reference in New Issue
Block a user