Search in sources :

Example 1 with TextWithDeleteAdapter

use of com.nolanlawson.keepscore.data.TextWithDeleteAdapter in project KeepScore by nolanlawson.

the class SettingsActivity method createAvailableSettingSetsAdapter.

private TextWithDeleteAdapter createAvailableSettingSetsAdapter() {
    List<String> availableSettingSets = new ArrayList<String>(SettingSetHelper.getAvailableSettingSets(this));
    Collections.sort(availableSettingSets);
    final TextWithDeleteAdapter adapter = new TextWithDeleteAdapter(this, availableSettingSets);
    adapter.setOnDeleteListener(new OnDeleteListener() {

        @Override
        public void onDelete(final String settingSetName) {
            onDeleteSettingSet(adapter, settingSetName);
        }
    });
    return adapter;
}
Also used : ArrayList(java.util.ArrayList) OnDeleteListener(com.nolanlawson.keepscore.data.TextWithDeleteAdapter.OnDeleteListener) TextWithDeleteAdapter(com.nolanlawson.keepscore.data.TextWithDeleteAdapter)

Example 2 with TextWithDeleteAdapter

use of com.nolanlawson.keepscore.data.TextWithDeleteAdapter in project KeepScore by nolanlawson.

the class SettingsActivity method loadSettings.

private void loadSettings() {
    Set<String> settingSets = SettingSetHelper.getAvailableSettingSets(this);
    if (settingSets.isEmpty()) {
        ToastHelper.showShort(this, R.string.toast_no_saved_settings);
        return;
    }
    // TODO: figure out why I can't get the AlertDialog to make the items themselves clickable
    final TextWithDeleteAdapter availableSetAdapter = createAvailableSettingSetsAdapter();
    final AlertDialog dialog = new AlertDialog.Builder(this).setCancelable(true).setTitle(R.string.pref_load_settings_name).setNegativeButton(android.R.string.cancel, null).setAdapter(availableSetAdapter, null).create();
    Callback<Integer> onClickListener = new Callback<Integer>() {

        @Override
        public void onCallback(Integer which) {
            showSavedSettingSetDialog((String) availableSetAdapter.getItem(which), new Runnable() {

                @Override
                public void run() {
                    dialog.dismiss();
                }
            });
        }
    };
    availableSetAdapter.setOnItemClickedListener(onClickListener);
    dialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) Callback(com.nolanlawson.keepscore.util.Callback) TextWithDeleteAdapter(com.nolanlawson.keepscore.data.TextWithDeleteAdapter)

Aggregations

TextWithDeleteAdapter (com.nolanlawson.keepscore.data.TextWithDeleteAdapter)2 AlertDialog (android.app.AlertDialog)1 OnDeleteListener (com.nolanlawson.keepscore.data.TextWithDeleteAdapter.OnDeleteListener)1 Callback (com.nolanlawson.keepscore.util.Callback)1 ArrayList (java.util.ArrayList)1