Adding limit.
parent
920e1543fe
commit
f3fc8622e8
|
@ -8,17 +8,14 @@ import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.*;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
import pl.tpolgrabia.urbanexplorer.R;
|
import pl.tpolgrabia.urbanexplorer.R;
|
||||||
import pl.tpolgrabia.urbanexplorer.adapters.WikiLocationsAdapter;
|
import pl.tpolgrabia.urbanexplorer.adapters.WikiLocationsAdapter;
|
||||||
import pl.tpolgrabia.urbanexplorer.callbacks.WikiResponseCallback;
|
import pl.tpolgrabia.urbanexplorer.callbacks.WikiResponseCallback;
|
||||||
import pl.tpolgrabia.urbanexplorer.callbacks.WikiStatus;
|
import pl.tpolgrabia.urbanexplorer.callbacks.WikiStatus;
|
||||||
import pl.tpolgrabia.urbanexplorer.dto.WikiResponse;
|
import pl.tpolgrabia.urbanexplorer.dto.WikiResponse;
|
||||||
import pl.tpolgrabia.urbanexplorer.utils.LocationUtils;
|
import pl.tpolgrabia.urbanexplorer.utils.LocationUtils;
|
||||||
|
import pl.tpolgrabia.urbanexplorer.utils.NumberUtils;
|
||||||
import pl.tpolgrabia.urbanexplorer.utils.WikiUtils;
|
import pl.tpolgrabia.urbanexplorer.utils.WikiUtils;
|
||||||
|
|
||||||
import static android.content.Context.LOCATION_SERVICE;
|
import static android.content.Context.LOCATION_SERVICE;
|
||||||
|
@ -61,7 +58,15 @@ public class WikiLocationsFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final Location location = locationService.getLastKnownLocation(LocationUtils.getDefaultLocation(getActivity()));
|
final Location location = locationService.getLastKnownLocation(LocationUtils.getDefaultLocation(getActivity()));
|
||||||
WikiUtils.fetchNearPlaces(getActivity(), location.getLatitude(), location.getLongitude(), 10L, new WikiResponseCallback() {
|
WikiUtils.fetchNearPlaces(
|
||||||
|
getActivity(),
|
||||||
|
location.getLatitude(),
|
||||||
|
location.getLongitude(),
|
||||||
|
NumberUtils.safeParseLong(
|
||||||
|
((EditText) inflatedView.findViewById(R.id.wiki_search_limit)).getText()),
|
||||||
|
NumberUtils.safeParseLong(
|
||||||
|
((EditText) inflatedView.findViewById(R.id.wiki_search_radius)).getText()),
|
||||||
|
new WikiResponseCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void callback(WikiStatus status, WikiResponse response) {
|
public void callback(WikiStatus status, WikiResponse response) {
|
||||||
// handling here wiki locations
|
// handling here wiki locations
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class WikiUtils {
|
||||||
final double latitude,
|
final double latitude,
|
||||||
final double longitude,
|
final double longitude,
|
||||||
final long resultsLimit,
|
final long resultsLimit,
|
||||||
|
final long radiusLimit,
|
||||||
final WikiResponseCallback callback) {
|
final WikiResponseCallback callback) {
|
||||||
final AQuery aq = new AQuery(ctx);
|
final AQuery aq = new AQuery(ctx);
|
||||||
aq.ajax("TODO", JSONObject.class, new AjaxCallback<JSONObject>(){
|
aq.ajax("TODO", JSONObject.class, new AjaxCallback<JSONObject>(){
|
||||||
|
@ -47,7 +48,7 @@ public class WikiUtils {
|
||||||
"&wbptterms=description" +
|
"&wbptterms=description" +
|
||||||
"&generator=geosearch" +
|
"&generator=geosearch" +
|
||||||
"&ggscoord=" + latitude + "%7C" + longitude +
|
"&ggscoord=" + latitude + "%7C" + longitude +
|
||||||
"&ggsradius=10000" +
|
"&ggsradius=" + radiusLimit +
|
||||||
"&ggslimit=" + resultsLimit +
|
"&ggslimit=" + resultsLimit +
|
||||||
"&format=" + WIKI_FORMAT;
|
"&format=" + WIKI_FORMAT;
|
||||||
aq.ajax(qurl, JSONObject.class, new AjaxCallback<JSONObject>() {
|
aq.ajax(qurl, JSONObject.class, new AjaxCallback<JSONObject>() {
|
||||||
|
|
|
@ -18,6 +18,15 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
|
<TextView android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/wiki_search_limit"/>
|
||||||
|
|
||||||
|
<EditText android:id="@+id/wiki_search_limit"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ListView android:id="@+id/wiki_places"
|
<ListView android:id="@+id/wiki_places"
|
||||||
|
|
|
@ -14,4 +14,5 @@
|
||||||
<string name="location_yrange">Location y-range</string>
|
<string name="location_yrange">Location y-range</string>
|
||||||
<string name="location_xrange">Location x-range</string>
|
<string name="location_xrange">Location x-range</string>
|
||||||
<string name="wiki_search_radius">Search radius</string>
|
<string name="wiki_search_radius">Search radius</string>
|
||||||
|
<string name="wiki_search_limit">Search results\' limit</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue