Search in sources :

Example 91 with Builder

use of android.support.v7.app.AlertDialog.Builder in project actor-platform by actorapp.

the class ShortcutActivity method onDismiss.

@Override
public void onDismiss(DialogInterface dialog) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AlertDialogStyle);
    input = new EditText(this);
    input.setVisibility(View.INVISIBLE);
    builder.setView(input);
    AlertDialog adHide = builder.create();
    adHide.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    adHide.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            dialog.dismiss();
            finish();
        }
    });
    adHide.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) ColorDrawable(android.graphics.drawable.ColorDrawable) DialogInterface(android.content.DialogInterface)

Example 92 with Builder

use of android.support.v7.app.AlertDialog.Builder in project react-native-image-picker by marcshilling.

the class UI method chooseDialog.

@NonNull
public static AlertDialog chooseDialog(@Nullable final ImagePickerModule module, @NonNull final ReadableMap options, @Nullable final OnAction callback) {
    final Context context = module.getActivity();
    if (context == null) {
        return null;
    }
    final ButtonsHelper buttons = ButtonsHelper.newInstance(options);
    final List<String> titles = buttons.getTitles();
    final List<String> actions = buttons.getActions();
    ArrayAdapter<String> adapter = new ArrayAdapter<>(context, R.layout.list_item, titles);
    AlertDialog.Builder builder = new AlertDialog.Builder(context, module.getDialogThemeId());
    if (ReadableMapUtils.hasAndNotEmpty(options, "title")) {
        builder.setTitle(options.getString("title"));
    }
    builder.setAdapter(adapter, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int index) {
            final String action = actions.get(index);
            switch(action) {
                case "photo":
                    callback.onTakePhoto();
                    break;
                case "library":
                    callback.onUseLibrary();
                    break;
                case "cancel":
                    callback.onCancel();
                    break;
                default:
                    callback.onCustomButton(action);
            }
        }
    });
    builder.setNegativeButton(buttons.btnCancel.title, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            callback.onCancel();
            dialogInterface.dismiss();
        }
    });
    final AlertDialog dialog = builder.create();
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(@NonNull final DialogInterface dialog) {
            callback.onCancel();
            dialog.dismiss();
        }
    });
    //dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    return dialog;
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ArrayAdapter(android.widget.ArrayAdapter) NonNull(android.support.annotation.NonNull)

Example 93 with Builder

use of android.support.v7.app.AlertDialog.Builder in project MaterialDrawer by mikepenz.

the class DrawerBuilder method buildForFragment.

/**
     * Build and add the DrawerBuilder to your activity
     *
     * @return
     */
public Drawer buildForFragment() {
    if (mUsed) {
        throw new RuntimeException("you must not reuse a DrawerBuilder builder");
    }
    if (mActivity == null) {
        throw new RuntimeException("please pass an activity");
    }
    if (mRootView == null) {
        throw new RuntimeException("please pass the view which should host the DrawerLayout");
    }
    //set that this builder was used. now you have to create a new one
    mUsed = true;
    // if the user has not set a drawerLayout use the default one :D
    if (mDrawerLayout == null) {
        withDrawerLayout(-1);
    }
    //set the drawer here...
    View originalContentView = mRootView.getChildAt(0);
    boolean alreadyInflated = originalContentView.getId() == R.id.materialize_root;
    //only add the new layout if it wasn't done before
    if (!alreadyInflated) {
        // remove the contentView
        mRootView.removeView(originalContentView);
    } else {
        //if it was already inflated we have to clean up again
        mRootView.removeAllViews();
    }
    //create the layoutParams to use for the contentView
    FrameLayout.LayoutParams layoutParamsContentView = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    //add the drawer
    mRootView.addView(mDrawerLayout, layoutParamsContentView);
    //set the id so we can check if it was already inflated
    mDrawerLayout.setId(R.id.materialize_root);
    //handle the navigation stuff of the ActionBarDrawerToggle and the drawer in general
    handleDrawerNavigation(mActivity, false);
    //build the view which will be set to the drawer
    Drawer result = buildView();
    // add the slider to the drawer
    mDrawerLayout.addView(originalContentView, 0);
    //define id for the sliderLayout
    mSliderLayout.setId(R.id.material_drawer_slider_layout);
    // add the slider to the drawer
    mDrawerLayout.addView(mSliderLayout, 1);
    return result;
}
Also used : FrameLayout(android.widget.FrameLayout) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 94 with Builder

