use of android.widget.Spinner in project ETSMobile-Android2 by ApplETS.
the class ProfileAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
if (position == 0) {
convertView = LayoutInflater.from(context).inflate(R.layout.row_profile_info_etudiant, parent, false);
InfoEtudiantViewHolder infoEtudiantViewHolder = new InfoEtudiantViewHolder();
infoEtudiantViewHolder.tvNomPrenom = (TextView) convertView.findViewById(R.id.profil_nom_prenom_item);
infoEtudiantViewHolder.tvCodePermanent = (TextView) convertView.findViewById(R.id.profil_code_permanent_item);
infoEtudiantViewHolder.tvSolde = (TextView) convertView.findViewById(R.id.profil_solde_item);
infoEtudiantViewHolder.tvCodeUniversel = (TextView) convertView.findViewById(R.id.profil_code_universel_item);
convertView.setTag(infoEtudiantViewHolder);
} else if (position == 1) {
convertView = LayoutInflater.from(context).inflate(R.layout.row_profile_liste_programmes, parent, false);
ListProgramViewHolder listProgramViewHolder = new ListProgramViewHolder();
listProgramViewHolder.spinnerProgram = (Spinner) convertView.findViewById(R.id.spinner_programmes);
listProgramViewHolder.tvCoursEchoues = (TextView) convertView.findViewById(R.id.profil_credit_echoue_item);
listProgramViewHolder.tvCoursEquivalents = (TextView) convertView.findViewById(R.id.profil_cours_equivalent_item);
listProgramViewHolder.tvCoursReussis = (TextView) convertView.findViewById(R.id.profil_cours_reussis_item);
listProgramViewHolder.tvCreditsInscrits = (TextView) convertView.findViewById(R.id.profil_credit_inscrit_item);
listProgramViewHolder.tvCreditsReussis = (TextView) convertView.findViewById(R.id.profil_credit_reussis_item);
listProgramViewHolder.tvMoyenne = (TextView) convertView.findViewById(R.id.profil_moyenne_item);
convertView.setTag(listProgramViewHolder);
}
}
if (position == 0) {
InfoEtudiantViewHolder infoEtudiantViewHolder = (InfoEtudiantViewHolder) convertView.getTag();
String nom = etudiant.nom != null ? etudiant.nom.trim() : "";
String prenom = etudiant.prenom != null ? etudiant.prenom.trim() : "";
infoEtudiantViewHolder.tvNomPrenom.setText(nom + ", " + prenom);
infoEtudiantViewHolder.tvCodePermanent.setText(etudiant.codePerm);
infoEtudiantViewHolder.tvSolde.setText(etudiant.soldeTotal);
infoEtudiantViewHolder.tvCodeUniversel.setText((ApplicationManager.userCredentials.getUsername()).toUpperCase());
} else if (position == 1) {
final ListProgramViewHolder listProgramViewHolder = (ListProgramViewHolder) convertView.getTag();
listProgramViewHolder.spinnerProgram.setAdapter(profileSpinnerAdapter);
Programme programme = (Programme) listProgramViewHolder.spinnerProgram.getSelectedItem();
listProgramViewHolder.tvMoyenne.setText(programme.moyenne);
listProgramViewHolder.tvCreditsReussis.setText(programme.nbCreditsCompletes);
listProgramViewHolder.tvCreditsInscrits.setText(programme.nbCreditsInscrits);
listProgramViewHolder.tvCoursReussis.setText(programme.nbCrsReussis);
listProgramViewHolder.tvCoursEquivalents.setText(programme.nbEquivalences);
listProgramViewHolder.tvCoursEchoues.setText(programme.nbCrsEchoues);
listProgramViewHolder.spinnerProgram.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// notifyDataSetChanged();
Programme selectedProgramme = profileSpinnerAdapter.getItem(position);
listProgramViewHolder.tvMoyenne.setText(selectedProgramme.moyenne);
listProgramViewHolder.tvCreditsReussis.setText(selectedProgramme.nbCreditsCompletes);
listProgramViewHolder.tvCreditsInscrits.setText(selectedProgramme.nbCreditsInscrits);
listProgramViewHolder.tvCoursReussis.setText(selectedProgramme.nbCrsReussis);
listProgramViewHolder.tvCoursEquivalents.setText(selectedProgramme.nbEquivalences);
listProgramViewHolder.tvCoursEchoues.setText(selectedProgramme.nbCrsEchoues);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
return convertView;
}
use of android.widget.Spinner in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class UserDictionaryAddWordFragment method updateSpinner.
private void updateSpinner() {
final ArrayList<LocaleRenderer> localesList = mContents.getLocalesList(getActivity());
final Spinner localeSpinner = (Spinner) mRootView.findViewById(R.id.user_dictionary_add_locale);
final ArrayAdapter<LocaleRenderer> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, localesList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
localeSpinner.setAdapter(adapter);
localeSpinner.setOnItemSelectedListener(this);
}
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 AntennaPod by AntennaPod.
the class OnlineFeedViewActivity method showFeedInformation.
/**
* Called when feed parsed successfully.
* This method is executed on the GUI thread.
*/
private void showFeedInformation(final Feed feed, Map<String, String> alternateFeedUrls) {
setContentView(R.layout.listview_activity);
this.feed = feed;
this.selectedDownloadUrl = feed.getDownload_url();
EventDistributor.getInstance().register(listener);
ListView listView = (ListView) findViewById(R.id.listview);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View header = inflater.inflate(R.layout.onlinefeedview_header, listView, false);
listView.addHeaderView(header);
listView.setAdapter(new FeedItemlistDescriptionAdapter(this, 0, feed.getItems()));
ImageView cover = (ImageView) header.findViewById(R.id.imgvCover);
TextView title = (TextView) header.findViewById(R.id.txtvTitle);
TextView author = (TextView) header.findViewById(R.id.txtvAuthor);
TextView description = (TextView) header.findViewById(R.id.txtvDescription);
Spinner spAlternateUrls = (Spinner) header.findViewById(R.id.spinnerAlternateUrls);
subscribeButton = (Button) header.findViewById(R.id.butSubscribe);
if (feed.getImage() != null && StringUtils.isNotBlank(feed.getImage().getDownload_url())) {
Glide.with(this).load(feed.getImage().getDownload_url()).placeholder(R.color.light_gray).error(R.color.light_gray).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).fitCenter().dontAnimate().into(cover);
}
title.setText(feed.getTitle());
author.setText(feed.getAuthor());
description.setText(feed.getDescription());
subscribeButton.setOnClickListener(v -> {
if (feed != null && feedInFeedlist(feed)) {
Intent intent = new Intent(OnlineFeedViewActivity.this, MainActivity.class);
intent.putExtra(MainActivity.EXTRA_FEED_ID, getFeedId(feed));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
} else {
Feed f = new Feed(selectedDownloadUrl, null, feed.getTitle());
f.setPreferences(feed.getPreferences());
this.feed = f;
try {
DownloadRequester.getInstance().downloadFeed(this, f);
} catch (DownloadRequestException e) {
Log.e(TAG, Log.getStackTraceString(e));
DownloadRequestErrorDialogCreator.newRequestErrorDialog(this, e.getMessage());
}
setSubscribeButtonState(feed);
}
});
if (alternateFeedUrls.isEmpty()) {
spAlternateUrls.setVisibility(View.GONE);
} else {
spAlternateUrls.setVisibility(View.VISIBLE);
final List<String> alternateUrlsList = new ArrayList<>();
final List<String> alternateUrlsTitleList = new ArrayList<>();
alternateUrlsList.add(feed.getDownload_url());
alternateUrlsTitleList.add(feed.getTitle());
alternateUrlsList.addAll(alternateFeedUrls.keySet());
for (String url : alternateFeedUrls.keySet()) {
alternateUrlsTitleList.add(alternateFeedUrls.get(url));
}
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, alternateUrlsTitleList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spAlternateUrls.setAdapter(adapter);
spAlternateUrls.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
selectedDownloadUrl = alternateUrlsList.get(position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
setSubscribeButtonState(feed);
}
Aggregations