Java 类android.widget.SpinnerAdapter 实例源码
项目:AndroidMuseumBleManager
文件:MergeSpinnerAdapter.java
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
for (ListAdapter piece : getPieces()) {
int size = piece.getCount();
if (position < size) {
return (((SpinnerAdapter) piece).getDropDownView(position,
convertView,
parent));
}
position -= size;
}
return (null);
}
项目:revolution-irc
文件:AutoResizeSpinner.java
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
SpinnerAdapter adapter = getAdapter();
if (adapter != null && MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.AT_MOST) {
View view = adapter.getView(getSelectedItemPosition(), null, this);
if (view.getLayoutParams() == null)
view.setLayoutParams(mDefaultLayoutParams);
view.measure(widthMeasureSpec, heightMeasureSpec);
int width = view.getMeasuredWidth();
if (getBackground() != null) {
getBackground().getPadding(mTempRect);
width += mTempRect.left + mTempRect.right;
}
this.setMeasuredDimension(Math.min(width, MeasureSpec.getSize(widthMeasureSpec)), this.getMeasuredHeight());
}
}
项目:boohee_v5.6
文件:AppCompatSpinner.java
public DropDownAdapter(@Nullable SpinnerAdapter adapter, @Nullable Theme dropDownTheme) {
this.mAdapter = adapter;
if (adapter instanceof ListAdapter) {
this.mListAdapter = (ListAdapter) adapter;
}
if (dropDownTheme == null) {
return;
}
if (AppCompatSpinner.IS_AT_LEAST_M && (adapter instanceof ThemedSpinnerAdapter)) {
ThemedSpinnerAdapter themedAdapter = (ThemedSpinnerAdapter) adapter;
if (themedAdapter.getDropDownViewTheme() != dropDownTheme) {
themedAdapter.setDropDownViewTheme(dropDownTheme);
}
} else if (adapter instanceof ThemedSpinnerAdapter) {
ThemedSpinnerAdapter themedAdapter2 = (ThemedSpinnerAdapter) adapter;
if (themedAdapter2.getDropDownViewTheme() == null) {
themedAdapter2.setDropDownViewTheme(dropDownTheme);
}
}
}
项目:Silectric
文件:SearchableSpinner.java
@Override
public void setAdapter(SpinnerAdapter adapter) {
if (!_isFromInit) {
_arrayAdapter = (ArrayAdapter) adapter;
if (!TextUtils.isEmpty(_strHintText) && !_isDirty) {
ArrayAdapter arrayAdapter = new ArrayAdapter(_context, android.R.layout
.simple_list_item_1, new String[]{_strHintText});
super.setAdapter(arrayAdapter);
} else {
super.setAdapter(adapter);
}
} else {
_isFromInit = false;
super.setAdapter(adapter);
}
}
项目:MDPreference
文件:Spinner.java
/**
* Set an adapter for this Spinner.
* @param adapter
*/
public void setAdapter(SpinnerAdapter adapter) {
if(mAdapter != null)
mAdapter.unregisterDataSetObserver(mDataSetObserver);
mRecycler.clear();
mAdapter = adapter;
mAdapter.registerDataSetObserver(mDataSetObserver);
onDataChanged();
if (mPopup != null)
mPopup.setAdapter(new DropDownAdapter(adapter));
else
mTempAdapter = new DropDownAdapter(adapter);
}
项目:solved-hacking-problem
文件:bi.java
public bi(SpinnerAdapter spinnerAdapter, Theme theme) {
this.f1367a = spinnerAdapter;
if (spinnerAdapter instanceof ListAdapter) {
this.f1368b = (ListAdapter) spinnerAdapter;
}
if (theme == null) {
return;
}
if (bg.f1353a && (spinnerAdapter instanceof ThemedSpinnerAdapter)) {
ThemedSpinnerAdapter themedSpinnerAdapter = (ThemedSpinnerAdapter) spinnerAdapter;
if (themedSpinnerAdapter.getDropDownViewTheme() != theme) {
themedSpinnerAdapter.setDropDownViewTheme(theme);
}
} else if (spinnerAdapter instanceof dd) {
dd ddVar = (dd) spinnerAdapter;
if (ddVar.m2705a() == null) {
ddVar.m2706a(theme);
}
}
}
项目:solved-hacking-problem
文件:bi.java
public bi(SpinnerAdapter spinnerAdapter, Theme theme) {
this.f1367a = spinnerAdapter;
if (spinnerAdapter instanceof ListAdapter) {
this.f1368b = (ListAdapter) spinnerAdapter;
}
if (theme == null) {
return;
}
if (bg.f1353a && (spinnerAdapter instanceof ThemedSpinnerAdapter)) {
ThemedSpinnerAdapter themedSpinnerAdapter = (ThemedSpinnerAdapter) spinnerAdapter;
if (themedSpinnerAdapter.getDropDownViewTheme() != theme) {
themedSpinnerAdapter.setDropDownViewTheme(theme);
}
} else if (spinnerAdapter instanceof dd) {
dd ddVar = (dd) spinnerAdapter;
if (ddVar.m2705a() == null) {
ddVar.m2706a(theme);
}
}
}
项目:permissionsModule
文件:AppCompatSpinner.java
@Override
public void setAdapter(SpinnerAdapter adapter) {
// The super constructor may call setAdapter before we're prepared.
// Postpone doing anything until we've finished construction.
if (!mPopupSet) {
mTempAdapter = adapter;
return;
}
super.setAdapter(adapter);
if (mPopup != null) {
final Context popupContext = mPopupContext == null ? getContext() : mPopupContext;
mPopup.setAdapter(new DropDownAdapter(adapter, popupContext.getTheme()));
}
}
项目:idec-mobile
文件:FileUploadFragment.java
@Override
public void onStart() {
super.onStart();
nodeindex = Config.currentSelectedStation;
SpinnerAdapter spinnerAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item,
IDECFunctions.getStationsNames());
stations_spinner.setAdapter(spinnerAdapter);
stations_spinner.setSelection(nodeindex);
if (input_action_send != null) {
handleFileChosen(input_action_send);
SimpleFunctions.debug("file was chosen");
} else {
SimpleFunctions.debug("File was not chosen, try to do by hand!");
}
}
项目:AndroidBleManager
文件:MergeSpinnerAdapter.java
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
for (ListAdapter piece : getPieces()) {
int size=piece.getCount();
if (position<size) {
return(((SpinnerAdapter)piece).getDropDownView(position,
convertView,
parent));
}
position-=size;
}
return(null);
}
项目:SecureSmartHome
文件:AddNewUserDeviceFragment.java
private void updateGroupSpinner() {
AppUserConfigurationHandler handler = getComponent(AppUserConfigurationHandler.KEY);
if (handler == null) {
Log.e(TAG, "Container not connected!");
return;
}
Set<Group> allGroups = handler.getAllGroups();
if (allGroups.size() < 1) {
Log.i(TAG, "No groups available, yet.");
return;
}
this.groups = Lists.newArrayList(Iterables.transform(allGroups, new Function<Group, String>() {
@Override
public String apply(Group input) {
return input.getName();
}
}));
SpinnerAdapter adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, groups);
spinner.setAdapter(adapter);
spinner.setEnabled(true);
}
项目:FMTech
文件:AppCompatSpinner.java
public void setAdapter(SpinnerAdapter paramSpinnerAdapter)
{
if (!this.mPopupSet) {
this.mTempAdapter = paramSpinnerAdapter;
}
do
{
return;
super.setAdapter(paramSpinnerAdapter);
} while (this.mPopup == null);
if (this.mPopupContext == null) {}
for (Context localContext = getContext();; localContext = this.mPopupContext)
{
this.mPopup.setAdapter(new DropDownAdapter(paramSpinnerAdapter, localContext.getTheme()));
return;
}
}
项目:material_fork
文件:Spinner.java
/**
* Set an adapter for this Spinner.
* @param adapter
*/
public void setAdapter(SpinnerAdapter adapter) {
if(mAdapter != null)
mAdapter.unregisterDataSetObserver(mDataSetObserver);
mRecycler.clear();
mAdapter = adapter;
mAdapter.registerDataSetObserver(mDataSetObserver);
onDataChanged();
if (mPopup != null)
mPopup.setAdapter(new DropDownAdapter(adapter));
else
mTempAdapter = new DropDownAdapter(adapter);
}
项目:ApiDemos
文件:Gallery2.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gallery_2);
// Get a cursor with all people
Cursor c = getContentResolver().query(Contacts.CONTENT_URI,
CONTACT_PROJECTION, null, null, null);
startManagingCursor(c);
SpinnerAdapter adapter = new SimpleCursorAdapter(this,
// Use a template that displays a text view
android.R.layout.simple_gallery_item,
// Give the cursor to the list adatper
c,
// Map the NAME column in the people database to...
new String[] {Contacts.DISPLAY_NAME},
// The "text1" view defined in the XML template
new int[] { android.R.id.text1 });
Gallery g = (Gallery) findViewById(R.id.gallery);
g.setAdapter(adapter);
}
项目:openwebnet-android
文件:ScenarioActivityTest.java
@Test
public void shouldVerifyOnCreate_initSpinner() {
List<EnvironmentModel> environments = Arrays.
asList(newEnvironment(100, "env1"), newEnvironment(101, "env2"));
List<GatewayModel> gateways = Arrays.
asList(newGateway("uuid1", "1.1.1.1", 1), newGateway("uuid2", "2.2.2.2", 2));
when(environmentService.findAll()).thenReturn(Observable.just(environments));
when(gatewayService.findAll()).thenReturn(Observable.just(gateways));
createWithIntent(null);
SpinnerAdapter adapterEnvironment = spinnerDeviceEnvironment.getAdapter();
assertFalse("should not be empty", adapterEnvironment.isEmpty());
assertEquals("should verify first element", "env1", adapterEnvironment.getItem(0));
assertEquals("should verify second element", "env2", adapterEnvironment.getItem(1));
assertEquals("should select default", 0, spinnerDeviceEnvironment.getSelectedItemPosition());
SpinnerAdapter adapterGateway = spinnerDeviceGateway.getAdapter();
assertFalse("should not be empty", adapterGateway.isEmpty());
assertEquals("should verify first element", "1.1.1.1:1", adapterGateway.getItem(0));
assertEquals("should verify second element", "2.2.2.2:2", adapterGateway.getItem(1));
assertEquals("should select default", 0, spinnerDeviceGateway.getSelectedItemPosition());
}
项目:openwebnet-android
文件:SoundActivityTest.java
@Test
public void shouldVerifyOnCreate_initSpinner_noResult() {
when(environmentService.findAll()).thenReturn(Observable.just(new ArrayList<>()));
when(gatewayService.findAll()).thenReturn(Observable.just(new ArrayList<>()));
createWithIntent(null);
SpinnerAdapter adapterEnvironment = spinnerDeviceEnvironment.getAdapter();
assertFalse("should not be empty", adapterEnvironment.isEmpty());
assertEquals("should verify first element", labelNone, adapterEnvironment.getItem(0));
SpinnerAdapter adapterGateway = spinnerDeviceGateway.getAdapter();
assertFalse("should not be empty", adapterGateway.isEmpty());
assertEquals("should verify first element", labelMissingGateway, adapterGateway.getItem(0));
verifyInitSpinnerSoundType();
}
项目:openwebnet-android
文件:AutomationActivityTest.java
@Test
public void shouldVerifyOnCreate_initSpinner() {
List<EnvironmentModel> environments = Arrays.
asList(newEnvironment(100, "env1"), newEnvironment(101, "env2"));
List<GatewayModel> gateways = Arrays.
asList(newGateway("uuid1", "1.1.1.1", 1), newGateway("uuid2", "2.2.2.2", 2));
when(environmentService.findAll()).thenReturn(Observable.just(environments));
when(gatewayService.findAll()).thenReturn(Observable.just(gateways));
createWithIntent(null);
SpinnerAdapter adapterEnvironment = spinnerDeviceEnvironment.getAdapter();
assertFalse("should not be empty", adapterEnvironment.isEmpty());
assertEquals("should verify first element", "env1", adapterEnvironment.getItem(0));
assertEquals("should verify second element", "env2", adapterEnvironment.getItem(1));
assertEquals("should select default", 0, spinnerDeviceEnvironment.getSelectedItemPosition());
SpinnerAdapter adapterGateway = spinnerDeviceGateway.getAdapter();
assertFalse("should not be empty", adapterGateway.isEmpty());
assertEquals("should verify first element", "1.1.1.1:1", adapterGateway.getItem(0));
assertEquals("should verify second element", "2.2.2.2:2", adapterGateway.getItem(1));
assertEquals("should select default", 0, spinnerDeviceGateway.getSelectedItemPosition());
}
项目:openwebnet-android
文件:LightActivityTest.java
@Test
public void shouldVerifyOnCreate_initSpinner_noResult() {
when(environmentService.findAll()).thenReturn(Observable.just(new ArrayList<>()));
when(gatewayService.findAll()).thenReturn(Observable.just(new ArrayList<>()));
createWithIntent(null);
SpinnerAdapter adapterEnvironment = spinnerDeviceEnvironment.getAdapter();
assertFalse("should not be empty", adapterEnvironment.isEmpty());
assertEquals("should verify first element", labelNone, adapterEnvironment.getItem(0));
SpinnerAdapter adapterGateway = spinnerDeviceGateway.getAdapter();
assertFalse("should not be empty", adapterGateway.isEmpty());
assertEquals("should verify first element", labelMissingGateway, adapterGateway.getItem(0));
verifyInitSpinnerLightType();
}
项目:offer
文件:OfferSlideMenuActivity.java
private void changeActionBar() {
ActionBar actionBar = getSupportActionBar();
if (actionBar == null) {
return;
}
actionBar.setDisplayShowCustomEnabled(false);
actionBar.setTitle("");
SpinnerAdapter mSpinnerAdapter =
ArrayAdapter.createFromResource(this, R.array.action_bar_action_month_list,
android.R.layout.simple_spinner_dropdown_item);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
actionBar.setSelectedNavigationItem(7); // 数字为几,就是为几月
ActionBar.OnNavigationListener mOnNavigationListener = new ActionBar.OnNavigationListener() {
// 获得ArrayAdapter需要的字符串数组
String[] strings = getResources().getStringArray(R.array.action_bar_action_month_list);
@Override
// 监听用户的选择
public boolean onNavigationItemSelected(int position, long itemId) {
return true;
}
};
actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);
}
项目:android_ui
文件:SpinnerLayout.java
/**
* Delegate method for {@link android.widget.Spinner#setAdapter(android.widget.SpinnerAdapter)}.
*/
public void setAdapter(@Nullable SpinnerAdapter adapter) {
this.mAdapter = adapter;
if (mSpinner != null) {
mSpinner.setAdapter(mAdapter);
if ((mPrivateFlags & PFLAG_ITEM_SELECTED_LISTENER_ATTACHED) == 0) {
mSpinner.setSelection(mSelection, false);
mSpinner.setOnItemSelectedListener(ITEM_SELECTED_LISTENER);
this.updatePrivateFlags(PFLAG_ITEM_SELECTED_LISTENER_ATTACHED, true);
}
}
}
项目:CSipSimple
文件:ActionBarImpl.java
@Override
public int getNavigationItemCount() {
switch (mActionView.getNavigationMode()) {
case NAVIGATION_MODE_TABS:
return mTabs.size();
case NAVIGATION_MODE_LIST:
SpinnerAdapter adapter = mActionView.getDropdownAdapter();
return adapter != null ? adapter.getCount() : 0;
default:
return 0;
}
}
项目:CSipSimple
文件:IcsAbsSpinner.java
/**
* The Adapter is used to provide the data which backs this Spinner.
* It also provides methods to transform spinner items based on their position
* relative to the selected item.
* @param adapter The SpinnerAdapter to use for this Spinner
*/
@Override
public void setAdapter(SpinnerAdapter adapter) {
if (null != mAdapter) {
mAdapter.unregisterDataSetObserver(mDataSetObserver);
resetList();
}
mAdapter = adapter;
mOldSelectedPosition = INVALID_POSITION;
mOldSelectedRowId = INVALID_ROW_ID;
if (mAdapter != null) {
mOldItemCount = mItemCount;
mItemCount = mAdapter.getCount();
checkFocus();
mDataSetObserver = new AdapterDataSetObserver();
mAdapter.registerDataSetObserver(mDataSetObserver);
int position = mItemCount > 0 ? 0 : INVALID_POSITION;
setSelectedPositionInt(position);
setNextSelectedPositionInt(position);
if (mItemCount == 0) {
// Nothing selected
checkSelectionChanged();
}
} else {
checkFocus();
resetList();
// Nothing selected
checkSelectionChanged();
}
requestLayout();
}
项目:CSipSimple
文件:IcsSpinner.java
@Override
public void setAdapter(SpinnerAdapter adapter) {
super.setAdapter(adapter);
if (mPopup != null) {
mPopup.setAdapter(new DropDownAdapter(adapter));
} else {
mTempAdapter = new DropDownAdapter(adapter);
}
}
项目:CSipSimple
文件:IcsSpinner.java
/**
* <p>Creates a new ListAdapter wrapper for the specified adapter.</p>
*
* @param adapter the Adapter to transform into a ListAdapter
*/
public DropDownAdapter(SpinnerAdapter adapter) {
this.mAdapter = adapter;
if (adapter instanceof ListAdapter) {
this.mListAdapter = (ListAdapter) adapter;
}
}
项目:simple-keyboard
文件:CustomInputStylePreference.java
private static void setSpinnerPosition(final Spinner spinner, final Object itemToSelect) {
final SpinnerAdapter adapter = spinner.getAdapter();
final int count = adapter.getCount();
for (int i = 0; i < count; i++) {
final Object item = spinner.getItemAtPosition(i);
if (item.equals(itemToSelect)) {
spinner.setSelection(i);
return;
}
}
}
项目:CustomFormViews
文件:NothingSelectedSpinnerAdapter.java
private NothingSelectedSpinnerAdapter(SpinnerAdapter spinnerAdapter, int nothingSelectedLayout,
int nothingSelectedDropdownLayout, Context context, String hint) {
this.adapter = spinnerAdapter;
this.context = context;
this.nothingSelectedLayout = nothingSelectedLayout;
this.nothingSelectedDropdownLayout = nothingSelectedDropdownLayout;
this.mHint = hint;
layoutInflater = LayoutInflater.from(context);
}
项目:Blockly
文件:BlockViewFactory.java
protected SpinnerAdapter getVariableAdapter() {
if (mVariableNameManager == null) {
throw new IllegalStateException("NameManager must be set before variable field is "
+ "instantiated.");
}
if (mVariableAdapter == null) {
mVariableAdapter = new BasicFieldVariableView.VariableViewAdapter(
mContext, mVariableNameManager, android.R.layout.simple_spinner_item);
}
return mVariableAdapter;
}
项目:Blockly
文件:BasicFieldVariableView.java
@Override
public void setAdapter(SpinnerAdapter adapter) {
mAdapter = (VariableViewAdapter) adapter;
super.setAdapter(adapter);
if (mAdapter != null) {
refreshSelection();
mAdapter.registerDataSetObserver(new DataSetObserver() {
@Override
public void onChanged() {
refreshSelection();
}
});
}
}
项目:Blockly
文件:VerticalBlockViewFactory.java
@Override
protected SpinnerAdapter getVariableAdapter() {
if (mVariableNameManager == null) {
throw new IllegalStateException("NameManager must be set before variable field is "
+ "instantiated.");
}
if (mVariableAdapter == null) {
BasicFieldVariableView.VariableViewAdapter
adapter = new BasicFieldVariableView.VariableViewAdapter(
mContext, mVariableNameManager, R.layout.default_spinner_closed_item);
adapter.setDropDownViewResource(R.layout.default_spinner_dropdown_item);
mVariableAdapter = adapter;
}
return mVariableAdapter;
}
项目:boohee_v5.6
文件:AppCompatSpinner.java
void computeContentWidth() {
Drawable background = getBackground();
int hOffset = 0;
if (background != null) {
background.getPadding(AppCompatSpinner.this.mTempRect);
hOffset = ViewUtils.isLayoutRtl(AppCompatSpinner.this) ? AppCompatSpinner.this.mTempRect.right : -AppCompatSpinner.this.mTempRect.left;
} else {
Rect access$300 = AppCompatSpinner.this.mTempRect;
AppCompatSpinner.this.mTempRect.right = 0;
access$300.left = 0;
}
int spinnerPaddingLeft = AppCompatSpinner.this.getPaddingLeft();
int spinnerPaddingRight = AppCompatSpinner.this.getPaddingRight();
int spinnerWidth = AppCompatSpinner.this.getWidth();
if (AppCompatSpinner.this.mDropDownWidth == -2) {
int contentWidth = AppCompatSpinner.this.compatMeasureContentWidth((SpinnerAdapter) this.mAdapter, getBackground());
int contentWidthLimit = (AppCompatSpinner.this.getContext().getResources().getDisplayMetrics().widthPixels - AppCompatSpinner.this.mTempRect.left) - AppCompatSpinner.this.mTempRect.right;
if (contentWidth > contentWidthLimit) {
contentWidth = contentWidthLimit;
}
setContentWidth(Math.max(contentWidth, (spinnerWidth - spinnerPaddingLeft) - spinnerPaddingRight));
} else if (AppCompatSpinner.this.mDropDownWidth == -1) {
setContentWidth((spinnerWidth - spinnerPaddingLeft) - spinnerPaddingRight);
} else {
setContentWidth(AppCompatSpinner.this.mDropDownWidth);
}
if (ViewUtils.isLayoutRtl(AppCompatSpinner.this)) {
hOffset += (spinnerWidth - spinnerPaddingRight) - getWidth();
} else {
hOffset += spinnerPaddingLeft;
}
setHorizontalOffset(hOffset);
}
项目:boohee_v5.6
文件:AppCompatSpinner.java
public void setAdapter(SpinnerAdapter adapter) {
if (this.mPopupSet) {
super.setAdapter(adapter);
if (this.mPopup != null) {
this.mPopup.setAdapter(new DropDownAdapter(adapter, (this.mPopupContext == null ? getContext() : this.mPopupContext).getTheme()));
return;
}
return;
}
this.mTempAdapter = adapter;
}
项目:boohee_v5.6
文件:AppCompatSpinner.java
private int compatMeasureContentWidth(SpinnerAdapter adapter, Drawable background) {
if (adapter == null) {
return 0;
}
int width = 0;
View itemView = null;
int itemType = 0;
int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 0);
int heightMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), 0);
int start = Math.max(0, getSelectedItemPosition());
int end = Math.min(adapter.getCount(), start + 15);
for (int i = Math.max(0, start - (15 - (end - start))); i < end; i++) {
int positionType = adapter.getItemViewType(i);
if (positionType != itemType) {
itemType = positionType;
itemView = null;
}
itemView = adapter.getView(i, itemView, this);
if (itemView.getLayoutParams() == null) {
itemView.setLayoutParams(new LayoutParams(-2, -2));
}
itemView.measure(widthMeasureSpec, heightMeasureSpec);
width = Math.max(width, itemView.getMeasuredWidth());
}
if (background == null) {
return width;
}
background.getPadding(this.mTempRect);
return width + (this.mTempRect.left + this.mTempRect.right);
}
项目:financisto1-holo
文件:RecurActivity.java
private void editRecur(Recur recur) {
editStartDate(recur.startDate);
RecurInterval interval = recur.interval;
SpinnerAdapter adapter = sInterval.getAdapter();
int count = adapter.getCount();
for (int i=0; i<count; i++) {
SpinnerItem item = (SpinnerItem)adapter.getItem(i);
if (interval == RecurInterval.valueOf(item.value)) {
sInterval.setSelection(i);
break;
}
}
View v = selectInterval(interval);
switch (interval) {
case EVERY_X_DAY:
editEveryXDay(v, recur);
break;
case WEEKLY:
editWeekly(v, recur);
break;
case SEMI_MONTHLY:
editSemiMonthly(v, recur);
break;
}
RecurPeriod period = recur.period;
sPeriod.setSelection(period.ordinal());
v = selectPeriod(period);
switch (period) {
case EXACTLY_TIMES:
editExactlyTimes(v, recur.periodParam);
break;
case STOPS_ON_DATE:
editStopsOnDate(v, recur.periodParam);
break;
}
}
项目:AOSP-Kayboard-7.1.2
文件:CustomInputStylePreference.java
private static void setSpinnerPosition(final Spinner spinner, final Object itemToSelect) {
final SpinnerAdapter adapter = spinner.getAdapter();
final int count = adapter.getCount();
for (int i = 0; i < count; i++) {
final Object item = spinner.getItemAtPosition(i);
if (item.equals(itemToSelect)) {
spinner.setSelection(i);
return;
}
}
}
项目:MDPreference
文件:Spinner.java
private int measureContentWidth(SpinnerAdapter adapter, Drawable background) {
if (adapter == null)
return 0;
int width = 0;
View itemView = null;
int itemType = 0;
final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
// Make sure the number of items we'll measure is capped. If it's a huge data set
// with wildly varying sizes, oh well.
int start = Math.max(0, getSelectedItemPosition());
final int end = Math.min(adapter.getCount(), start + MAX_ITEMS_MEASURED);
final int count = end - start;
start = Math.max(0, start - (MAX_ITEMS_MEASURED - count));
for (int i = start; i < end; i++) {
final int positionType = adapter.getItemViewType(i);
if (positionType != itemType) {
itemType = positionType;
itemView = null;
}
itemView = adapter.getView(i, itemView, null);
if (itemView.getLayoutParams() == null)
itemView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
itemView.measure(widthMeasureSpec, heightMeasureSpec);
width = Math.max(width, itemView.getMeasuredWidth());
}
// Add background padding to measured width
if (background != null) {
background.getPadding(mTempRect);
width += mTempRect.left + mTempRect.right;
}
return width;
}
项目:MDPreference
文件:Spinner.java
void computeContentWidth() {
final Drawable background = getBackground();
int hOffset = 0;
if (background != null) {
background.getPadding(mTempRect);
hOffset = mIsRtl ? mTempRect.right : -mTempRect.left;
} else
mTempRect.left = mTempRect.right = 0;
final int spinnerPaddingLeft = Spinner.this.getPaddingLeft();
final int spinnerPaddingRight = Spinner.this.getPaddingRight();
final int spinnerWidth = Spinner.this.getWidth();
if (mDropDownWidth == WRAP_CONTENT) {
int contentWidth = measureContentWidth((SpinnerAdapter) mAdapter, getBackground());
final int contentWidthLimit = getContext().getResources().getDisplayMetrics().widthPixels - mTempRect.left - mTempRect.right;
if (contentWidth > contentWidthLimit)
contentWidth = contentWidthLimit;
setContentWidth(Math.max(contentWidth, spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight));
} else if (mDropDownWidth == MATCH_PARENT)
setContentWidth(spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight);
else
setContentWidth(mDropDownWidth);
if (mIsRtl)
hOffset += spinnerWidth - spinnerPaddingRight - getWidth();
else
hOffset += spinnerPaddingLeft;
setHorizontalOffset(hOffset);
}
项目:todo-list
文件:NewTaskDescriptionFragment.java
private void initPrioritySpinner() {
final List<TaskPriority> priorities = ImmutableList.of(HIGH, NORMAL, LOW);
final SpinnerAdapter adapter = new ArrayAdapter<>(getContext(),
R.layout.item_priopity,
R.id.priority,
priorities);
spinner.setAdapter(adapter);
spinner.setSelection(priorities.indexOf(NORMAL));
}
项目:solved-hacking-problem
文件:bg.java
private int m2544a(SpinnerAdapter spinnerAdapter, Drawable drawable) {
if (spinnerAdapter == null) {
return 0;
}
int makeMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 0);
int makeMeasureSpec2 = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), 0);
int max = Math.max(0, getSelectedItemPosition());
int min = Math.min(spinnerAdapter.getCount(), max + 15);
int max2 = Math.max(0, max - (15 - (min - max)));
View view = null;
int i = 0;
max = 0;
while (max2 < min) {
View view2;
int itemViewType = spinnerAdapter.getItemViewType(max2);
if (itemViewType != max) {
view2 = null;
} else {
itemViewType = max;
view2 = view;
}
view = spinnerAdapter.getView(max2, view2, this);
if (view.getLayoutParams() == null) {
view.setLayoutParams(new LayoutParams(-2, -2));
}
view.measure(makeMeasureSpec, makeMeasureSpec2);
i = Math.max(i, view.getMeasuredWidth());
max2++;
max = itemViewType;
}
if (drawable == null) {
return i;
}
drawable.getPadding(this.f1364l);
return (this.f1364l.left + this.f1364l.right) + i;
}
项目:solved-hacking-problem
文件:bg.java
public void setAdapter(SpinnerAdapter spinnerAdapter) {
if (this.f1361i) {
super.setAdapter(spinnerAdapter);
if (this.f1362j != null) {
this.f1362j.m2589a(new bi(spinnerAdapter, (this.f1358f == null ? getContext() : this.f1358f).getTheme()));
return;
}
return;
}
this.f1360h = spinnerAdapter;
}
项目:solved-hacking-problem
文件:bj.java
void m2591b() {
int i;
Drawable d = m2569d();
if (d != null) {
d.getPadding(this.f1401a.f1364l);
i = du.m2794a(this.f1401a) ? this.f1401a.f1364l.right : -this.f1401a.f1364l.left;
} else {
Rect b = this.f1401a.f1364l;
this.f1401a.f1364l.right = 0;
b.left = 0;
i = 0;
}
int paddingLeft = this.f1401a.getPaddingLeft();
int paddingRight = this.f1401a.getPaddingRight();
int width = this.f1401a.getWidth();
if (this.f1401a.f1363k == -2) {
int a = this.f1401a.m2544a((SpinnerAdapter) this.f1403d, m2569d());
int i2 = (this.f1401a.getContext().getResources().getDisplayMetrics().widthPixels - this.f1401a.f1364l.left) - this.f1401a.f1364l.right;
if (a <= i2) {
i2 = a;
}
m2574f(Math.max(i2, (width - paddingLeft) - paddingRight));
} else if (this.f1401a.f1363k == -1) {
m2574f((width - paddingLeft) - paddingRight);
} else {
m2574f(this.f1401a.f1363k);
}
m2566b(du.m2794a(this.f1401a) ? ((width - paddingRight) - m2577h()) + i : i + paddingLeft);
}