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;
}
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();
}
Aggregations