mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Always include currently opened message in the message list
This should fix various bugs where moving to the next/previous message didn't work.
This commit is contained in:
parent
79059e30da
commit
f16082eab3
@ -1118,15 +1118,17 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
} else {
|
} else {
|
||||||
mMessageViewContainer.removeView(mMessageViewPlaceHolder);
|
mMessageViewContainer.removeView(mMessageViewPlaceHolder);
|
||||||
|
|
||||||
|
if (mMessageListFragment != null) {
|
||||||
|
mMessageListFragment.setActiveMessage(messageReference);
|
||||||
|
}
|
||||||
|
|
||||||
MessageViewFragment fragment = MessageViewFragment.newInstance(messageReference);
|
MessageViewFragment fragment = MessageViewFragment.newInstance(messageReference);
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
ft.replace(R.id.message_view_container, fragment);
|
ft.replace(R.id.message_view_container, fragment);
|
||||||
mMessageViewFragment = fragment;
|
mMessageViewFragment = fragment;
|
||||||
ft.commit();
|
ft.commit();
|
||||||
|
|
||||||
if (mDisplayMode == DisplayMode.SPLIT_VIEW) {
|
if (mDisplayMode != DisplayMode.SPLIT_VIEW) {
|
||||||
mMessageListFragment.setActiveMessage(messageReference);
|
|
||||||
} else {
|
|
||||||
showMessageView();
|
showMessageView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1042,12 +1042,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
mSenderAboveSubject = K9.messageListSenderAboveSubject();
|
mSenderAboveSubject = K9.messageListSenderAboveSubject();
|
||||||
|
|
||||||
if (!mLoaderJustInitialized) {
|
if (!mLoaderJustInitialized) {
|
||||||
// Refresh the message list
|
restartLoader();
|
||||||
LoaderManager loaderManager = getLoaderManager();
|
|
||||||
for (int i = 0; i < mAccountUuids.length; i++) {
|
|
||||||
loaderManager.restartLoader(i, null, this);
|
|
||||||
mCursorValid[i] = false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
mLoaderJustInitialized = false;
|
mLoaderJustInitialized = false;
|
||||||
}
|
}
|
||||||
@ -1090,6 +1085,19 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
updateTitle();
|
updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void restartLoader() {
|
||||||
|
if (mCursorValid == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh the message list
|
||||||
|
LoaderManager loaderManager = getLoaderManager();
|
||||||
|
for (int i = 0; i < mAccountUuids.length; i++) {
|
||||||
|
loaderManager.restartLoader(i, null, this);
|
||||||
|
mCursorValid[i] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initializePullToRefresh(LayoutInflater inflater, View layout) {
|
private void initializePullToRefresh(LayoutInflater inflater, View layout) {
|
||||||
mPullToRefreshView = (PullToRefreshListView) layout.findViewById(R.id.message_list);
|
mPullToRefreshView = (PullToRefreshListView) layout.findViewById(R.id.message_list);
|
||||||
|
|
||||||
@ -3222,7 +3230,19 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
StringBuilder query = new StringBuilder();
|
StringBuilder query = new StringBuilder();
|
||||||
List<String> queryArgs = new ArrayList<String>();
|
List<String> queryArgs = new ArrayList<String>();
|
||||||
if (needConditions) {
|
if (needConditions) {
|
||||||
|
boolean selectActive = mActiveMessage != null && mActiveMessage.accountUuid.equals(accountUuid);
|
||||||
|
|
||||||
|
if (selectActive) {
|
||||||
|
query.append("(" + MessageColumns.UID + " = ? AND " + SpecialColumns.FOLDER_NAME + " = ?) OR (");
|
||||||
|
queryArgs.add(mActiveMessage.uid);
|
||||||
|
queryArgs.add(mActiveMessage.folderName);
|
||||||
|
}
|
||||||
|
|
||||||
SqlQueryBuilder.buildWhereClause(account, mSearch.getConditions(), query, queryArgs);
|
SqlQueryBuilder.buildWhereClause(account, mSearch.getConditions(), query, queryArgs);
|
||||||
|
|
||||||
|
if (selectActive) {
|
||||||
|
query.append(')');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String selection = query.toString();
|
String selection = query.toString();
|
||||||
@ -3453,6 +3473,13 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
*/
|
*/
|
||||||
public void setActiveMessage(MessageReference messageReference) {
|
public void setActiveMessage(MessageReference messageReference) {
|
||||||
mActiveMessage = messageReference;
|
mActiveMessage = messageReference;
|
||||||
|
|
||||||
|
// Reload message list with modified query that always includes the active message
|
||||||
|
if (isAdded()) {
|
||||||
|
restartLoader();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redraw list immediately
|
||||||
if (mAdapter != null) {
|
if (mAdapter != null) {
|
||||||
mAdapter.notifyDataSetChanged();
|
mAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user