Search in sources :

Example 66 with AdapterView

use of android.widget.AdapterView in project Android-AccountChooser by frakbot.

the class ChooseAccountTypeActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "ChooseAccountTypeActivity.onCreate(savedInstanceState=" + savedInstanceState + ")");
    }
    // Read the validAccountTypes, if present, and add them to the setOfAllowableAccountTypes
    Set<String> setOfAllowableAccountTypes = null;
    String[] validAccountTypes = getIntent().getStringArrayExtra(ChooseTypeAndAccountActivity.EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY);
    if (validAccountTypes != null) {
        setOfAllowableAccountTypes = new HashSet<String>(validAccountTypes.length);
        for (String type : validAccountTypes) {
            setOfAllowableAccountTypes.add(type);
        }
    }
    // create a map of account authenticators
    buildTypeToAuthDescriptionMap();
    // Create a list of authenticators that are allowable. Filter out those that
    // don't match the allowable account types, if provided.
    mAuthenticatorInfosToDisplay = new ArrayList<AuthInfo>(mTypeToAuthenticatorInfo.size());
    for (Map.Entry<String, AuthInfo> entry : mTypeToAuthenticatorInfo.entrySet()) {
        final String type = entry.getKey();
        final AuthInfo info = entry.getValue();
        if (setOfAllowableAccountTypes != null && !setOfAllowableAccountTypes.contains(type)) {
            continue;
        }
        mAuthenticatorInfosToDisplay.add(info);
    }
    if (mAuthenticatorInfosToDisplay.isEmpty()) {
        Bundle bundle = new Bundle();
        bundle.putString(AccountManager.KEY_ERROR_MESSAGE, "no allowable account types");
        setResult(Activity.RESULT_OK, new Intent().putExtras(bundle));
        finish();
        return;
    }
    if (mAuthenticatorInfosToDisplay.size() == 1) {
        setResultAndFinish(mAuthenticatorInfosToDisplay.get(0).desc.type);
        return;
    }
    setContentView(R.layout.choose_account_type);
    // Setup the list
    ListView list = (ListView) findViewById(android.R.id.list);
    // Use an existing ListAdapter that will map an array of strings to TextViews
    list.setAdapter(new AccountArrayAdapter(this, android.R.layout.simple_list_item_1, mAuthenticatorInfosToDisplay));
    list.setChoiceMode(ListView.CHOICE_MODE_NONE);
    list.setTextFilterEnabled(false);
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            setResultAndFinish(mAuthenticatorInfosToDisplay.get(position).desc.type);
        }
    });
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) HashMap(java.util.HashMap) Map(java.util.Map)

Example 67 with AdapterView

use of android.widget.AdapterView in project Android-AccountChooser by frakbot.

the class ChooseTypeAndAccountActivity method populateUIAccountList.

/**
     * Populates the UI ListView with the given list of items and selects an item
     * based on {@code mSelectedItemIndex} member variable.
     */
private final void populateUIAccountList(String[] listItems) {
    ListView list = (ListView) findViewById(android.R.id.list);
    list.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice, listItems));
    list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    list.setItemsCanFocus(false);
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            mSelectedItemIndex = position;
            mOkButton.setEnabled(true);
        }
    });
    if (mSelectedItemIndex != SELECTED_ITEM_NONE) {
        list.setItemChecked(mSelectedItemIndex, true);
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "List item " + mSelectedItemIndex + " should be selected");
        }
    }
}
Also used : ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 68 with AdapterView

use of android.widget.AdapterView in project rebound by facebook.

the class PlaygroundActivity method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (mAnimating) {
        return;
    }
    Class<? extends View> clazz = SAMPLES.get(position).viewClass;
    View sampleView = null;
    try {
        Constructor<? extends View> ctor = clazz.getConstructor(Context.class);
        sampleView = ctor.newInstance(PlaygroundActivity.this);
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    if (sampleView == null) {
        return;
    }
    mAnimating = true;
    mCurrentExample = new ExampleContainerView(this);
    mCurrentExample.addView(sampleView);
    mRootView.addView(mCurrentExample);
    mCurrentExample.postDelayed(new Runnable() {

        @Override
        public void run() {
            mCurrentExample.reveal(true, new ExampleContainerView.Callback() {

                @Override
                public void onProgress(double progress) {
                    float scale = (float) SpringUtil.mapValueFromRangeToRange(progress, 0, 1, 0.8, 1);
                    mRootContainer.setScaleX(scale);
                    mRootContainer.setScaleY(scale);
                    mRootContainer.setAlpha((float) progress);
                }

                @Override
                public void onEnd() {
                    mAnimating = false;
                }
            });
        }
    }, 100);
}
Also used : View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 69 with AdapterView

use of android.widget.AdapterView in project AndroidSDK-RecipeBook by gabu.

the class Recipe052 method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    String[] data = { "Point", "Line", "Rect", "Circle", "Oval", "Arc", "Path" };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, data);
    mSpinner = (Spinner) findViewById(R.id.spinner);
    mSpinner.setAdapter(adapter);
    mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch(position) {
                case 0:
                    mCanvasView.setDrawMode(CanvasView.DRAW_POINT);
                    break;
                case 1:
                    mCanvasView.setDrawMode(CanvasView.DRAW_LINE);
                    break;
                case 2:
                    mCanvasView.setDrawMode(CanvasView.DRAW_RECT);
                    break;
                case 3:
                    mCanvasView.setDrawMode(CanvasView.DRAW_CIRCLE);
                    break;
                case 4:
                    mCanvasView.setDrawMode(CanvasView.DRAW_OVAL);
                    break;
                case 5:
                    mCanvasView.setDrawMode(CanvasView.DRAW_ARC);
                    break;
                case 6:
                    mCanvasView.setDrawMode(CanvasView.DRAW_PATH);
                    break;
            }
            mCanvasView.invalidate();
        }

        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });
    mCanvasView = (CanvasView) findViewById(R.id.canvas_view);
}
Also used : OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) View(android.view.View) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 70 with AdapterView

use of android.widget.AdapterView in project facebook-android-sdk by facebook.

the class AccountKitLoginActivity method setupAdvancedUIOptions.

private void setupAdvancedUIOptions() {
    advancedUISwitch = (Switch) findViewById(R.id.advanced_ui_switch);
    final View advancedUIOptionsLayout = findViewById(R.id.advanced_ui_options);
    final List<CharSequence> buttonNames = new ArrayList<>();
    buttonNames.add("Default");
    for (ButtonType buttonType : ButtonType.values()) {
        buttonNames.add(buttonType.name());
    }
    final ArrayAdapter<CharSequence> buttonNameAdapter = new ArrayAdapter<>(AccountKitLoginActivity.this, android.R.layout.simple_spinner_dropdown_item, buttonNames);
    advancedUISwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                if (isSkinSelected()) {
                    advancedUISwitch.setChecked(false);
                    Toast.makeText(AccountKitLoginActivity.this, R.string.skin_ui_required, Toast.LENGTH_LONG).show();
                    return;
                }
                advancedUIOptionsLayout.setVisibility(View.VISIBLE);
                final Spinner entryButtonSpinner = (Spinner) findViewById(R.id.entry_button_spinner);
                if (entryButtonSpinner != null) {
                    entryButtonSpinner.setAdapter(buttonNameAdapter);
                    entryButtonSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) {
                            // First position is empty, so anything past that
                            if (position > 0) {
                                entryButton = ButtonType.valueOf(entryButtonSpinner.getSelectedItem().toString());
                            } else {
                                entryButton = null;
                            }
                        }

                        @Override
                        public void onNothingSelected(final AdapterView<?> parent) {
                            entryButton = null;
                        }
                    });
                }
                final Spinner confirmButtonSpinner = (Spinner) findViewById(R.id.confirm_button_spinner);
                if (confirmButtonSpinner != null) {
                    confirmButtonSpinner.setAdapter(buttonNameAdapter);
                    confirmButtonSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) {
                            // that
                            if (position > 0) {
                                confirmButton = ButtonType.valueOf(confirmButtonSpinner.getSelectedItem().toString());
                            } else {
                                confirmButton = null;
                            }
                        }

                        @Override
                        public void onNothingSelected(final AdapterView<?> parent) {
                            confirmButton = null;
                        }
                    });
                }
                final Spinner textPositionSpinner = (Spinner) findViewById(R.id.text_position_spinner);
                if (textPositionSpinner != null) {
                    final List<CharSequence> textPositions = new ArrayList<>();
                    textPositions.add("Default");
                    for (TextPosition textPosition : TextPosition.values()) {
                        textPositions.add(textPosition.name());
                    }
                    final ArrayAdapter<CharSequence> textPositionAdapter = new ArrayAdapter<>(AccountKitLoginActivity.this, android.R.layout.simple_spinner_dropdown_item, textPositions);
                    textPositionSpinner.setAdapter(textPositionAdapter);
                    textPositionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) {
                            // that
                            if (position > 0) {
                                textPosition = TextPosition.valueOf(textPositionSpinner.getSelectedItem().toString());
                            } else {
                                textPosition = null;
                            }
                        }

                        @Override
                        public void onNothingSelected(final AdapterView<?> parent) {
                            textPosition = null;
                        }
                    });
                }
            } else if (isReverbThemeSelected()) {
                advancedUISwitch.setChecked(true);
                Toast.makeText(AccountKitLoginActivity.this, R.string.reverb_advanced_ui_required, Toast.LENGTH_LONG).show();
            } else {
                advancedUIOptionsLayout.setVisibility(View.GONE);
            }
        }
    });
}
Also used : Spinner(android.widget.Spinner) ArrayList(java.util.ArrayList) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) TextPosition(com.facebook.accountkit.ui.TextPosition) AdapterView(android.widget.AdapterView) ArrayList(java.util.ArrayList) List(java.util.List) ButtonType(com.facebook.accountkit.ui.ButtonType) ArrayAdapter(android.widget.ArrayAdapter) CompoundButton(android.widget.CompoundButton)

Aggregations

AdapterView (android.widget.AdapterView)677 View (android.view.View)653 ListView (android.widget.ListView)412 TextView (android.widget.TextView)342 Intent (android.content.Intent)177 ImageView (android.widget.ImageView)174 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)142 ArrayAdapter (android.widget.ArrayAdapter)75 ArrayList (java.util.ArrayList)71 ViewGroup (android.view.ViewGroup)63 AbsListView (android.widget.AbsListView)59 GridView (android.widget.GridView)58 Bundle (android.os.Bundle)53 Spinner (android.widget.Spinner)50 LinearLayout (android.widget.LinearLayout)49 OnClickListener (android.view.View.OnClickListener)46 RecyclerView (android.support.v7.widget.RecyclerView)42 DialogInterface (android.content.DialogInterface)41 SuppressLint (android.annotation.SuppressLint)38 LayoutInflater (android.view.LayoutInflater)34