mirror of
https://github.com/woheller69/solxpect.git
synced 2025-12-16 17:30:13 +01:00
Close keyboard after 3s
This commit is contained in:
parent
117adab1c6
commit
5039510970
1 changed files with 17 additions and 13 deletions
|
|
@ -62,6 +62,8 @@ public class AddLocationDialogOmGeocodingAPI extends DialogFragment {
|
||||||
|
|
||||||
private static final int TRIGGER_AUTO_COMPLETE = 100;
|
private static final int TRIGGER_AUTO_COMPLETE = 100;
|
||||||
private static final long AUTO_COMPLETE_DELAY = 300;
|
private static final long AUTO_COMPLETE_DELAY = 300;
|
||||||
|
private static final int TRIGGER_HIDE_KEYBOARD = 200;
|
||||||
|
private static final long HIDE_KEYBOARD_DELAY = 3000;
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
private AutoSuggestAdapter autoSuggestAdapter;
|
private AutoSuggestAdapter autoSuggestAdapter;
|
||||||
String urlSuffix="v1/search?name=";
|
String urlSuffix="v1/search?name=";
|
||||||
|
|
@ -145,8 +147,9 @@ public class AddLocationDialogOmGeocodingAPI extends DialogFragment {
|
||||||
public void onTextChanged(CharSequence s, int start, int before,
|
public void onTextChanged(CharSequence s, int start, int before,
|
||||||
int count) {
|
int count) {
|
||||||
handler.removeMessages(TRIGGER_AUTO_COMPLETE);
|
handler.removeMessages(TRIGGER_AUTO_COMPLETE);
|
||||||
handler.sendEmptyMessageDelayed(TRIGGER_AUTO_COMPLETE,
|
handler.sendEmptyMessageDelayed(TRIGGER_AUTO_COMPLETE, AUTO_COMPLETE_DELAY);
|
||||||
AUTO_COMPLETE_DELAY);
|
handler.removeMessages(TRIGGER_HIDE_KEYBOARD);
|
||||||
|
handler.sendEmptyMessageDelayed(TRIGGER_HIDE_KEYBOARD, HIDE_KEYBOARD_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -155,20 +158,21 @@ public class AddLocationDialogOmGeocodingAPI extends DialogFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
handler = new Handler(Looper.getMainLooper(), new Handler.Callback() {
|
handler = new Handler(Looper.getMainLooper(), msg -> {
|
||||||
@Override
|
if (msg.what == TRIGGER_AUTO_COMPLETE) {
|
||||||
public boolean handleMessage(Message msg) {
|
if (!TextUtils.isEmpty(autoCompleteTextView.getText())) {
|
||||||
if (msg.what == TRIGGER_AUTO_COMPLETE) {
|
try {
|
||||||
if (!TextUtils.isEmpty(autoCompleteTextView.getText())) {
|
makeApiCall(URLEncoder.encode(autoCompleteTextView.getText().toString(), StandardCharsets.UTF_8.name()));
|
||||||
try {
|
} catch (UnsupportedEncodingException e) {
|
||||||
makeApiCall(URLEncoder.encode(autoCompleteTextView.getText().toString(), StandardCharsets.UTF_8.name()));
|
e.printStackTrace();
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
} else if (msg.what == TRIGGER_HIDE_KEYBOARD) {
|
||||||
|
//Hide keyboard to show entries behind the keyboard
|
||||||
|
final InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
imm.hideSoftInputFromWindow(rootView.getWindowToken(), 0);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.setPositiveButton(activity.getString(R.string.dialog_add_add_button), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(activity.getString(R.string.dialog_add_add_button), new DialogInterface.OnClickListener() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue