Search in sources :

Example 81 with AlertDialog

use of android.support.v7.app.AlertDialog in project Camera-Roll-Android-App by kollerlukas.

the class FileExplorerActivity method fabClicked.

public void fabClicked(View v) {
    if (showAnimations()) {
        animateFab(false);
    }
    View dialogLayout = LayoutInflater.from(this).inflate(R.layout.input_dialog_layout, (ViewGroup) findViewById(R.id.root_view), false);
    final EditText editText = dialogLayout.findViewById(R.id.edit_text);
    AlertDialog dialog = new AlertDialog.Builder(this, theme.getDialogThemeRes()).setTitle(R.string.new_folder).setView(dialogLayout).setPositiveButton(R.string.create, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            String filename = editText.getText().toString();
            File_POJO newFolder = new File_POJO(currentDir.getPath() + "/" + filename, false);
            File_POJO[] files = new File_POJO[] { newFolder };
            Intent intent = FileOperation.getDefaultIntent(FileExplorerActivity.this, FileOperation.NEW_DIR, files);
            startService(intent);
        }
    }).setNegativeButton(getString(R.string.cancel), null).setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            animateFab(true);
        }
    }).create();
    // noinspection ConstantConditions
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    dialog.show();
}
Also used : EditText(android.widget.EditText) AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) File_POJO(us.koller.cameraroll.data.models.File_POJO) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 82 with AlertDialog

use of android.support.v7.app.AlertDialog in project FaceRecognitionApp by Lauszus.

the class FaceRecognitionAppActivity method showLabelsDialog.

private void showLabelsDialog() {
    // Get all unique labels
    Set<String> uniqueLabelsSet = new HashSet<>(imagesLabels);
    if (!uniqueLabelsSet.isEmpty()) {
        // Make sure that there are any labels
        // Inspired by: http://stackoverflow.com/questions/15762905/how-can-i-display-a-list-view-in-an-android-alert-dialog
        AlertDialog.Builder builder = new AlertDialog.Builder(FaceRecognitionAppActivity.this);
        builder.setTitle("Select label:");
        builder.setPositiveButton("New face", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                showEnterLabelDialog();
            }
        });
        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                // Remove last image
                images.remove(images.size() - 1);
            }
        });
        // Prevent the user from closing the dialog
        builder.setCancelable(false);
        // Convert to String array for ArrayAdapter
        String[] uniqueLabels = uniqueLabelsSet.toArray(new String[uniqueLabelsSet.size()]);
        // Sort labels alphabetically
        Arrays.sort(uniqueLabels);
        final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(FaceRecognitionAppActivity.this, android.R.layout.simple_list_item_1, uniqueLabels) {

            @Override
            @NonNull
            public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
                TextView textView = (TextView) super.getView(position, convertView, parent);
                if (getResources().getBoolean(R.bool.isTablet))
                    // Make text slightly bigger on tablets compared to phones
                    textView.setTextSize(20);
                else
                    // Increase text size a little bit
                    textView.setTextSize(18);
                return textView;
            }
        };
        ListView mListView = new ListView(FaceRecognitionAppActivity.this);
        // Set adapter, so the items actually show up
        mListView.setAdapter(arrayAdapter);
        // Set the ListView
        builder.setView(mListView);
        // Show dialog and store in final variable, so it can be dismissed by the ListView
        final AlertDialog dialog = builder.show();
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                dialog.dismiss();
                addLabel(arrayAdapter.getItem(position));
            }
        });
    } else
        // If there is no existing labels, then ask the user for a new label
        showEnterLabelDialog();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ViewGroup(android.view.ViewGroup) SurfaceView(android.view.SurfaceView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ListView(android.widget.ListView) NonNull(android.support.annotation.NonNull) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter) Nullable(android.support.annotation.Nullable) HashSet(java.util.HashSet)

Example 83 with AlertDialog

use of android.support.v7.app.AlertDialog in project remusic by aa112901.

