Small fixes/clean-ups.

- Fixed account selector default account look-up
- Renamed MessageListFragment.onRestoreInstanceState
  to loadState.
  (Activity.onRestoreInstanceState is called after onStart,
  but this one is called in onCreate, so it wasn't a good
  idea to use the same name.)
- Changed mailbox cursur requery timeout to 3 seconds
- Added some TODOs.

Change-Id: Ia2242cd9f74936d24756b800eacd126958eed330
This commit is contained in:
Makoto Onuki 2010-08-04 11:33:52 -07:00
parent 8ac10f28cb
commit 94506fdaf6
6 changed files with 14 additions and 7 deletions

View File

@ -34,6 +34,8 @@ import android.widget.TextView;
* TODO Use layout? Or use the standard resources that ActionBarDemo uses?
* TODO Revisit the sort order when we get more detailed UI spec. (current sort order makes things
* simpler for now.) Maybe we can just use SimpleCursorAdapter.
*
* TODO We actually don't need the auto-requery. Just refresh it when we modify accounts.
*/
public class AccountSelectorAdapter extends CursorAdapter {
private static final int AUTO_REQUERY_TIMEOUT = 5 * 1000; // in ms

View File

@ -25,7 +25,6 @@ import android.app.LoaderManager.LoaderCallbacks;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
@ -41,6 +40,8 @@ import java.security.InvalidParameterException;
* - call bindActivityInfo() to provide the account ID and set callbacks
* - provide callbacks for onOpen and onRefresh
* - pass-through implementations of onCreateContextMenu() and onContextItemSelected() (temporary)
*
* TODO Restoring ListView state -- don't do this when changing accounts
*/
public class MailboxListFragment extends ListFragment implements OnItemClickListener {
private static final int LOADER_ID_MAILBOX_LIST = 1;

View File

@ -16,6 +16,7 @@
package com.android.email.activity;
import com.android.email.Email;
import com.android.email.R;
import com.android.email.Utility;
import com.android.email.data.ThrottlingCursorLoader;
@ -31,6 +32,7 @@ import android.database.MatrixCursor;
import android.database.MatrixCursor.RowBuilder;
import android.database.MergeCursor;
import android.graphics.Typeface;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -48,7 +50,7 @@ import android.widget.TextView;
* TODO Unit test, when UI is settled.
*/
/* package */ class MailboxesAdapter extends CursorAdapter {
private static final int AUTO_REQUERY_TIMEOUT = 5000; // in ms
private static final int AUTO_REQUERY_TIMEOUT = 3 * 1000; // in ms
private static final String[] PROJECTION = new String[] { MailboxColumns.ID,
MailboxColumns.DISPLAY_NAME, MailboxColumns.TYPE, MailboxColumns.UNREAD_COUNT,
@ -131,6 +133,9 @@ import android.widget.TextView;
* @return mailboxes Loader for an account.
*/
public static Loader<Cursor> createLoader(Context context, long accountId) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
Log.d(Email.LOG_TAG, "MailboxesAdapter createLoader accountId=" + accountId);
}
return new MailboxesLoader(context, accountId);
}

View File

@ -167,7 +167,7 @@ public class MessageListFragment extends ListFragment implements OnItemClickList
if (savedInstanceState != null) {
// Fragment doesn't have this method. Call it manually.
onRestoreInstanceState(savedInstanceState);
loadState(savedInstanceState);
}
}
@ -238,7 +238,7 @@ public class MessageListFragment extends ListFragment implements OnItemClickList
}
// Unit tests use it
/* package */ void onRestoreInstanceState(Bundle savedInstanceState) {
/* package */ void loadState(Bundle savedInstanceState) {
mSavedItemTop = savedInstanceState.getInt(STATE_SELECTED_ITEM_TOP, 0);
mSavedItemPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION, -1);
Set<Long> checkedset = mListAdapter.getSelectedSet();

View File

@ -375,8 +375,7 @@ MessageListXLFragmentManager.TargetActivity {
// Find the currently selected account, and select it.
int defaultSelection = 0;
if (mFragmentManager.isAccountSelected()) {
// Need to change the selection
accountsCursor.moveToFirst();
accountsCursor.moveToPosition(-1);
int i = 0;
while (accountsCursor.moveToNext()) {
final long accountId = AccountSelectorAdapter.getAccountId(accountsCursor);

View File

@ -152,7 +152,7 @@ public class MessageListUnitTests
Set<Long> checkedset = ((MessagesAdapter)mListAdapter).getSelectedSet();
assertEquals(0, checkedset.size());
bundle.putLongArray(STATE_CHECKED_ITEMS, checkedarray);
mMessageList.getListFragmentForTest().onRestoreInstanceState(bundle);
mMessageList.getListFragmentForTest().loadState(bundle);
checkedset = ((MessagesAdapter)mListAdapter).getSelectedSet();
assertEquals(3, checkedset.size());
assertTrue(checkedset.contains(1L));