Search in sources :

Example 81 with Spinner

use of android.widget.Spinner in project android_frameworks_base by DirtyUnicorns.

the class PopupWindowVisibility method onCreate.

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.popup_window_visibility);
    mFrame = findViewById(R.id.frame);
    mHide = (Button) findViewById(R.id.hide);
    mHide.setOnClickListener(this);
    mShow = (Button) findViewById(R.id.show);
    mShow.setOnClickListener(this);
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mStrings);
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(spinnerAdapter);
    ArrayAdapter<String> autoAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES);
    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.auto);
    textView.setAdapter(autoAdapter);
}
Also used : Spinner(android.widget.Spinner) ArrayAdapter(android.widget.ArrayAdapter) AutoCompleteTextView(android.widget.AutoCompleteTextView)

Example 82 with Spinner

use of android.widget.Spinner in project YourAppIdea by Michenux.

the class AirportListFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (BuildConfig.DEBUG) {
        Log.i(YourApplication.LOG_TAG, "AirportListFragment.onCreateOptionsMenu");
    }
    inflater.inflate(R.menu.airport_menu, menu);
    MenuItem modeMenuItem = menu.findItem(R.id.airport_menuMode);
    Spinner spinner = (Spinner) MenuItemCompat.getActionView(modeMenuItem).findViewById(R.id.airport_mode_spinner);
    if (this.mCurrentMode.equals("in")) {
        spinner.setSelection(0, false);
    } else {
        spinner.setSelection(1, false);
    }
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int position, long row) {
            if (position == 0) {
                AirportListFragment.this.mCurrentMode = "in";
            } else {
                AirportListFragment.this.mCurrentMode = "out";
            }
            AirportListFragment.this.startRequest();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
}
Also used : Spinner(android.widget.Spinner) MenuItem(android.view.MenuItem) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 83 with Spinner

use of android.widget.Spinner in project LeafPic by HoraApps.

the class AlbumsFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Album selectedAlbum = adapter.getFirstSelectedAlbum();
    switch(item.getItemId()) {
        case R.id.select_all:
            if (adapter.getSelectedCount() == adapter.getItemCount())
                adapter.clearSelected();
            else
                adapter.selectAll();
            return true;
        case R.id.pin_album:
            if (selectedAlbum != null) {
                boolean b = selectedAlbum.togglePinAlbum();
                db().setPined(selectedAlbum.getPath(), b);
                adapter.clearSelected();
                adapter.sort();
            }
            return true;
        case R.id.clear_album_cover:
            if (selectedAlbum != null) {
                selectedAlbum.removeCoverAlbum();
                db().setCover(selectedAlbum.getPath(), null);
                adapter.clearSelected();
                adapter.notifyItemChanaged(selectedAlbum);
                // TODO: 4/5/17 updateui
                return true;
            }
            return false;
        case R.id.hide:
            final AlertDialog hideDialog = AlertDialogsHelper.getTextDialog(((ThemedActivity) getActivity()), hidden ? R.string.unhide : R.string.hide, hidden ? R.string.unhide_album_message : R.string.hide_album_message);
            hideDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(hidden ? R.string.unhide : R.string.hide).toUpperCase(), (dialog, id) -> {
                ArrayList<String> hiddenPaths = AlbumsHelper.getLastHiddenPaths();
                for (Album album : adapter.getSelectedAlbums()) {
                    if (hidden) {
                        // unhide
                        AlbumsHelper.unHideAlbum(album.getPath(), getContext());
                        hiddenPaths.remove(album.getPath());
                    } else {
                        // hide
                        AlbumsHelper.hideAlbum(album.getPath(), getContext());
                        hiddenPaths.add(album.getPath());
                    }
                }
                AlbumsHelper.saveLastHiddenPaths(hiddenPaths);
                adapter.removeSelectedAlbums();
                updateToolbar();
            });
            if (!hidden) {
                hideDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.exclude).toUpperCase(), (dialog, which) -> {
                    for (Album album : adapter.getSelectedAlbums()) {
                        db().excludeAlbum(album.getPath());
                        excuded.add(album.getPath());
                    }
                    adapter.removeSelectedAlbums();
                });
            }
            hideDialog.setButton(DialogInterface.BUTTON_NEGATIVE, this.getString(R.string.cancel).toUpperCase(), (dialogInterface, i) -> hideDialog.dismiss());
            hideDialog.show();
            return true;
        case R.id.shortcut:
            AlbumsHelper.createShortcuts(getContext(), adapter.getSelectedAlbums());
            adapter.clearSelected();
            return true;
        case R.id.name_sort_mode:
            adapter.changeSortingMode(SortingMode.NAME);
            AlbumsHelper.setSortingMode(SortingMode.NAME);
            item.setChecked(true);
            return true;
        case R.id.date_taken_sort_mode:
            adapter.changeSortingMode(SortingMode.DATE);
            AlbumsHelper.setSortingMode(SortingMode.DATE);
            item.setChecked(true);
            return true;
        case R.id.size_sort_mode:
            adapter.changeSortingMode(SortingMode.SIZE);
            AlbumsHelper.setSortingMode(SortingMode.SIZE);
            item.setChecked(true);
            return true;
        case R.id.numeric_sort_mode:
            adapter.changeSortingMode(SortingMode.NUMERIC);
            AlbumsHelper.setSortingMode(SortingMode.NUMERIC);
            item.setChecked(true);
            return true;
        case R.id.ascending_sort_order:
            item.setChecked(!item.isChecked());
            SortingOrder sortingOrder = SortingOrder.fromValue(item.isChecked());
            adapter.changeSortingOrder(sortingOrder);
            AlbumsHelper.setSortingOrder(sortingOrder);
            return true;
        case R.id.exclude:
            final AlertDialog.Builder excludeDialogBuilder = new AlertDialog.Builder(getActivity(), getDialogStyle());
            final View excludeDialogLayout = LayoutInflater.from(getContext()).inflate(R.layout.dialog_exclude, null);
            TextView textViewExcludeTitle = excludeDialogLayout.findViewById(R.id.text_dialog_title);
            TextView textViewExcludeMessage = excludeDialogLayout.findViewById(R.id.text_dialog_message);
            final Spinner spinnerParents = excludeDialogLayout.findViewById(R.id.parents_folder);
            spinnerParents.getBackground().setColorFilter(getIconColor(), PorterDuff.Mode.SRC_ATOP);
            ((CardView) excludeDialogLayout.findViewById(R.id.message_card)).setCardBackgroundColor(getCardBackgroundColor());
            textViewExcludeTitle.setBackgroundColor(getPrimaryColor());
            textViewExcludeTitle.setText(getString(R.string.exclude));
            if (adapter.getSelectedCount() > 1) {
                textViewExcludeMessage.setText(R.string.exclude_albums_message);
                spinnerParents.setVisibility(View.GONE);
            } else {
                textViewExcludeMessage.setText(R.string.exclude_album_message);
                spinnerParents.setAdapter(getThemeHelper().getSpinnerAdapter(adapter.getFirstSelectedAlbum().getParentsFolders()));
            }
            textViewExcludeMessage.setTextColor(getTextColor());
            excludeDialogBuilder.setView(excludeDialogLayout);
            excludeDialogBuilder.setPositiveButton(this.getString(R.string.exclude).toUpperCase(), (dialog, id) -> {
                if (adapter.getSelectedCount() > 1) {
                    for (Album album : adapter.getSelectedAlbums()) {
                        db().excludeAlbum(album.getPath());
                        excuded.add(album.getPath());
                    }
                    adapter.removeSelectedAlbums();
                } else {
                    String path = spinnerParents.getSelectedItem().toString();
                    db().excludeAlbum(path);
                    excuded.add(path);
                    adapter.removeAlbumsThatStartsWith(path);
                    adapter.forceSelectedCount(0);
                }
                updateToolbar();
            });
            excludeDialogBuilder.setNegativeButton(this.getString(R.string.cancel).toUpperCase(), null);
            excludeDialogBuilder.show();
            return true;
        case R.id.delete:
            /* class DeleteAlbums extends AsyncTask<String, Integer, Boolean> {

                    //private AlertDialog dialog;
                    List<Album> selectedAlbums;
                    DeleteAlbumsDialog newFragment;


                    @Override
                    protected void onPreExecute() {
                        super.onPreExecute();
                        newFragment = new DeleteAlbumsDialog();
                        Bundle b = new Bundle();
                        b.putParcelableArrayList("albums", ((ArrayList<Album>) adapter.getSelectedAlbums()));

                        newFragment.setArguments(b);
                        newFragment.show(getFragmentManager(), "dialog");
                        //newFragment.setTitle("asd");

                        //dialog = AlertDialogsHelper.getProgressDialog(((ThemedActivity) getActivity()), getString(R.string.delete), getString(R.string.deleting_images));
                        //dialog.show();


                    }

                    @Override
                    protected Boolean doInBackground(String... arg0) {

                        return true;
                    }

                    @Override
                    protected void onPostExecute(Boolean result) {
                        */
            /*if (result) {
                            if (albumsMode) {
                                albumsAdapter.clearSelected();
                                //albumsAdapter.notifyDataSetChanged();
                            } else {
                                if (getAlbum().getMedia().size() == 0) {
                                    getAlbums().removeCurrentAlbum();
                                    albumsAdapter.notifyDataSetChanged();
                                    displayAlbums();
                                } else
                                    oldMediaAdapter.swapDataSet(getAlbum().getMedia());
                            }
                        } else requestSdCardPermissions();

                        supportInvalidateOptionsMenu();
                        checkNothing();
                        dialog.dismiss();*/
            /*
                    }
                }*/
            final AlertDialog alertDialog = AlertDialogsHelper.getTextDialog(((ThemedActivity) getActivity()), R.string.delete, R.string.delete_album_message);
            alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, this.getString(R.string.cancel).toUpperCase(), (dialogInterface, i) -> alertDialog.dismiss());
            alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, this.getString(R.string.delete).toUpperCase(), (dialog1, id) -> {
                if (Security.isPasswordOnDelete()) {
                    Security.authenticateUser(((ThemedActivity) getActivity()), new Security.AuthCallBack() {

                        @Override
                        public void onAuthenticated() {
                        /*new DeleteAlbums().execute();*/
                        }

                        @Override
                        public void onError() {
                            Toast.makeText(getContext(), R.string.wrong_password, Toast.LENGTH_SHORT).show();
                        }
                    });
                }
            /* else new DeleteAlbums().execute();*/
            });
            alertDialog.show();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Spinner(android.widget.Spinner) CardView(android.support.v7.widget.CardView) Album(org.horaapps.leafpic.data.Album) Security(org.horaapps.leafpic.util.Security) BindView(butterknife.BindView) View(android.view.View) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ThemedActivity(org.horaapps.liz.ThemedActivity) SortingOrder(org.horaapps.leafpic.data.sort.SortingOrder) TextView(android.widget.TextView)

Example 84 with Spinner

use of android.widget.Spinner in project LeafPic by HoraApps.

the class SelectAlbumBuilder method setupDialog.

@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);
    View contentView = View.inflate(getContext(), R.layout.select_folder_bottom_sheet, null);
    final RecyclerView mRecyclerView = contentView.findViewById(R.id.folders);
    final Spinner spinner = contentView.findViewById(R.id.storage_spinner);
    currentFolderPath = contentView.findViewById(R.id.bottom_sheet_sub_title);
    exploreModePanel = contentView.findViewById(R.id.ll_explore_mode_panel);
    imgExploreMode = contentView.findViewById(R.id.toggle_hidden_icon);
    theme = ThemeHelper.getInstanceLoaded(getContext());
    sdCardPath = StorageHelper.getSdcardPath(getContext());
    mRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
    mRecyclerView.addItemDecoration(new GridSpacingItemDecoration(2, Measure.pxToDp(3, getContext()), true));
    adapter = new BottomSheetAlbumsAdapter();
    mRecyclerView.setAdapter(adapter);
    spinner.setAdapter(new VolumeSpinnerAdapter(contentView.getContext()));
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long l) {
            switch(pos) {
                case INTERNAL_STORAGE:
                    displayContentFolder(Environment.getExternalStorageDirectory());
                    break;
                default:
                    // }
                    break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    /**
     *SET UP THEME*
     */
    contentView.findViewById(R.id.rl_bottom_sheet_title).setBackgroundColor(theme.getPrimaryColor());
    exploreModePanel.setBackgroundColor(theme.getPrimaryColor());
    contentView.findViewById(R.id.ll_select_folder).setBackgroundColor(theme.getCardBackgroundColor());
    theme.setColorScrollBarDrawable(ContextCompat.getDrawable(dialog.getContext(), R.drawable.ic_scrollbar));
    mRecyclerView.setBackgroundColor(theme.getBackgroundColor());
    fabDone = contentView.findViewById(R.id.fab_bottomsheet_done);
    fabDone.setBackgroundTintList(ColorStateList.valueOf(theme.getAccentColor()));
    fabDone.setImageDrawable(new IconicsDrawable(getContext()).icon(GoogleMaterial.Icon.gmd_done).color(Color.WHITE));
    fabDone.setVisibility(exploreMode ? View.VISIBLE : View.GONE);
    fabDone.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
            onFolderSelected.folderSelected(currentFolderPath.getText().toString());
        }
    });
    ((TextView) contentView.findViewById(R.id.bottom_sheet_title)).setText(title);
    ((ThemedIcon) contentView.findViewById(R.id.create_new_folder_icon)).setColor(theme.getIconColor());
    contentView.findViewById(R.id.rl_create_new_folder).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final EditText editText = new EditText(getContext());
            AlertDialog insertTextDialog = AlertDialogsHelper.getInsertTextDialog(((ThemedActivity) getActivity()), editText, R.string.new_folder);
            insertTextDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    File folderPath = new File(currentFolderPath.getText().toString() + File.separator + editText.getText().toString());
                    if (folderPath.mkdir())
                        displayContentFolder(folderPath);
                }
            });
            insertTextDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                }
            });
            insertTextDialog.show();
        }
    });
    contentView.findViewById(R.id.rl_bottom_sheet_title).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!forzed) {
                toggleExplorerMode(!exploreMode);
                fabDone.setVisibility(exploreMode ? View.VISIBLE : View.GONE);
            }
        }
    });
    dialog.setContentView(contentView);
    CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
    CoordinatorLayout.Behavior behavior = layoutParams.getBehavior();
    if (behavior != null && behavior instanceof BottomSheetBehavior) {
        ((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
    }
    adapter.notifyDataSetChanged();
    toggleExplorerMode(exploreMode);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Spinner(android.widget.Spinner) BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) TextView(android.widget.TextView) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) EditText(android.widget.EditText) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) GridLayoutManager(android.support.v7.widget.GridLayoutManager) ThemedIcon(org.horaapps.liz.ui.ThemedIcon) RecyclerView(android.support.v7.widget.RecyclerView) AdapterView(android.widget.AdapterView) File(java.io.File) GridSpacingItemDecoration(org.horaapps.leafpic.views.GridSpacingItemDecoration)

