use of android.widget.Spinner in project UltimateAndroid by cymcsg.
the class ConfigureStandupTimer method onClick.
public void onClick(View v) {
Intent i = new Intent(this, StandupTimer.class);
meetingLength = getMeetingLengthFromUI();
i.putExtra("meetingLength", meetingLength);
TextView t = (TextView) findViewById(R.id.num_participants);
numParticipants = parseNumberOfParticipants(t);
i.putExtra("numParticipants", numParticipants);
Spinner teamNameSpinner = (Spinner) findViewById(R.id.team_names);
teamNamesPos = teamNameSpinner.getSelectedItemPosition();
i.putExtra("teamName", (String) teamNameSpinner.getSelectedItem());
if (numParticipants < 1 || (Prefs.allowUnlimitedParticipants(this) == false && numParticipants > 20)) {
showInvalidNumberOfParticipantsDialog();
} else {
saveState();
startTimer(i);
}
}
use of android.widget.Spinner in project AntennaPod by AntennaPod.
the class ProxyDialog method createDialog.
public Dialog createDialog() {
dialog = new MaterialDialog.Builder(context).title(R.string.pref_proxy_title).customView(R.layout.proxy_settings, true).positiveText(R.string.proxy_test_label).negativeText(R.string.cancel_label).onPositive((dialog1, which) -> {
if (!testSuccessful) {
dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
test();
return;
}
String type = (String) ((Spinner) dialog1.findViewById(R.id.spType)).getSelectedItem();
ProxyConfig proxy;
if (Proxy.Type.valueOf(type) == Proxy.Type.DIRECT) {
proxy = ProxyConfig.direct();
} else {
String host = etHost.getText().toString();
String port = etPort.getText().toString();
String username = etUsername.getText().toString();
if (TextUtils.isEmpty(username)) {
username = null;
}
String password = etPassword.getText().toString();
if (TextUtils.isEmpty(password)) {
password = null;
}
int portValue = 0;
if (!TextUtils.isEmpty(port)) {
portValue = Integer.valueOf(port);
}
proxy = ProxyConfig.http(host, portValue, username, password);
}
UserPreferences.setProxyConfig(proxy);
AntennapodHttpClient.reinit();
dialog.dismiss();
}).onNegative((dialog1, which) -> dialog1.dismiss()).autoDismiss(false).build();
View view = dialog.getCustomView();
spType = (Spinner) view.findViewById(R.id.spType);
String[] types = { Proxy.Type.DIRECT.name(), Proxy.Type.HTTP.name() };
ArrayAdapter<String> adapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, types);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spType.setAdapter(adapter);
ProxyConfig proxyConfig = UserPreferences.getProxyConfig();
spType.setSelection(adapter.getPosition(proxyConfig.type.name()));
etHost = (EditText) view.findViewById(R.id.etHost);
if (!TextUtils.isEmpty(proxyConfig.host)) {
etHost.setText(proxyConfig.host);
}
etHost.addTextChangedListener(requireTestOnChange);
etPort = (EditText) view.findViewById(R.id.etPort);
if (proxyConfig.port > 0) {
etPort.setText(String.valueOf(proxyConfig.port));
}
etPort.addTextChangedListener(requireTestOnChange);
etUsername = (EditText) view.findViewById(R.id.etUsername);
if (!TextUtils.isEmpty(proxyConfig.username)) {
etUsername.setText(proxyConfig.username);
}
etUsername.addTextChangedListener(requireTestOnChange);
etPassword = (EditText) view.findViewById(R.id.etPassword);
if (!TextUtils.isEmpty(proxyConfig.password)) {
etPassword.setText(proxyConfig.username);
}
etPassword.addTextChangedListener(requireTestOnChange);
if (proxyConfig.type == Proxy.Type.DIRECT) {
enableSettings(false);
setTestRequired(false);
}
spType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
enableSettings(position > 0);
setTestRequired(position > 0);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
enableSettings(false);
}
});
txtvMessage = (TextView) view.findViewById(R.id.txtvMessage);
checkValidity();
return dialog;
}
use of android.widget.Spinner in project android_frameworks_base by DirtyUnicorns.
the class SurfaceCompositionMeasuringActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// Detect Andromeda devices by having free-form window management feature.
mAndromeda = getPackageManager().hasSystemFeature(PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT);
detectRefreshRate();
// To layouts in parent. First contains list of Surfaces and second
// controls. Controls stay on top.
RelativeLayout rootLayout = new RelativeLayout(this);
rootLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
CustomLayout layout = new CustomLayout(this);
layout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
Rect rect = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
mWidth = rect.right;
mHeight = rect.bottom;
long maxMemoryPerSurface = roundToNextPowerOf2(mWidth) * roundToNextPowerOf2(mHeight) * 4;
// Use 75% of available memory.
int surfaceCnt = (int) ((getMemoryInfo().availMem * 3) / (4 * maxMemoryPerSurface));
if (surfaceCnt < MIN_NUMBER_OF_SURFACES) {
throw new RuntimeException("Not enough memory to allocate " + MIN_NUMBER_OF_SURFACES + " surfaces.");
}
if (surfaceCnt > MAX_NUMBER_OF_SURFACES) {
surfaceCnt = MAX_NUMBER_OF_SURFACES;
}
LinearLayout controlLayout = new LinearLayout(this);
controlLayout.setOrientation(LinearLayout.VERTICAL);
controlLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mMeasureCompositionButton = createButton("Compositor speed.", controlLayout);
mMeasureAllocationButton = createButton("Allocation speed", controlLayout);
String[] pixelFomats = new String[PIXEL_FORMATS.length];
for (int i = 0; i < pixelFomats.length; ++i) {
pixelFomats[i] = getPixelFormatInfo(PIXEL_FORMATS[i]);
}
mPixelFormatSelector = new Spinner(this);
ArrayAdapter<String> pixelFormatSelectorAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, pixelFomats);
pixelFormatSelectorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mPixelFormatSelector.setAdapter(pixelFormatSelectorAdapter);
mPixelFormatSelector.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
controlLayout.addView(mPixelFormatSelector);
mResultView = new TextView(this);
mResultView.setBackgroundColor(0);
mResultView.setText("Press button to start test.");
mResultView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
controlLayout.addView(mResultView);
mSystemInfoView = new TextView(this);
mSystemInfoView.setBackgroundColor(0);
mSystemInfoView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
controlLayout.addView(mSystemInfoView);
for (int i = 0; i < surfaceCnt; ++i) {
CustomSurfaceView view = new CustomSurfaceView(this, "Surface:" + i);
// to mark as media overlay.
if (i == 0) {
view.setLayoutParams(new CustomLayout.LayoutParams(0, 0, mWidth, mHeight));
view.setZOrderMediaOverlay(false);
} else {
// Z order of other layers is not predefined so make offset on x and reverse
// offset on y to make sure that surface is visible in any layout.
int x = i;
int y = (surfaceCnt - i);
view.setLayoutParams(new CustomLayout.LayoutParams(x, y, x + mWidth, y + mHeight));
view.setZOrderMediaOverlay(true);
}
view.setVisibility(View.INVISIBLE);
layout.addView(view);
mViews.add(view);
}
rootLayout.addView(layout);
rootLayout.addView(controlLayout);
setContentView(rootLayout);
}
use of android.widget.Spinner in project Etar-Calendar by Etar-Group.
the class EventViewUtils method addReminder.
/**
* Adds a reminder to the displayed list of reminders. The values/labels
* arrays must not change after calling here, or the spinners we created
* might index into the wrong entry. Returns true if successfully added
* reminder, false if no reminders can be added.
*
* onItemSelected allows a listener to be set for any changes to the
* spinners in the reminder. If a listener is set it will store the
* initial position of the spinner into the spinner's tag for comparison
* with any new position setting.
*/
public static boolean addReminder(Activity activity, View view, View.OnClickListener listener, ArrayList<LinearLayout> items, ArrayList<Integer> minuteValues, ArrayList<String> minuteLabels, ArrayList<Integer> methodValues, ArrayList<String> methodLabels, ReminderEntry newReminder, int maxReminders, OnItemSelectedListener onItemSelected) {
if (items.size() >= maxReminders) {
return false;
}
LayoutInflater inflater = activity.getLayoutInflater();
LinearLayout parent = (LinearLayout) view.findViewById(R.id.reminder_items_container);
LinearLayout reminderItem = (LinearLayout) inflater.inflate(R.layout.edit_reminder_item, null);
parent.addView(reminderItem);
ImageButton reminderRemoveButton;
reminderRemoveButton = (ImageButton) reminderItem.findViewById(R.id.reminder_remove);
reminderRemoveButton.setOnClickListener(listener);
/*
* The spinner has the default set of labels from the string resource file, but we
* want to drop in our custom set of labels because it may have additional entries.
*/
Spinner spinner = (Spinner) reminderItem.findViewById(R.id.reminder_minutes_value);
setReminderSpinnerLabels(activity, spinner, minuteLabels);
int index = findMinutesInReminderList(minuteValues, newReminder.getMinutes());
spinner.setSelection(index);
if (onItemSelected != null) {
spinner.setTag(index);
spinner.setOnItemSelectedListener(onItemSelected);
}
/*
* Configure the alert-method spinner. Methods not supported by the current Calendar
* will not be shown.
*/
spinner = (Spinner) reminderItem.findViewById(R.id.reminder_method_value);
setReminderSpinnerLabels(activity, spinner, methodLabels);
index = findMethodInReminderList(methodValues, newReminder.getMethod());
spinner.setSelection(index);
if (onItemSelected != null) {
spinner.setTag(index);
spinner.setOnItemSelectedListener(onItemSelected);
}
items.add(reminderItem);
return true;
}
use of android.widget.Spinner in project AdMoney by ErnestoGonAr.
the class EstablecerActivity method evento.
public void evento(View view) {
bandera = false;
Spinner spinner = (Spinner) findViewById(R.id.spinner);
String pregunta = spinner.getSelectedItem().toString();
EditText p1 = (EditText) findViewById(R.id.pin);
String pin = p1.getText().toString();
EditText p2 = (EditText) findViewById(R.id.pinC);
String pin2 = p2.getText().toString();
EditText r = (EditText) findViewById(R.id.pregSeg);
String resp = r.getText().toString();
if (spinner.getSelectedItemPosition() == 0) {
Toast toast = Toast.makeText(this, "Selecciona una pregunta", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
return;
}
if (resp.equals("")) {
Toast toast = Toast.makeText(this, "Escribe tu respuesta", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
return;
}
if (!(pin.length() == 4)) {
Toast toast = Toast.makeText(this, "NIP debe ser de 4 digitos", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
return;
}
if (!pin.equals(pin2)) {
Toast toast = Toast.makeText(this, "El NIP no coincide", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
return;
}
if (db.isthereData()) {
db.updateLOGINN(pin, pregunta, resp);
}
db.insertarLOGINN(pin, pregunta, resp);
bandera = true;
}
Aggregations