Skip to content

Commit 284d7f5

Browse files
AkshGautamtherajanmaurya
authored andcommitted
Fix #937:Hiding keyboard on button press
1 parent d7d220d commit 284d7f5

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

mifosng-android/src/main/java/com/mifos/mifosxdroid/core/ProgressableDialogFragment.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.mifos.mifosxdroid.core;
22

3+
import android.content.Context;
34
import android.os.Bundle;
45
import android.support.annotation.Nullable;
56
import android.support.v4.app.DialogFragment;
67
import android.util.Log;
78
import android.view.View;
9+
import android.view.inputmethod.InputMethodManager;
810
import android.widget.ProgressBar;
911
import android.widget.ViewFlipper;
1012

@@ -48,4 +50,11 @@ public void showProgress(boolean show) {
4850
" Fragment contains a ViewFlipper with ID \"view_flipper\"?");
4951
}
5052
}
53+
54+
public void hideKeyboard(View view) {
55+
InputMethodManager inputManager = (InputMethodManager) getActivity()
56+
.getSystemService(Context.INPUT_METHOD_SERVICE);
57+
inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager
58+
.RESULT_UNCHANGED_SHOWN);
59+
}
5160
}

mifosng-android/src/main/java/com/mifos/mifosxdroid/dialogfragments/identifierdialog/IdentifierDialogFragment.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.view.ViewGroup;
88
import android.widget.AdapterView;
99
import android.widget.ArrayAdapter;
10+
import android.widget.Button;
1011
import android.widget.EditText;
1112
import android.widget.Spinner;
1213
import android.widget.Toast;
@@ -39,16 +40,19 @@ public class IdentifierDialogFragment extends ProgressableDialogFragment impleme
3940
IdentifierDialogMvpView, AdapterView.OnItemSelectedListener {
4041

4142
@BindView(R.id.sp_identifier_type)
42-
Spinner sp_identifier_type;
43+
Spinner spIdentifierType;
4344

4445
@BindView(R.id.sp_identifier_status)
45-
Spinner sp_identifier_status;
46+
Spinner spIdentifierStatus;
4647

4748
@BindView(R.id.et_description)
48-
EditText et_description;
49+
EditText etDescription;
50+
51+
@BindView(R.id.btn_create_identifier)
52+
Button btnIdentifier;
4953

5054
@BindView(R.id.et_unique_id)
51-
EditText et_unique_id;
55+
EditText etUniqueId;
5256

5357
@BindArray(R.array.status)
5458
String[] identifierStatus;
@@ -112,40 +116,39 @@ public void showIdentifierSpinners() {
112116
android.R.layout.simple_spinner_item, mListIdentifierType);
113117
mIdentifierTypeAdapter
114118
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
115-
sp_identifier_type.setAdapter(mIdentifierTypeAdapter);
116-
sp_identifier_type.setOnItemSelectedListener(this);
119+
spIdentifierType.setAdapter(mIdentifierTypeAdapter);
120+
spIdentifierType.setOnItemSelectedListener(this);
117121

118122
mIdentifierStatusAdapter = new ArrayAdapter<>(getActivity(),
119123
android.R.layout.simple_spinner_item, identifierStatus);
120124
mIdentifierStatusAdapter
121125
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
122-
sp_identifier_status.setAdapter(mIdentifierStatusAdapter);
123-
sp_identifier_status.setOnItemSelectedListener(this);
126+
spIdentifierStatus.setAdapter(mIdentifierStatusAdapter);
127+
spIdentifierStatus.setOnItemSelectedListener(this);
124128

125129
}
126130

127131
@OnClick(R.id.btn_create_identifier)
128132
void onClickCreateIdentifier() {
129-
130-
if (et_unique_id.getText().toString().trim().equals("")) {
131-
et_unique_id.setError(getResources().getString(R.string.unique_id_required));
133+
if (etUniqueId.getText().toString().trim().equals("")) {
134+
etUniqueId.setError(getResources().getString(R.string.unique_id_required));
132135
} else if (mListIdentifierType.size() == 0) {
133136
showError(R.string.empty_identifier_document_type);
134137
} else {
138+
hideKeyboard(btnIdentifier);
135139
IdentifierPayload identifierPayload = new IdentifierPayload();
136140
identifierPayload.setDocumentTypeId(identifierDocumentTypeId);
137141
identifierPayload.setStatus(status);
138-
identifierPayload.setDocumentKey(et_unique_id.getText().toString());
139-
identifierPayload.setDescription(et_description.getText().toString());
142+
identifierPayload.setDocumentKey(etUniqueId.getText().toString());
143+
identifierPayload.setDescription(etDescription.getText().toString());
140144

141145
// Add the values in the identifier. It'll be sent to the calling Fragment
142146
// if the request is successful.
143147
identifier = new Identifier();
144-
identifier.setDescription(et_description.getText().toString());
145-
identifier.setDocumentKey(et_unique_id.getText().toString());
148+
identifier.setDescription(etDescription.getText().toString());
149+
identifier.setDocumentKey(etUniqueId.getText().toString());
146150
identifier.setDocumentType(documentTypeHashMap
147-
.get(sp_identifier_type.getSelectedItem().toString()));
148-
151+
.get(spIdentifierType.getSelectedItem().toString()));
149152
mIdentifierDialogPresenter.createClientIdentifier(clientId, identifierPayload);
150153
}
151154
}

0 commit comments

Comments
 (0)