Search in sources :

Example 1 with Builder

use of android.support.v7.app.AlertDialog.Builder in project FlexibleAdapter by davideas.

the class EditItemDialog method onCreateDialog.

@SuppressLint({ "InflateParams", "HandlerLeak" })
@Override
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
    //Pick up bundle parameters
    Bundle bundle;
    if (savedInstanceState == null) {
        bundle = getArguments();
    } else {
        bundle = savedInstanceState;
    }
    mTitle = bundle.getString(ARG_TITLE);
    mPosition = bundle.getInt(ARG_ITEM_POSITION);
    //Inflate custom view
    View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_edit_item, null);
    final EditText editText = (EditText) dialogView.findViewById(R.id.text_edit_title);
    //, R.style.AppTheme_AlertDialog);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.dialog_edit_title).setView(dialogView).setNegativeButton(R.string.CANCEL, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Utils.hideSoftInputFrom(getActivity(), editText);
            dialog.dismiss();
        }
    }).setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            getListener().onTitleModified(mPosition, editText.getText().toString().trim());
            Utils.hideSoftInputFrom(getActivity(), editText);
            dialog.dismiss();
        }
    });
    final AlertDialog editDialog = builder.create();
    editDialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            updateOkButtonState(editDialog, null);
        }
    });
    if (mTitle != null) {
        editText.setText(mTitle);
        editText.selectAll();
    }
    editText.requestFocus();
    editText.addTextChangedListener(new SimpleTextWatcher() {

        private static final long DELAY = 400L;

        private static final int TRIGGER = 1;

        private Handler mHandler = new Handler() {

            @Override
            public void handleMessage(Message msg) {
                if (msg.what == TRIGGER) {
                    updateOkButtonState(editDialog, editText);
                }
            }
        };

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            updateOkButtonState(editDialog, null);
        }

        @Override
        public void afterTextChanged(Editable s) {
            mHandler.removeMessages(TRIGGER);
            mHandler.sendEmptyMessageDelayed(TRIGGER, DELAY);
        }
    });
    editDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return editDialog;
}
Also used : EditText(android.widget.EditText) AlertDialog(android.support.v7.app.AlertDialog) Message(android.os.Message) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) Handler(android.os.Handler) View(android.view.View) SuppressLint(android.annotation.SuppressLint) SimpleTextWatcher(eu.davidea.common.SimpleTextWatcher) Editable(android.text.Editable) SuppressLint(android.annotation.SuppressLint)

Example 2 with Builder

use of android.support.v7.app.AlertDialog.Builder in project HoloEverywhere by Prototik.

the class SwitchScreenPreference method onPrepareDialog.

@Override
void onPrepareDialog(Dialog dialog) {
    if (VERSION.SDK_INT < 11) {
        MenuBuilder builder = new MenuBuilder(dialog.getContext());
        onCreateOptionsMenu(builder);
        ActionBarView abv = (ActionBarView) dialog.getWindow().getDecorView().findViewById(R.id.action_bar);
        abv.setMenu(builder, this);
    }
}
Also used : ActionBarView(android.support.v7.internal.widget.ActionBarView) MenuBuilder(android.support.v7.internal.view.menu.MenuBuilder)

Example 3 with Builder

use of android.support.v7.app.AlertDialog.Builder in project HoloEverywhere by Prototik.

the class ActionBarView method setMenu.

