forked from upstream-mirrors/OpenTracks
Add isGeoCoderPresent in the ApiAdapter.java.
This commit is contained in:
@@ -86,6 +86,11 @@ public class Api7Adapter implements ApiAdapter {
|
|||||||
return new ApacheHttpTransport();
|
return new ApacheHttpTransport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isGeoCoderPresent() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BluetoothSocket getBluetoothSocket(BluetoothDevice bluetoothDevice) throws IOException {
|
public BluetoothSocket getBluetoothSocket(BluetoothDevice bluetoothDevice) throws IOException {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.google.api.client.http.javanet.NetHttpTransport;
|
|||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.content.SharedPreferences.Editor;
|
import android.content.SharedPreferences.Editor;
|
||||||
|
import android.location.Geocoder;
|
||||||
import android.os.StrictMode;
|
import android.os.StrictMode;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -63,4 +64,9 @@ public class Api9Adapter extends Api8Adapter {
|
|||||||
public HttpTransport getHttpTransport() {
|
public HttpTransport getHttpTransport() {
|
||||||
return new NetHttpTransport();
|
return new NetHttpTransport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isGeoCoderPresent() {
|
||||||
|
return Geocoder.isPresent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,13 @@ public interface ApiAdapter {
|
|||||||
*/
|
*/
|
||||||
public HttpTransport getHttpTransport();
|
public HttpTransport getHttpTransport();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if GeoCoder is present.
|
||||||
|
* <p>
|
||||||
|
* Due to changes in API level 9.
|
||||||
|
*/
|
||||||
|
public boolean isGeoCoderPresent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@link BluetoothSocket}.
|
* Gets a {@link BluetoothSocket}.
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class TrackNameUtils {
|
|||||||
* @param location the location
|
* @param location the location
|
||||||
*/
|
*/
|
||||||
private static String getReverseGeoCoding(Context context, Location location) {
|
private static String getReverseGeoCoding(Context context, Location location) {
|
||||||
if (location == null || !Geocoder.isPresent()) {
|
if (location == null || !ApiAdapterFactory.getApiAdapter().isGeoCoderPresent()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Geocoder geocoder = new Geocoder(context);
|
Geocoder geocoder = new Geocoder(context);
|
||||||
|
|||||||
Reference in New Issue
Block a user