Ejemplo n.º 1
0
  @Override
  protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();

    if (mContactAdapter != null && mContactAdapter.getCursor() != null) {
      mContactAdapter.getCursor().close();
      mContactAdapter = null;
    }
  }
 @Override
 protected void onPostExecute(List<Contact> result) {
   if (result != null) {
     ContactAdapter adapter = (ContactAdapter) contactList.getAdapter();
     adapter.refresh(result);
   }
   // FIXME we don't have to do this every time!
   loadingProgress.setVisibility(View.GONE);
   contactList.setEmptyView(emptyList);
 }
Ejemplo n.º 3
0
  public void doFilter(Uri uri, String filterString) {
    if (!uri.equals(mUri)) {
      mUri = uri;

      Cursor contactCursor = runQuery(filterString);

      if (mContactAdapter == null) {
        mContactAdapter = new ContactAdapter(mContext, contactCursor);
        mFilter = mContactAdapter.getFilter();
        mFilterList.setAdapter(mContactAdapter);
      } else {
        mContactAdapter.changeCursor(contactCursor);
      }

      // contactCursor.close();

    } else {
      mFilter.filter(filterString);
    }
  }
  private void refreshList() {
    this.contact_adapter.clear();
    ContactRepositoryInterface datasource =
        ContactRepositoryFactory.getInstance().getContactRepository(this, this);
    datasource.open();
    for (Contact c : datasource.all()) {
      this.contact_adapter.add(c);
    }
    datasource.close();
    this.contact_adapter.notifyDataSetChanged();

    EditText search_box = (EditText) findViewById(R.id.search_box);
    contact_adapter.getFilter().filter(search_box.getText().toString());
  }
 @Override
 protected void onResume() {
   super.onResume();
   mAdapter.notifyDataSetChanged();
 }
Ejemplo n.º 6
0
 public Cursor getContactAtPosition(int position) {
   return (Cursor) mContactAdapter.getItem(position);
 }