public void setMenu(SupportMenu menu, MenuPresenter.Callback cb) {
    if (menu == mOptionsMenu) {
        return;
    }
    if (mOptionsMenu != null) {
        mOptionsMenu.removeMenuPresenter(mActionMenuPresenter);
        mOptionsMenu.removeMenuPresenter(mExpandedMenuPresenter);
    }
    MenuBuilder builder = (MenuBuilder) menu;
    mOptionsMenu = builder;
    if (mMenuView != null) {
        final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
        if (oldParent != null) {
            oldParent.removeView(mMenuView);
        }
    }
    if (mActionMenuPresenter == null) {
        mActionMenuPresenter = new ActionMenuPresenter(mContext);
        mActionMenuPresenter.setCallback(cb);
        mActionMenuPresenter.setId(R.id.action_menu_presenter);
        mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
    }
    ActionMenuView menuView;
    final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
    if (!mSplitActionBar) {
        mActionMenuPresenter.setExpandedActionViewsExclusive(getResources().getBoolean(R.bool.abc_action_bar_expanded_action_views_exclusive));
        configPresenters(builder);
        menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        final ViewGroup oldParent = (ViewGroup) menuView.getParent();
        if (oldParent != null && oldParent != this) {
            oldParent.removeView(menuView);
        }
        addView(menuView, layoutParams);
    } else {
        mActionMenuPresenter.setExpandedActionViewsExclusive(false);
        // Allow full screen width in split mode.
        mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels, true);
        // No limit to the item count; use whatever will fit.
        mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
        // Span the whole width
        layoutParams.width = LayoutParams.FILL_PARENT;
        configPresenters(builder);
        menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        if (mSplitView != null) {
            final ViewGroup oldParent = (ViewGroup) menuView.getParent();
            if (oldParent != null && oldParent != mSplitView) {
                oldParent.removeView(menuView);
            }
            menuView.setVisibility(getAnimatedVisibility());
            mSplitView.addView(menuView, layoutParams);
        } else {
            // We'll add this later if we missed it this time.
            menuView.setLayoutParams(layoutParams);
        }
    }
    mMenuView = menuView;
}
Also used : ViewGroup(android.view.ViewGroup) ActionMenuView(android.support.v7.internal.view.menu.ActionMenuView) MenuBuilder(android.support.v7.internal.view.menu.MenuBuilder) SubMenuBuilder(android.support.v7.internal.view.menu.SubMenuBuilder) ActionMenuPresenter(android.support.v7.internal.view.menu.ActionMenuPresenter)

Example 4 with Builder

use of android.support.v7.app.AlertDialog.Builder in project NewPipe by TeamNewPipe.

the class VideoItemDetailFragment method playVideo.