the class AddNetPlaylistDialog method onCreateView.

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    // 设置无标题
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (getArguments() != null) {
        musics = getArguments().getParcelableArrayList("songs");
        author = getArguments().getString("author");
    }
    playlistInfo = PlaylistInfo.getInstance(mContext);
    playlistsManager = PlaylistsManager.getInstance(mContext);
    View view = inflater.inflate(R.layout.fragment_add_playlist, container);
    LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
    LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.create_new_playlist);
    recyclerView = (RecyclerView) view.findViewById(R.id.add_playlist_recyclerview);
    linearLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final AlertDialog alertDialog = new AlertDialog.Builder(mContext).create();
            alertDialog.setView((mContext.getLayoutInflater().inflate(R.layout.dialog, null)));
            alertDialog.show();
            Window window = alertDialog.getWindow();
            window.setContentView(R.layout.dialog);
            final EditText editText = (EditText) (window.findViewById(R.id.message));
            editText.requestFocus();
            (window.findViewById(R.id.positiveButton)).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    alertDialog.dismiss();
                }
            });
            (window.findViewById(R.id.negativeButton)).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    dismiss();
                    new Thread(new Runnable() {

                        @Override
                        public void run() {
                            Log.e("addplay", "here");
                            String albumart = null;
                            for (MusicInfo info : musics) {
                                albumart = info.albumData;
                                if (info.islocal) {
                                    if (albumart.equals(MusicUtils.getAlbumdata(MainApplication.context, info.songId)))
                                        break;
                                } else if (!TextUtils.isEmpty(albumart)) {
                                    break;
                                }
                            }
                            long playlistid = editText.getText().hashCode();
                            playlistInfo.addPlaylist(playlistid, editText.getText().toString(), musics.size(), albumart, author);
                            playlistsManager.insertLists(mContext, playlistid, musics);
                            Intent intent = new Intent(IConstants.PLAYLIST_COUNT_CHANGED);
                            MainApplication.context.sendBroadcast(intent);
                        }
                    }).start();
                    alertDialog.dismiss();
                }
            });
        }
    });
    ArrayList<Playlist> playlists = playlistInfo.getPlaylist();
    recyclerView.setLayoutManager(layoutManager);
    AddPlaylistAdapter adapter = new AddPlaylistAdapter(playlists);
    recyclerView.setAdapter(adapter);
    // setItemDecoration();
    return view;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Window(android.view.Window) EditText(android.widget.EditText) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Playlist(com.wm.remusic.info.Playlist) MusicInfo(com.wm.remusic.info.MusicInfo) LinearLayout(android.widget.LinearLayout)

Example 84 with AlertDialog

use of android.support.v7.app.AlertDialog in project open-event-android by fossasia.

