Java Code Examples for android.widget.CursorAdapter#changeCursor()

The following examples show how to use android.widget.CursorAdapter#changeCursor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TopLevelActivity.java    From HeadFirstAndroid with MIT License 6 votes vote down vote up
@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();
    }
}
 
Example 2
Source File: AdapterRule.java    From tracker-control-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onViewRecycled(ViewHolder holder) {
    super.onViewRecycled(holder);

    //Context context = holder.itemView.getContext();
    //GlideApp.with(context).clear(holder.ivIcon);

    CursorAdapter adapter = (CursorAdapter) holder.lvAccess.getAdapter();
    if (adapter != null) {
        Log.i(TAG, "Closing access cursor");
        adapter.changeCursor(null);
        holder.lvAccess.setAdapter(null);
    }
}
 
Example 3
Source File: AdapterRule.java    From NetGuard with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onViewRecycled(ViewHolder holder) {
    super.onViewRecycled(holder);

    //Context context = holder.itemView.getContext();
    //GlideApp.with(context).clear(holder.ivIcon);

    CursorAdapter adapter = (CursorAdapter) holder.lvAccess.getAdapter();
    if (adapter != null) {
        Log.i(TAG, "Closing access cursor");
        adapter.changeCursor(null);
        holder.lvAccess.setAdapter(null);
    }
}