This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { | |
| @Override | |
| public boolean onQueryTextSubmit(String query) { | |
| return true; | |
| } | |
| @Override | |
| public boolean onQueryTextChange(String newText) { | |
| if (!newText.isEmpty()) { | |
| RecyclerView.Adapter adapter = new NamesAdapter(namesAPI.searchForName(newText)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { | |
| @Override | |
| public boolean onQueryTextSubmit(String query) { | |
| return true; | |
| } | |
| @Override | |
| public boolean onQueryTextChange(String newText) { | |
| if (!newText.isEmpty()) { | |
| adapter.setNamesList(namesAPI.searchForName(query)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Override | |
| public boolean onQueryTextChange(String newText) { | |
| if (!newText.isEmpty()) { | |
| adapter.setNamesList(namesAPI.searchForName(query)); | |
| adapter.notifyDataSetChanged(); | |
| apiCallsTextView.setText("API CALLS: " + apiCalls++); | |
| } | |
| return true; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class RxSearch { | |
| public static Observable<String> fromSearchView(@NonNull final SearchView searchView) { | |
| final BehaviorSubject<String> subject = BehaviorSubject.create(""); | |
| searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { | |
| @Override | |
| public boolean onQueryTextSubmit(String query) { | |
| subject.onCompleted(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RxSearch.fromSearchView(searchView) | |
| .debounce(300, TimeUnit.MILLISECONDS) | |
| .observeOn(AndroidSchedulers.mainThread()) | |
| .subscribe(query -> { | |
| adapter.setNamesList(namesAPI.searchForName(query)); | |
| adapter.notifyDataSetChanged(); | |
| apiCallsTextView.setText("API CALLS: " + apiCalls++); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RxSearch.fromSearchView(searchView) | |
| .debounce(300, TimeUnit.MILLISECONDS) | |
| .filter(item -> item.length() > 1) | |
| .observeOn(AndroidSchedulers.mainThread()) | |
| .subscribe(query -> { | |
| adapter.setNamesList(namesAPI.searchForName(query)); | |
| adapter.notifyDataSetChanged(); | |
| apiCallsTextView.setText("API CALLS: " + apiCalls++); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| from flask import Flask, Response | |
| app = Flask(__name__) | |
| data = { | |
| 'id': 7, | |
| 'name': 'James', | |
| 'surname': 'Bond', | |
| 'sex': 'male', | |
| 'status': 'M.I.A.' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class DataModel { | |
| private String status; | |
| private String sex; | |
| private String surname; | |
| private String name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class DataDeserializer implements JsonDeserializer<DataModel> { | |
| @Override | |
| public DataModel deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | |
| JsonObject jsonDataObject = json.getAsJsonObject(); | |
| String status = jsonDataObject.get("status").getAsString(); | |
| String sex = jsonDataObject.get("sex").getAsString(); | |
| String surname = jsonDataObject.get("surname").getAsString(); | |
| String name = jsonDataObject.get("name").getAsString(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class BaseDeserializerTest { | |
| protected InputStream getResourceInputStream(String name) { | |
| return this.getClass().getClassLoader().getResourceAsStream(name); | |
| } | |
| protected Reader getResourceReader(String name) { | |
| return new InputStreamReader(getResourceInputStream(name)); | |
| } | |
| } |
OlderNewer