mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
Add isGeoCoderPresent in the ApiAdapter.java.
This commit is contained in:
@@ -85,7 +85,12 @@ public class Api7Adapter implements ApiAdapter {
|
||||
public HttpTransport getHttpTransport() {
|
||||
return new ApacheHttpTransport();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isGeoCoderPresent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BluetoothSocket getBluetoothSocket(BluetoothDevice bluetoothDevice) throws IOException {
|
||||
try {
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.api.client.http.javanet.NetHttpTransport;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.location.Geocoder;
|
||||
import android.os.StrictMode;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -53,14 +54,19 @@ public class Api9Adapter extends Api8Adapter {
|
||||
.penaltyLog()
|
||||
.build());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte[] copyByteArray(byte[] input, int start, int end) {
|
||||
return Arrays.copyOfRange(input, start, end);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HttpTransport getHttpTransport() {
|
||||
return new NetHttpTransport();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGeoCoderPresent() {
|
||||
return Geocoder.isPresent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,13 @@ public interface ApiAdapter {
|
||||
*/
|
||||
public HttpTransport getHttpTransport();
|
||||
|
||||
/**
|
||||
* Returns true if GeoCoder is present.
|
||||
* <p>
|
||||
* Due to changes in API level 9.
|
||||
*/
|
||||
public boolean isGeoCoderPresent();
|
||||
|
||||
/**
|
||||
* Gets a {@link BluetoothSocket}.
|
||||
* <p>
|
||||
|
||||
@@ -95,7 +95,7 @@ public class TrackNameUtils {
|
||||
* @param location the location
|
||||
*/
|
||||
private static String getReverseGeoCoding(Context context, Location location) {
|
||||
if (location == null || !Geocoder.isPresent()) {
|
||||
if (location == null || !ApiAdapterFactory.getApiAdapter().isGeoCoderPresent()) {
|
||||
return null;
|
||||
}
|
||||
Geocoder geocoder = new Geocoder(context);
|
||||
|
||||
Reference in New Issue
Block a user