Skip to content

Commit

Permalink
Update PostSettingsInputDialogFragment.java
Browse files Browse the repository at this point in the history
  • Loading branch information
neeldoshii committed Jun 11, 2024
1 parent baffe30 commit dc5b518
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public interface PostSettingsInputDialogListener {
private static final String DISABLE_EMPTY_INPUT_TAG = "disable_empty_input";
private static final String MULTILINE_INPUT_TAG = "is_multiline_input";

private PostSettingsInputDialogBinding binding;
private PostSettingsInputDialogBinding mBinding;
private String mCurrentInput;
private String mTitle;
private String mHint;
Expand Down Expand Up @@ -97,29 +97,29 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
new MaterialAlertDialogBuilder(new ContextThemeWrapper(getActivity(), R.style.PostSettingsTheme));
LayoutInflater layoutInflater = requireActivity().getLayoutInflater();
//noinspection InflateParams
binding = PostSettingsInputDialogBinding.inflate(layoutInflater,null,false);
builder.setView(binding.getRoot());
mBinding = PostSettingsInputDialogBinding.inflate(layoutInflater, null, false);
builder.setView(mBinding.getRoot());
if (mIsMultilineInput) {
binding.postSettingsInputDialogEditText.setRawInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
mBinding.postSettingsInputDialogEditText.setRawInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
} else {
binding.postSettingsInputDialogEditText.setInputType(InputType.TYPE_CLASS_TEXT);
mBinding.postSettingsInputDialogEditText.setInputType(InputType.TYPE_CLASS_TEXT);
}
if (!TextUtils.isEmpty(mCurrentInput)) {
binding.postSettingsInputDialogEditText.setText(mCurrentInput);
mBinding.postSettingsInputDialogEditText.setText(mCurrentInput);
// move the cursor to the end
binding.postSettingsInputDialogEditText.setSelection(mCurrentInput.length());
mBinding.postSettingsInputDialogEditText.setSelection(mCurrentInput.length());
}
binding.postSettingsInputDialogEditText.addTextChangedListener(this);
mBinding.postSettingsInputDialogEditText.addTextChangedListener(this);

binding.postSettingsInputDialogInputLayout.setHint(mTitle);
mBinding.postSettingsInputDialogInputLayout.setHint(mTitle);

binding.postSettingsInputDialogHint.setText(mHint);
mBinding.postSettingsInputDialogHint.setText(mHint);

builder.setNegativeButton(R.string.cancel, null);
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mCurrentInput = Objects.requireNonNull(binding.postSettingsInputDialogEditText.getText()).toString();
mCurrentInput = Objects.requireNonNull(mBinding.postSettingsInputDialogEditText.getText()).toString();
if (mListener != null) {
mListener.onInputUpdated(mCurrentInput);
}
Expand Down

0 comments on commit dc5b518

Please sign in to comment.