Search in sources :

Example 6 with SavedGameAdapter

use of com.nolanlawson.keepscore.data.SavedGameAdapter 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();
}
Also used : SavedGameAdapter(com.nolanlawson.keepscore.data.SavedGameAdapter) GameSummary(com.nolanlawson.keepscore.db.GameSummary)

Example 7 with SavedGameAdapter

use of com.nolanlawson.keepscore.data.SavedGameAdapter 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();
}
Also used : DialogInterface(android.content.DialogInterface) SavedGameAdapter(com.nolanlawson.keepscore.data.SavedGameAdapter) OnClickListener(android.view.View.OnClickListener) GameSummary(com.nolanlawson.keepscore.db.GameSummary) HashSet(java.util.HashSet)

Aggregations

SavedGameAdapter (com.nolanlawson.keepscore.data.SavedGameAdapter)7 GameSummary (com.nolanlawson.keepscore.db.GameSummary)5 TimePeriod (com.nolanlawson.keepscore.data.TimePeriod)2 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.view.View.OnClickListener)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1