use of android.widget.Spinner in project android_frameworks_base by ResurrectionRemix.
the class BaseActivity method onCreate.
@CallSuper
@Override
public void onCreate(Bundle icicle) {
// Record the time when onCreate is invoked for metric.
mStartTime = new Date().getTime();
super.onCreate(icicle);
final Intent intent = getIntent();
addListenerForLaunchCompletion();
setContentView(mLayoutId);
mDrawer = DrawerController.create(this);
mState = getState(icicle);
Metrics.logActivityLaunch(this, mState, intent);
mRoots = DocumentsApplication.getRootsCache(this);
getContentResolver().registerContentObserver(RootsCache.sNotificationUri, false, mRootsCacheObserver);
mSearchManager = new SearchViewManager(this, icicle);
DocumentsToolbar toolbar = (DocumentsToolbar) findViewById(R.id.toolbar);
setActionBar(toolbar);
mNavigator = new NavigationView(mDrawer, toolbar, (Spinner) findViewById(R.id.stack), mState, this);
// Base classes must update result in their onCreate.
setResult(Activity.RESULT_CANCELED);
}
use of android.widget.Spinner in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppOpsDetails method refreshUi.
private boolean refreshUi() {
if (mPackageInfo == null) {
return false;
}
setAppLabelAndIcon(mPackageInfo);
Resources res = getActivity().getResources();
mOperationsSection.removeAllViews();
String lastPermGroup = "";
boolean isPlatformSigned = isPlatformSigned();
for (AppOpsState.OpsTemplate tpl : AppOpsState.ALL_TEMPLATES) {
/* If we are platform signed, only show the root switch, this
* one is safe to toggle while other permission-based ones could
* certainly cause system-wide problems
*/
if (isPlatformSigned && tpl != AppOpsState.SU_TEMPLATE) {
continue;
}
List<AppOpsState.AppOpEntry> entries = mState.buildState(tpl, mPackageInfo.applicationInfo.uid, mPackageInfo.packageName);
for (final AppOpsState.AppOpEntry entry : entries) {
final AppOpsManager.OpEntry firstOp = entry.getOpEntry(0);
final View view = mInflater.inflate(R.layout.app_ops_details_item, mOperationsSection, false);
mOperationsSection.addView(view);
String perm = AppOpsManager.opToPermission(firstOp.getOp());
if (perm != null) {
try {
PermissionInfo pi = mPm.getPermissionInfo(perm, 0);
if (pi.group != null && !lastPermGroup.equals(pi.group)) {
lastPermGroup = pi.group;
PermissionGroupInfo pgi = mPm.getPermissionGroupInfo(pi.group, 0);
if (pgi.icon != 0) {
((ImageView) view.findViewById(R.id.op_icon)).setImageDrawable(pgi.loadIcon(mPm));
}
}
} catch (NameNotFoundException e) {
}
}
((TextView) view.findViewById(R.id.op_name)).setText(entry.getSwitchText(mState));
((TextView) view.findViewById(R.id.op_counts)).setText(entry.getCountsText(res));
((TextView) view.findViewById(R.id.op_time)).setText(entry.getTimeText(res, true));
Spinner sp = (Spinner) view.findViewById(R.id.spinnerWidget);
sp.setVisibility(View.GONE);
Switch sw = (Switch) view.findViewById(R.id.switchWidget);
sw.setVisibility(View.GONE);
final int switchOp = AppOpsManager.opToSwitch(firstOp.getOp());
int mode = mAppOps.checkOpNoThrow(switchOp, entry.getPackageOps().getUid(), entry.getPackageOps().getPackageName());
sp.setSelection(modeToPosition(mode));
sp.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
boolean firstMode = true;
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
if (firstMode) {
firstMode = false;
return;
}
mAppOps.setMode(switchOp, entry.getPackageOps().getUid(), entry.getPackageOps().getPackageName(), positionToMode(position));
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
// Do nothing
}
});
sw.setChecked(mAppOps.checkOpNoThrow(switchOp, entry.getPackageOps().getUid(), entry.getPackageOps().getPackageName()) == AppOpsManager.MODE_ALLOWED);
sw.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mAppOps.setMode(switchOp, entry.getPackageOps().getUid(), entry.getPackageOps().getPackageName(), isChecked ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED);
}
});
if (AppOpsManager.isStrictOp(switchOp)) {
sp.setVisibility(View.VISIBLE);
} else {
sw.setVisibility(View.VISIBLE);
}
}
}
return true;
}
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 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