use of android.widget.Spinner in project recyclerview-animators by wasabeef.
the class AnimatorSampleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_animator_sample);
Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
if (getIntent().getBooleanExtra("GRID", true)) {
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
} else {
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
recyclerView.setItemAnimator(new SlideInLeftAnimator());
final MainAdapter adapter = new MainAdapter(this, new ArrayList<>(Arrays.asList(data)));
recyclerView.setAdapter(adapter);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
for (Type type : Type.values()) {
spinnerAdapter.add(type.name());
}
spinner.setAdapter(spinnerAdapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
recyclerView.setItemAnimator(Type.values()[position].getAnimator());
recyclerView.getItemAnimator().setAddDuration(500);
recyclerView.getItemAnimator().setRemoveDuration(500);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
adapter.add("newly added item", 1);
}
});
findViewById(R.id.del).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
adapter.remove(1);
}
});
}
use of android.widget.Spinner in project WordPress-Android by wordpress-mobile.
the class AddCategoryActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((WordPress) getApplication()).component().inject(this);
setContentView(R.layout.add_category);
if (savedInstanceState == null) {
mSite = (SiteModel) getIntent().getSerializableExtra(WordPress.SITE);
} else {
mSite = (SiteModel) savedInstanceState.getSerializable(WordPress.SITE);
}
if (mSite == null) {
ToastUtils.showToast(this, R.string.blog_not_found, ToastUtils.Duration.SHORT);
finish();
return;
}
loadCategories();
final Button cancelButton = (Button) findViewById(R.id.cancel);
final Button okButton = (Button) findViewById(R.id.ok);
okButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
String categoryName = ((EditText) findViewById(R.id.category_name)).getText().toString();
String categoryDesc = ((EditText) findViewById(R.id.category_desc)).getText().toString();
Spinner categorySpinner = (Spinner) findViewById(R.id.parent_category);
CategoryNode selectedCategory = (CategoryNode) categorySpinner.getSelectedItem();
long parentId = (selectedCategory != null) ? selectedCategory.getCategoryId() : 0;
if (categoryName.replaceAll(" ", "").equals("")) {
// Name field cannot be empty
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(AddCategoryActivity.this);
dialogBuilder.setTitle(getResources().getText(R.string.required_field));
dialogBuilder.setMessage(getResources().getText(R.string.cat_name_required));
dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Just close the window.
}
});
dialogBuilder.setCancelable(true);
dialogBuilder.create().show();
} else {
Bundle bundle = new Bundle();
TermModel newCategory = new TermModel();
newCategory.setTaxonomy(TaxonomyStore.DEFAULT_TAXONOMY_CATEGORY);
newCategory.setName(categoryName);
newCategory.setDescription(categoryDesc);
newCategory.setParentRemoteId(parentId);
bundle.putSerializable(KEY_CATEGORY, newCategory);
Intent mIntent = new Intent();
mIntent.putExtras(bundle);
setResult(RESULT_OK, mIntent);
finish();
}
}
});
cancelButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Intent mIntent = new Intent();
setResult(RESULT_CANCELED, mIntent);
finish();
}
});
}
use of android.widget.Spinner in project WordPress-Android by wordpress-mobile.
the class AddCategoryActivity method loadCategories.
private void loadCategories() {
CategoryNode rootCategory = CategoryNode.createCategoryTreeFromList(mTaxonomyStore.getCategoriesForSite(mSite));
ArrayList<CategoryNode> categoryLevels = CategoryNode.getSortedListOfCategoriesFromRoot(rootCategory);
categoryLevels.add(0, new CategoryNode(0, 0, getString(R.string.none)));
if (categoryLevels.size() > 0) {
ParentCategorySpinnerAdapter categoryAdapter = new ParentCategorySpinnerAdapter(this, R.layout.categories_row_parent, categoryLevels);
Spinner sCategories = (Spinner) findViewById(R.id.parent_category);
sCategories.setAdapter(categoryAdapter);
}
}
use of android.widget.Spinner in project Conversations by siacs.
the class StartConversationActivity method showCreateConferenceDialog.
private void showCreateConferenceDialog() {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.create_conference);
final View dialogView = getLayoutInflater().inflate(R.layout.create_conference_dialog, null);
final Spinner spinner = (Spinner) dialogView.findViewById(R.id.account);
final EditText subject = (EditText) dialogView.findViewById(R.id.subject);
populateAccountSpinner(this, mActivatedAccounts, spinner);
builder.setView(dialogView);
builder.setPositiveButton(R.string.choose_participants, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!xmppConnectionServiceBound) {
return;
}
final Account account = getSelectedAccount(spinner);
if (account == null) {
return;
}
Intent intent = new Intent(getApplicationContext(), ChooseContactActivity.class);
intent.putExtra("multiple", true);
intent.putExtra("show_enter_jid", true);
intent.putExtra("subject", subject.getText().toString());
intent.putExtra(EXTRA_ACCOUNT, account.getJid().toBareJid().toString());
intent.putExtra(ChooseContactActivity.EXTRA_TITLE_RES_ID, R.string.choose_participants);
startActivityForResult(intent, REQUEST_CREATE_CONFERENCE);
}
});
builder.setNegativeButton(R.string.cancel, null);
mCurrentDialog = builder.create();
mCurrentDialog.show();
}
use of android.widget.Spinner in project platform_frameworks_base by android.
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);
}
Aggregations