private void update() { // Update the older/newer buttons & label. int count = MailItems.getMailItemCount(); int max = startIndex + VISIBLE_EMAIL_COUNT; if (max > count) { max = count; } // Update the nav bar. navBar.update(startIndex, count, max); // Show the selected emails. int i = 0; for (; i < VISIBLE_EMAIL_COUNT; ++i) { // Don't read past the end. if (startIndex + i >= MailItems.getMailItemCount()) { break; } MailItem item = MailItems.getMailItem(startIndex + i); // Add a new row to the table, then set each of its columns to the // email's sender and subject values. table.setText(i, 0, item.sender); table.setText(i, 1, item.email); table.setText(i, 2, item.subject); } // Clear any remaining slots. for (; i < VISIBLE_EMAIL_COUNT; ++i) { table.removeRow(table.getRowCount() - 1); } }
void older() { // Move forward a page. startIndex += VISIBLE_EMAIL_COUNT; if (startIndex >= MailItems.getMailItemCount()) { startIndex -= VISIBLE_EMAIL_COUNT; } else { styleRow(selectedRow, false); selectedRow = -1; update(); } }
/** * Selects the given row (relative to the current page). * * @param row the row to be selected */ private void selectRow(int row) { // When a row (other than the first one, which is used as a header) is // selected, display its associated MailItem. MailItem item = MailItems.getMailItem(startIndex + row); if (item == null) { return; } styleRow(selectedRow, false); styleRow(row, true); item.read = true; selectedRow = row; if (listener != null) { listener.onItemSelected(item); } }