the class ScheduleFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.action_sort:
            final AlertDialog.Builder dialogSort = new AlertDialog.Builder(context).setTitle(R.string.dialog_sort_title).setSingleChoiceItems(R.array.session_sort, sortType, (dialog, which) -> {
                sortType = which;
                SharedPreferencesUtil.putInt(ConstantStrings.PREF_SORT_SCHEDULE, which);
                notifyUpdate(-1, selectedTracks);
            }).setPositiveButton(R.string.ascending, (dialog, which) -> {
                sortOrder = SortOrder.SORT_ORDER_ASCENDING;
                SharedPreferencesUtil.putInt(ConstantStrings.PREF_SORT_ORDER, sortOrder);
                notifyUpdate(-1, selectedTracks);
                dialog.dismiss();
            }).setNegativeButton(R.string.descending, (dialog, which) -> {
                sortOrder = SortOrder.SORT_ORDER_DESCENDING;
                SharedPreferencesUtil.putInt(ConstantStrings.PREF_SORT_ORDER, sortOrder);
                notifyUpdate(-1, selectedTracks);
                dialog.dismiss();
            });
            AlertDialog dialog = dialogSort.show();
            dialog.getButton(sortOrder == SortOrder.SORT_ORDER_ASCENDING ? AlertDialog.BUTTON_NEGATIVE : AlertDialog.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(context, android.R.color.darker_gray));
            dialog.getButton(sortOrder == SortOrder.SORT_ORDER_ASCENDING ? AlertDialog.BUTTON_POSITIVE : AlertDialog.BUTTON_NEGATIVE);
            dialog.show();
            break;
        default:
    }
    return super.onOptionsItemSelected(item);
}
Also used : AlertDialog(android.app.AlertDialog) Context(android.content.Context) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) LinearLayout(android.widget.LinearLayout) ConstantStrings(org.fossasia.openevent.common.ConstantStrings) Arrays(java.util.Arrays) Bundle(android.os.Bundle) KeyEvent(android.view.KeyEvent) SnackbarUtil(org.fossasia.openevent.common.ui.SnackbarUtil) Utils(org.fossasia.openevent.common.utils.Utils) ImageView(android.widget.ImageView) ViewPager(android.support.v4.view.ViewPager) NonNull(android.support.annotation.NonNull) OnClick(butterknife.OnClick) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) TabLayout(android.support.design.widget.TabLayout) Track(org.fossasia.openevent.data.Track) ZoneOffset(org.threeten.bp.ZoneOffset) Instant(org.threeten.bp.Instant) View(android.view.View) ZoneId(org.threeten.bp.ZoneId) R(org.fossasia.openevent.R) ActionBar(android.support.v7.app.ActionBar) BookmarkStatus(org.fossasia.openevent.core.bookmark.BookmarkStatus) StrategyRegistry(org.fossasia.openevent.config.StrategyRegistry) FloatingActionButton(android.support.design.widget.FloatingActionButton) LayoutInflater(android.view.LayoutInflater) ContextCompat(android.support.v4.content.ContextCompat) BaseFragment(org.fossasia.openevent.common.ui.base.BaseFragment) DateConverter(org.fossasia.openevent.common.date.DateConverter) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) SharedPreferencesUtil(org.fossasia.openevent.common.utils.SharedPreferencesUtil) AlertDialog(android.app.AlertDialog) ViewModelProviders(android.arch.lifecycle.ViewModelProviders) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) TextView(android.widget.TextView) OnBookmarkSelectedListener(org.fossasia.openevent.core.bookmark.OnBookmarkSelectedListener) Nullable(android.support.annotation.Nullable) Snackbar(android.support.design.widget.Snackbar) SortOrder(org.fossasia.openevent.common.utils.SortOrder)

Example 85 with AlertDialog

use of android.support.v7.app.AlertDialog in project RespawnIRC-Android by FranckRJ.

the class ChoosePageNumberDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog alertToShow;
    Window currentWindow;
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    @SuppressLint("InflateParams") View mainView = getActivity().getLayoutInflater().inflate(R.layout.dialog_choosepagenumber, null);
    pageNumberEdit = mainView.findViewById(R.id.pagenumber_edit_choosepagenumber);
    pageNumberEdit.setOnEditorActionListener(actionInEditTextListener);
    builder.setTitle(R.string.choosePageNumber).setView(mainView).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
        }
    }).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            pageNumberChoosed();
        }
    });
    alertToShow = builder.create();
    currentWindow = alertToShow.getWindow();
    if (currentWindow != null) {
        currentWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    }
    return alertToShow;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Window(android.view.Window) DialogInterface(android.content.DialogInterface) SuppressLint(android.annotation.SuppressLint) TextView(android.widget.TextView) View(android.view.View) SuppressLint(android.annotation.SuppressLint) NonNull(android.support.annotation.NonNull)

Aggregations

AlertDialog (android.support.v7.app.AlertDialog)410 DialogInterface (android.content.DialogInterface)274 View (android.view.View)219 TextView (android.widget.TextView)165 Intent (android.content.Intent)117 EditText (android.widget.EditText)86 ImageView (android.widget.ImageView)69 Button (android.widget.Button)68 LayoutInflater (android.view.LayoutInflater)59 RecyclerView (android.support.v7.widget.RecyclerView)54 NonNull (android.support.annotation.NonNull)52 AdapterView (android.widget.AdapterView)51 SuppressLint (android.annotation.SuppressLint)50 ArrayList (java.util.ArrayList)49 Bundle (android.os.Bundle)47 ListView (android.widget.ListView)42 Context (android.content.Context)35 SharedPreferences (android.content.SharedPreferences)35 Uri (android.net.Uri)32 LinearLayout (android.widget.LinearLayout)30