use of android.widget.ArrayAdapter in project JamsMusicPlayer by psaravan.
the class EqualizerActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
//Context.
mContext = getApplicationContext();
mApp = (Common) mContext.getApplicationContext();
mFragment = this;
setTheme();
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_equalizer);
//Equalizer container elements.
mScrollView = (ScrollView) findViewById(R.id.equalizerScrollView);
mScrollView.setBackgroundColor(UIElementsHelper.getBackgroundColor(mContext));
//50Hz equalizer controls.
equalizer50HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer50Hz);
text50HzGainTextView = (TextView) findViewById(R.id.text50HzGain);
text50Hz = (TextView) findViewById(R.id.text50Hz);
//130Hz equalizer controls.
equalizer130HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer130Hz);
text130HzGainTextView = (TextView) findViewById(R.id.text130HzGain);
text130Hz = (TextView) findViewById(R.id.text130Hz);
//320Hz equalizer controls.
equalizer320HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer320Hz);
text320HzGainTextView = (TextView) findViewById(R.id.text320HzGain);
text320Hz = (TextView) findViewById(R.id.text320Hz);
//800Hz equalizer controls.
equalizer800HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer800Hz);
text800HzGainTextView = (TextView) findViewById(R.id.text800HzGain);
text800Hz = (TextView) findViewById(R.id.text800Hz);
//2kHz equalizer controls.
equalizer2kHzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer2kHz);
text2kHzGainTextView = (TextView) findViewById(R.id.text2kHzGain);
text2kHz = (TextView) findViewById(R.id.text2kHz);
//5kHz equalizer controls.
equalizer5kHzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer5kHz);
text5kHzGainTextView = (TextView) findViewById(R.id.text5kHzGain);
text5kHz = (TextView) findViewById(R.id.text5kHz);
//12.5kHz equalizer controls.
equalizer12_5kHzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer12_5kHz);
text12_5kHzGainTextView = (TextView) findViewById(R.id.text12_5kHzGain);
text12_5kHz = (TextView) findViewById(R.id.text12_5kHz);
//Equalizer preset controls.
loadPresetButton = (RelativeLayout) findViewById(R.id.loadPresetButton);
saveAsPresetButton = (RelativeLayout) findViewById(R.id.saveAsPresetButton);
resetAllButton = (RelativeLayout) findViewById(R.id.resetAllButton);
loadPresetText = (TextView) findViewById(R.id.load_preset_text);
savePresetText = (TextView) findViewById(R.id.save_as_preset_text);
resetAllText = (TextView) findViewById(R.id.reset_all_text);
//Audio FX elements.
virtualizerSeekBar = (SeekBar) findViewById(R.id.virtualizer_seekbar);
bassBoostSeekBar = (SeekBar) findViewById(R.id.bass_boost_seekbar);
reverbSpinner = (Spinner) findViewById(R.id.reverb_spinner);
virtualizerTitle = (TextView) findViewById(R.id.virtualizer_title_text);
bassBoostTitle = (TextView) findViewById(R.id.bass_boost_title_text);
reverbTitle = (TextView) findViewById(R.id.reverb_title_text);
text50HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
text130HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
text320HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
text800HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
text2kHzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
text5kHzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
text12_5kHzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
text50Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
text130Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
text320Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
text800Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
text2kHz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
text5kHz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
text12_5kHz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
loadPresetText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Bold"));
savePresetText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Bold"));
resetAllText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Bold"));
text50HzGainTextView.setPaintFlags(text50HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
text130HzGainTextView.setPaintFlags(text130HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
text320HzGainTextView.setPaintFlags(text320HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
text800HzGainTextView.setPaintFlags(text130HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
text2kHzGainTextView.setPaintFlags(text320HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
text5kHzGainTextView.setPaintFlags(text130HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
text12_5kHzGainTextView.setPaintFlags(text320HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
text50Hz.setPaintFlags(text50Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
text130Hz.setPaintFlags(text130Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
text320Hz.setPaintFlags(text320Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
text800Hz.setPaintFlags(text800Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
text2kHz.setPaintFlags(text2kHz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
text5kHz.setPaintFlags(text5kHz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
text12_5kHz.setPaintFlags(text12_5kHz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
loadPresetText.setPaintFlags(text50HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
savePresetText.setPaintFlags(text50HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
resetAllText.setPaintFlags(text50HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
text50HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
text130HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
text320HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
text800HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
text2kHzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
text5kHzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
text12_5kHzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
text50Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
text130Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
text320Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
text800Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
text2kHz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
text5kHz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
text12_5kHz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
//Init reverb presets.
ArrayList<String> reverbPresets = new ArrayList<String>();
reverbPresets.add("None");
reverbPresets.add("Large Hall");
reverbPresets.add("Large Room");
reverbPresets.add("Medium Hall");
reverbPresets.add("Medium Room");
reverbPresets.add("Small Room");
reverbPresets.add("Plate");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, reverbPresets);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
reverbSpinner.setAdapter(dataAdapter);
//Set the max values for the seekbars.
virtualizerSeekBar.setMax(1000);
bassBoostSeekBar.setMax(1000);
virtualizerTitle.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
virtualizerTitle.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
virtualizerTitle.setPaintFlags(virtualizerTitle.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
bassBoostTitle.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
bassBoostTitle.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
bassBoostTitle.setPaintFlags(bassBoostTitle.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
reverbTitle.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
reverbTitle.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
reverbTitle.setPaintFlags(reverbTitle.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
resetAllButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//Reset all sliders to 0.
equalizer50HzSeekBar.setProgressAndThumb(16);
equalizer130HzSeekBar.setProgressAndThumb(16);
equalizer320HzSeekBar.setProgressAndThumb(16);
equalizer800HzSeekBar.setProgressAndThumb(16);
equalizer2kHzSeekBar.setProgressAndThumb(16);
equalizer5kHzSeekBar.setProgressAndThumb(16);
equalizer12_5kHzSeekBar.setProgressAndThumb(16);
virtualizerSeekBar.setProgress(0);
bassBoostSeekBar.setProgress(0);
reverbSpinner.setSelection(0, false);
//Apply the new setings to the service.
applyCurrentEQSettings();
//Show a confirmation toast.
Toast.makeText(mContext, R.string.eq_reset, Toast.LENGTH_SHORT).show();
}
});
loadPresetButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
buildLoadPresetDialog().show();
}
});
saveAsPresetButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
buildSavePresetDialog().show();
}
});
equalizer50HzSeekBar.setOnSeekBarChangeListener(equalizer50HzListener);
equalizer130HzSeekBar.setOnSeekBarChangeListener(equalizer130HzListener);
equalizer320HzSeekBar.setOnSeekBarChangeListener(equalizer320HzListener);
equalizer800HzSeekBar.setOnSeekBarChangeListener(equalizer800HzListener);
equalizer2kHzSeekBar.setOnSeekBarChangeListener(equalizer2kHzListener);
equalizer5kHzSeekBar.setOnSeekBarChangeListener(equalizer5kHzListener);
equalizer12_5kHzSeekBar.setOnSeekBarChangeListener(equalizer12_5kHzListener);
virtualizerSeekBar.setOnSeekBarChangeListener(virtualizerListener);
bassBoostSeekBar.setOnSeekBarChangeListener(bassBoostListener);
reverbSpinner.setOnItemSelectedListener(reverbListener);
//Get the saved equalizer settings and apply them to the UI elements.
new AsyncInitSlidersTask().execute();
}
use of android.widget.ArrayAdapter in project JamsMusicPlayer by psaravan.
the class SettingsActivity____ method onCreate.
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
//Context.
mContext = this;
mSettingsActivity = this;
mApp = (Common) mContext.getApplicationContext();
//Initialize SharedPreferences.
sharedPreferences = this.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
//Set the UI theme.
if (mApp.getCurrentTheme() == Common.DARK_THEME) {
this.setTheme(R.style.AppThemeNoActionBar);
} else {
this.setTheme(R.style.AppThemeNoActionBarLight);
}
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
preferenceManager = this.getPreferenceManager();
//Retrieve the preferences based on their unique keys.
upgradePreference = preferenceManager.findPreference("preference_key_upgrade");
appThemePreference = preferenceManager.findPreference("preference_key_app_theme");
playerColorSchemePreference = preferenceManager.findPreference("preference_key_player_color_scheme");
trackChangeAnimationPreference = preferenceManager.findPreference("preference_key_track_change_animation");
defaultScreenPreference = preferenceManager.findPreference("preference_key_startup_screen");
artistsLayoutPreference = preferenceManager.findPreference("preference_key_artists_layout");
albumArtistsLayoutPreference = preferenceManager.findPreference("preference_key_album_artists_layout");
albumsLayoutPreference = preferenceManager.findPreference("preference_key_albums_layout");
lockscreenControlsPreference = preferenceManager.findPreference("preference_key_lockscreen_controls");
albumArtStylePreference = preferenceManager.findPreference("preference_key_album_art_style");
albumArtSourcesPreference = preferenceManager.findPreference("preference_key_album_art_sources");
albumArtScanDownloadPreference = preferenceManager.findPreference("preference_key_scan_download_album_art");
chooseGooglePlayMusicAccountPreference = preferenceManager.findPreference("preference_key_google_play_music_account");
getPinnedSongsPreference = preferenceManager.findPreference("preference_key_get_pinned_songs");
defaultFolderPreference = preferenceManager.findPreference("preference_key_default_folder");
addMusicLibraryPreference = preferenceManager.findPreference("preference_key_add_music_library");
editMusicLibraryPreference = preferenceManager.findPreference("preference_key_edit_music_library");
deleteMusicLibraryPreference = preferenceManager.findPreference("preference_key_delete_music_library");
selectFoldersPreference = preferenceManager.findPreference("preference_key_select_folders");
rescanFoldersPreference = preferenceManager.findPreference("preference_key_rescan_folders");
scanFrequencyPreference = preferenceManager.findPreference("preference_key_scan_frequency");
blacklistManagerPreference = preferenceManager.findPreference("preference_key_blacklist_manager");
unblacklistAllPreference = preferenceManager.findPreference("preference_key_unblacklist_all");
scrobblingPreference = preferenceManager.findPreference("preference_key_scrobbling");
headphonesUnplugActionPreference = preferenceManager.findPreference("preference_key_headphones_unplug_action");
crossfadeTracksPreference = preferenceManager.findPreference("preference_key_crossfade_tracks");
crossfadeTracksDurationPreference = preferenceManager.findPreference("preference_key_crossfade_tracks_duration");
equalizerPreference = preferenceManager.findPreference("preference_key_equalizer_toggle");
licensesPreference = preferenceManager.findPreference("preference_key_licenses");
contactUsPreference = preferenceManager.findPreference("preference_key_contact_us");
//Set the preference icons.
upgradePreference.setIcon(UIElementsHelper.getIcon(mContext, "checkmark"));
appThemePreference.setIcon(UIElementsHelper.getIcon(mContext, "color_palette"));
playerColorSchemePreference.setIcon(UIElementsHelper.getIcon(mContext, "color_palette_play"));
trackChangeAnimationPreference.setIcon(UIElementsHelper.getIcon(mContext, "customize_screens"));
defaultScreenPreference.setIcon(UIElementsHelper.getIcon(mContext, "default_screen"));
artistsLayoutPreference.setIcon(UIElementsHelper.getIcon(mContext, "mic"));
albumArtistsLayoutPreference.setIcon(UIElementsHelper.getIcon(mContext, "album_artists"));
albumsLayoutPreference.setIcon(UIElementsHelper.getIcon(mContext, "albums"));
lockscreenControlsPreference.setIcon(UIElementsHelper.getIcon(mContext, "lockscreen_controls"));
getPinnedSongsPreference.setIcon(UIElementsHelper.getIcon(mContext, "pin_settings"));
chooseGooglePlayMusicAccountPreference.setIcon(UIElementsHelper.getIcon(mContext, "accounts"));
addMusicLibraryPreference.setIcon(UIElementsHelper.getIcon(mContext, "add_new_library"));
editMusicLibraryPreference.setIcon(UIElementsHelper.getIcon(mContext, "edit_library"));
deleteMusicLibraryPreference.setIcon(UIElementsHelper.getIcon(mContext, "delete_library"));
albumArtStylePreference.setIcon(UIElementsHelper.getIcon(mContext, "cover_art_icon"));
albumArtSourcesPreference.setIcon(UIElementsHelper.getIcon(mContext, "album_art_source"));
albumArtScanDownloadPreference.setIcon(UIElementsHelper.getIcon(mContext, "auto_cover_fetch"));
defaultFolderPreference.setIcon(UIElementsHelper.getIcon(mContext, "folders_settings"));
selectFoldersPreference.setIcon(UIElementsHelper.getIcon(mContext, "folders_settings"));
rescanFoldersPreference.setIcon(UIElementsHelper.getIcon(mContext, "rescan"));
scanFrequencyPreference.setIcon(UIElementsHelper.getIcon(mContext, "scan_frequency"));
blacklistManagerPreference.setIcon(UIElementsHelper.getIcon(mContext, "manage_blacklists"));
unblacklistAllPreference.setIcon(UIElementsHelper.getIcon(mContext, "unblacklist_all"));
scrobblingPreference.setIcon(UIElementsHelper.getIcon(mContext, "scrobbling"));
headphonesUnplugActionPreference.setIcon(UIElementsHelper.getIcon(mContext, "headphones"));
crossfadeTracksPreference.setIcon(UIElementsHelper.getIcon(mContext, "crossfade_tracks"));
crossfadeTracksDurationPreference.setIcon(UIElementsHelper.getIcon(mContext, "crossfade_tracks_duration"));
equalizerPreference.setIcon(UIElementsHelper.getIcon(mContext, "equalizer_settings"));
licensesPreference.setIcon(UIElementsHelper.getIcon(mContext, "licenses"));
contactUsPreference.setIcon(UIElementsHelper.getIcon(mContext, "contact_us"));
if (sharedPreferences.getBoolean("TRIAL", true) == false) {
PreferenceScreen screen = getPreferenceScreen();
PreferenceCategory upgradePrefCategory = (PreferenceCategory) preferenceManager.findPreference("upgrade_pref_category");
screen.removePreference(upgradePrefCategory);
}
upgradePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
//initInAppBilling();
Intent intent = new Intent(mContext, com.jams.music.player.LauncherActivity.LauncherActivity.class);
intent.putExtra("UPGRADE", true);
startActivity(intent);
finish();
return false;
}
});
//Set click listeners on each preference.
appThemePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
Intent intent = new Intent(mContext, PreferenceDialogLauncherActivity.class);
intent.putExtra("INDEX", 0);
startActivity(intent);
return false;
}
});
playerColorSchemePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
Intent intent = new Intent(mContext, PreferenceDialogLauncherActivity.class);
intent.putExtra("INDEX", 1);
startActivity(intent);
return false;
}
});
trackChangeAnimationPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
int selectedIndex = sharedPreferences.getInt("TRACK_CHANGE_ANIMATION", 0);
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(R.string.track_change_animation);
View layoutView = mSettingsActivity.getLayoutInflater().inflate(R.layout.generic_message_listview_dialog_layout, null);
TextView message = (TextView) layoutView.findViewById(R.id.generic_message);
ListView listView = (ListView) layoutView.findViewById(R.id.generic_listview);
message.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
message.setPaintFlags(message.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
message.setText(R.string.track_change_animation_info);
String[] values = { mSettingsActivity.getResources().getString(R.string.slide_away), mSettingsActivity.getResources().getString(R.string.zoom_out_and_slide_away), mSettingsActivity.getResources().getString(R.string.depth_transformer) };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(mSettingsActivity, android.R.layout.simple_list_item_single_choice, android.R.id.text1, values);
listView.setAdapter(adapter);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setItemChecked(selectedIndex, true);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int which, long arg3) {
Toast.makeText(mContext, R.string.changes_saved, Toast.LENGTH_SHORT).show();
sharedPreferences.edit().putInt("TRACK_CHANGE_ANIMATION", which).commit();
mTrackChangeAnimationDialog.dismiss();
}
});
builder.setView(layoutView);
mTrackChangeAnimationDialog = builder.create();
mTrackChangeAnimationDialog.show();
return false;
}
});
defaultScreenPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
//Get the current preference.
int currentPreference = sharedPreferences.getInt("STARTUP_SCREEN", 0);
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
//builder.setTitle(R.string.startup_screen);
builder.setSingleChoiceItems(R.array.startup_screen_items, currentPreference, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
sharedPreferences.edit().putInt("STARTUP_SCREEN", which).commit();
dialog.dismiss();
Toast.makeText(mContext, R.string.changes_saved, Toast.LENGTH_SHORT).show();
}
});
builder.create().show();
return false;
}
});
artistsLayoutPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
//Get the current preference.
int currentPreference = sharedPreferences.getInt("ARTISTS_LAYOUT_PREF", 0);
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(R.string.artists_layout);
builder.setSingleChoiceItems(R.array.layout_preference_items, currentPreference, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
sharedPreferences.edit().putInt("ARTISTS_LAYOUT_PREF", which).commit();
dialog.dismiss();
Toast.makeText(mContext, R.string.changes_saved, Toast.LENGTH_SHORT).show();
}
});
builder.create().show();
return false;
}
});
albumArtistsLayoutPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
//Get the current preference.
int currentPreference = sharedPreferences.getInt("ALBUM_ARTISTS_LAYOUT_PREF", 0);
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(R.string.album_artists_layout);
builder.setSingleChoiceItems(R.array.layout_preference_items, currentPreference, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
sharedPreferences.edit().putInt("ALBUM_ARTISTS_LAYOUT_PREF", which).commit();
dialog.dismiss();
Toast.makeText(mContext, R.string.changes_saved, Toast.LENGTH_SHORT).show();
}
});
builder.create().show();
return false;
}
});
albumsLayoutPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
//Get the current preference.
int currentPreference = sharedPreferences.getInt("ALBUMS_LAYOUT_PREF", 0);
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(R.string.albums_layout);
builder.setSingleChoiceItems(R.array.layout_preference_items, currentPreference, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
sharedPreferences.edit().putInt("ALBUMS_LAYOUT_PREF", which).commit();
dialog.dismiss();
Toast.makeText(mContext, R.string.changes_saved, Toast.LENGTH_SHORT).show();
}
});
builder.create().show();
return false;
}
});
lockscreenControlsPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
//Get the current preference.
int currentPreference = sharedPreferences.getInt(Common.SHOW_LOCKSCREEN_CONTROLS, 0);
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
//builder.setTitle(R.string.lockscreen_controls);
builder.setSingleChoiceItems(R.array.enable_disable, currentPreference, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
sharedPreferences.edit().putInt(Common.SHOW_LOCKSCREEN_CONTROLS, which).commit();
dialog.dismiss();
//Enable/disable the lockscreen controls for this session.
try {
if (which == 0) {
Toast.makeText(mContext, R.string.changes_saved, Toast.LENGTH_SHORT).show();
if (sharedPreferences.getBoolean("SERVICE_RUNNING", false) == true) {
mApp.getService().initRemoteControlClient();
mApp.getService().updateRemoteControlClients(mApp.getService().getCurrentSong());
}
} else if (which == 1) {
if (sharedPreferences.getBoolean("SERVICE_RUNNING", false) == true) {
Toast.makeText(mContext, R.string.lockscreen_controls_disabled_next_run, Toast.LENGTH_LONG).show();
} else {
Toast.makeText(mContext, R.string.changes_saved, Toast.LENGTH_SHORT).show();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
builder.create().show();
return false;
}
});
defaultFolderPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(R.string.default_folder_for_folders_view);
builder.setMessage(R.string.default_folder_for_folders_view_info);
builder.setPositiveButton(R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
return false;
}
});
chooseGooglePlayMusicAccountPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
final AccountManager accountManager = AccountManager.get(mContext);
final Account[] accounts = accountManager.getAccounts();
final int size = accounts.length;
final String[] accountNames = new String[size + 1];
accountNames[0] = "Don't use Google Play Music";
//Create a new array with a list of all account names on the device.
for (int i = 0; i < accounts.length; i++) {
accountNames[i + 1] = accounts[i].name;
}
//Get the current account name (if it exists) and get the index of the account name.
String currentAccountName = sharedPreferences.getString("GOOGLE_PLAY_MUSIC_ACCOUNT", "");
int accountIndex = -1;
if (!currentAccountName.isEmpty()) {
for (int i = 0; i < accounts.length; i++) {
if (currentAccountName.equals(accountNames[i + 1])) {
accountIndex = i + 1;
}
}
} else {
accountIndex = 0;
}
//Display a list of all accounts that are currently on the device.
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(R.string.select_google_account);
builder.setSingleChoiceItems(accountNames, accountIndex, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int position) {
if (position != 0) {
//Start the sign-in process.
Toast.makeText(mContext, R.string.signing_in_dot_dot_dot, Toast.LENGTH_SHORT).show();
sharedPreferences.edit().putString("GOOGLE_PLAY_MUSIC_ACCOUNT", accountNames[position]).commit();
AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask(mContext.getApplicationContext(), mSettingsActivity, false, accountNames[position]);
task.execute();
} else {
Toast.makeText(mContext, R.string.google_play_music_disabled, Toast.LENGTH_SHORT).show();
sharedPreferences.edit().putBoolean("GOOGLE_PLAY_MUSIC_ENABLED", false).commit();
sharedPreferences.edit().putString("GOOGLE_PLAY_MUSIC_ACCOUNT", "").commit();
//Restart the app.
final Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
startActivity(i);
}
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
return false;
}
});
getPinnedSongsPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
mApp.queueSongsToPin(true, false, null);
return false;
}
});
addMusicLibraryPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
Intent intent = new Intent(mContext, PreferenceDialogLauncherActivity.class);
intent.putExtra("INDEX", 13);
startActivity(intent);
return false;
}
});
editMusicLibraryPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(mContext, PreferenceDialogLauncherActivity.class);
intent.putExtra("INDEX", 14);
intent.putExtra("OPERATION", "EDIT");
startActivity(intent);
return false;
}
});
deleteMusicLibraryPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
Intent intent = new Intent(mContext, PreferenceDialogLauncherActivity.class);
intent.putExtra("INDEX", 14);
intent.putExtra("OPERATION", "DELETE");
startActivity(intent);
return false;
}
});
albumArtStylePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
Intent intent = new Intent(mContext, PreferenceDialogLauncherActivity.class);
intent.putExtra("INDEX", 3);
startActivity(intent);
return false;
}
});
albumArtSourcesPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
Intent intent = new Intent(mContext, PreferenceDialogLauncherActivity.class);
intent.putExtra("INDEX", 4);
startActivity(intent);
return false;
}
});
albumArtScanDownloadPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
//Start the service that will download album art.
mContext.startService(new Intent(mContext, AutoFetchAlbumArtService.class));
return false;
}
});
selectFoldersPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
Intent intent = new Intent(mContext, PreferenceDialogLauncherActivity.class);
intent.putExtra("INDEX", 5);
startActivity(intent);
return false;
}
});
rescanFoldersPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
//Seting the "REBUILD_LIBRARY" flag to true will force MainActivity to rescan the folders.
sharedPreferences.edit().putBoolean("REBUILD_LIBRARY", true).commit();
//Restart the app.
final Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
startActivity(i);
return false;
}
});
scanFrequencyPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
Intent intent = new Intent(mContext, PreferenceDialogLauncherActivity.class);
intent.putExtra("INDEX", 7);
startActivity(intent);
return false;
}
});
blacklistManagerPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
/* Intent intent = new Intent(mContext, PreferenceDialogLauncherActivity.class);
intent.putExtra("INDEX", 8);
startActivity(intent);*/
/*String[] blacklistManagerChoices = { mContext.getResources().getString(R.string.manage_blacklisted_artists),
mContext.getResources().getString(R.string.manage_blacklisted_albums),
mContext.getResources().getString(R.string.manage_blacklisted_songs),
mContext.getResources().getString(R.string.manage_blacklisted_playlists) };
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
//Set the dialog title.
builder.setTitle(R.string.blacklist_manager);
builder.setItems(blacklistManagerChoices, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Bundle bundle = new Bundle();
if (which==0) {
bundle.putString("MANAGER_TYPE", "ARTISTS");
} else if (which==1) {
bundle.putString("MANAGER_TYPE", "ALBUMS");
} else if (which==2) {
bundle.putString("MANAGER_TYPE", "SONGS");
} else if (which==3) {
bundle.putString("MANAGER_TYPE", "PLAYLISTS");
}
dialog.dismiss();
Intent intent = new Intent(mContext, BlacklistManagerActivity.class);
intent.putExtras(bundle);
startActivity(intent);
}
});
builder.create().show();*/
Intent intent = new Intent(mContext, BlacklistManagerActivity.class);
startActivity(intent);
return false;
}
});
unblacklistAllPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
AsyncUnblacklistAllSongsTask task = new AsyncUnblacklistAllSongsTask();
task.execute();
return false;
}
});
/* bluetoothControlsPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
// TODO Auto-generated method stub
return false;
}
});
headphonesUnplugActionPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
// TODO Auto-generated method stub
return false;
}
});*/
scrobblingPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
int currentSelection = 0;
if (sharedPreferences.getInt("SCROBBLING", 0) == 0) {
currentSelection = 0;
} else if (sharedPreferences.getInt("SCROBBLING", 0) == 1) {
currentSelection = 1;
} else if (sharedPreferences.getInt("SCROBBLING", 0) == 2) {
currentSelection = 2;
}
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(R.string.scrobbling);
builder.setSingleChoiceItems(R.array.scrobbling_options, currentSelection, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Toast.makeText(mContext, R.string.changes_saved, Toast.LENGTH_SHORT).show();
sharedPreferences.edit().putInt("SCROBBLING", which).commit();
}
});
builder.create().show();
return false;
}
});
headphonesUnplugActionPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
//Get the current selection.
int currentSelection;
if (sharedPreferences.getString("UNPLUG_ACTION", "DO_NOTHING").equals("DO_NOTHING")) {
currentSelection = 0;
} else {
currentSelection = 1;
}
String[] unplugActionsArray = mContext.getResources().getStringArray(R.array.headphones_unplug_actions);
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(R.string.headphones_unplug_action);
builder.setSingleChoiceItems(unplugActionsArray, currentSelection, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Toast.makeText(mContext, R.string.changes_saved, Toast.LENGTH_SHORT).show();
if (which == 0) {
sharedPreferences.edit().putString("UNPLUG_ACTION", "DO_NOTHING").commit();
if (sharedPreferences.getBoolean("SERVICE_RUNNING", false) == true) {
mApp.getService().unregisterReceiver(mApp.getService().getHeadsetPlugReceiver());
}
} else {
sharedPreferences.edit().putString("UNPLUG_ACTION", "PAUSE_MUSIC_PLAYBACK").commit();
if (sharedPreferences.getBoolean("SERVICE_RUNNING", false) == true) {
mApp.getService().registerHeadsetPlugReceiver();
}
}
}
});
builder.create().show();
return false;
}
});
crossfadeTracksPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
int currentSelection;
if (sharedPreferences.getBoolean(Common.CROSSFADE_ENABLED, false) == true) {
currentSelection = 0;
} else {
currentSelection = 1;
}
String[] enableDisableArray = mContext.getResources().getStringArray(R.array.enable_disable);
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(R.string.crossfade_tracks);
builder.setSingleChoiceItems(enableDisableArray, currentSelection, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Toast.makeText(mContext, R.string.changes_saved, Toast.LENGTH_SHORT).show();
if (which == 0) {
sharedPreferences.edit().putBoolean(Common.CROSSFADE_ENABLED, true).commit();
//Enable crossfade for the current queue.
if (mApp.isServiceRunning() && mApp.getService().getHandler() != null) {
mApp.getService().getHandler().post(mApp.getService().startCrossFadeRunnable);
}
} else {
sharedPreferences.edit().putBoolean(Common.CROSSFADE_ENABLED, false).commit();
//Disable crossfade for the current queue.
if (mApp.isServiceRunning() && mApp.getService().getHandler() != null) {
mApp.getService().getHandler().removeCallbacks(mApp.getService().startCrossFadeRunnable);
mApp.getService().getHandler().removeCallbacks(mApp.getService().crossFadeRunnable);
}
}
}
});
builder.create().show();
return false;
}
});
crossfadeTracksDurationPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
AlertDialog.Builder builder = new AlertDialog.Builder(mSettingsActivity);
builder.setTitle(R.string.crossfade_duration);
RelativeLayout dialogView = (RelativeLayout) mSettingsActivity.getLayoutInflater().inflate(R.layout.dialog_crossfade_duration, null);
final TextView durationText = (TextView) dialogView.findViewById(R.id.crossfade_duration_text);
final SeekBar durationSeekBar = (SeekBar) dialogView.findViewById(R.id.crossfade_duration_seekbar);
int currentSeekBarDuration = sharedPreferences.getInt(Common.CROSSFADE_DURATION, 5);
durationSeekBar.setMax(14);
durationSeekBar.setProgress(currentSeekBarDuration);
durationText.setText(currentSeekBarDuration + " secs");
durationSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
sharedPreferences.edit().putInt(Common.CROSSFADE_DURATION, (progress + 1)).commit();
durationText.setText((progress + 1) + " secs");
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
});
builder.setView(dialogView);
builder.setPositiveButton(R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int arg1) {
dialog.dismiss();
Toast.makeText(mContext, R.string.changes_saved, Toast.LENGTH_SHORT).show();
}
});
builder.create().show();
return false;
}
});
equalizerPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
boolean currentSetting = sharedPreferences.getBoolean("EQUALIZER_ENABLED", true);
int intCurrentSetting = -1;
if (currentSetting == true)
intCurrentSetting = 0;
else
intCurrentSetting = 1;
AlertDialog.Builder builder = new AlertDialog.Builder(mSettingsActivity);
builder.setTitle(R.string.equalizer);
builder.setSingleChoiceItems(R.array.enable_disable, intCurrentSetting, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
boolean isEnabled;
if (which == 0)
isEnabled = true;
else
isEnabled = false;
sharedPreferences.edit().putBoolean("EQUALIZER_ENABLED", isEnabled).commit();
Toast.makeText(mContext, R.string.changes_saved, Toast.LENGTH_SHORT).show();
if (Build.PRODUCT.contains("HTC") && which == 0) {
showHTCEqualizerIssueDialog();
}
if (sharedPreferences.getBoolean("SERVICE_RUNNING", false) == true && which == 0) {
mApp.getService().initAudioFX();
} else if (sharedPreferences.getBoolean("SERVICE_RUNNING", false) == true && which == 1) {
try {
mApp.getService().getEqualizerHelper().releaseEQObjects();
} catch (Exception e) {
e.printStackTrace();
}
}
dialog.dismiss();
}
private void showHTCEqualizerIssueDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(R.string.htc_devices);
builder.setMessage(R.string.htc_devices_equalizer_issue);
builder.setPositiveButton(R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
});
builder.create().show();
return false;
}
});
licensesPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
Intent intent = new Intent(mContext, PreferenceDialogLauncherActivity.class);
intent.putExtra("INDEX", 12);
startActivity(intent);
return false;
}
});
contactUsPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "jamsmusicplayer@gmail.com", null));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Jams Music Player Support");
startActivity(Intent.createChooser(emailIntent, "Send email"));
return false;
}
});
}
use of android.widget.ArrayAdapter in project FlatUI by eluleci.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// converts the default values to dp to be compatible with different screen sizes
FlatUI.initDefaultValues(this);
// Default theme should be set before content view is added
FlatUI.setDefaultTheme(APP_THEME);
setContentView(R.layout.activity_main);
// Getting action bar background and applying it
getSupportActionBar().setBackgroundDrawable(FlatUI.getActionBarDrawable(this, APP_THEME, false, 2));
// titles
flatTextViews.add((FlatTextView) findViewById(R.id.title_edittexts));
flatTextViews.add((FlatTextView) findViewById(R.id.title_seekbar));
flatTextViews.add((FlatTextView) findViewById(R.id.title_buttons));
flatTextViews.add((FlatTextView) findViewById(R.id.title_buttons_shape));
flatTextViews.add((FlatTextView) findViewById(R.id.title_buttons_text_appearance));
flatTextViews.add((FlatTextView) findViewById(R.id.title_buttons_touch_effect));
flatTextViews.add((FlatTextView) findViewById(R.id.title_checkbox));
flatTextViews.add((FlatTextView) findViewById(R.id.title_checkbox_enabled));
flatTextViews.add((FlatTextView) findViewById(R.id.title_checkbox_disabled));
flatTextViews.add((FlatTextView) findViewById(R.id.title_radiobutton));
flatTextViews.add((FlatTextView) findViewById(R.id.title_radiobutton_enabled));
flatTextViews.add((FlatTextView) findViewById(R.id.title_radiobutton_disabled));
flatTextViews.add((FlatTextView) findViewById(R.id.title_toggle_button));
flatTextViews.add((FlatTextView) findViewById(R.id.title_toggle_enabled));
flatTextViews.add((FlatTextView) findViewById(R.id.title_toggle_disabled));
flatTextViews.add((FlatTextView) findViewById(R.id.title_themes));
flatTextViews.add((FlatTextView) findViewById(R.id.title_themes_note));
// edit texts
flatEditTexts.add((FlatEditText) findViewById(R.id.edittext_flat));
flatEditTexts.add((FlatEditText) findViewById(R.id.edittext_box));
flatEditTexts.add((FlatEditText) findViewById(R.id.edittext_transparentbox));
flatEditTexts.add((FlatEditText) findViewById(R.id.edittext_transparent));
// buttons
flatButtons.add((FlatButton) findViewById(R.id.button_block));
flatButtons.add((FlatButton) findViewById(R.id.button_flat));
flatButtons.add((FlatButton) findViewById(R.id.button_light));
flatButtons.add((FlatButton) findViewById(R.id.button_white));
flatButtons.add((FlatButton) findViewById(R.id.button_dark_text));
flatButtons.add((FlatButton) findViewById(R.id.button_ease));
flatButtons.add((FlatButton) findViewById(R.id.button_ripple));
// check boxes
flatCheckBoxes.add((FlatCheckBox) findViewById(R.id.checkbox_unchecked_enabled));
flatCheckBoxes.add((FlatCheckBox) findViewById(R.id.checkbox_checked_enabled));
flatCheckBoxes.add((FlatCheckBox) findViewById(R.id.checkbox_unchecked_disabled));
flatCheckBoxes.add((FlatCheckBox) findViewById(R.id.checkbox_checked_disabled));
// radio buttons
flatRadioButtons.add((FlatRadioButton) findViewById(R.id.radio_unchecked_enabled));
flatRadioButtons.add((FlatRadioButton) findViewById(R.id.radio_unchecked_disabled));
flatRadioButtons.add((FlatRadioButton) findViewById(R.id.radio_checked_disabled));
radioCheckedEnabled = (FlatRadioButton) findViewById(R.id.radio_checked_enabled);
flatRadioButtons.add(radioCheckedEnabled);
radioCheckedEnabled.setChecked(true);
// toggle buttons
flatToggleButtons.add((FlatToggleButton) findViewById(R.id.toggle_unchecked_enabled));
flatToggleButtons.add((FlatToggleButton) findViewById(R.id.toggle_checked_enabled));
flatToggleButtons.add((FlatToggleButton) findViewById(R.id.toggle_unchecked_disabled));
flatToggleButtons.add((FlatToggleButton) findViewById(R.id.toggle_checked_disabled));
flatSeekBar = (FlatSeekBar) findViewById(R.id.seekbar);
flatSeekBar.setProgress(30);
flatSeekBar.setSecondaryProgress(40);
/**
* This part is an example of spinner usage. You can change the theme of this spinner by
* editing the layout files spinner_button and simple_flat_list_item.
*/
Spinner spinner = (Spinner) findViewById(R.id.themes_spinner);
// Create an ArrayAdapter using the string array and a custom spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.themes_array, R.layout.spinner_button);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(R.layout.simple_flat_list_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// preventing the spinner to change the theme on start
if (!isSpinnerSelectedBefore) {
isSpinnerSelectedBefore = true;
return;
}
int themeReference = APP_THEME;
switch(position) {
case 0:
themeReference = FlatUI.SAND;
break;
case 1:
themeReference = FlatUI.ORANGE;
break;
case 2:
themeReference = FlatUI.CANDY;
break;
case 3:
themeReference = FlatUI.BLOSSOM;
break;
case 4:
themeReference = FlatUI.GRAPE;
break;
case 5:
themeReference = FlatUI.DEEP;
break;
case 6:
themeReference = FlatUI.SKY;
break;
case 7:
themeReference = FlatUI.GRASS;
break;
case 8:
themeReference = FlatUI.DARK;
break;
case 9:
themeReference = FlatUI.SNOW;
break;
case 10:
themeReference = FlatUI.SEA;
break;
case 11:
themeReference = FlatUI.BLOOD;
break;
}
changeTheme(themeReference);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
/**
* Autocomplete textview. You can change the EditText color via theme but
* you need to set a layout for the rows as shown below. This is the same
* row that is used in the spinner example.
*/
AutoCompleteTextView actv = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
String[] themes = getResources().getStringArray(R.array.themes_array);
ArrayAdapter acAdapter = new ArrayAdapter(this, R.layout.simple_flat_list_item, themes);
actv.setAdapter(acAdapter);
}
use of android.widget.ArrayAdapter in project cw-omnibus by commonsguy.
the class ContactSpinners method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Spinner spin = (Spinner) findViewById(R.id.spinner);
spin.setOnItemSelectedListener(this);
ArrayAdapter<String> aa = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.options));
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(aa);
}
use of android.widget.ArrayAdapter in project cw-advandroid by commonsguy.
the class ActionModeDemo method performActions.
@SuppressWarnings("unchecked")
public boolean performActions(MenuItem item) {
ArrayAdapter<String> adapter = (ArrayAdapter<String>) getListAdapter();
SparseBooleanArray checked = getListView().getCheckedItemPositions();
switch(item.getItemId()) {
case R.id.cap:
for (int i = 0; i < checked.size(); i++) {
if (checked.valueAt(i)) {
int position = checked.keyAt(i);
String word = words.get(position);
word = word.toUpperCase();
adapter.remove(words.get(position));
adapter.insert(word, position);
}
}
return (true);
case R.id.remove:
ArrayList<Integer> positions = new ArrayList<Integer>();
for (int i = 0; i < checked.size(); i++) {
if (checked.valueAt(i)) {
positions.add(checked.keyAt(i));
}
}
Collections.sort(positions, Collections.reverseOrder());
for (int position : positions) {
adapter.remove(words.get(position));
}
getListView().clearChoices();
return (true);
}
return (false);
}
Aggregations