Created
March 11, 2016 03:37
-
-
Save ronbeltran/18c89d20785cd6d22225 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ronbeltran.projectname; | |
import android.content.Context; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.UUID; | |
public class TaskLab { | |
/** | |
* Singleton class to hold task list | |
* */ | |
private static TaskLab sTaskLab; | |
private List<Task> mTasks; | |
public static TaskLab get(Context context) { | |
if(sTaskLab == null){ | |
sTaskLab = new TaskLab(context); | |
} | |
return sTaskLab; | |
} | |
private TaskLab(Context context) { | |
mTasks = new ArrayList<>(); | |
// generate dummy tasks | |
for(int i=0; i<100; i++){ | |
Task task = new Task(); | |
task.setBody("Task #" + i); | |
task.setIsPublic(i % 2 == 0); | |
mTasks.add(task); | |
} | |
} | |
public List<Task> getTasks() { | |
return mTasks; | |
} | |
public Task getTask(UUID id) { | |
for(Task task: mTasks) { | |
if(task.getId().equals(id)){ | |
return task; | |
} | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment