searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(final String query) {
//вызовется при нажатии на лупу на клавиатуре
return false;
}
@Override
public boolean onQueryTextChange(final String newText) {
//вызовется при изменении ведённого текста
return true;
}
});
public String ServerQuery() throws IOException {
OkHttpClient client = new OkHttpClient();
String json = getJson();
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), json);
Request request = new Request.Builder()
.url(getUrl())
.put(body)
.build();
Response response = client.newCall(request).execute();
return response.body().string();
}
return null;
}
if (Looper.myLooper() == null){
Looper.prepare();
}
private void refreshUserCoordinates(final Context contextThread) {
Intent intent = getIntent();
final String user = intent.getStringExtra("user");
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
if (Looper.myLooper() == null)
{
Looper.prepare();
}
GeoPosition geoPosition = new GeoPosition();
geoPosition.SetUpLocationListener(contextThread);
ServerInteraction serverInteraction = new ServerInteraction("http://razdvatri.ru/refreshCoordinates.php",
"{\"user\" " + ":\"" + user + "\", \"latitude\" " + ":\"" + geoPosition.getLatitude() + "\", \"longitude\" :" + "\"" + geoPosition.getLongitude() + "\"" + "}", "put");
serverInteraction.execute();
}
}, 0L, 50L * 1000);
}