public void deleteMemory(Memory memoryToDelete, String markerID) { // Update the model Memory memory = Memory.findById(Memory.class, memoryToDelete.getId()); memory.delete(); // Notify the map mMemoryChanged.onMemoryRemoved(memory, markerID); }
public List<Memory> getMemories() { // Get the memories from the model try { return Memory.listAll(Memory.class); } catch (Exception e) { return null; } }
public void createMemory(Memory newMemory) { // Create new memory if (newMemory.getTitle() == null || newMemory.getTitle().equals("")) { newMemory.setTitle("Untitled"); } if (newMemory.getDate() == null) { newMemory.setDate(Calendar.getInstance()); } newMemory.save(); // Notify map here mMemoryChanged.onMemoryAdded(newMemory); }
public Memory findMemoryByID(Long id) { // get the memory with a given id return Memory.findById(Memory.class, id); }
public List<Memory> findMemoryByTitle(String title) { // get the memories with a given title return Memory.find(Memory.class, "title = ?", title); }
public void updateMemory(Memory updatedMemory) { // Update the model Memory memory = Memory.findById(Memory.class, updatedMemory.getId()); if (updatedMemory.getTitle() == null || updatedMemory.getTitle().equals("")) { updatedMemory.setTitle("Untitled"); } else { memory.setTitle(updatedMemory.getTitle()); } memory.setDate(updatedMemory.getDate()); memory.setPeople(updatedMemory.getPeople()); memory.setPhotoURI(updatedMemory.getPhotoURI()); memory.setDescription(updatedMemory.getDescription()); memory.setLatitude(updatedMemory.getLatitude()); memory.setLongitude(updatedMemory.getLongitude()); memory.setPlaceName(updatedMemory.getPlaceName()); memory.save(); // Notify the map mMemoryChanged.onMemoryUpdated(memory); }