Last active
June 29, 2017 16:32
-
-
Save thatfiredev/eaa39ed03ddb6b4d254e174663b2bc6f to your computer and use it in GitHub Desktop.
Utilizado no artigo Android Architecture Components - LiveData: https://medium.com/@rosariopfernandes/aac5-9c56e6b4cffc
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
| public LiveData<List<Tarefa>> getTarefas() { | |
| if(tarefas == null) { | |
| carregarDados(); | |
| } | |
| if(tarefas.getValue().size()==0) { | |
| //Transformations.map() | |
| tarefas = Transformations.map(tarefas, new Function<List<Tarefa>, | |
| List<Tarefa>>() { | |
| @Override | |
| public List<Tarefa> apply(List<Tarefa> novasTarefas) { | |
| novasTarefas.add(new Tarefa(0, "Bem-vindo", | |
| "Bem-vindo ao mundo dos Architecture Components")); | |
| return novasTarefas; | |
| } | |
| }); | |
| } | |
| return tarefas; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment