use of android.widget.Spinner in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SupportItemAdapter method bindOfflineEscalationOptions.
private void bindOfflineEscalationOptions(ViewHolder holder, OfflineEscalationData data) {
// Bind Title
holder.tileTitleView.setText(data.tileTitle);
holder.tileTitleView.setContentDescription(data.tileTitleDescription);
holder.tileSummaryView.setText(data.tileSummary);
// Bind spinner
final Spinner spinner = (Spinner) holder.itemView.findViewById(R.id.spinner);
final ArrayAdapter<String> adapter = new ArrayAdapter(mActivity, android.R.layout.simple_spinner_dropdown_item, data.countries);
spinner.setAdapter(adapter);
final List<String> countryCodes = mSupportFeatureProvider.getPhoneSupportCountryCodes();
for (int i = 0; i < countryCodes.size(); i++) {
if (TextUtils.equals(countryCodes.get(i), mSelectedCountry)) {
spinner.setSelection(i);
break;
}
}
spinner.setOnItemSelectedListener(mSpinnerItemSelectListener);
// Bind buttons
if (data.tollFreePhone != null) {
holder.text1View.setText(data.tollFreePhone.number);
holder.text1View.setVisibility(View.VISIBLE);
holder.text1View.setOnClickListener(mEscalationClickListener);
} else {
holder.text1View.setVisibility(View.GONE);
}
if (data.tolledPhone != null) {
holder.text2View.setText(mActivity.getString(R.string.support_international_phone_title));
holder.text2View.setVisibility(View.VISIBLE);
holder.text2View.setOnClickListener(mEscalationClickListener);
} else {
holder.text2View.setVisibility(View.GONE);
}
if (ActivityManager.isUserAMonkey()) {
holder.text1View.setVisibility(View.GONE);
holder.text2View.setVisibility(View.GONE);
spinner.setVisibility(View.GONE);
holder.itemView.findViewById(R.id.support_text).setVisibility(View.GONE);
}
}
use of android.widget.Spinner in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SimPreferenceDialog method createEditDialog.
private void createEditDialog(Bundle bundle) {
final Resources res = mContext.getResources();
EditText nameText = (EditText) mDialogLayout.findViewById(R.id.sim_name);
nameText.setText(mSubInfoRecord.getDisplayName());
final Spinner tintSpinner = (Spinner) mDialogLayout.findViewById(R.id.spinner);
SelectColorAdapter adapter = new SelectColorAdapter(mContext, R.layout.settings_color_picker_item, mColorStrings);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
tintSpinner.setAdapter(adapter);
for (int i = 0; i < mTintArr.length; i++) {
if (mTintArr[i] == mSubInfoRecord.getIconTint()) {
tintSpinner.setSelection(i);
mTintSelectorPos = i;
break;
}
}
tintSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
tintSpinner.setSelection(pos);
mTintSelectorPos = pos;
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
final TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
TextView numberView = (TextView) mDialogLayout.findViewById(R.id.number);
final String rawNumber = tm.getLine1Number(mSubInfoRecord.getSubscriptionId());
if (TextUtils.isEmpty(rawNumber)) {
numberView.setText(res.getString(com.android.internal.R.string.unknownName));
} else {
numberView.setText(PhoneNumberUtils.formatNumber(rawNumber));
}
String simCarrierName = tm.getSimOperatorName(mSubInfoRecord.getSubscriptionId());
TextView carrierView = (TextView) mDialogLayout.findViewById(R.id.carrier);
carrierView.setText(!TextUtils.isEmpty(simCarrierName) ? simCarrierName : mContext.getString(com.android.internal.R.string.unknownName));
mBuilder.setTitle(String.format(res.getString(R.string.sim_editor_title), (mSubInfoRecord.getSimSlotIndex() + 1)));
mBuilder.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
final EditText nameText = (EditText) mDialogLayout.findViewById(R.id.sim_name);
String displayName = nameText.getText().toString();
int subId = mSubInfoRecord.getSubscriptionId();
mSubInfoRecord.setDisplayName(displayName);
mSubscriptionManager.setDisplayName(displayName, subId, SubscriptionManager.NAME_SOURCE_USER_INPUT);
final int tintSelected = tintSpinner.getSelectedItemPosition();
int subscriptionId = mSubInfoRecord.getSubscriptionId();
int tint = mTintArr[tintSelected];
mSubInfoRecord.setIconTint(tint);
mSubscriptionManager.setIconTint(tint, subscriptionId);
dialog.dismiss();
}
});
mBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
}
});
mBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
finish();
}
});
AlertDialog dialog = mBuilder.show();
final Button button = dialog.getButton(AlertDialog.BUTTON1);
if (TextUtils.isEmpty(mSubInfoRecord.getDisplayName()) || TextUtils.getTrimmedLength(mSubInfoRecord.getDisplayName()) == 0) {
button.setEnabled(false);
}
nameText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
button.setEnabled(TextUtils.getTrimmedLength(s) > 0);
}
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
});
}
use of android.widget.Spinner in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SpinnerPreference method onBindViewHolder.
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
Spinner spinner = (Spinner) holder.findViewById(R.id.cycles_spinner);
spinner.setAdapter(mAdapter);
spinner.setSelection(mPosition);
spinner.setOnItemSelectedListener(mOnSelectedListener);
}
use of android.widget.Spinner in project UltimateAndroid by cymcsg.
the class RecyclerViewItemAnimatorActivity method setupSpinner.
private void setupSpinner() {
Spinner spinner = (Spinner) findViewById(R.id.spinner);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.animators, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
switch(position) {
case 0:
mRecyclerView.setItemAnimator(new SlideInOutLeftItemAnimator(mRecyclerView));
break;
case 1:
mRecyclerView.setItemAnimator(new SlideInOutRightItemAnimator(mRecyclerView));
break;
case 2:
mRecyclerView.setItemAnimator(new SlideInOutTopItemAnimator(mRecyclerView));
break;
case 3:
mRecyclerView.setItemAnimator(new SlideInOutBottomItemAnimator(mRecyclerView));
break;
case 4:
mRecyclerView.setItemAnimator(new ScaleInOutItemAnimator(mRecyclerView));
break;
case 5:
mRecyclerView.setItemAnimator(new SlideScaleInOutRightItemAnimator(mRecyclerView));
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
}
use of android.widget.Spinner in project UltimateAndroid by cymcsg.
the class CropperSample method onCreate.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.cropper_activity);
// Sets fonts for all
Typeface mFont = Typeface.createFromAsset(getAssets(), "Roboto-Thin.ttf");
ViewGroup root = (ViewGroup) findViewById(R.id.mylayout);
setFont(root, mFont);
// Initialize components of the app
final CropImageView cropImageView = (CropImageView) findViewById(R.id.CropImageView);
final SeekBar aspectRatioXSeek = (SeekBar) findViewById(R.id.aspectRatioXSeek);
final SeekBar aspectRatioYSeek = (SeekBar) findViewById(R.id.aspectRatioYSeek);
final ToggleButton fixedAspectRatioToggle = (ToggleButton) findViewById(R.id.fixedAspectRatioToggle);
Spinner showGuidelinesSpin = (Spinner) findViewById(R.id.showGuidelinesSpin);
// Sets sliders to be disabled until fixedAspectRatio is set
aspectRatioXSeek.setEnabled(false);
aspectRatioYSeek.setEnabled(false);
// Set initial spinner value
showGuidelinesSpin.setSelection(ON_TOUCH);
//Sets the rotate button
final Button rotateButton = (Button) findViewById(R.id.Button_rotate);
rotateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
cropImageView.rotateImage(ROTATE_NINETY_DEGREES);
}
});
// Sets fixedAspectRatio
fixedAspectRatioToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
cropImageView.setFixedAspectRatio(isChecked);
if (isChecked) {
aspectRatioXSeek.setEnabled(true);
aspectRatioYSeek.setEnabled(true);
} else {
aspectRatioXSeek.setEnabled(false);
aspectRatioYSeek.setEnabled(false);
}
}
});
// Sets initial aspect ratio to 10/10, for demonstration purposes
cropImageView.setAspectRatio(DEFAULT_ASPECT_RATIO_VALUES, DEFAULT_ASPECT_RATIO_VALUES);
// Sets aspectRatioX
final TextView aspectRatioX = (TextView) findViewById(R.id.aspectRatioX);
aspectRatioXSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar aspectRatioXSeek, int progress, boolean fromUser) {
try {
mAspectRatioX = progress;
cropImageView.setAspectRatio(progress, mAspectRatioY);
aspectRatioX.setText(" " + progress);
} catch (IllegalArgumentException e) {
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
// Sets aspectRatioY
final TextView aspectRatioY = (TextView) findViewById(R.id.aspectRatioY);
aspectRatioYSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar aspectRatioYSeek, int progress, boolean fromUser) {
try {
mAspectRatioY = progress;
cropImageView.setAspectRatio(mAspectRatioX, progress);
aspectRatioY.setText(" " + progress);
} catch (IllegalArgumentException e) {
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
// Sets up the Spinner
showGuidelinesSpin.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
cropImageView.setGuidelines(i);
}
public void onNothingSelected(AdapterView<?> adapterView) {
return;
}
});
final Button cropButton = (Button) findViewById(R.id.Button_crop);
cropButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
croppedImage = cropImageView.getCroppedImage();
ImageView croppedImageView = (ImageView) findViewById(R.id.croppedImageView);
croppedImageView.setImageBitmap(croppedImage);
}
});
}
Aggregations