Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #937:Hiding keyboard on button press #983

Merged
merged 1 commit into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.mifos.mifosxdroid.core;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.ProgressBar;
import android.widget.ViewFlipper;

Expand Down Expand Up @@ -48,4 +50,11 @@ public void showProgress(boolean show) {
" Fragment contains a ViewFlipper with ID \"view_flipper\"?");
}
}

public void hideKeyboard(View view) {
InputMethodManager inputManager = (InputMethodManager) getActivity()
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager
.RESULT_UNCHANGED_SHOWN);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
Expand Down Expand Up @@ -39,16 +40,19 @@ public class IdentifierDialogFragment extends ProgressableDialogFragment impleme
IdentifierDialogMvpView, AdapterView.OnItemSelectedListener {

@BindView(R.id.sp_identifier_type)
Spinner sp_identifier_type;
Spinner spIdentifierType;

@BindView(R.id.sp_identifier_status)
Spinner sp_identifier_status;
Spinner spIdentifierStatus;

@BindView(R.id.et_description)
EditText et_description;
EditText etDescription;

@BindView(R.id.btn_create_identifier)
Button btnIdentifier;

@BindView(R.id.et_unique_id)
EditText et_unique_id;
EditText etUniqueId;

@BindArray(R.array.status)
String[] identifierStatus;
Expand Down Expand Up @@ -112,40 +116,39 @@ public void showIdentifierSpinners() {
android.R.layout.simple_spinner_item, mListIdentifierType);
mIdentifierTypeAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp_identifier_type.setAdapter(mIdentifierTypeAdapter);
sp_identifier_type.setOnItemSelectedListener(this);
spIdentifierType.setAdapter(mIdentifierTypeAdapter);
spIdentifierType.setOnItemSelectedListener(this);

mIdentifierStatusAdapter = new ArrayAdapter<>(getActivity(),
android.R.layout.simple_spinner_item, identifierStatus);
mIdentifierStatusAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp_identifier_status.setAdapter(mIdentifierStatusAdapter);
sp_identifier_status.setOnItemSelectedListener(this);
spIdentifierStatus.setAdapter(mIdentifierStatusAdapter);
spIdentifierStatus.setOnItemSelectedListener(this);

}

@OnClick(R.id.btn_create_identifier)
void onClickCreateIdentifier() {

if (et_unique_id.getText().toString().trim().equals("")) {
et_unique_id.setError(getResources().getString(R.string.unique_id_required));
if (etUniqueId.getText().toString().trim().equals("")) {
etUniqueId.setError(getResources().getString(R.string.unique_id_required));
} else if (mListIdentifierType.size() == 0) {
showError(R.string.empty_identifier_document_type);
} else {
hideKeyboard(btnIdentifier);
IdentifierPayload identifierPayload = new IdentifierPayload();
identifierPayload.setDocumentTypeId(identifierDocumentTypeId);
identifierPayload.setStatus(status);
identifierPayload.setDocumentKey(et_unique_id.getText().toString());
identifierPayload.setDescription(et_description.getText().toString());
identifierPayload.setDocumentKey(etUniqueId.getText().toString());
identifierPayload.setDescription(etDescription.getText().toString());

// Add the values in the identifier. It'll be sent to the calling Fragment
// if the request is successful.
identifier = new Identifier();
identifier.setDescription(et_description.getText().toString());
identifier.setDocumentKey(et_unique_id.getText().toString());
identifier.setDescription(etDescription.getText().toString());
identifier.setDocumentKey(etUniqueId.getText().toString());
identifier.setDocumentType(documentTypeHashMap
.get(sp_identifier_type.getSelectedItem().toString()));

.get(spIdentifierType.getSelectedItem().toString()));
mIdentifierDialogPresenter.createClientIdentifier(clientId, identifierPayload);
}
}
Expand Down