Skip to content

Instantly share code, notes, and snippets.

View JorgeCastilloPrz's full-sized avatar
🎉
Mostly Android stuff now, also FP

Jorge Castillo JorgeCastilloPrz

🎉
Mostly Android stuff now, also FP
View GitHub Profile
public class ApplicationClass extends Application {
private ObjectGraph objectGraph;
@Override
public void onCreate() {
super.onCreate();
objectGraph = ObjectGraph.create(getModules().toArray());
objectGraph.inject(this);
}
public void BookController {
private static BookController instance = null;
private BookRepository bookRepository = new PersistentBookRepository();
protected BookController() {}
public static BookController getInstance() {
if(instance == null) {
instance = new BookController();
@JorgeCastilloPrz
JorgeCastilloPrz / gist:a13f129743fd7a4d6b60
Last active August 29, 2015 14:08
Medium - Dependency injection - 1
public interface BookRepository {
public List<Book> getAllBooks();
public List<Book> getAllBooksFromUser(int userId);
public List<Book> getAllBooksByCategory(BookCategory category);
public Book getBook(int bookId);
public Book getBookByName(String bookName);
public void removeBook(int bookId);
public void markAsCompleted(int bookId);
}