Java 类android.widget.CursorAdapter 实例源码

项目:Mybilibili    文件:MySearchView.java   
/**
 * 关注1
 * 模糊查询数据 & 显示到ListView列表上
 */
private void queryData(String tempName) {

    // 1. 模糊搜索
    Cursor cursor = helper.getReadableDatabase().rawQuery(
            "select id as _id,name from Search where name like '%" + tempName + "%' order by id desc ", null);
    // 2. 创建adapter适配器对象 & 装入模糊搜索的结果
    adapter = new SimpleCursorAdapter(mContext, android.R.layout.simple_list_item_1, cursor, new String[] { "name" },
            new int[] { android.R.id.text1 }, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    // 3. 设置适配器
    listView.setAdapter(adapter);
    adapter.notifyDataSetChanged();

    System.out.println(cursor.getCount());
    // 当输入框为空 & 数据库中有搜索记录时,显示 "删除搜索记录"按钮
    if (tempName.equals("") && cursor.getCount() != 0){
        tv_clear.setVisibility(VISIBLE);
    }
    else {
        tv_clear.setVisibility(INVISIBLE);
    };

}
项目:RoadLab-Pro    文件:RoadListFragment.java   
@Override
protected void delete(final BaseModel model) {
    final RoadModel road = (RoadModel) model;
    if (road.isDefaultRoad()) {
        showDefaultProjectToast();
        return;
    }
    new AsyncTask<Void, Void, Cursor>() {

        @Override
        protected Cursor doInBackground(Void[] params) {
            MeasurementsDataHelper.getInstance().deleteRoad(road.getId(), true);
            final Cursor cursor = roadDAO.getAllRoadByFolderIdCursor(((RoadModel) model).getFolderId());
            return cursor;
        }

        @Override
        protected void onPostExecute(Cursor o) {
            super.onPostExecute(o);
            ((CursorAdapter)getAdapter()).swapCursor(o);
        }
    }.execute();
}
项目:RoadLab-Pro    文件:MeasurementListFragment.java   
@Override
protected void delete(final BaseModel model) {
    new AsyncTask<Void, Void, Cursor>() {
        @Override
        protected Cursor doInBackground(Void[] params) {
            MeasurementModel measurement = (MeasurementModel) model;
            MeasurementsDataHelper.getInstance().deleteMeasurement(measurement.getId(), true);
            final Cursor cursor = measurementDAO.getAllMeasurementByRoadIdCursor(roadModel.getId());
            return cursor;
        }
        @Override
        protected void onPostExecute(Cursor o) {
            super.onPostExecute(o);
            ((CursorAdapter)getAdapter()).swapCursor(o);
        }
    }.execute();
}
项目:RoadLab-Pro    文件:FolderListFragment.java   
@Override
protected void delete(final BaseModel model) {
    final FolderModel project = (FolderModel) model;
    if (project.isDefaultProject()) {
        showDefaultProjectToast();
        return;
    }
    new AsyncTask<Void, Void, Cursor>() {
        @Override
        protected Cursor doInBackground(Void[] params) {
            MeasurementsDataHelper.getInstance().deleteProject(project.getId(), true);
            final Cursor cursor = folderDAO.getAllFolderCursor();
            return cursor;
        }
        @Override
        protected void onPostExecute(Cursor o) {
            super.onPostExecute(o);
            ((CursorAdapter)getAdapter()).swapCursor(o);
        }
    }.execute();
}
项目:RoadLab-Pro    文件:FolderListFragment.java   
public void refreshFolders() {
    new AsyncTask<Void, Void, Cursor>() {
        @Override
        protected Cursor doInBackground(Void[] params) {
            //long folderId = folderDAO.putFolder(folderModel);
            MeasurementsDataHelper.getInstance().refreshFoldersCountersSync();
            final Cursor cursor = folderDAO.getAllFolderCursor();
            return cursor;
        }
        @Override
        protected void onPostExecute(Cursor o) {
            super.onPostExecute(o);
            ((CursorAdapter)getAdapter()).swapCursor(o);
        }
    }.execute();
}
项目:RoadLab-Pro    文件:TagsListFragment.java   
@Override
protected void delete(final BaseModel model) {
    new AsyncTask<Void, Void, Cursor>() {
        @Override
        protected Cursor doInBackground(Void[] params) {
            TagModel tagModel = (TagModel) model;
            tagDAO.delete(tagModel);
            final Cursor cursor = tagDAO.
            getTagsByRoadIdCursor(RAApplication.getInstance().getCurrentRoadId());
            return cursor;
        }

        @Override
        protected void onPostExecute(Cursor o) {
            ((CursorAdapter) getAdapter()).swapCursor(o);
        }
    }.execute();
}
项目:murmur    文件:StarredFragment.java   
private void swapCursor(){

        int offsetFromTop = 0;
        int firstVisiblePosition = Math.max(0, feedListView.getFirstVisiblePosition());
        if(feedListView.getChildCount() > 0) {
            offsetFromTop = feedListView.getChildAt(0).getTop();
        }

        CursorAdapter newAdapter = ((CursorAdapter) feedListView.getAdapter());
        newAdapter.swapCursor(getCursor());
        if(SearchHelper.searchToSQL(query) == null) {
            ((FeedAdapter) newAdapter).setHighlight(Utils.getKeywords(query));
        }
        feedListView.setAdapter(newAdapter);

        feedListView.setSelectionFromTop(firstVisiblePosition, offsetFromTop);
    }
项目:murmur    文件:StarredFragment.java   
private void setListInSelectionMode(){

        inSelectionMode = true;

        ((FeedAdapter) feedListView.getAdapter()).setSelectionMode(true);
        swapCursor();
        feedListView.setOnItemLongClickListener(null);
        feedListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Cursor c = ((CursorAdapter) feedListView.getAdapter()).getCursor();
                c.moveToPosition(position);
                boolean isChecked = c.getInt(c.getColumnIndex(MessageStore.COL_CHECKED)) == MessageStore.TRUE;
                String message = c.getString(c.getColumnIndex(MessageStore.COL_MESSAGE));

                MessageStore.getInstance(getActivity()).checkMessage(message, !isChecked);
                swapCursor();
                setActionbar();

            }
        });
        setActionbar();

        newPostButton.setVisibility(View.INVISIBLE);
    }
项目:murmur    文件:ContactsFragment.java   
private void swapCursor(){

        int offsetFromTop = 0;
        int firstVisiblePosition = Math.max(0, contactListView.getFirstVisiblePosition());
        if(contactListView.getChildCount() > 0) {
            offsetFromTop = contactListView.getChildAt(0).getTop();
        }

        CursorAdapter newAdapter = ((CursorAdapter) contactListView.getAdapter());
        newAdapter.swapCursor(getCursor());
        if(SearchHelper.searchToSQL(query) == null) {
            ((ContactAdapter) newAdapter).setHighlight(Utils.getKeywords(query));
        }
        contactListView.setAdapter(newAdapter);

        contactListView.setSelectionFromTop(firstVisiblePosition, offsetFromTop);
    }
项目:murmur    文件:ExpandedMessageFragment.java   
private void swapCursor(){

        int offsetFromTop = 0;
        int firstVisiblePosition = Math.max(0, listView.getFirstVisiblePosition());
        if(listView.getChildCount() > 0) {
            offsetFromTop = listView.getChildAt(0).getTop();
        }

        CursorAdapter newAdapter = ((CursorAdapter) listView.getAdapter());
        newAdapter.swapCursor(getCursor());
        if(SearchHelper.searchToSQL(query) == null) {
            ((FeedReplyAdapter) newAdapter).setHighlight(Utils.getKeywords(query));
        }
        listView.setAdapter(newAdapter);

        listView.setSelectionFromTop(firstVisiblePosition, offsetFromTop);
        parentMessage.setAdapter(new FeedAdapter(getActivity(), MessageStore.getInstance(getActivity()).getMessageById(messageId), false, feedAdapterCallbacks));
    }
