Example usage for android.app Dialog setContentView

List of usage examples for android.app Dialog setContentView

Introduction

In this page you can find the example usage for android.app Dialog setContentView.

Prototype

public void setContentView(@NonNull View view) 

Source Link

Document

Set the screen content to an explicit view.

Usage

From source file:com.example.dany.jjdraw.MainActivity.java

@Override
public void onClick(View view) {
    if (view.getId() == R.id.draw_btn) {
        final Dialog brushDialog = new Dialog(this);
        brushDialog.setTitle("Brush size");
        brushDialog.setContentView(R.layout.brush_chooser);
        ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush);
        smallBtn.setOnClickListener(new OnClickListener() {
            @Override//from  ww  w .  j a  v  a2 s  .  com
            public void onClick(View v) {
                drawView.setBrushSize(smallBrush);
                drawView.setLastBrushSize(smallBrush);
                drawView.setErase(false);
                brushDialog.dismiss();
            }
        });

        ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush);
        mediumBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                drawView.setBrushSize(mediumBrush);
                drawView.setLastBrushSize(mediumBrush);
                drawView.setErase(false);
                brushDialog.dismiss();
            }
        });

        ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush);
        largeBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                drawView.setBrushSize(largeBrush);
                drawView.setLastBrushSize(largeBrush);
                drawView.setErase(false);
                brushDialog.dismiss();
            }
        });

        brushDialog.show();
    } else if (view.getId() == R.id.erase_btn) {
        //switch to erase - choose size
        final Dialog brushDialog = new Dialog(this);
        brushDialog.setTitle("Eraser size");
        brushDialog.setContentView(R.layout.brush_chooser);

        ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush);
        smallBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                drawView.setErase(true);
                drawView.setBrushSize(smallBrush);
                brushDialog.dismiss();
            }
        });
        ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush);
        mediumBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                drawView.setErase(true);
                drawView.setBrushSize(mediumBrush);
                brushDialog.dismiss();
            }
        });
        ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush);
        largeBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                drawView.setErase(true);
                drawView.setBrushSize(largeBrush);
                brushDialog.dismiss();
            }
        });
        brushDialog.show();
    }

    else if (view.getId() == R.id.new_btn) {
        //new button
        AlertDialog.Builder newDialog = new AlertDialog.Builder(this);
        newDialog.setTitle("New drawing");
        newDialog.setMessage("Start new drawing (you will lose the current drawing)?");
        newDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                drawView.startNew(null);
                dialog.dismiss();
            }
        });
        newDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        newDialog.show();
    }

    else if (view.getId() == R.id.save_btn) {
        //save drawing
        AlertDialog.Builder saveDialog = new AlertDialog.Builder(this);
        saveDialog.setTitle("Save drawing");
        saveDialog.setMessage("Save drawing to device Gallery?");
        saveDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {

                //save drawing
                drawView.setDrawingCacheEnabled(true);
                String imgSaved = MediaStore.Images.Media.insertImage(MainActivity.this.getContentResolver(),
                        drawView.getDrawingCache(), UUID.randomUUID().toString() + ".png", "drawing");

                if (imgSaved != null) {
                    Toast savedToast = Toast.makeText(getApplicationContext(), "Drawing saved to Gallery!",
                            Toast.LENGTH_SHORT);
                    savedToast.show();
                } else {
                    for (int i = 0; i < 3; i++) { // tried to increase the duration
                        Toast unsavedToast = Toast.makeText(getApplicationContext(),
                                "Oops! Image could not be saved. "
                                        + "Explicit write permission to storage device may required."
                                        + "Check Settings->" + "Application Manager->" + "JJDraw->"
                                        + "Permissions.",
                                Toast.LENGTH_LONG);
                        unsavedToast.show();
                    }
                }

                drawView.destroyDrawingCache();
            }
        });
        saveDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        saveDialog.show();
    }

}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Utility method to display an alert dialog. Use instead of AlertDialog to
 * get the right styling.//from  w w  w  . ja  v  a2s  .  c  o m
 * 
 * @param context
 * @param message
 */
public static void displayAlert(final Launcher context, String message) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.alert);

    final TextView alertTextView = (TextView) dialog.findViewById(R.id.alertText);
    alertTextView.setText(message);
    Button alertButton = (Button) dialog.findViewById(R.id.alertButton);
    alertButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.showCover(false);
            dialog.dismiss();
        }

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display the list of Spotlight web apps:
 * https://www.google.com/tv/spotlight-gallery.html Allow the user to launch
 * a web app in the browser./*from   ww w. ja va2 s .co  m*/
 * 
 * @param context
 */
