androidx.appcompat.app.AppCompatDialog Java Examples

The following examples show how to use androidx.appcompat.app.AppCompatDialog. 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: ScannerStatusFragmentDialog.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 5 votes vote down vote up
@SuppressWarnings("UnnecessaryLocalVariable")
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    // Remove title
    AppCompatDialog dialog = (AppCompatDialog) getDialog();
    dialog.supportRequestWindowFeature(Window.FEATURE_NO_TITLE);

    View view = inflater.inflate(R.layout.layout_common_message_dialog, container, false);
    return view;
}
 
Example #2
Source File: NeopixelColorPickerFragment.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 5 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Remove title
    AppCompatDialog dialog = (AppCompatDialog) getDialog();
    dialog.supportRequestWindowFeature(Window.FEATURE_NO_TITLE);

    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.fragment_neopixel_colorpicker, container, false);
}
 
Example #3
Source File: NeopixelBoardSelectorFragment.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 5 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Remove title
    AppCompatDialog dialog = (AppCompatDialog) getDialog();
    if (dialog != null) {
        dialog.supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    }

    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.fragment_neopixel_boardselector, container, false);
}
 
Example #4
Source File: NeopixelComponentSelectorFragment.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 5 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Remove title
    AppCompatDialog dialog = (AppCompatDialog) getDialog();
    if (dialog != null) {
        dialog.supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    }

    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.fragment_neopixel_componentselector, container, false);
}
 
Example #5
Source File: NeopixelComponentSelectorFragment.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // Dismiss on click outside
    AppCompatDialog dialog = (AppCompatDialog) getDialog();
    if (dialog != null) {
        dialog.setCanceledOnTouchOutside(true);
    }

    // UI
    Context context = getContext();
    if (context != null) {
        RecyclerView standardComponentsRecyclerView = view.findViewById(R.id.standardComponentsRecyclerView);
        standardComponentsRecyclerView.setHasFixedSize(true);
        standardComponentsRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false));
        RecyclerView.Adapter standardBoardSizesAdapter = new StandardComponentsAdapter(mSelectedComponent, components -> {
            mSelectedComponent = components;
            if (mListener != null) {
                mListener.onComponentsSelected(components, mIs400KhzEnabled);
                dismiss();
            }
        });
        standardComponentsRecyclerView.setAdapter(standardBoardSizesAdapter);


        SwitchCompat mode400HhzSwitch = view.findViewById(R.id.mode400HhzSwitch);
        mode400HhzSwitch.setChecked(mIs400KhzEnabled);
        mode400HhzSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
            if (buttonView.isPressed()) {
                mIs400KhzEnabled = isChecked;
                if (mListener != null) {
                    mListener.onComponentsSelected(mSelectedComponent, mIs400KhzEnabled);
                }
            }
        });
    }
}
 
Example #6
Source File: NeopixelBoardSelectorFragment.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 4 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // Dismiss on click outside
    AppCompatDialog dialog = (AppCompatDialog) getDialog();
    if (dialog != null) {
        dialog.setCanceledOnTouchOutside(true);
    }

    // UI
    Context context = getContext();
    if (context != null) {
        RecyclerView standardSizesRecyclerView = view.findViewById(R.id.standardSizesRecyclerView);
        standardSizesRecyclerView.setHasFixedSize(true);
        standardSizesRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false));
        RecyclerView.Adapter standardBoardSizesAdapter = new StandardBoardSizesAdapter(context, index -> {
            mListener.onBoardIndexSelected(index);
            dismiss();
        });
        standardSizesRecyclerView.setAdapter(standardBoardSizesAdapter);

        Button lineStripButton = view.findViewById(R.id.lineStripButton);
        lineStripButton.setOnClickListener(view1 -> {
            AlertDialog.Builder alert = new AlertDialog.Builder(context);
            alert.setTitle(R.string.neopixelboardselector_linestriplength_title);
            final EditText input = new EditText(context);
            input.setHint(R.string.neopixelboardselector_linestriplength_hint);
            input.setInputType(InputType.TYPE_CLASS_NUMBER);
            input.setRawInputType(Configuration.KEYBOARD_12KEY);
            alert.setView(input);
            alert.setPositiveButton(R.string.neopixelboardselector_linestriplength_action, (alertDialog, whichButton) -> {
                String valueString = String.valueOf(input.getText());
                int value = 8;      // Default length
                try {
                    int number = Integer.parseInt(valueString);
                    if (number > 0) {
                        value = number;
                    }
                } catch (Exception e) {
                    Log.d(TAG, "Cannot parse value");
                }

                mListener.onLineStripSelected(value);
            });
            alert.setNegativeButton(android.R.string.cancel, (alertDialog, whichButton) -> {
            });
            alert.show();
        });
    }
}
 
Example #7
Source File: FileExplorerDialog.java    From GetApk with MIT License 4 votes vote down vote up
@Override
public boolean onMenuItemClick(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
        case R.id.confirm:
            mBuilder.pathSelectListener.onSelected((String) mPathTV.getText());
            dismiss();
            break;
        case R.id.create:
            new AlertDialog.Builder(getContext())
                    .setTitle(R.string.new_create_folder)
                    .setView(R.layout.item_edit)
                    .setNegativeButton(R.string.cancel, null)
                    .setPositiveButton(R.string.new_create, new OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            AppCompatEditText editText = ((AppCompatDialog) dialog).findViewById(R.id.name_et);
                            String name = editText.getText().toString();
                            if (TextUtils.isEmpty(name)) {
                                name = getContext().getString(R.string.new_create_folder);
                            }
                            try {
                                String path = mPathTV.getText().toString();
                                FileUtil.newCreateFolder(path, name);
                                if (mDisposable != null && !mDisposable.isDisposed()) {
                                    mDisposable.dispose();
                                }
                                mDisposable = mPresenter.getFiles(path);
                                addDisposable(mDisposable);
                            } catch (IOException e) {
                                e.printStackTrace();
                            }

                        }
                    })
                    .show().setCanceledOnTouchOutside(false);
            break;
    }

    return true;
}