Fix usage of deprecated LocationClient

This commit is contained in:
mar-v-in 2015-02-14 23:18:28 +01:00
parent 2a3cdfed4f
commit 4b4e173add
8 changed files with 32 additions and 26 deletions

2
GmsApi

@ -1 +1 @@
Subproject commit 19b0b0f1d782640c0e5a9a381a0191665de0b053
Subproject commit 3243e7d3ecf2f7ff92279b61c4a7e7831356f5c7

@ -1 +1 @@
Subproject commit 3efecf38ca8b1f89cd8f0c40eea4b497f1563d90
Subproject commit a650ca5beac2a374460d820935b40f9539e692db

View File

@ -3,7 +3,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'com.android.tools.build:gradle:1.0.1'
}
}

View File

@ -35,45 +35,45 @@ public class LocationClient extends AbstractPlayServicesClient {
return LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
}
public PendingResult requestLocationUpdates(LocationRequest request,
public void requestLocationUpdates(LocationRequest request,
LocationListener listener) {
assertConnected();
return LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request,
listener);
LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request,
listener).await();
}
public PendingResult requestLocationUpdates(LocationRequest request,
public void requestLocationUpdates(LocationRequest request,
LocationListener listener, Looper looper) {
assertConnected();
return LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request,
listener, looper);
LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request,
listener, looper).await();
}
public PendingResult requestLocationUpdates(LocationRequest request,
public void requestLocationUpdates(LocationRequest request,
PendingIntent callbackIntent) {
assertConnected();
return LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request,
callbackIntent);
LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request,
callbackIntent).await();
}
public PendingResult removeLocationUpdates(LocationListener listener) {
public void removeLocationUpdates(LocationListener listener) {
assertConnected();
return LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, listener);
LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, listener).await();
}
public PendingResult removeLocationUpdates(PendingIntent callbackIntent) {
public void removeLocationUpdates(PendingIntent callbackIntent) {
assertConnected();
return LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient,
callbackIntent);
LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient,
callbackIntent).await();
}
public PendingResult setMockMode(boolean isMockMode) {
public void setMockMode(boolean isMockMode) {
assertConnected();
return LocationServices.FusedLocationApi.setMockMode(googleApiClient, isMockMode);
LocationServices.FusedLocationApi.setMockMode(googleApiClient, isMockMode).await();
}
public PendingResult setMockLocation(Location mockLocation) {
public void setMockLocation(Location mockLocation) {
assertConnected();
return LocationServices.FusedLocationApi.setMockLocation(googleApiClient, mockLocation);
LocationServices.FusedLocationApi.setMockLocation(googleApiClient, mockLocation).await();
}
}

View File

@ -45,6 +45,7 @@ public class GmsConnector<C extends ApiConnection, R extends Result, O extends A
public AbstractPendingResult<R> connect() {
Log.d(TAG, "connect()");
apiClient.getApiConnection(api);
Looper looper = apiClient.getLooper();
final AbstractPendingResult<R> result = new AbstractPendingResult<>(looper);
Message msg = new Message();
@ -67,8 +68,8 @@ public class GmsConnector<C extends ApiConnection, R extends Result, O extends A
Log.d(TAG, "Handler : handleMessage");
AbstractPendingResult<R> result = (AbstractPendingResult<R>) msg.obj;
try {
result.deliverResult(callback.onClientAvailable((C) apiClient.getApiConnection
(api)));
C connection = (C)apiClient.getApiConnection(api);
result.deliverResult(callback.onClientAvailable(connection));
} catch (RemoteException ignored) {
}

View File

@ -16,6 +16,8 @@
package org.microg.gms.common.api;
import android.util.Log;
import com.google.android.gms.common.GooglePlayServicesClient;
import com.google.android.gms.common.api.GoogleApiClient;
@ -23,6 +25,7 @@ import org.microg.gms.common.ForwardConnectionCallbacks;
import org.microg.gms.common.ForwardConnectionFailedListener;
public class AbstractPlayServicesClient implements GooglePlayServicesClient {
private static final String TAG = "GmsPlatServicesClient";
protected final GoogleApiClient googleApiClient;
@ -36,11 +39,13 @@ public class AbstractPlayServicesClient implements GooglePlayServicesClient {
@Override
public void connect() {
Log.d(TAG, "connect()");
googleApiClient.connect();
}
@Override
public void disconnect() {
Log.d(TAG, "disconnect()");
googleApiClient.disconnect();
}

View File

@ -123,7 +123,7 @@ public class GoogleApiClientImpl implements GoogleApiClient {
public synchronized void connect() {
Log.d(TAG, "connect()");
if (isConnected() || isConnecting()) {
Log.d(TAG, "Already connected/connecting, noting to do");
Log.d(TAG, "Already connected/connecting, nothing to do");
return;
}
for (ApiConnection connection : apiConnections.values()) {

View File

@ -129,8 +129,8 @@ public class FusedLocationProviderApiImpl implements FusedLocationProviderApi {
@Override
public Result onClientAvailable(LocationClientImpl client) throws
RemoteException {
runnable.run(client);
return Status.SUCCESS;
runnable.run(client);
return Status.SUCCESS;
}
}).connect();
}