public static void displayAllSpotlight(final Launcher context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.spotlight_grid);

    final GridView gridView = (GridView) dialog.findViewById(R.id.grid);
    final ArrayList<SpotlightInfo> spotlights = SpotlightTable.getAllSpotlights(context);
    gridView.setAdapter(new AllSpotlightAdapter(context, spotlights));
    gridView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SpotlightInfo spotlightInfo = (SpotlightInfo) parent.getAdapter().getItem(position);
            spotlightInfo.invoke(context);
            context.showCover(false);
            dialog.dismiss();
            Analytics.logEvent(Analytics.INVOKE_SPOTLIGHT_WEB_APP);
        }

    });
    gridView.setDrawingCacheEnabled(true);
    gridView.setOnKeyListener(onKeyListener);
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_SPOTLIGHT_WEB_APPS);
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display introduction to the user for first time launch
 * //  w  w w .  j  av a 2  s  .c om
 * @param context
 */
public static void displayIntroduction(final Launcher context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.introduction);

    Typeface lightTypeface = ((LauncherApplication) context.getApplicationContext()).getLightTypeface(context);

    TextView titleTextView = (TextView) dialog.findViewById(R.id.intro_title);
    titleTextView.setTypeface(lightTypeface);
    TextView textView1 = (TextView) dialog.findViewById(R.id.intro_text1);
    textView1.setTypeface(lightTypeface);
    TextView textView2 = (TextView) dialog.findViewById(R.id.intro_text2);
    textView2.setTypeface(lightTypeface);

    ((Button) dialog.findViewById(R.id.intro_button)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.showCover(false);
            dialog.dismiss();
        }

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_INTRODUCTION);
}

From source file:com.android.nobadgift.DashboardActivity.java

private void displayConfirmationDialog() {
    try {//from  w  ww .  j  a v  a  2 s  . com
        Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.custom_dialog);
        dialog.setTitle("Successfully Scanned!");
        dialog.setCanceledOnTouchOutside(true);
        dialog.setCancelable(true);
        dialog.setOnDismissListener(new OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                displayInfoDialog();
            }
        });
        TextView text = (TextView) dialog.findViewById(R.id.dialogText);
        text.setText("\"" + itemName + "\"");
        ImageView image = (ImageView) dialog.findViewById(R.id.dialogImage);
        image.setImageBitmap(retrievedImage);
        dialog.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:it.andreale.mdatetimepicker.time.TimePickerDialog.java

@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // restore old state if not null
    if (savedInstanceState != null) {
        mHeaderColor = savedInstanceState.getInt(SAVED_HEADER_COLOR, DEFAULT_ACCENT_COLOR);
        mPositiveColor = savedInstanceState.getInt(SAVED_POSITIVE_COLOR, DEFAULT_ACCENT_COLOR);
        mNegativeColor = savedInstanceState.getInt(SAVED_NEGATIVE_COLOR, DEFAULT_ACCENT_COLOR);
        mDarkTheme = savedInstanceState.getBoolean(SAVED_DARK_MODE, false);
        mCircleColor = savedInstanceState.getInt(SAVED_CIRCLE_COLOR,
                mDarkTheme ? Color.parseColor("#555555") : Color.parseColor("#eeeeee"));
        mSelectorColor = savedInstanceState.getInt(SAVED_SELECTOR_COLOR, DEFAULT_ACCENT_COLOR);
        mDefaultTextColor = savedInstanceState.getInt(SAVED_TEXT_COLOR, mDarkTheme ? Color.BLACK : Color.WHITE);
        mSelectedTextColor = savedInstanceState.getInt(SAVED_SELECTED_TEXT_COLOR,
                mDarkTheme ? Color.WHITE : Color.BLACK);
        mCalendar = (Calendar) savedInstanceState.getSerializable(SAVED_CALENDAR);
        mPositiveText = savedInstanceState.getString(SAVED_POSITIVE_TEXT, getString(android.R.string.ok));
        mNegativeText = savedInstanceState.getString(SAVED_NEGATIVE_TEXT, getString(android.R.string.cancel));
        m24HourMode = savedInstanceState.getBoolean(SAVED_HOUR_MODE, false);
        mBuilderFlag = true;/*from ww  w . j av  a  2  s . co m*/
    } else {
        // check builder flag
        if (!mBuilderFlag) {
            throw new IllegalStateException("You must initialize TimePickerDialog throw Builder class");
        }
    }
    // inflate view
    View view = inflatePickerView(savedInstanceState);
    // style views
    mHeaderView.setBackgroundColor(mHeaderColor);
    view.setBackgroundColor(mDarkTheme ? BACKGROUND_DARK : BACKGROUND_LIGHT);
    // create dialog
    Dialog dialog = new Dialog(getActivity());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(view);
    return dialog;
}