项目:murmur    文件:FeedFragment.java   
private void swapCursor(){

        int offsetFromTop = 0;
        int firstVisiblePosition = Math.max(0, feedListView.getFirstVisiblePosition());
        if(feedListView.getChildCount() > 0) {
            offsetFromTop = feedListView.getChildAt(0).getTop();
        }

        CursorAdapter newAdapter = ((CursorAdapter) feedListView.getAdapter());
        newAdapter.swapCursor(getCursor());
        if(SearchHelper.searchToSQL(query) == null) {
            ((FeedAdapter) newAdapter).setHighlight(Utils.getKeywords(query));
        }
        feedListView.setAdapter(newAdapter);

        feedListView.setSelectionFromTop(firstVisiblePosition, offsetFromTop);
    }
项目:Search_Layout    文件:SearchView.java   
/**
 * 关注1
 * 模糊查询数据 & 显示到ListView列表上
 */
private void queryData(String tempName) {

    // 1. 模糊搜索
    Cursor cursor = helper.getReadableDatabase().rawQuery(
            "select id as _id,name from records where name like '%" + tempName + "%' order by id desc ", null);
    // 2. 创建adapter适配器对象 & 装入模糊搜索的结果
    adapter = new SimpleCursorAdapter(context, android.R.layout.simple_list_item_1, cursor, new String[] { "name" },
            new int[] { android.R.id.text1 }, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    // 3. 设置适配器
    listView.setAdapter(adapter);
    adapter.notifyDataSetChanged();

    System.out.println(cursor.getCount());
    // 当输入框为空 & 数据库中有搜索记录时,显示 "删除搜索记录"按钮
    if (tempName.equals("") && cursor.getCount() != 0){
        tv_clear.setVisibility(VISIBLE);
    }
    else {
        tv_clear.setVisibility(INVISIBLE);
    };

}
项目:TextSecure    文件:ContactSelectionListFragment.java   
private void handleSelectAll() {
  selectedContacts.clear();

  Cursor cursor = null;

  try {
    cursor = ContactAccessor.getInstance().getCursorForContactsWithNumbers(getActivity());

    while (cursor != null && cursor.moveToNext()) {
      ContactData contactData = ContactAccessor.getInstance().getContactData(getActivity(), cursor);

      if      (contactData.numbers.isEmpty())   continue;
      else if (contactData.numbers.size() == 1) addSingleNumberContact(contactData);
      else                                      addMultipleNumberContact(contactData, null);
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  ((CursorAdapter)getListView().getAdapter()).notifyDataSetChanged();
}
项目:cat-chat-android    文件:ConversationActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_conversation);

    Bundle extras = getIntent().getExtras();

    mShowSentMessages = extras.getBoolean("sentMessages", false);

    if(mShowSentMessages) {
        getActionBar().setTitle(R.string.sent_messages);
    } else {
        mUserId = extras.getString("fromUserId");
        String userEmail = extras.getString("fromUserEmail");

        getActionBar().setTitle(userEmail);
    }

    final ListAdapter adapter = new ConversationAdapter(this, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    getListView().setAdapter(adapter);
    getLoaderManager().initLoader(0, null, this);
}
项目:HeadFirstAndroid    文件:DrinkCategoryActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ListView listDrinks = getListView();

    try {
        SQLiteOpenHelper starbuzzDatabaseHelper = new StarbuzzDatabaseHelper(this);
        db = starbuzzDatabaseHelper.getReadableDatabase();

        cursor = db.query("DRINK",
                          new String[]{"_id", "NAME"},
                          null, null, null, null, null);

        CursorAdapter listAdapter = new SimpleCursorAdapter(this,
                                                            android.R.layout.simple_list_item_1,
                                                            cursor,
                                                            new String[]{"NAME"},
                                                            new int[]{android.R.id.text1},
                                                            0);
        listDrinks.setAdapter(listAdapter);
    } catch(SQLiteException e) {
        Toast toast = Toast.makeText(this, "Database unavailable", Toast.LENGTH_SHORT);
        toast.show();
    }
}
项目:HeadFirstAndroid    文件:TopLevelActivity.java   
@Override
public void onRestart() {
    super.onRestart();
    try {
        StarbuzzDatabaseHelper starbuzzDatabaseHelper = new StarbuzzDatabaseHelper(this);
        db = starbuzzDatabaseHelper.getReadableDatabase();
        Cursor newCursor = db.query("DRINK",
                                    new String[] { "_id", "NAME"},
                                    "FAVORITE = 1",
                                    null, null, null, null);
        ListView listFavorites = (ListView)findViewById(R.id.list_favorites);
        CursorAdapter adapter = (CursorAdapter) listFavorites.getAdapter();
        adapter.changeCursor(newCursor);
        favoritesCursor = newCursor;
    } catch(SQLiteException e) {
        Toast toast = Toast.makeText(this, "Database unavailable", Toast.LENGTH_SHORT);
        toast.show();
    }
}
项目:android-money-manager-ex    文件:InvestmentTransactionEditActivity.java   
private void displayStock(Stock stock, InvestmentTransactionViewHolder viewHolder) {
    if (mAccount == null) return;

    // Date
    String dateDisplay = new MmxDate(stock.getPurchaseDate()).toString(Constants.LONG_DATE_PATTERN);
    viewHolder.dateView.setText(dateDisplay);

    // Account.
    Cursor cursor = ((CursorAdapter) viewHolder.accountSpinner.getAdapter()).getCursor();
    int accountIndex = SpinnerHelper.getPosition(mAccount.getName(), Account.ACCOUNTNAME, cursor);
    if (accountIndex >= 0) {
        viewHolder.accountSpinner.setSelection(accountIndex, true);
    }

    viewHolder.stockNameEdit.setText(stock.getName());
    viewHolder.symbolEdit.setText(stock.getSymbol());

    showNumberOfShares();
    showPurchasePrice();
    viewHolder.notesEdit.setText(stock.getNotes());
    showCommission();
    showCurrentPrice();
    showValue();
}
项目:Securecom-Messaging    文件:ContactSelectionListFragment.java   
private void handleSelectAll() {
  selectedContacts.clear();

  Cursor cursor = null;

  try {
    cursor = ContactAccessor.getInstance().getCursorForContactsWithNumbers(getActivity());

    while (cursor != null && cursor.moveToNext()) {
      ContactData contactData = ContactAccessor.getInstance().getContactData(getActivity(), cursor);

      if      (contactData.numbers.isEmpty())   continue;
      else if (contactData.numbers.size() == 1) addSingleNumberContact(contactData);
      else                                      addMultipleNumberContact(contactData, null);
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  ((CursorAdapter)getListView().getAdapter()).notifyDataSetChanged();
}
项目:CircularView    文件:CircularViewCursorAdapter.java   
void init(final Cursor c, int flags) {
    if ((flags & CursorAdapter.FLAG_AUTO_REQUERY) == CursorAdapter.FLAG_AUTO_REQUERY) {
        flags |= CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER;
        mAutoRequery = true;
    } else {
        mAutoRequery = false;
    }
    boolean cursorPresent = c != null;
    mCursor = c;
    mDataValid = cursorPresent;
    mRowIDColumn = cursorPresent ? c.getColumnIndexOrThrow("_id") : -1;
    if ((flags & CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER) == CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER) {
        mChangeObserver = new ChangeObserver();
        mDataSetObserver = new MyDataSetObserver();
    } else {
        mChangeObserver = null;
        mDataSetObserver = null;
    }

    if (cursorPresent) {
        if (mChangeObserver != null) c.registerContentObserver(mChangeObserver);
        if (mDataSetObserver != null) c.registerDataSetObserver(mDataSetObserver);
    }
}
项目:Securecom-Text    文件:ContactSelectionListFragment.java   
private void handleSelectAll() {
  selectedContacts.clear();

  Cursor cursor = null;

  try {
    cursor = ContactAccessor.getInstance().getCursorForContactsWithNumbers(getActivity());

    while (cursor != null && cursor.moveToNext()) {
      ContactData contactData = ContactAccessor.getInstance().getContactData(getActivity(), cursor);

      if      (contactData.numbers.isEmpty())   continue;
      else if (contactData.numbers.size() == 1) addSingleNumberContact(contactData);
      else                                      addMultipleNumberContact(contactData, null);
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  ((CursorAdapter)getListView().getAdapter()).notifyDataSetChanged();
}
项目:AndroidClient    文件:CircularViewCursorAdapter.java   
void init(final Cursor c, int flags) {
    if ((flags & CursorAdapter.FLAG_AUTO_REQUERY) == CursorAdapter.FLAG_AUTO_REQUERY) {
        flags |= CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER;
        mAutoRequery = true;
    } else {
        mAutoRequery = false;
    }
    boolean cursorPresent = c != null;
    mCursor = c;
    mDataValid = cursorPresent;
    mRowIDColumn = cursorPresent ? c.getColumnIndexOrThrow("_id") : -1;
    if ((flags & CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER) == CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER) {
        mChangeObserver = new ChangeObserver();
        mDataSetObserver = new MyDataSetObserver();
    } else {
        mChangeObserver = null;
        mDataSetObserver = null;
    }

    if (cursorPresent) {
        if (mChangeObserver != null) c.registerContentObserver(mChangeObserver);
        if (mDataSetObserver != null) c.registerDataSetObserver(mDataSetObserver);
    }
}
项目:WanderWiki-client    文件:TrackManager.java   
@Override
protected void onPause() {
    // Remember position in listview (before any adapter change)
    prevItemVisible = getListView().getFirstVisiblePosition();

    CursorAdapter adapter = (CursorAdapter) getListAdapter();
    if (adapter != null) {
        // Prevents on-screen 'no tracks' message
        getListView().setEmptyView(findViewById(android.R.id.empty));
        // Properly close the adapter cursor
        Cursor cursor = adapter.getCursor();
        stopManagingCursor(cursor);
        cursor.close();
        setListAdapter(null);
    }

    super.onPause();
}
项目:CS492-FA13    文件:MainActivity.java   
private void assignListAdapter()
{

    // Use the content resolver to get a list of
    // contacts from the People app content provider
    // and assign member cursor.
    getContacts();

    // Create the cursor adapter and assign cursor from above.
    _adapter = new SimpleCursorAdapter(this, 
                                       R.layout.contact_list_row, 
                                       _cursor, 
                                       new String[] { ContactsContract.Contacts.DISPLAY_NAME }, 
                                       new int[] { R.id.textViewName }, 
                                       CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

    // Assign adapter to list fragment.
    _fragmentList.setListAdapter(_adapter);

}
项目:SuperGenPass    文件:Super_Gen_Pass.java   
private void initDomainPasswordEntry() {
    mDomainEdit = (AutoCompleteTextView) findViewById(R.id.domain_edit);

    mMasterPwEdit = (VisualHashEditText) findViewById(R.id.password_edit);

    mMasterPwEdit.setOnEditorActionListener(this);

    final SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, null,
                    new String[] { "domain" }, new int[] { android.R.id.text1 },
                    CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

    adapter.setFilterQueryProvider(this);
    adapter.setStringConversionColumn(DOMAIN_COLUMN);

    // initialize the autocompletion
    mDomainEdit.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(final AdapterView<?> arg0, final View arg1, final int arg2,
                final long arg3) {
            mMasterPwEdit.requestFocus();
        }
    });
    mDomainEdit.setAdapter(adapter);
}
项目:beeline    文件:MainActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case CONNECTION_FAILURE_RESOLUTION_REQUEST:
        if (resultCode == RESULT_OK) {
            Toast.makeText(this, "Resolution now ok, could retry now.", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(this, "Resolution failed.", Toast.LENGTH_SHORT).show();
        }
        break;
    case ENTRY_ACTION_REQUEST:
        if (resultCode == RESULT_OK) {
            // refresh
            dbc = queryEntries();
            ((CursorAdapter) listLocations.getAdapter()).changeCursor(dbc);
        }
        break;
    default:
        Toast.makeText(this, "Unknown activity result.", Toast.LENGTH_SHORT).show();
    }
}
项目:beeline    文件:MainActivity.java   
protected void updateLocations(Location location) {
    // display location as latitude/longitude
    if (location != null) {
        textLatLng.setText(String.format("%s  %s%n%s  %s",
                getResources().getText(R.string.text_latitude),
                Utilities.formatLatLon(location.getLatitude()),
                getResources().getText(R.string.text_longitude),
                Utilities.formatLatLon(location.getLongitude())));
    } else {
        textLatLng.setText(R.string.latlng_unknown);
    }

    // remember last position
    lastLocation = location;

    // force list view to update
    ((CursorAdapter) listLocations.getAdapter()).notifyDataSetChanged();
}
项目:VikingGTD    文件:ActionsListFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    try {
        setHasOptionsMenu(true);
    } catch(Exception ex) {
        Log.e(TAG, "Failed to create menu: " + ex.getMessage());
    }

    adapter_ = new ActionItemAdapter(getActivity(), CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

    setListAdapter(adapter_);

    getLoaderManager().initLoader(LOADER_ACTIONS, null, lm_ = new LoaderMgr());

    if (savedInstanceState != null) {
        // Restore last state for checked position.
        cur_list_position_ = savedInstanceState.getInt("cur_list_position", 0);
    }

    registerForContextMenu(getListView());
}
项目:UyghurWeather    文件:ChooseAreaActivity.java   
public void ShowProvince() {
    Cursor cursor = DataSupport.findBySQL("SELECT id AS _id, province FROM Location GROUP BY province ORDER BY province");
    adapter = new SimpleCursorAdapter(this, R.layout.choose_area_item, cursor,
            new String[] {"province"}, new int[] {R.id.place}, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    listView.setAdapter(adapter);
    chooseWhat.setText("选择省份");
}
项目:aos-Video    文件:CursorBrowserByVideo.java   
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    if(loader.getId()==0) { //if was called with this fragment, not a child
        if (mCursor == null) {
            mCursor = cursor;
            bindAdapter();
        } else {
            boolean forceReloadUI = (mCursor.getCount() == 0 || cursor.getCount() == 0);
            mCursor = cursor;
            ((CursorAdapter) mBrowserAdapter).changeCursor(cursor);
            if (forceReloadUI) {
                postBindAdapter();
            }
        }
    }
}
项目:ZhiHuIndex-master    文件:SearchActivity.java   
private void queryData(String tempName) {
    Cursor cursor = helper.getReadableDatabase().rawQuery(
            "select id as _id,name from records where name like '%" +
                    tempName + "%' order by id desc ", null);
    // 创建adapter适配器对象
    adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, cursor, new String[] { "name" },
            new int[] { android.R.id.text1 }, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    // 设置适配器
    listview.setAdapter(adapter);
    adapter.notifyDataSetChanged();
}
项目:RoadLab-Pro    文件:RoadListFragment.java   
public void refreshRoads() {
    new AsyncTask<Void, Void, Cursor>() {
        @Override
        protected Cursor doInBackground(Void[] params) {
            MeasurementsDataHelper.getInstance().refreshRoadsCountersSync();
            final Cursor cursor = roadDAO.getAllRoadByFolderIdCursor(folder.getId());
            return cursor;
        }
        @Override
        protected void onPostExecute(Cursor o) {
            super.onPostExecute(o);
            ((CursorAdapter)getAdapter()).swapCursor(o);
        }
    }.execute();
}
项目:RoadLab-Pro    文件:MeasurementListFragment.java   
public void refreshItems() {
    new AsyncTask<Void, Void, Cursor>() {
        @Override
        protected Cursor doInBackground(Void[] params) {
            MeasurementsDataHelper.getInstance().refreshMeasurementsCountersSync();
            final Cursor cursor = measurementDAO.getAllMeasurementByRoadIdCursor(roadModel.getId());
            return cursor;
        }
        @Override
        protected void onPostExecute(Cursor o) {
            super.onPostExecute(o);
            ((CursorAdapter)getAdapter()).swapCursor(o);
        }
    }.execute();
}
项目:RoadLab-Pro    文件:SwipeListFragment.java   
protected void initAdapter(boolean force) {
    if (force || adapter == null) {
        adapter = createAdapter();
    }
    if (adapter != null && adapter instanceof CursorAdapter) {
        ((CursorAdapter) adapter).setFilterQueryProvider(new MyFilterQueryProvider());
    }
    startSearch(getSearchText());
    listView.setAdapter(adapter);
}
项目:RoadLab-Pro    文件:TagsListFragment.java   
public void refreshTags() {
    new AsyncTask<Void, Void, Cursor>() {
        @Override
        protected Cursor doInBackground(Void[] params) {
            final Cursor cursor = tagDAO.getTagsByRoadIdCursor(RAApplication.getInstance().getCurrentRoadId());
            return cursor;
        }
        @Override
        protected void onPostExecute(Cursor o) {
            ((CursorAdapter)getAdapter()).swapCursor(o);
        }
    }.execute();
}
项目:murmur    文件:ContactsFragment.java   
private void setListInSelectionMode(){

        inSelectionMode = true;

        ((ContactAdapter)contactListView.getAdapter()).setSelectionMode(inSelectionMode);
        swapCursor();
        contactListView.setOnItemLongClickListener(null);
        contactListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Cursor c = ((CursorAdapter) contactListView.getAdapter()).getCursor();
                c.moveToPosition(position);
                boolean isChecked = c.getInt(c.getColumnIndex(FriendStore.COL_CHECKED)) == FriendStore.TRUE;
                String publicKey = c.getString(c.getColumnIndex(FriendStore.COL_PUBLIC_KEY));

                FriendStore.getInstance(getActivity()).setChecked(publicKey, !isChecked);
                swapCursor();

                int checkedCount = (int) FriendStore.getInstance(getActivity()).getCheckedCount();

                ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(checkedCount <= 99 ? String.valueOf(checkedCount) : "+99");
                updateSelectAll();
                if (menu != null) menu.findItem(R.id.action_delete).setEnabled(checkedCount > 0);

            }
        });
        setActionbar();
    }
