@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    DatabaseHandler dbHandler = new DatabaseHandler(this);

    // this will be moved into a service layer later
    if (dbHandler.getBookCount() == 0) {
      // if we have no books, then we must add the default ones
      BookService service = new BookService();
      Book bookToAdd = service.getDefaultEntry();
      dbHandler.addBook(bookToAdd);
    }

    List<Book> allBooksFromDb = dbHandler.getAllBooks();

    setContentView(R.layout.activity_scrolling);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null)
                .show();
          }
        });
  }
示例#2
0
  /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    Book book = books.createBook("H2G2", 5.55F);

    List<Item> items = new ArrayList<>();
    Item item = new Item();
    items.add(item);
    PurchaseOrder po = purchase.compute(items);
    purchase.create(items);
    response.getWriter().println(book.toString() + " PurchaseOrder = " + po);

    //		response.getWriter().println("CDI!!!");
  }
 @Before
 public void setUp() {
   this.bookService = BookService.getInstance();
   this.bookDAOMock = mock(BookDAO.class);
   setInternalState(this.bookService, "genericDAO", this.bookDAOMock);
 }