From source file:com.orange.datavenue.DatasourceListFragment.java

private void createDatasource() {
    final android.app.Dialog dialog = new android.app.Dialog(getActivity());

    dialog.setContentView(R.layout.create_datasource_dialog);

    dialog.setTitle(R.string.add_datasource);

    final LinearLayout callbackLayout = (LinearLayout) dialog.findViewById(R.id.callback_layout);
    final EditText name = (EditText) dialog.findViewById(R.id.name);
    final EditText description = (EditText) dialog.findViewById(R.id.description);
    final EditText serial = (EditText) dialog.findViewById(R.id.serial);
    final EditText callback = (EditText) dialog.findViewById(R.id.callback);
    final CheckBox status = (CheckBox) dialog.findViewById(R.id.status);

    status.setChecked(true); // by default status is activated

    Button actionButton = (Button) dialog.findViewById(R.id.add_button);

    actionButton.setOnClickListener(new View.OnClickListener() {
        @Override/* w  ww  .j  ava2s  .  co m*/
        public void onClick(View view) {
            Log.d(TAG_NAME, "name : " + name.getText().toString());
            Log.d(TAG_NAME, "description : " + description.getText().toString());
            Log.d(TAG_NAME, "serial : " + serial.getText().toString());
            Log.d(TAG_NAME, "status : " + status.isChecked());

            Datasource newDatasource = new Datasource();

            newDatasource.setName(name.getText().toString());
            newDatasource.setDescription(description.getText().toString());
            newDatasource.setSerial(serial.getText().toString());

            String callbackUrl = callback.getText().toString();

            if ("".equals(callbackUrl)) {
                newDatasource.setCallback(null);
            } else {
                try {
                    URL url = new URL(callbackUrl);
                    Callback newCallback = new Callback();
                    newCallback.setUrl(url.toString());
                    newCallback.setStatus("activated");
                    newCallback.setName("Callback");
                    newCallback.setDescription("application callback");
                    newDatasource.setCallback(newCallback);
                } catch (MalformedURLException e) {
                    Log.e(TAG_NAME, e.toString());
                    newDatasource.setCallback(null);
                    callback.setText("");
                }
            }

            if (status.isChecked()) {
                newDatasource.setStatus("activated");
            } else {
                newDatasource.setStatus("deactivated");
            }

            CreateDatasourceOperation createDatasourceOperation = new CreateDatasourceOperation(
                    Model.instance.oapiKey, Model.instance.key, newDatasource, new OperationCallback() {
                        @Override
                        public void process(Object object, Exception exception) {
                            if (exception == null) {
                                getDatasources();
                            } else {
                                Errors.displayError(getActivity(), exception);
                            }
                        }
                    });

            createDatasourceOperation.execute("");

            dialog.dismiss();
        }
    });

    Button cancelButton = (Button) dialog.findViewById(R.id.cancel_button);
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });

    dialog.setCancelable(false);
    dialog.show();
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display a dialog to confirm that the user wants to delete an item.
 * //from  www. j  ava 2  s.c om
 * @param context
 */
public static void displayDeleteItem(final Launcher context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.confirmation);

    TextView confirmationTextView = (TextView) dialog.findViewById(R.id.confirmationText);
    confirmationTextView.setText(context.getString(R.string.dialog_delete_item_message));
    Button buttonYes = (Button) dialog.findViewById(R.id.button1);
    buttonYes.setText(context.getString(R.string.dialog_yes));
    buttonYes.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.deleteCurrentItem();
            context.showCover(false);
            dialog.dismiss();
        }

    });
    Button buttonNo = (Button) dialog.findViewById(R.id.button2);
    buttonNo.setText(context.getString(R.string.dialog_no));
    buttonNo.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.showCover(false);
            dialog.dismiss();
        }

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_DELETE_ITEM);
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display a dialog to confirm that a user wants to delete a row.
 * /*from www.  j  a  v a 2  s. c  om*/
 * @param context
 */
public static void displayDeleteRow(final Launcher context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.confirmation);

    TextView confirmationTextView = (TextView) dialog.findViewById(R.id.confirmationText);
    confirmationTextView.setText(context.getString(R.string.dialog_delete_row_message));
    Button buttonYes = (Button) dialog.findViewById(R.id.button1);
    buttonYes.setText(context.getString(R.string.dialog_yes));
    buttonYes.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.deleteCurrentRow();
            context.showCover(false);
            dialog.dismiss();
        }

    });
    Button buttonNo = (Button) dialog.findViewById(R.id.button2);
    buttonNo.setText(context.getString(R.string.dialog_no));
    buttonNo.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.showCover(false);
            dialog.dismiss();
        }

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_DELETE_ROW);
}

