9502c15b by chiangbt

update 3.27

1 parent d06eca08
......@@ -27,6 +27,7 @@ dependencies {
compile 'com.esri.arcgis.android:arcgis-android:10.2.9'
compile 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar'
compile 'com.github.arimorty:floatingsearchview:2.1.1'
compile 'com.amitshekhar.android:android-networking:0.2.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
......
......@@ -12,7 +12,12 @@ import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import com.androidnetworking.AndroidNetworking;
import com.androidnetworking.error.ANError;
import com.androidnetworking.interfaces.JSONArrayRequestListener;
import com.androidnetworking.interfaces.JSONObjectRequestListener;
import com.arlib.floatingsearchview.FloatingSearchView;
import com.arlib.floatingsearchview.suggestions.model.SearchSuggestion;
import com.esri.android.map.LocationDisplayManager;
import com.esri.android.map.MapView;
import com.esri.android.map.event.OnStatusChangedListener;
......@@ -26,6 +31,10 @@ import com.pashanhoo.landsurvey.layers.tianditu.TianDiTuTiledMapServiceType;
import com.pashanhoo.landsurvey.search.DataHelper;
import com.pashanhoo.landsurvey.utils.AppInfo;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class MainActivity extends AppCompatActivity {
private MapView mapView;
......@@ -177,16 +186,58 @@ public class MainActivity extends AppCompatActivity {
}
});
floatingSearchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() {
floatingSearchView.setOnSearchListener(new FloatingSearchView.OnSearchListener() {
@Override
public void onSuggestionClicked(SearchSuggestion searchSuggestion) {
}
@Override
public void onSearchAction(String currentQuery) {
if(currentQuery.length() > 3) {
String str = "{\"keyWord\":\""+ currentQuery +"\",\"level\":\"11\",\"mapBound\":\"76.24832,30.1129,156.40458,49.97618\",\"queryType\":\"1\",\"count\":\"10\",\"start\":\"0\",\"queryTerminal\":\"1000\"}";
AndroidNetworking.post("http://map.tianditu.com/query.shtml")
.addBodyParameter("type", "query")
.addBodyParameter("postStr", str)
.setTag("test")
.build()
.getAsJSONObject(new JSONObjectRequestListener() {
@Override
public void onResponse(JSONObject response) {
JSONArray Jarray = null;
try {
Jarray = response.getJSONArray("pois");
for (int i = 0; i < Jarray.length(); i++)
{
JSONObject Jasonobject = Jarray.getJSONObject(i);
Log.i("b", Jasonobject.getString("name"));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onSearchTextChanged(String oldQuery, String newQuery) {
if (!oldQuery.equals("") && newQuery.equals("")) {
floatingSearchView.clearSuggestions();
} else{
public void onError(ANError anError) {
}
});
}
}
});
// floatingSearchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() {
// @Override
// public void onSearchTextChanged(String oldQuery, String newQuery) {
// if (!oldQuery.equals("") && newQuery.equals("")) {
// floatingSearchView.clearSuggestions();
// } else{
// if(newQuery.length()>3){
//
// }
// }
// }
// });
}
@Override
......
......@@ -29,10 +29,10 @@
android:layout_height="match_parent"
android:layout_marginTop="70dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="16dp"
app:floatingSearch_searchHint="地名地址检索..."
app:floatingSearch_suggestionsListAnimDuration="250"
app:floatingSearch_showSearchKey="false"
app:floatingSearch_leftActionMode="showHamburger"
app:floatingSearch_menu="@menu/menu_main"
app:floatingSearch_close_search_on_keyboard_dismiss="true"/>
......