List of usage examples for android.widget Spinner setAdapter
@Override public void setAdapter(SpinnerAdapter adapter)
From source file:com.matthewmitchell.peercoin_android_wallet.ui.WalletActivity.java
private Dialog createRestoreWalletDialog() { final View view = getLayoutInflater().inflate(R.layout.restore_wallet_dialog, null); final Spinner fileView = (Spinner) view.findViewById(R.id.import_keys_from_storage_file); final EditText passwordView = (EditText) view.findViewById(R.id.import_keys_from_storage_password); final DialogBuilder dialog = new DialogBuilder(this); dialog.setTitle(R.string.import_keys_dialog_title); dialog.setView(view);/*from w w w . jav a2 s .c om*/ dialog.setPositiveButton(R.string.import_keys_dialog_button_import, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { final File file = (File) fileView.getSelectedItem(); final String password = passwordView.getText().toString().trim(); passwordView.setText(null); // get rid of it asap if (WalletUtils.BACKUP_FILE_FILTER.accept(file)) restoreWalletFromProtobuf(file, CloseAction.CLOSE_RECREATE); else if (WalletUtils.KEYS_FILE_FILTER.accept(file)) restorePrivateKeysFromBase58(file, CloseAction.CLOSE_RECREATE); else if (Crypto.OPENSSL_FILE_FILTER.accept(file)) restoreWalletFromEncrypted(file, password, CloseAction.CLOSE_RECREATE); } }); dialog.setNegativeButton(R.string.button_cancel, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { passwordView.setText(null); // get rid of it asap } }); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(final DialogInterface dialog) { passwordView.setText(null); // get rid of it asap } }); final FileAdapter adapter = new FileAdapter(this) { @Override public View getDropDownView(final int position, View row, final ViewGroup parent) { final File file = getItem(position); final boolean isExternal = Constants.Files.EXTERNAL_WALLET_BACKUP_DIR.equals(file.getParentFile()); final boolean isEncrypted = Crypto.OPENSSL_FILE_FILTER.accept(file); if (row == null) row = inflater.inflate(R.layout.restore_wallet_file_row, null); final TextView filenameView = (TextView) row .findViewById(R.id.wallet_import_keys_file_row_filename); filenameView.setText(file.getName()); final TextView securityView = (TextView) row .findViewById(R.id.wallet_import_keys_file_row_security); final String encryptedStr = context .getString(isEncrypted ? R.string.import_keys_dialog_file_security_encrypted : R.string.import_keys_dialog_file_security_unencrypted); final String storageStr = context .getString(isExternal ? R.string.import_keys_dialog_file_security_external : R.string.import_keys_dialog_file_security_internal); securityView.setText(encryptedStr + ", " + storageStr); final TextView createdView = (TextView) row.findViewById(R.id.wallet_import_keys_file_row_created); createdView.setText(context.getString( isExternal ? R.string.import_keys_dialog_file_created_manual : R.string.import_keys_dialog_file_created_automatic, DateUtils.getRelativeTimeSpanString(context, file.lastModified(), true))); return row; } }; fileView.setAdapter(adapter); return dialog.create(); }
From source file:biz.bokhorst.xprivacy.ActivityShare.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Check privacy service client if (!PrivacyService.checkClient()) return;//from www.j a v a 2 s . co m // Get data int userId = Util.getUserId(Process.myUid()); final Bundle extras = getIntent().getExtras(); final String action = getIntent().getAction(); final int[] uids = (extras != null && extras.containsKey(cUidList) ? extras.getIntArray(cUidList) : new int[0]); final String restrictionName = (extras != null ? extras.getString(cRestriction) : null); int choice = (extras != null && extras.containsKey(cChoice) ? extras.getInt(cChoice) : -1); if (action.equals(ACTION_EXPORT)) mFileName = (extras != null && extras.containsKey(cFileName) ? extras.getString(cFileName) : null); // License check if (action.equals(ACTION_IMPORT) || action.equals(ACTION_EXPORT)) { if (!Util.isProEnabled() && Util.hasProLicense(this) == null) { Util.viewUri(this, ActivityMain.cProUri); finish(); return; } } else if (action.equals(ACTION_FETCH) || (action.equals(ACTION_TOGGLE) && uids.length > 1)) { if (Util.hasProLicense(this) == null) { Util.viewUri(this, ActivityMain.cProUri); finish(); return; } } // Registration check if (action.equals(ACTION_SUBMIT) && !registerDevice(this)) { finish(); return; } // Check whether we need a user interface if (extras != null && extras.containsKey(cInteractive) && extras.getBoolean(cInteractive, false)) mInteractive = true; // Set layout setContentView(R.layout.sharelist); setSupportActionBar((Toolbar) findViewById(R.id.widgetToolbar)); // Reference controls final TextView tvDescription = (TextView) findViewById(R.id.tvDescription); final ScrollView svToggle = (ScrollView) findViewById(R.id.svToggle); final RadioGroup rgToggle = (RadioGroup) findViewById(R.id.rgToggle); final Spinner spRestriction = (Spinner) findViewById(R.id.spRestriction); RadioButton rbClear = (RadioButton) findViewById(R.id.rbClear); RadioButton rbTemplateFull = (RadioButton) findViewById(R.id.rbTemplateFull); RadioButton rbODEnable = (RadioButton) findViewById(R.id.rbEnableOndemand); RadioButton rbODDisable = (RadioButton) findViewById(R.id.rbDisableOndemand); final Spinner spTemplate = (Spinner) findViewById(R.id.spTemplate); final CheckBox cbClear = (CheckBox) findViewById(R.id.cbClear); final Button btnOk = (Button) findViewById(R.id.btnOk); final Button btnCancel = (Button) findViewById(R.id.btnCancel); // Set title if (action.equals(ACTION_TOGGLE)) { mActionId = R.string.menu_toggle; getSupportActionBar().setSubtitle(R.string.menu_toggle); } else if (action.equals(ACTION_IMPORT)) { mActionId = R.string.menu_import; getSupportActionBar().setSubtitle(R.string.menu_import); } else if (action.equals(ACTION_EXPORT)) { mActionId = R.string.menu_export; getSupportActionBar().setSubtitle(R.string.menu_export); } else if (action.equals(ACTION_FETCH)) { mActionId = R.string.menu_fetch; getSupportActionBar().setSubtitle(R.string.menu_fetch); } else if (action.equals(ACTION_SUBMIT)) { mActionId = R.string.menu_submit; getSupportActionBar().setSubtitle(R.string.menu_submit); } else { finish(); return; } // Get localized restriction name List<String> listRestrictionName = new ArrayList<String>( PrivacyManager.getRestrictions(this).navigableKeySet()); listRestrictionName.add(0, getString(R.string.menu_all)); // Build restriction adapter SpinnerAdapter saRestriction = new SpinnerAdapter(this, android.R.layout.simple_spinner_item); saRestriction.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); saRestriction.addAll(listRestrictionName); // Setup restriction spinner int pos = 0; if (restrictionName != null) for (String restriction : PrivacyManager.getRestrictions(this).values()) { pos++; if (restrictionName.equals(restriction)) break; } spRestriction.setAdapter(saRestriction); spRestriction.setSelection(pos); // Build template adapter SpinnerAdapter spAdapter = new SpinnerAdapter(this, android.R.layout.simple_spinner_item); spAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); String defaultName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, "0", getString(R.string.title_default)); spAdapter.add(defaultName); for (int i = 1; i <= 4; i++) { String alternateName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, Integer.toString(i), getString(R.string.title_alternate) + " " + i); spAdapter.add(alternateName); } spTemplate.setAdapter(spAdapter); // Build application list AppListTask appListTask = new AppListTask(); appListTask.executeOnExecutor(mExecutor, uids); // Import/export filename if (action.equals(ACTION_EXPORT) || action.equals(ACTION_IMPORT)) { // Check for availability of sharing intent Intent file = new Intent(Intent.ACTION_GET_CONTENT); file.setType("file/*"); boolean hasIntent = Util.isIntentAvailable(ActivityShare.this, file); // Get file name if (mFileName == null) if (action.equals(ACTION_EXPORT)) { String packageName = null; if (uids.length == 1) try { ApplicationInfoEx appInfo = new ApplicationInfoEx(this, uids[0]); packageName = appInfo.getPackageName().get(0); } catch (Throwable ex) { Util.bug(null, ex); } mFileName = getFileName(this, hasIntent, packageName); } else mFileName = (hasIntent ? null : getFileName(this, false, null)); if (mFileName == null) fileChooser(); else showFileName(); if (action.equals(ACTION_IMPORT)) cbClear.setVisibility(View.VISIBLE); } else if (action.equals(ACTION_FETCH)) { tvDescription.setText(getBaseURL()); cbClear.setVisibility(View.VISIBLE); } else if (action.equals(ACTION_TOGGLE)) { tvDescription.setVisibility(View.GONE); spRestriction.setVisibility(View.VISIBLE); svToggle.setVisibility(View.VISIBLE); // Listen for radio button rgToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { btnOk.setEnabled(checkedId >= 0); spRestriction.setVisibility( checkedId == R.id.rbEnableOndemand || checkedId == R.id.rbDisableOndemand ? View.GONE : View.VISIBLE); spTemplate.setVisibility(checkedId == R.id.rbTemplateCategory || checkedId == R.id.rbTemplateFull || checkedId == R.id.rbTemplateMergeSet || checkedId == R.id.rbTemplateMergeReset ? View.VISIBLE : View.GONE); } }); boolean ondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true); rbODEnable.setVisibility(ondemand ? View.VISIBLE : View.GONE); rbODDisable.setVisibility(ondemand ? View.VISIBLE : View.GONE); if (choice == CHOICE_CLEAR) rbClear.setChecked(true); else if (choice == CHOICE_TEMPLATE) rbTemplateFull.setChecked(true); } else tvDescription.setText(getBaseURL()); if (mInteractive) { // Enable ok // (showFileName does this for export/import) if (action.equals(ACTION_SUBMIT) || action.equals(ACTION_FETCH)) btnOk.setEnabled(true); // Listen for ok btnOk.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { btnOk.setEnabled(false); // Toggle if (action.equals(ACTION_TOGGLE)) { mRunning = true; for (int i = 0; i < rgToggle.getChildCount(); i++) ((RadioButton) rgToggle.getChildAt(i)).setEnabled(false); int pos = spRestriction.getSelectedItemPosition(); String restrictionName = (pos == 0 ? null : (String) PrivacyManager.getRestrictions(ActivityShare.this).values().toArray()[pos - 1]); new ToggleTask().executeOnExecutor(mExecutor, restrictionName); // Import } else if (action.equals(ACTION_IMPORT)) { mRunning = true; cbClear.setEnabled(false); new ImportTask().executeOnExecutor(mExecutor, new File(mFileName), cbClear.isChecked()); } // Export else if (action.equals(ACTION_EXPORT)) { mRunning = true; new ExportTask().executeOnExecutor(mExecutor, new File(mFileName)); // Fetch } else if (action.equals(ACTION_FETCH)) { if (uids.length > 0) { mRunning = true; cbClear.setEnabled(false); new FetchTask().executeOnExecutor(mExecutor, cbClear.isChecked()); } } // Submit else if (action.equals(ACTION_SUBMIT)) { if (uids.length > 0) { if (uids.length <= cSubmitLimit) { mRunning = true; new SubmitTask().executeOnExecutor(mExecutor); } else { String message = getString(R.string.msg_limit, cSubmitLimit + 1); Toast.makeText(ActivityShare.this, message, Toast.LENGTH_LONG).show(); btnOk.setEnabled(false); } } } } }); } else btnOk.setEnabled(false); // Listen for cancel btnCancel.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { if (mRunning) { mAbort = true; Toast.makeText(ActivityShare.this, getString(R.string.msg_abort), Toast.LENGTH_LONG).show(); } else finish(); } }); }
From source file:systems.soapbox.ombuds.client.ui.WalletActivity.java
private Dialog createRestoreWalletDialog() { final View view = getLayoutInflater().inflate(R.layout.restore_wallet_dialog, null); final TextView messageView = (TextView) view.findViewById(R.id.restore_wallet_dialog_message); final Spinner fileView = (Spinner) view.findViewById(R.id.import_keys_from_storage_file); final EditText passwordView = (EditText) view.findViewById(R.id.import_keys_from_storage_password); final DialogBuilder dialog = new DialogBuilder(this); dialog.setTitle(R.string.import_keys_dialog_title); dialog.setView(view);//from w ww . j ava 2 s .com dialog.setPositiveButton(R.string.import_keys_dialog_button_import, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { final File file = (File) fileView.getSelectedItem(); final String password = passwordView.getText().toString().trim(); passwordView.setText(null); // get rid of it asap if (WalletUtils.BACKUP_FILE_FILTER.accept(file)) restoreWalletFromProtobuf(file); else if (WalletUtils.KEYS_FILE_FILTER.accept(file)) restorePrivateKeysFromBase58(file); else if (Crypto.OPENSSL_FILE_FILTER.accept(file)) restoreWalletFromEncrypted(file, password); } }); dialog.setNegativeButton(R.string.button_cancel, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { passwordView.setText(null); // get rid of it asap } }); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(final DialogInterface dialog) { passwordView.setText(null); // get rid of it asap } }); final FileAdapter adapter = new FileAdapter(this) { @Override public View getDropDownView(final int position, View row, final ViewGroup parent) { final File file = getItem(position); final boolean isExternal = Constants.Files.EXTERNAL_WALLET_BACKUP_DIR.equals(file.getParentFile()); final boolean isEncrypted = Crypto.OPENSSL_FILE_FILTER.accept(file); if (row == null) row = inflater.inflate(R.layout.restore_wallet_file_row, null); final TextView filenameView = (TextView) row .findViewById(R.id.wallet_import_keys_file_row_filename); filenameView.setText(file.getName()); final TextView securityView = (TextView) row .findViewById(R.id.wallet_import_keys_file_row_security); final String encryptedStr = context .getString(isEncrypted ? R.string.import_keys_dialog_file_security_encrypted : R.string.import_keys_dialog_file_security_unencrypted); final String storageStr = context .getString(isExternal ? R.string.import_keys_dialog_file_security_external : R.string.import_keys_dialog_file_security_internal); securityView.setText(encryptedStr + ", " + storageStr); final TextView createdView = (TextView) row.findViewById(R.id.wallet_import_keys_file_row_created); createdView.setText(context.getString( isExternal ? R.string.import_keys_dialog_file_created_manual : R.string.import_keys_dialog_file_created_automatic, DateUtils.getRelativeTimeSpanString(context, file.lastModified(), true))); return row; } }; final String path; final String backupPath = Constants.Files.EXTERNAL_WALLET_BACKUP_DIR.getAbsolutePath(); final String storagePath = Constants.Files.EXTERNAL_STORAGE_DIR.getAbsolutePath(); if (backupPath.startsWith(storagePath)) path = backupPath.substring(storagePath.length()); else path = backupPath; messageView.setText(getString(R.string.import_keys_dialog_message, path)); fileView.setAdapter(adapter); return dialog.create(); }
From source file:info.corne.performancetool.MainActivity.java
/** * This function will be triggered when the hardware info * is loaded, It will then use that info to fill the view * in the activities. //from ww w. j a v a2 s . c o m * @param result A array with all the info needed. */ public void hardwareInfoLoaded(String[] result) { // Get the views Spinner governorSpinner = (Spinner) findViewById(R.id.governorSpinner); Spinner frequencyCapSpinner = (Spinner) findViewById(R.id.frequencyCapSpinner); Spinner suspendCapSpinner = (Spinner) findViewById(R.id.suspendCapSpinner); Spinner audioCapSpinner = (Spinner) findViewById(R.id.audioCapSpinner); Spinner ioSchedulerSpinner = (Spinner) findViewById(R.id.ioSchedulerSpinner); SeekBar maxCpusSeek = (SeekBar) findViewById(R.id.maxCpusSeek); Switch ocSwitch = (Switch) findViewById(R.id.overclockSwitch); Switch lpOcSwitch = (Switch) findViewById(R.id.lpOverclockSwitch); Switch gpuScalingSwitch = (Switch) findViewById(R.id.gpuScalingSwitch); Switch gpuQuickOCSwitch = (Switch) findViewById(R.id.gpuOCSwitch); TextView gpuOCValues = (TextView) findViewById(R.id.gpuOCValues); Spinner a2dpCapSpinner = (Spinner) findViewById(R.id.a2dpCapSpinner); // The returned data will be stored in their variables. String[] governors = result[0].split(" "); String[] freqencies = result[1].split(" "); // frequenciesShort will be Disabled + all the frequencies in MHz. String[] frequenciesShort = new String[freqencies.length + 1]; String[] suspendFreqsShort = new String[freqencies.length + 1]; String[] audioFreqsShort = new String[freqencies.length + 1]; String[] a2dpFreqShort = new String[freqencies.length + 1]; Spinner cpqGovernorSpinner = (Spinner) findViewById(R.id.cpqGovernorSpinner); String[] cpqGovernors = result[10].split(" "); frequenciesShort[0] = getResources().getString(R.string.disabled_string); suspendFreqsShort[0] = getResources().getString(R.string.disabled_string); audioFreqsShort[0] = getResources().getString(R.string.disabled_string); a2dpFreqShort[0] = getResources().getString(R.string.disabled_string); ioSchedulers = result[4].split(" "); int currentFrequencyPos = freqencies.length - 1; int currentSuspendPos = 0; int currentAudioPos = 0; int currentA2dpPos = 0; int currentIOScheduler = ioSchedulers.length - 1; // Will loop trough the frequencies and convert them to MHz. for (int i = 0; i < freqencies.length; i++) { if (result[3].indexOf("000") == -1) currentFrequencyPos = 0; else if (result[3].compareTo(freqencies[i]) == 0) currentFrequencyPos = i + 1; if (result[8].indexOf("000") == -1) currentSuspendPos = 0; else if (result[8].compareTo(freqencies[i]) == 0) currentSuspendPos = i + 1; if (result[9].equals("Error")) audioCapSpinner.setVisibility(View.GONE); if (result[9].indexOf("000") == -1) currentAudioPos = 0; else if (result[9].compareTo(freqencies[i]) == 0) currentAudioPos = i + 1; if (result[18].equals("Error")) a2dpCapSpinner.setVisibility(View.GONE); if (result[18].indexOf("000") == -1) currentA2dpPos = 0; else if (result[18].compareTo(freqencies[i]) == 0) currentA2dpPos = i + 1; frequenciesShort[i + 1] = freqencies[i].replaceFirst("000", "") + getResources().getString(R.string.mhz); suspendFreqsShort[i + 1] = freqencies[i].replaceFirst("000", "") + getResources().getString(R.string.mhz); audioFreqsShort[i + 1] = freqencies[i].replaceFirst("000", "") + getResources().getString(R.string.mhz); a2dpFreqShort[i + 1] = freqencies[i].replaceFirst("000", "") + getResources().getString(R.string.mhz); } // And that will also be stored in the adapter. frequencyCapSpinner.setAdapter(generateAdapter(frequenciesShort)); suspendCapSpinner.setAdapter(generateAdapter(suspendFreqsShort)); audioCapSpinner.setAdapter(generateAdapter(audioFreqsShort)); a2dpCapSpinner.setAdapter(generateAdapter(a2dpFreqShort)); // And the current selected freq will be selected. frequencyCapSpinner.setSelection(currentFrequencyPos); suspendCapSpinner.setSelection(currentSuspendPos); audioCapSpinner.setSelection(currentAudioPos); a2dpCapSpinner.setSelection(currentA2dpPos); // All the governors will be add to the spinner. governorSpinner.setAdapter(generateAdapter(governors)); // And the current selected governor will be selected // in the spinner. for (int i = 0; i < governors.length; i++) { if (result[2].compareTo(governors[i]) == 0) governorSpinner.setSelection(i); } // Will search for the currently selected IO scheduler. for (int i = 0; i < ioSchedulers.length; i++) { if (ioSchedulers[i].charAt(0) == '[') { currentIOScheduler = i; ioSchedulers[i] = ioSchedulers[i].substring(1, ioSchedulers[i].length() - 1); } } // And fill the spinners/set selection ioSchedulerSpinner.setAdapter(generateAdapter(ioSchedulers)); ioSchedulerSpinner.setSelection(currentIOScheduler); // If overclock is one turn the switch on. if (result[5].equals("1")) ocSwitch.setChecked(true); else ocSwitch.setChecked(false); onOverclockSwitchClick(ocSwitch); if (!result[6].equals("Error") || !result[7].equals("Error")) { if (!result[6].equals("Error")) { maxCpusSeek.setProgress((int) Float.parseFloat(result[6]) - 1); } if (!result[7].equals("Error")) { maxCpusSeek.setProgress((int) Float.parseFloat(result[7]) - 1); } } else { maxCpusSeek.setVisibility(View.GONE); ((TextView) findViewById(R.id.maxCpusTextView)).setVisibility(View.GONE); } if (!result[11].equals("Error")) { cpqGovernorSpinner.setAdapter(generateAdapter(cpqGovernors)); for (int i = 0; i < cpqGovernors.length; i++) { if (result[11].compareTo(cpqGovernors[i]) == 0) cpqGovernorSpinner.setSelection(i); } } else { cpqGovernorSpinner.setVisibility(View.GONE); ((TextView) findViewById(R.id.cpqGovernorTextView)).setVisibility(View.GONE); } if (!result[12].equals("Error")) { // If lp overclock is one turn the switch on. if (result[12].equals("1")) lpOcSwitch.setChecked(true); else lpOcSwitch.setChecked(false); onLpOverclockSwitchClick(lpOcSwitch); } else { lpOcSwitch.setVisibility(View.GONE); ((TextView) findViewById(R.id.lpOverclockInfo)).setVisibility(View.GONE); } if (!result[13].equals("Error")) { if (result[13].equals("1")) gpuScalingSwitch.setChecked(true); else gpuScalingSwitch.setChecked(false); } else { gpuScalingSwitch.setVisibility(View.GONE); } if (!result[14].equals("Error")) { if (result[14].equals("0")) { cpuHotplugging = true; updateCpuHotpluggingView(true); } else { cpuHotplugging = false; updateCpuHotpluggingView(true); } } else { cpuHotplugging = true; updateCpuHotpluggingView(true); ((RadioButton) findViewById(R.id.cpu_hotplug_mode)).setVisibility(View.GONE); ((RadioButton) findViewById(R.id.cpu_manual_mode)).setVisibility(View.GONE); } if (!result[15].equals("Error")) { updateActiveCpusView(result[15]); } if (!result[16].equals("Error")) { if (result[16].equals("1")) gpuQuickOCSwitch.setChecked(true); else gpuQuickOCSwitch.setChecked(false); } else { gpuQuickOCSwitch.setVisibility(View.GONE); } if (!result[17].equals("Error")) { gpuOCValuesString = result[17]; gpuOCValues.setText(gpuOCValuesString); } else { gpuOCValues.setVisibility(View.GONE); } dialog.dismiss(); updateFromView(); updatePreferences(""); refreshProfilesList(); ListView profilesList = (ListView) findViewById(R.id.profilesListView); registerForContextMenu(profilesList); profilesList.setOnItemClickListener(this); }
From source file:com.serenegiant.autoparrot.BaseAutoPilotFragment.java
private void initPreprocess2(final View rootView) { Switch sw;// w w w. j av a 2 s .c o m Spinner spinner; SeekBar sb; mMaxThinningLoopFormat = getString(R.string.trace_max_thinning_loop); // OpenGL|ES?? // mGLESSmoothType = getInt(mPref, KEY_SMOOTH_TYPE, DEFAULT_SMOOTH_TYPE); // spinner = (Spinner)rootView.findViewById(R.id.use_smooth_spinner); // spinner.setAdapter(new SmoothTypeAdapter(getActivity())); // spinner.setOnItemSelectedListener(mOnItemSelectedListener); // // OpenGL|ES?????? // mEnableGLESCanny = mPref.getBoolean(KEY_ENABLE_EDGE_DETECTION, DEFAULT_ENABLE_EDGE_DETECTION); // sw = (Switch)rootView.findViewById(R.id.use_canny_sw); // sw.setChecked(mEnableGLESCanny); // sw.setOnCheckedChangeListener(mOnCheckedChangeListener); // ??????? mFillContour = mPref.getBoolean(KEY_FILL_INNER_CONTOUR, DEFAULT_FILL_INNER_CONTOUR); sw = (Switch) rootView.findViewById(R.id.use_fill_contour_sw); sw.setChecked(mFillContour); sw.setOnCheckedChangeListener(mOnCheckedChangeListener); // // Native??Canny????? // mEnableNativeCanny = mPref.getBoolean(KEY_ENABLE_NATIVE_EDGE_DETECTION, DEFAULT_ENABLE_NATIVE_EDGE_DETECTION); // sw = (Switch)rootView.findViewById(R.id.use_native_canny_sw); // sw.setChecked(mEnableNativeCanny); // sw.setOnCheckedChangeListener(mOnCheckedChangeListener); // native??? mNativeSmoothType = getInt(mPref, KEY_NATIVE_SMOOTH_TYPE, DEFAULT_NATIVE_SMOOTH_TYPE); spinner = (Spinner) rootView.findViewById(R.id.use_native_smooth_spinner); spinner.setAdapter(new SmoothTypeAdapter(getActivity())); spinner.setOnItemSelectedListener(mOnItemSelectedListener); // native??? mMaxThinningLoop = getInt(mPref, KEY_NATIVE_MAX_THINNING_LOOP, DEFAULT_NATIVE_MAX_THINNING_LOOP); mMaxThinningLoopLabel = (TextView) rootView.findViewById(R.id.max_thinning_loop_textview); sb = (SeekBar) rootView.findViewById(R.id.max_thinning_loop_seekbar); sb.setMax(20); sb.setProgress(mMaxThinningLoop); sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateMaxThinningLoop(mMaxThinningLoop); }
From source file:com.hivewallet.androidclient.wallet.ui.WalletActivity.java
private Dialog createImportKeysDialog() { final View view = getLayoutInflater().inflate(R.layout.import_keys_from_storage_dialog, null); final Spinner fileView = (Spinner) view.findViewById(R.id.import_keys_from_storage_file); final EditText passwordView = (EditText) view.findViewById(R.id.import_keys_from_storage_password); final DialogBuilder dialog = new DialogBuilder(this); dialog.setTitle(R.string.import_keys_dialog_title); dialog.setView(view);//from www. j a va 2 s . co m dialog.setPositiveButton(R.string.import_keys_dialog_button_import, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { final File file = (File) fileView.getSelectedItem(); final String password = passwordView.getText().toString().trim(); passwordView.setText(null); // get rid of it asap final boolean isProtobuf = file.getName() .startsWith(Constants.Files.WALLET_KEY_BACKUP_PROTOBUF + '.') || file.getName().startsWith(Constants.Files.EXTERNAL_WALLET_BACKUP + '-') || file.getName().startsWith(Constants.Files.EXTERNAL_WALLET_TMP_FILE); if (isProtobuf) restoreWalletFromProtobuf(file, password); else importPrivateKeysFromBase58(file, password); } }); dialog.setNegativeButton(R.string.button_cancel, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { passwordView.setText(null); // get rid of it asap } }); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(final DialogInterface dialog) { passwordView.setText(null); // get rid of it asap } }); final FileAdapter adapter = new FileAdapter(this) { @Override public View getDropDownView(final int position, View row, final ViewGroup parent) { final File file = getItem(position); File externalWalletBackupDir = new File(getFilesDir(), Constants.Files.EXTERNAL_WALLET_BACKUP_DIR); File selectedExternalWalletBackup = new File(getFilesDir(), Constants.Files.EXTERNAL_WALLET_TMP_FILE); final boolean isExternal = selectedExternalWalletBackup.equals(file); final boolean isManual = externalWalletBackupDir.equals(file.getParentFile()); final boolean isEncrypted = Crypto.OPENSSL_FILE_FILTER.accept(file); if (row == null) row = inflater.inflate(R.layout.wallet_import_keys_file_row, null); final TextView filenameView = (TextView) row .findViewById(R.id.wallet_import_keys_file_row_filename); filenameView.setText(file.getName()); final TextView securityView = (TextView) row .findViewById(R.id.wallet_import_keys_file_row_security); final String encryptedStr = context .getString(isEncrypted ? R.string.import_keys_dialog_file_security_encrypted : R.string.import_keys_dialog_file_security_unencrypted); final String storageStr = isExternal ? "" : ", " + context.getString(R.string.import_keys_dialog_file_security_internal); securityView.setText(encryptedStr + storageStr); final TextView createdView = (TextView) row.findViewById(R.id.wallet_import_keys_file_row_created); if (isExternal) { createdView.setText(context.getString(R.string.import_keys_dialog_file_just_selected)); } else if (isManual) { createdView.setText(context.getString(R.string.import_keys_dialog_file_created_manual, DateUtils.getRelativeTimeSpanString(context, file.lastModified(), true))); } else { createdView.setText(context.getString(R.string.import_keys_dialog_file_created_automatic, DateUtils.getRelativeTimeSpanString(context, file.lastModified(), true))); } return row; } }; fileView.setAdapter(adapter); return dialog.create(); }
From source file:com.digi.android.wva.fragments.EndpointOptionsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (mConfig == null && savedInstanceState == null) { Log.e(TAG, "mConfig is null, not showing dialog!"); return null; }//from w ww . jav a2s. c om LayoutInflater inf = getActivity().getLayoutInflater(); View v = inf.inflate(R.layout.dialog_endpoint_options, null); // Suppresses warnings, and ensures the layout exists. assert v != null; final TextView subIntervalTV = (TextView) v.findViewById(R.id.textView_interval); final TextView alarmInfoTV = (TextView) v.findViewById(R.id.alarm_info); final CheckBox subscribedCB = (CheckBox) v.findViewById(R.id.subscribedCheckbox); final CheckBox alarmCB = (CheckBox) v.findViewById(R.id.alarmCheckbox); final EditText subInterval = (EditText) v.findViewById(R.id.subscriptionInterval); final EditText alarmThreshold = (EditText) v.findViewById(R.id.alarmThreshold); final Spinner typeSpinner = (Spinner) v.findViewById(R.id.alarmTypeSpinner); final LinearLayout makeAlarmSection = (LinearLayout) v.findViewById(R.id.section_make_alarm); final LinearLayout showAlarmSection = (LinearLayout) v.findViewById(R.id.section_show_alarm); final CheckBox dcSendCB = (CheckBox) v.findViewById(R.id.dcPushCheckbox); String alarmInfo = "No alarm yet"; boolean isSubscribed = false; String endpointName = "UNKNOWN"; int sinterval = 10; boolean alarmCreated = false; double threshold = 0; int alarmtypeidx = 0; boolean isSendingToDC = false; if (savedInstanceState != null && savedInstanceState.containsKey("config")) { mConfig = savedInstanceState.getParcelable("config"); } if (mConfig != null) { endpointName = mConfig.getEndpoint(); alarmInfo = mConfig.getAlarmSummary(); if (mConfig.getSubscriptionConfig() != null) { isSubscribed = mConfig.getSubscriptionConfig().isSubscribed(); sinterval = mConfig.getSubscriptionConfig().getInterval(); isSendingToDC = mConfig.shouldBePushedToDeviceCloud(); } else { // Not subscribed; default interval value from preferences. String i = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getString("pref_default_interval", "0"); try { sinterval = Integer.parseInt(i); } catch (NumberFormatException e) { Log.d(TAG, "Failed to parse default interval from preferences: " + i); sinterval = 0; } } if (mConfig.getAlarmConfig() != null) { alarmCreated = mConfig.getAlarmConfig().isCreated(); threshold = mConfig.getAlarmConfig().getThreshold(); String typestr = AlarmType.makeString(mConfig.getAlarmConfig().getType()); for (int i = 0; i < alarmTypes.length; i++) { if (alarmTypes[i].toLowerCase(Locale.US).equals(typestr)) alarmtypeidx = i; } } } // Set up event listeners on EditText and CheckBox items subscribedCB.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { subInterval.setEnabled(isChecked); subIntervalTV.setEnabled(isChecked); } }); alarmCB.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { typeSpinner.setEnabled(isChecked); alarmThreshold.setEnabled(false); // If type spinner is set to Change, we want threshold disabled again if (isChecked) { alarmThreshold.setEnabled(!shouldDisableAlarmThreshold(typeSpinner.getSelectedItemPosition())); } } }); typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) { if (alarmCB.isChecked() && shouldDisableAlarmThreshold(position)) alarmThreshold.setEnabled(false); else if (!alarmCB.isChecked()) alarmThreshold.setEnabled(false); else alarmThreshold.setEnabled(true); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); subIntervalTV.setEnabled(false); subInterval.setEnabled(false); alarmThreshold.setEnabled(false); typeSpinner.setEnabled(false); alarmInfoTV.setText(alarmInfo); // Click checkboxes, show data depending on if subscription or alarm // has been added already if (isSubscribed) subscribedCB.performClick(); if (alarmCreated) { showAlarmSection.setVisibility(View.VISIBLE); makeAlarmSection.setVisibility(View.GONE); alarmCB.setText("Remove alarm"); } else { makeAlarmSection.setVisibility(View.VISIBLE); showAlarmSection.setVisibility(View.GONE); alarmCB.setText("Create alarm"); } dcSendCB.setChecked(isSendingToDC); subInterval.setText(Integer.toString(sinterval)); alarmThreshold.setText(Double.toString(threshold)); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.alarm_types, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); typeSpinner.setAdapter(adapter); typeSpinner.setSelection(alarmtypeidx); DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { // Fetch the EndpointsAdapter's configuration for this endpoint. // (We might have gotten mConfig from the saved instance bundle) EndpointConfiguration cfg = EndpointsAdapter.getInstance() .findEndpointConfiguration(mConfig.getEndpoint()); // Set whether this endpoint's data should be pushed to Device Cloud if (cfg != null) { cfg.setPushToDeviceCloud(dcSendCB.isChecked()); } // Handle (un)subscribing if (isUnsubscribing(subscribedCB.isChecked())) { unsubscribe(mConfig.getEndpoint()); } else if (subscribedCB.isChecked()) { if (handleMakingSubscription(subInterval)) { // Subscription was successful... most likely. Log.d(TAG, "Probably subscribed to endpoint."); } else { // Invalid interval. Toast.makeText(getActivity(), getString(R.string.configure_endpoints_toast_invalid_sub_interval), Toast.LENGTH_SHORT).show(); } } // Handle adding/removing alarm as necessary if (isRemovingAlarm(alarmCB.isChecked())) { removeAlarm(mConfig.getEndpoint(), mConfig.getAlarmConfig().getType()); } else if (alarmCB.isChecked()) { Editable thresholdText = alarmThreshold.getText(); String thresholdString; if (thresholdText == null) thresholdString = ""; else thresholdString = thresholdText.toString(); double threshold; try { threshold = Double.parseDouble(thresholdString); } catch (NumberFormatException e) { Toast.makeText(getActivity(), getString(R.string.configure_endpoints_invalid_threshold), Toast.LENGTH_SHORT).show(); return; } int alarmidx = typeSpinner.getSelectedItemPosition(); if (alarmidx == -1) { // But... how? Log.wtf(TAG, "alarm type index -1 ?"); return; } String type = alarmTypes[alarmidx]; AlarmType atype = AlarmType.fromString(type); createAlarm(mConfig.getEndpoint(), atype, threshold); } dialog.dismiss(); } }; return new AlertDialog.Builder(getActivity()).setView(v).setTitle("Endpoint: " + endpointName) .setPositiveButton("Save", clickListener) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Cancel means just dismiss the dialog. dialog.dismiss(); } }).create(); }
From source file:com.nest5.businessClient.Initialactivity.java
@Override public void OnInventoryObjectFragmentCreated(View v) { // llenar el spinner con los ingredientes disponibles inventoryTable = (TableLayout) v.findViewById(R.id.inventory_my_table); List<Ingredient> ingres = ingredientDatasource.getAllIngredient(); Spinner ingSpin = (Spinner) v.findViewById(R.id.inventory_ingredient_spinner); List<String> nombres = new ArrayList<String>(); String nombreActual = ""; for (Ingredient current : ingres) { String name = current.getName().trim().toLowerCase(Locale.getDefault()); if (!nombreActual.equals(name)) { nombreActual = name;/*w w w .j a va 2 s.c o m*/ nombres.add(nombreActual); } } ArrayAdapter<String> adapt = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_single_choice, nombres); ingSpin.setAdapter(adapt); ingSpin.setOnItemSelectedListener(ingSpinListener); }
From source file:com.nest5.businessClient.Initialactivity.java
@Override public void OnOrderFomrFragmentCreatedListener(View v) { Spinner addToOpenTable = (Spinner) v.findViewById(R.id.open_tables_add_order); TextView title = (TextView) v.findViewById(R.id.add_toopentable_title); if (openTables.size() > 0) { title.setVisibility(View.VISIBLE); addToOpenTable.setVisibility(View.VISIBLE); ArrayList<String> nameTables = new ArrayList<String>(); nameTables.add("No, es una mesa nueva."); for (CurrentTable<Table, Integer> current : openTables) { nameTables.add(current.getTable().getName()); }/*from w w w . j ava 2s . c o m*/ ArrayAdapter<String> adapter = new ArrayAdapter<String>(Initialactivity.this, android.R.layout.simple_spinner_item, nameTables); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); addToOpenTable.setAdapter(adapter); addToOpenTable.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { int pos = position - 1; currentSelectedAddTable = pos; if (pos > -1) currentTable = openTables.get(pos); } @Override public void onNothingSelected(AdapterView<?> arg0) { //currentSelectedAddTable = -1; } }); } else { title.setVisibility(View.INVISIBLE); addToOpenTable.setVisibility(View.INVISIBLE); } }
From source file:g7.bluesky.launcher3.Launcher.java
@Override protected void onCreate(Bundle savedInstanceState) { activity = this; if (DEBUG_STRICT_MODE) { StrictMode.setThreadPolicy(/*w w w .jav a 2s .com*/ new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork() // or .detectAll() for all detectable problems .penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects() .detectLeakedClosableObjects().penaltyLog().penaltyDeath().build()); } if (mLauncherCallbacks != null) { mLauncherCallbacks.preOnCreate(); } super.onCreate(savedInstanceState); LauncherAppState.setApplicationContext(getApplicationContext()); LauncherAppState app = LauncherAppState.getInstance(); LauncherAppState.getLauncherProvider().setLauncherProviderChangeListener(this); // Lazy-initialize the dynamic grid DeviceProfile grid = app.initDynamicGrid(this); // the LauncherApplication should call this, but in case of Instrumentation it might not be present yet mSharedPrefs = getSharedPreferences(LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE); // Set defaultSharedPref defaultSharedPref = PreferenceManager.getDefaultSharedPreferences(this); mIsSafeModeEnabled = getPackageManager().isSafeMode(); mModel = app.setLauncher(this); mIconCache = app.getIconCache(); mIconCache.flushInvalidIcons(grid); mDragController = new DragController(this); mInflater = getLayoutInflater(); mStats = new Stats(this); mAppWidgetManager = AppWidgetManagerCompat.getInstance(this); mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID); mAppWidgetHost.startListening(); // If we are getting an onCreate, we can actually preempt onResume and unset mPaused here, // this also ensures that any synchronous binding below doesn't re-trigger another // LauncherModel load. mPaused = false; if (PROFILE_STARTUP) { android.os.Debug.startMethodTracing(Environment.getExternalStorageDirectory() + "/launcher"); } checkForLocaleChange(); setContentView(R.layout.launcher); setupViews(); grid.layout(this); registerContentObservers(); lockAllApps(); mSavedState = savedInstanceState; restoreState(mSavedState); if (PROFILE_STARTUP) { android.os.Debug.stopMethodTracing(); } if (!mRestoring) { if (DISABLE_SYNCHRONOUS_BINDING_CURRENT_PAGE) { // If the user leaves launcher, then we should just load items asynchronously when // they return. mModel.startLoader(true, PagedView.INVALID_RESTORE_PAGE); } else { // We only load the page synchronously if the user rotates (or triggers a // configuration change) while launcher is in the foreground mModel.startLoader(true, mWorkspace.getRestorePage()); } } // For handling default keys mDefaultKeySsb = new SpannableStringBuilder(); Selection.setSelection(mDefaultKeySsb, 0); IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); registerReceiver(mCloseSystemDialogsReceiver, filter); // On large interfaces, we want the screen to auto-rotate based on the current orientation unlockScreenOrientation(true); if (mLauncherCallbacks != null) { mLauncherCallbacks.onCreate(savedInstanceState); if (mLauncherCallbacks.hasLauncherOverlay()) { ViewStub stub = (ViewStub) findViewById(R.id.launcher_overlay_stub); mLauncherOverlayContainer = (InsettableFrameLayout) stub.inflate(); mLauncherOverlay = mLauncherCallbacks.setLauncherOverlayView(mLauncherOverlayContainer, mLauncherOverlayCallbacks); mWorkspace.setLauncherOverlay(mLauncherOverlay); } } if (shouldShowIntroScreen()) { showIntroScreen(); } else { showFirstRunActivity(); showFirstRunClings(); } //create extramenu //llExtraMenu = (LinearLayout) findViewById(R.id.ll_extra_menu); //llExtraMenu.addView(new ExtraMenu(this, null)); flLauncher = (LauncherRootView) findViewById(R.id.launcher); mExtraMenu = new ExtraMenu(this, null); flLauncher.addView(mExtraMenu); if (!defaultSharedPref.getBoolean(SettingConstants.EXTRA_MENU_PREF_KEY, false)) { mExtraMenu.setVisibility(View.GONE); } editTextFilterApps.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void afterTextChanged(Editable arg0) { String searchString = editTextFilterApps.getText().toString(); if (listApps != null && listApps.size() > 0) { if (searchString.trim().length() > 0) { ArrayList<AppInfo> searchList = new ArrayList<>(); for (AppInfo appInfo : listApps) { String appTitle = StringUtil .convertVNString(appInfo.getTitle().toString().toLowerCase().trim()); searchString = StringUtil.convertVNString(searchString.toLowerCase().trim()); if (appTitle.contains(searchString)) { searchList.add(appInfo); } } mAppsCustomizeContent.setApps(searchList); } else { mAppsCustomizeContent.setApps((ArrayList<AppInfo>) listApps); } } } }); // Spinner element Spinner spinner = (Spinner) findViewById(R.id.spinner); // Spinner click listener spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // Clear spinner text ((TextView) view).setText(null); SharedPreferences.Editor editor = defaultSharedPref.edit(); editor.putInt(SettingConstants.SORT_PREF_KEY, position); editor.apply(); // Value from preference int prefVal = defaultSharedPref.getInt(SettingConstants.SORT_PREF_KEY, SettingConstants.SORT_A_Z); LauncherUtil.sortListApps(defaultSharedPref, listApps, prefVal); mAppsCustomizeContent.invalidatePageData(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); // Creating adapter for spinner ArrayAdapter<CharSequence> dataAdapter = ArrayAdapter.createFromResource(this, R.array.sort_options, android.R.layout.simple_spinner_item); // Drop down layout style - list view with radio button dataAdapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice); // attaching data adapter to spinner spinner.setAdapter(dataAdapter); // Set default value final int prefSortOptionVal = defaultSharedPref.getInt(SettingConstants.SORT_PREF_KEY, SettingConstants.SORT_A_Z); spinner.setSelection(prefSortOptionVal); // Listen on pref change prefChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { if (key.equalsIgnoreCase(SettingConstants.EXTRA_MENU_PREF_KEY)) { if (!defaultSharedPref.getBoolean(SettingConstants.EXTRA_MENU_PREF_KEY, false)) { mExtraMenu.setVisibility(View.GONE); } else { mExtraMenu.setVisibility(View.VISIBLE); } } else if (key.equalsIgnoreCase(SettingConstants.ICON_THEME_PREF_KEY)) { mModel.forceReload(); loadIconPack(); } } }; defaultSharedPref.registerOnSharedPreferenceChangeListener(prefChangeListener); }