public void playVideo(final StreamInfo info) {
    // ----------- THE MAGIC MOMENT ---------------
    VideoStream selectedVideoStream = info.video_streams.get(actionBarHandler.getSelectedVideoStream());
    if (PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(activity.getString(R.string.use_external_video_player_key), false)) {
        // External Player
        Intent intent = new Intent();
        try {
            intent.setAction(Intent.ACTION_VIEW).setDataAndType(Uri.parse(selectedVideoStream.url), MediaFormat.getMimeById(selectedVideoStream.format)).putExtra(Intent.EXTRA_TITLE, info.title).putExtra("title", info.title);
            // HERE !!!
            activity.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
            AlertDialog.Builder builder = new AlertDialog.Builder(activity);
            builder.setMessage(R.string.no_player_found).setPositiveButton(R.string.install, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Intent intent = new Intent().setAction(Intent.ACTION_VIEW).setData(Uri.parse(activity.getString(R.string.fdroid_vlc_url)));
                    activity.startActivity(intent);
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            builder.create().show();
        }
    } else {
        if (PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(activity.getString(R.string.use_exoplayer_key), false)) {
            // TODO: Fix this mess
            if (streamThumbnail != null)
                ActivityCommunicator.getCommunicator().backgroundPlayerThumbnail = streamThumbnail;
            if (info.dashMpdUrl != null && !info.dashMpdUrl.isEmpty()) {
                // try dash
                Intent intent = new Intent(activity, ExoPlayerActivity.class).setData(Uri.parse(info.dashMpdUrl));
                //.putExtra(ExoPlayerActivity.CONTENT_TYPE_EXTRA, Util.TYPE_DASH);
                startActivity(intent);
            } else if ((info.audio_streams != null && !info.audio_streams.isEmpty()) && (info.video_only_streams != null && !info.video_only_streams.isEmpty())) {
            // try smooth streaming
            } else {
                //default streaming
                Intent intent = new Intent(activity, ExoPlayerActivity.class).setDataAndType(Uri.parse(selectedVideoStream.url), MediaFormat.getMimeById(selectedVideoStream.format)).putExtra(ExoPlayerActivity.VIDEO_TITLE, info.title).putExtra(ExoPlayerActivity.CHANNEL_NAME, info.uploader);
                //.putExtra(ExoPlayerActivity.CONTENT_TYPE_EXTRA, Util.TYPE_OTHER);
                // HERE !!!
                activity.startActivity(intent);
            }
        //-------------
        } else {
            // Internal Player
            Intent intent = new Intent(activity, PlayVideoActivity.class).putExtra(PlayVideoActivity.VIDEO_TITLE, info.title).putExtra(PlayVideoActivity.STREAM_URL, selectedVideoStream.url).putExtra(PlayVideoActivity.VIDEO_URL, info.webpage_url).putExtra(PlayVideoActivity.START_POSITION, info.start_position);
            //also HERE !!!
            activity.startActivity(intent);
        }
    }
// --------------------------------------------
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) InfoItemBuilder(org.schabi.newpipe.info_list.InfoItemBuilder) VideoStream(org.schabi.newpipe.extractor.stream_info.VideoStream) Intent(android.content.Intent) Point(android.graphics.Point) ExoPlayerActivity(org.schabi.newpipe.player.ExoPlayerActivity)

Example 5 with Builder

use of android.support.v7.app.AlertDialog.Builder in project SeriesGuide by UweTrottmann.

the class RateDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder;
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    @SuppressLint("InflateParams") View layout = inflater.inflate(R.layout.dialog_trakt_rate, null);
    unbinder = ButterKnife.bind(this, layout);
    for (int i = 0; i < ratingButtons.size(); i++) {
        Button ratingButton = ratingButtons.get(i);
        ratingButton.setText(TraktTools.buildUserRatingString(getContext(), i + 1));
    }
    // rating buttons from 1 (worst) to 10 (best)
    ratingButtons.get(0).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            rate(Rating.WEAKSAUCE);
        }
    });
    ratingButtons.get(1).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            rate(Rating.TERRIBLE);
        }
    });
    ratingButtons.get(2).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            rate(Rating.BAD);
        }
    });
    ratingButtons.get(3).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            rate(Rating.POOR);
        }
    });
    ratingButtons.get(4).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            rate(Rating.MEH);
        }
    });
    ratingButtons.get(5).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            rate(Rating.FAIR);
        }
    });
    ratingButtons.get(6).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            rate(Rating.GOOD);
        }
    });
    ratingButtons.get(7).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            rate(Rating.GREAT);
        }
    });
    ratingButtons.get(8).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            rate(Rating.SUPERB);
        }
    });
    ratingButtons.get(9).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            rate(Rating.TOTALLYNINJA);
        }
    });
    builder = new AlertDialog.Builder(getActivity());
    builder.setView(layout);
    return builder.create();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Button(android.widget.Button) LayoutInflater(android.view.LayoutInflater) SuppressLint(android.annotation.SuppressLint) View(android.view.View) SuppressLint(android.annotation.SuppressLint) NonNull(android.support.annotation.NonNull)

Aggregations

AlertDialog (android.support.v7.app.AlertDialog)114 DialogInterface (android.content.DialogInterface)76 View (android.view.View)67 TextView (android.widget.TextView)48 Intent (android.content.Intent)36 RecyclerView (android.support.v7.widget.RecyclerView)27 ListView (android.widget.ListView)23 Dialog (android.app.Dialog)22 LayoutInflater (android.view.LayoutInflater)20 ImageView (android.widget.ImageView)20 EditText (android.widget.EditText)18 SuppressLint (android.annotation.SuppressLint)17 Context (android.content.Context)17 Bundle (android.os.Bundle)15 NonNull (android.support.annotation.NonNull)14 Button (android.widget.Button)13 ArrayList (java.util.ArrayList)12 BrowserDialog (acr.browser.lightning.dialog.BrowserDialog)10 OnClickListener (android.content.DialogInterface.OnClickListener)10 ScrollView (android.widget.ScrollView)10