public class ChooseNearLocationActivity
extends AppCompatActivity
implements android.widget.SearchView.OnQueryTextListener
FindNetworkActivity
to restrict displayed networks to those with a near
that
matches where the user lives.Modifier and Type | Field and Description |
---|---|
private SearchAdapter<org.codethechange.culturemesh.models.Location> |
adapter
Populates the list of results with autocomplete results
|
static java.lang.String |
CHOSEN_PLACE
Identifier for the
Intent whose value is the Location the user chose |
private RequestQueue |
queue
Queue of asynchronous tasks for network operations
|
static int |
RESULT_OK
Result code to signal via the
Intent that the user successfully chose a
Location |
private android.widget.ListView |
searchList
List of autocomplete results
|
private android.widget.SearchView |
searchView
The field into which the user enters their query
|
Constructor and Description |
---|
ChooseNearLocationActivity() |
Modifier and Type | Method and Description |
---|---|
protected void |
onCreate(android.os.Bundle savedInstanceState)
Setup the activity.
|
boolean |
onQueryTextChange(java.lang.String newText)
Whenever the query text changes, do nothing because sending network requests every time is
unnecessary.
|
boolean |
onQueryTextSubmit(java.lang.String query)
When the user submits their query,
search() is run to
populated the results with matching Location s |
void |
search()
Get the query present in the
searchView and pass it to the
server via API.Get#autocompletePlace(RequestQueue, String, Response.Listener) to get
a list of matching Location s. |
public static final java.lang.String CHOSEN_PLACE
Intent
whose value is the Location
the user chosepublic static final int RESULT_OK
Intent
that the user successfully chose a
Location
private SearchAdapter<org.codethechange.culturemesh.models.Location> adapter
private android.widget.ListView searchList
private android.widget.SearchView searchView
private RequestQueue queue
protected void onCreate(android.os.Bundle savedInstanceState)
com.android.volley.RequestQueue
, the adapter
that populates the list of results, and the listener that handles clicks on items in the
results listsavedInstanceState
- Previous state that is passed through to superclasspublic boolean onQueryTextSubmit(java.lang.String query)
search()
is run to
populated the results with matching Location
sonQueryTextSubmit
in interface android.widget.SearchView.OnQueryTextListener
query
- User's query. Not used.true
public void search()
searchView
and pass it to the
server via API.Get#autocompletePlace(RequestQueue, String, Response.Listener)
to get
a list of matching Location
s. These are used to populate the
adapter
.public boolean onQueryTextChange(java.lang.String newText)
onQueryTextChange
in interface android.widget.SearchView.OnQueryTextListener
newText
- The updated query texttrue