Back to project page ShoppingList.
The source code is released under:
GNU General Public License
If you think the Android project ShoppingList listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package net.sledzdev.shoppinglist.manager; // ww w . ja v a 2 s.c om import android.content.ContentValues; import android.database.Cursor; import com.google.common.collect.ImmutableList; import net.sledzdev.shoppinglist.model.ShoppingList; import net.sledzdev.shoppinglist.content.ListsTable; import net.sledzdev.shoppinglist.model.ShoppingListFactory; import java.util.ArrayList; import java.util.List; /** * Created by Mariusz on 21.12.13. */ public class ListsContentTransformer implements ContentTransformer<ShoppingList> { @Override public List<ShoppingList> transformCursor(Cursor cursor) { List<ShoppingList> lists = new ArrayList<ShoppingList>(); while(cursor.moveToNext()) { lists.add(ShoppingListFactory.createShoppingList( cursor.getLong(cursor.getColumnIndexOrThrow(ListsTable.C_ID)), cursor.getString(cursor.getColumnIndexOrThrow(ListsTable.C_NAME)) )); } return ImmutableList.copyOf(lists); } @Override public ContentValues transformValue(ShoppingList value) { ContentValues values = new ContentValues(); if (!value.isNewList()) { values.put(ListsTable.C_ID, value.getId()); } values.put(ListsTable.C_NAME, value.name); return values; } }