mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
Enable loading more search results from the server
This commit is contained in:
parent
b108e7a539
commit
5accadab00
@ -348,6 +348,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
|
|
||||||
private boolean mRemoteSearchPerformed = false;
|
private boolean mRemoteSearchPerformed = false;
|
||||||
private Future mRemoteSearchFuture = null;
|
private Future mRemoteSearchFuture = null;
|
||||||
|
public List<Message> mExtraSearchResults;
|
||||||
|
|
||||||
private String mTitle;
|
private String mTitle;
|
||||||
private LocalSearch mSearch = null;
|
private LocalSearch mSearch = null;
|
||||||
@ -606,26 +607,29 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
if (view == mFooterView) {
|
if (view == mFooterView) {
|
||||||
if (mCurrentFolder != null && !mSearch.isManualSearch()) {
|
if (mCurrentFolder != null && !mSearch.isManualSearch()) {
|
||||||
|
|
||||||
mController.loadMoreMessages(mAccount, mFolderName, null);
|
mController.loadMoreMessages(mAccount, mFolderName, null);
|
||||||
} /*else if (mRemoteSearch && mAdapter.mExtraSearchResults != null && mAdapter.mExtraSearchResults.size() > 0 && mSearchAccount != null) {
|
|
||||||
int numResults = mAdapter.mExtraSearchResults.size();
|
} else if (mCurrentFolder != null && isRemoteSearch() &&
|
||||||
Context appContext = getActivity().getApplicationContext();
|
mExtraSearchResults != null && mExtraSearchResults.size() > 0) {
|
||||||
Account account = Preferences.getPreferences(appContext).getAccount(mSearchAccount);
|
|
||||||
if (account == null) {
|
int numResults = mExtraSearchResults.size();
|
||||||
updateFooter("", false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int limit = mAccount.getRemoteSearchNumResults();
|
int limit = mAccount.getRemoteSearchNumResults();
|
||||||
List<Message> toProcess = mAdapter.mExtraSearchResults;
|
|
||||||
|
List<Message> toProcess = mExtraSearchResults;
|
||||||
|
|
||||||
if (limit > 0 && numResults > limit) {
|
if (limit > 0 && numResults > limit) {
|
||||||
toProcess = toProcess.subList(0, limit);
|
toProcess = toProcess.subList(0, limit);
|
||||||
mAdapter.mExtraSearchResults = mAdapter.mExtraSearchResults.subList(limit, mAdapter.mExtraSearchResults.size());
|
mExtraSearchResults = mExtraSearchResults.subList(limit,
|
||||||
|
mExtraSearchResults.size());
|
||||||
} else {
|
} else {
|
||||||
mAdapter.mExtraSearchResults = null;
|
mExtraSearchResults = null;
|
||||||
updateFooter("", false);
|
updateFooter("", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
mController.loadSearchResults(mAccount, mCurrentFolder.name, toProcess, mListener);
|
mController.loadSearchResults(mAccount, mCurrentFolder.name, toProcess, mListener);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1444,6 +1448,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
public void remoteSearchFinished(Account acct, String folder, int numResults, List<Message> extraResults) {
|
public void remoteSearchFinished(Account acct, String folder, int numResults, List<Message> extraResults) {
|
||||||
mHandler.progress(false);
|
mHandler.progress(false);
|
||||||
mHandler.remoteSearchFinished();
|
mHandler.remoteSearchFinished();
|
||||||
|
mExtraSearchResults = extraResults;
|
||||||
if (extraResults != null && extraResults.size() > 0) {
|
if (extraResults != null && extraResults.size() > 0) {
|
||||||
mHandler.updateFooter(String.format(mContext.getString(R.string.load_more_messages_fmt), acct.getRemoteSearchNumResults()), false);
|
mHandler.updateFooter(String.format(mContext.getString(R.string.load_more_messages_fmt), acct.getRemoteSearchNumResults()), false);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user