From source file:com.adithya321.sharesanalysis.fragments.SharePurchaseFragment.java

@Nullable
@Override/*  w w  w.  j a va 2  s. c om*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_share_purchase, container, false);

    databaseHandler = new DatabaseHandler(getContext());
    sharePurchasesRecyclerView = (RecyclerView) root.findViewById(R.id.share_purchases_recycler_view);
    emptyTV = (TextView) root.findViewById(R.id.empty);
    arrow = (ImageView) root.findViewById(R.id.arrow);
    setRecyclerViewAdapter();

    FloatingActionButton addPurchaseFab = (FloatingActionButton) root.findViewById(R.id.add_purchase_fab);
    addPurchaseFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Dialog dialog = new Dialog(getContext());
            dialog.setTitle("Add Share Purchase");
            dialog.setContentView(R.layout.dialog_add_share_purchase);
            dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.WRAP_CONTENT);
            dialog.show();

            final AutoCompleteTextView name = (AutoCompleteTextView) dialog.findViewById(R.id.share_name);
            List<String> nseList = ShareUtils.getNseList(getContext());
            FilterWithSpaceAdapter<String> arrayAdapter = new FilterWithSpaceAdapter<>(getContext(),
                    android.R.layout.simple_dropdown_item_1line, nseList);
            name.setThreshold(1);
            name.setAdapter(arrayAdapter);

            final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner);

            ArrayList<String> shares = new ArrayList<>();
            for (Share share : sharesList) {
                shares.add(share.getName());
            }
            ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(),
                    android.R.layout.simple_spinner_item, shares);
            spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(spinnerAdapter);

            final RadioButton newRB = (RadioButton) dialog.findViewById(R.id.radioBtn_new);
            RadioButton existingRB = (RadioButton) dialog.findViewById(R.id.radioBtn_existing);
            if (shares.size() == 0)
                existingRB.setVisibility(View.GONE);
            (newRB).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    name.setVisibility(View.VISIBLE);
                    spinner.setVisibility(View.GONE);
                }
            });

            (existingRB).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    name.setVisibility(View.GONE);
                    spinner.setVisibility(View.VISIBLE);
                }
            });

            Calendar calendar = Calendar.getInstance();
            year_start = calendar.get(Calendar.YEAR);
            month_start = calendar.get(Calendar.MONTH) + 1;
            day_start = calendar.get(Calendar.DAY_OF_MONTH);
            final Button selectDate = (Button) dialog.findViewById(R.id.select_date);
            selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/")
                    .append(year_start));
            selectDate.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Dialog dialog = new DatePickerDialog(getActivity(), onDateSetListener, year_start,
                            month_start - 1, day_start);
                    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialog) {
                            selectDate.setText(new StringBuilder().append(day_start).append("/")
                                    .append(month_start).append("/").append(year_start));
                        }
                    });
                    dialog.show();
                }
            });

            Button addPurchaseBtn = (Button) dialog.findViewById(R.id.add_purchase_btn);
            addPurchaseBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Share share = new Share();
                    share.setId(databaseHandler.getNextKey("share"));
                    share.setPurchases(new RealmList<Purchase>());
                    Purchase purchase = new Purchase();
                    purchase.setId(databaseHandler.getNextKey("purchase"));

                    if (newRB.isChecked()) {
                        String sName = name.getText().toString().trim();
                        if (sName.equals("")) {
                            Toast.makeText(getActivity(), "Invalid Name", Toast.LENGTH_SHORT).show();
                            return;
                        } else {
                            share.setName(sName);
                            purchase.setName(sName);
                        }
                    }

                    String stringStartDate = year_start + " " + month_start + " " + day_start;
                    DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH);
                    try {
                        Date date = format.parse(stringStartDate);
                        share.setDateOfInitialPurchase(date);
                        purchase.setDate(date);
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares);
                    try {
                        purchase.setQuantity(Integer.parseInt(quantity.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    EditText price = (EditText) dialog.findViewById(R.id.buying_price);
                    try {
                        purchase.setPrice(Double.parseDouble(price.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Buying Price", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    purchase.setType("buy");
                    if (newRB.isChecked()) {
                        if (!databaseHandler.addShare(share, purchase)) {
                            Toast.makeText(getActivity(), "Share Already Exists", Toast.LENGTH_SHORT).show();
                            return;
                        }
                    } else {
                        purchase.setName(spinner.getSelectedItem().toString());
                        databaseHandler.addPurchase(spinner.getSelectedItem().toString(), purchase);
                    }
                    setRecyclerViewAdapter();
                    dialog.dismiss();
                }
            });
        }
    });

    return root;
}