use of android.support.v7.app.AlertDialog.Builder in project AboutLibraries by mikepenz.

the class LibraryItem method openLicense.

/**
     * helper method to open the license dialog / or website
     *
     * @param ctx         Context for startActivity
     * @param libsBuilder
     * @param library
     */
private void openLicense(Context ctx, LibsBuilder libsBuilder, Library library) {
    try {
        if (libsBuilder.showLicenseDialog && !TextUtils.isEmpty(library.getLicense().getLicenseDescription())) {
            AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
            builder.setMessage(Html.fromHtml(library.getLicense().getLicenseDescription()));
            builder.create().show();
        } else {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(library.getLicense().getLicenseWebsite()));
            ctx.startActivity(browserIntent);
        }
    } catch (Exception ex) {
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) LibsBuilder(com.mikepenz.aboutlibraries.LibsBuilder) Intent(android.content.Intent)

Example 95 with Builder

use of android.support.v7.app.AlertDialog.Builder in project Timber by naman14.

the class AlbumDetailFragment method setAlbumart.

private void setAlbumart() {
    ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(albumID).toString(), albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build(), new ImageLoadingListener() {

        @Override
        public void onLoadingStarted(String imageUri, View view) {
        }

        @Override
        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            loadFailed = true;
            MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(context).setIcon(MaterialDrawableBuilder.IconValue.SHUFFLE).setColor(TimberUtils.getBlackWhiteColor(Config.accentColor(context, Helpers.getATEKey(context))));
            ATEUtils.setFabBackgroundTint(fab, Config.accentColor(context, Helpers.getATEKey(context)));
            fab.setImageDrawable(builder.build());
        }

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            try {
                new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {

                    @Override
                    public void onGenerated(Palette palette) {
                        Palette.Swatch swatch = palette.getVibrantSwatch();
                        if (swatch != null) {
                            primaryColor = swatch.getRgb();
                            collapsingToolbarLayout.setContentScrimColor(primaryColor);
                            if (getActivity() != null)
                                ATEUtils.setStatusBarColor(getActivity(), Helpers.getATEKey(getActivity()), primaryColor);
                        } else {
                            Palette.Swatch swatchMuted = palette.getMutedSwatch();
                            if (swatchMuted != null) {
                                primaryColor = swatchMuted.getRgb();
                                collapsingToolbarLayout.setContentScrimColor(primaryColor);
                                if (getActivity() != null)
                                    ATEUtils.setStatusBarColor(getActivity(), Helpers.getATEKey(getActivity()), primaryColor);
                            }
                        }
                        MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(getActivity()).setIcon(MaterialDrawableBuilder.IconValue.SHUFFLE).setSizeDp(30);
                        if (primaryColor != -1) {
                            builder.setColor(TimberUtils.getBlackWhiteColor(primaryColor));
                            ATEUtils.setFabBackgroundTint(fab, primaryColor);
                            fab.setImageDrawable(builder.build());
                        } else {
                            if (context != null) {
                                ATEUtils.setFabBackgroundTint(fab, Config.accentColor(context, Helpers.getATEKey(context)));
                                builder.setColor(TimberUtils.getBlackWhiteColor(Config.accentColor(context, Helpers.getATEKey(context))));
                                fab.setImageDrawable(builder.build());
                            }
                        }
                    }
                });
            } catch (Exception ignored) {
            }
        }

        @Override
        public void onLoadingCancelled(String imageUri, View view) {
        }
    });
}
Also used : Palette(android.support.v7.graphics.Palette) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) MaterialDrawableBuilder(net.steamcrafted.materialiconlib.MaterialDrawableBuilder) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) MaterialDrawableBuilder(net.steamcrafted.materialiconlib.MaterialDrawableBuilder) Bitmap(android.graphics.Bitmap) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

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