/** Initiates the list of all assigned Presets. */ protected void refresh() { final List<IPreset> presetsList = new ArrayList<IPreset>(); /* Only add undeleted presets to the list. */ for (IPreset preset : this.app.getAssignedPresets()) { if (!preset.isDeleted()) { presetsList.add(preset); } } AdapterPresets presetsAdapter = new AdapterPresets(getApplicationContext(), presetsList); ListView presetListView = (ListView) findViewById(R.id.ListView_Presets); presetListView.setAdapter(presetsAdapter); presetListView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapter, View view, int position, long arg3) { openPreset(presetsList.get(position)); } }); /* Determine if the Presets-List is empty, and display a text instead. */ TextView tv = (TextView) findViewById(R.id.TextView_NoPresets); if (presetsList.size() > 0) { tv.setVisibility(View.GONE); } else { tv.setVisibility(View.VISIBLE); } }
/** * Open the PresetActivity for one Preset * * @param preset Preset to open */ public void openPreset(IPreset preset) { Intent i = new Intent(TabPresets.this, ActivityPreset.class); i.putExtra(GUIConstants.PRESET_IDENTIFIER, preset.getLocalIdentifier()); startActivity(i); }