コード例 #1
0
 @Override
 public void onLoadFinished(Loader<Cursor> arg0, Cursor cursor) {
   accountCursor = cursor;
   cursorAdapter.changeCursor(
       AccountCursorAdapter.createMergeCursor(getActivity(), accountCursor));
   if (cursor.getCount() > 0) {
     refresh();
   }
 }
コード例 #2
0
  // ///////////////////////////////////////////////////////////////////////////
  // DROPDOWN EVENTS
  // ///////////////////////////////////////////////////////////////////////////
  @Override
  public void onItemSelected(
      AdapterView<?> parentView, View selectedItemView, int position, long id) {
    Cursor cursor = (Cursor) parentView.getItemAtPosition(position);
    int accountId = cursor.getInt(AccountSchema.COLUMN_ID_ID);

    switch (accountId) {
      case AccountCursorAdapter.NETWORK_ITEM:
        ((MainActivity) getActivity()).displayNetworks();
        hideSlidingMenu(false);
        break;
      case AccountCursorAdapter.MANAGE_ITEM:
        ((MainActivity) getActivity()).displayAccounts();
        hideSlidingMenu(false);
        break;

      default:
        Account currentAccount = SessionUtils.getAccount(getActivity());
        if (currentAccount != null
            && cursor.getCount() > 1
            && currentAccount.getId() != cursor.getLong(AccountSchema.COLUMN_ID_ID)) {
          hideSlidingMenu(true);

          // Request session loading for the selected account.
          LocalBroadcastManager.getInstance(getActivity())
              .sendBroadcast(
                  new Intent(IntentIntegrator.ACTION_LOAD_ACCOUNT)
                      .putExtra(
                          IntentIntegrator.EXTRA_ACCOUNT_ID,
                          cursor.getLong(AccountSchema.COLUMN_ID_ID)));

          // Update dropdown menu (eventual new items to display)
          cursorAdapter.swapCursor(
              AccountCursorAdapter.createMergeCursor(getActivity(), accountCursor));
        }
        break;
    }
  }
コード例 #3
0
 @Override
 public void onLoaderReset(Loader<Cursor> arg0) {
   cursorAdapter.changeCursor(null);
 }