Example 85 with Spinner

use of android.widget.Spinner in project J2ME-Loader by nikita36078.

the class ChoiceGroup method getItemContentView.

@Override
public View getItemContentView() {
    Context context = getOwnerForm().getParentActivity();
    switch(choiceType) {
        case EXCLUSIVE:
            if (buttongroup == null) {
                buttongroup = new RadioGroup(context);
                initButtonGroup();
                ((RadioGroup) buttongroup).setOnCheckedChangeListener(radiolistener);
            }
            return buttongroup;
        case MULTIPLE:
            if (buttongroup == null) {
                buttongroup = new LinearLayout(context);
                initButtonGroup();
            }
            return buttongroup;
        case POPUP:
            if (spinner == null) {
                adapter = new CompoundSpinnerAdapter(context);
                spinner = new Spinner(context);
                spinner.setAdapter(adapter);
                int size = selected.size();
                for (int i = 0; i < size; i++) {
                    adapter.append(strings.get(i), images.get(i));
                }
                if (selectedIndex >= 0 && selectedIndex < selected.size()) {
                    spinner.setSelection(selectedIndex);
                }
                spinner.setOnItemSelectedListener(spinlistener);
            }
            return spinner;
        default:
            throw new InternalError();
    }
}
Also used : Context(android.content.Context) CompoundSpinnerAdapter(javax.microedition.lcdui.list.CompoundSpinnerAdapter) RadioGroup(android.widget.RadioGroup) Spinner(android.widget.Spinner) LinearLayout(android.widget.LinearLayout)

Aggregations

Spinner (android.widget.Spinner)160 View (android.view.View)70 AdapterView (android.widget.AdapterView)58 TextView (android.widget.TextView)51 ArrayAdapter (android.widget.ArrayAdapter)50 LinearLayout (android.widget.LinearLayout)29 EditText (android.widget.EditText)20 Intent (android.content.Intent)19 Button (android.widget.Button)19 RecyclerView (android.support.v7.widget.RecyclerView)18 CompoundButton (android.widget.CompoundButton)16 ViewGroup (android.view.ViewGroup)13 ImageView (android.widget.ImageView)13 DialogInterface (android.content.DialogInterface)12 CheckBox (android.widget.CheckBox)11 ListView (android.widget.ListView)11 ArrayList (java.util.ArrayList)11 AutoCompleteTextView (android.widget.AutoCompleteTextView)9 AlertDialog (android.app.AlertDialog)7 LayoutInflater (android.view.LayoutInflater)7