项目:truth-android    文件:CursorAdapterSubject.java   
public static SubjectFactory<CursorAdapterSubject, CursorAdapter> type() {
  return new SubjectFactory<CursorAdapterSubject, CursorAdapter>() {
    @Override
    public CursorAdapterSubject getSubject(FailureStrategy fs, CursorAdapter that) {
      return new CursorAdapterSubject(fs, that);
    }
  };
}
项目:TextSecure    文件:ContactSelectionListFragment.java   
public void onClick(DialogInterface dialog, int which) {
  ContactData selected = selectedContacts.get(contactData.id);

  if (selected == null && textView != null) {
    if (textView != null) textView.setChecked(false);
  } else if (selected.numbers.size() == 0) {
    selectedContacts.remove(selected.id);
    if (textView != null) textView.setChecked(false);
  }

  if (textView == null)
    ((CursorAdapter)getListView().getAdapter()).notifyDataSetChanged();
}
项目:RefugeeBuddyAndroid    文件:ListLocationsActivity.java   
private void setupLocationsAdapter(String server_id) {
    LocationTasks.getAllLocations(this, server_id, new OnDataSetReceivedListener() {
        @Override
        public void onDataSetReceived(Cursor cursor) {
            mLocationAdapter = new LocationCursorAdapter(ListLocationsActivity.this, cursor, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
            ListView listView = (ListView) findViewById(R.id.detected_activities_listview);
            listView.setAdapter(mLocationAdapter);
        }
    });
}
项目:flavordex    文件:AppImportDialog.java   
@Override
public void onLoaderReset(Loader<Cursor> loader) {
    final CursorAdapter adapter = (CursorAdapter)getListAdapter();
    if(adapter != null) {
        adapter.swapCursor(null);
    }
}
项目:flavordex    文件:EntryFormHelper.java   
@Override
public void onLoadFinished(Loader loader, Cursor data) {
    switch(loader.getId()) {
        case LOADER_MAKERS:
            ((CursorAdapter)mTxtMaker.getAdapter()).swapCursor(data);
    }
}