use of com.nolanlawson.keepscore.db.GameSummary in project KeepScore by nolanlawson.
the class MainActivity method onPause.
@Override
public void onPause() {
super.onPause();
log.d("onPause()");
// save which items were checked and where we are in the list
lastChecked = new HashSet<GameSummary>();
for (SavedGameAdapter subAdapter : adapter.getSubAdapters()) {
lastChecked.addAll(subAdapter.getChecked());
}
lastPosition = getListView().getFirstVisiblePosition();
}
use of com.nolanlawson.keepscore.db.GameSummary in project KeepScore by nolanlawson.
the class MainActivity method organizeGamesByTimePeriod.
private SortedMap<TimePeriod, List<GameSummary>> organizeGamesByTimePeriod(List<GameSummary> games) {
SortedMap<TimePeriod, List<GameSummary>> result = new TreeMap<TimePeriod, List<GameSummary>>();
Iterator<TimePeriod> timePeriodIterator = Arrays.asList(TimePeriod.values()).iterator();
TimePeriod timePeriod = timePeriodIterator.next();
Date date = new Date();
for (GameSummary game : games) {
// them in order
while (!timePeriodMatches(date, timePeriod, game)) {
timePeriod = timePeriodIterator.next();
}
List<GameSummary> existing = result.get(timePeriod);
if (existing == null) {
result.put(timePeriod, new ArrayList<GameSummary>(Collections.singleton(game)));
} else {
existing.add(game);
}
}
return result;
}
use of com.nolanlawson.keepscore.db.GameSummary in project KeepScore by nolanlawson.
the class MainActivity method showDeleteSelectedDialog.
private void showDeleteSelectedDialog() {
final Set<GameSummary> games = new HashSet<GameSummary>();
for (SavedGameAdapter subAdapter : adapter.getSectionsMap().values()) {
games.addAll(subAdapter.getChecked());
}
String message = games.size() == 1 ? getString(R.string.text_game_will_be_deleted) : String.format(getString(R.string.text_games_will_be_deleted), games.size());
new AlertDialog.Builder(this).setCancelable(true).setTitle(R.string.title_confirm_delete).setMessage(message).setNegativeButton(android.R.string.cancel, null).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
deleteGames(games);
}
}).show();
}
Aggregations