Java Code Examples for android.support.v7.app.AlertDialog#dismiss()

The following examples show how to use android.support.v7.app.AlertDialog#dismiss() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColorPicker.java    From ForPDA with GNU General Public License v3.0 5 votes vote down vote up
public ColorPicker(Context context, SpectrumPalette.OnColorSelectedListener listener) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout layoutContainer = (LinearLayout) inflater.inflate(R.layout.color_picker_layout, null);


    ViewPager viewPager = (ViewPager) layoutContainer.findViewById(R.id.color_picker_pager);

    List<ScrollView> viewList = new ArrayList<>();
    ScrollView scrollView = new ScrollView(context);
    ScrollView scrollView1 = new ScrollView(context);
    SpectrumPalette materialColors = new SpectrumPalette(context);
    materialColors.setColors(context.getResources().getIntArray(R.array.md_colors));
    SpectrumPalette forumColors = new SpectrumPalette(context);
    forumColors.setColors(context.getResources().getIntArray(R.array.forum_colors));
    scrollView.addView(materialColors);
    scrollView1.addView(forumColors);
    viewList.add(scrollView);
    viewList.add(scrollView1);

    viewPager.setAdapter(new MyPagerAdapter(viewList));
    ((TabLayout) layoutContainer.findViewById(R.id.color_picker_tab_layout)).setupWithViewPager(viewPager);
    AlertDialog dialog = new AlertDialog.Builder(context)
            .setView(layoutContainer)
            .show();
    SpectrumPalette.OnColorSelectedListener mainListener = i -> {
        if (listener != null) {
            listener.onColorSelected(i);
        }
        dialog.dismiss();
    };
    materialColors.setOnColorSelectedListener(mainListener);
    forumColors.setOnColorSelectedListener(mainListener);

}
 
Example 2
Source File: PhoneActivity.java    From Sensor-Data-Logger with Apache License 2.0 5 votes vote down vote up
/**
 * Will be called when the reachability of a connected @Node
 * (e.g. wearable device) has changed
 */
@Override
public void onReachabilityUpdated(String nodeId, boolean isReachable) {
    Log.d(TAG, "Reachability of " + nodeId + " changed to: " + String.valueOf(isReachable));

    // generate a readable message
    String nodeName = app.getGoogleApiMessenger().getNodeName(nodeId);
    String message = isReachable ? getString(R.string.device_connected) : getString(R.string.device_disconnected);
    message = message.replace("[DEVICENAME]", nodeName);

    // notify the user with a @Snackbar
    View parentLayout = findViewById(android.R.id.content);
    Snackbar.make(parentLayout, message, Snackbar.LENGTH_LONG)
            .setDuration(Snackbar.LENGTH_LONG)
            .show();

    if (isReachable) {
        // update reachability dialog, if any
        AlertDialog reachabilityDialog = reachabilityDialogs.get(nodeId);
        if (reachabilityDialog != null && reachabilityDialog.isShowing()) {
            reachabilityDialog.dismiss();
            showSensorSelectionDialog();
        }
    }

    // re-send available data requests
    sendSensorEventDataRequests();
}
 
Example 3
Source File: CreatePublicChannelDialog.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
private void goBack(AlertDialog dialog, CreatePublicChannelDialogBinding binding) {
    if (nameEntered) {
        nameEntered = false;
        updateInputs(binding, true);
        updateButtons(dialog);
    } else {
        dialog.dismiss();
    }
}
 
Example 4
Source File: XmppActivity.java    From Conversations with GNU General Public License v3.0 4 votes vote down vote up
@SuppressLint("InflateParams")
private void quickEdit(final String previousValue,
                       final OnValueEdited callback,
                       final @StringRes int hint,
                       boolean password,
                       boolean permitEmpty) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    DialogQuickeditBinding binding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.dialog_quickedit, null, false);
    if (password) {
        binding.inputEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
    builder.setPositiveButton(R.string.accept, null);
    if (hint != 0) {
        binding.inputLayout.setHint(getString(hint));
    }
    binding.inputEditText.requestFocus();
    if (previousValue != null) {
        binding.inputEditText.getText().append(previousValue);
    }
    builder.setView(binding.getRoot());
    builder.setNegativeButton(R.string.cancel, null);
    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(d -> SoftKeyboardUtils.showKeyboard(binding.inputEditText));
    dialog.show();
    View.OnClickListener clickListener = v -> {
        String value = binding.inputEditText.getText().toString();
        if (!value.equals(previousValue) && (!value.trim().isEmpty() || permitEmpty)) {
            String error = callback.onValueEdited(value);
            if (error != null) {
                binding.inputLayout.setError(error);
                return;
            }
        }
        SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
        dialog.dismiss();
    };
    dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(clickListener);
    dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setOnClickListener((v -> {
        SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
        dialog.dismiss();
    }));
    dialog.setCanceledOnTouchOutside(false);
    dialog.setOnDismissListener(dialog1 -> {
        SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
    });
}