Java源码示例:com.google.android.gms.common.api.Api
示例1
@Override
public Api.ApiOptions.HasOptions getOptionsFor(Api<? extends Api.ApiOptions> api) {
if (Auth.GOOGLE_SIGN_IN_API.equals(api)) {
GoogleSignInOptions.Builder googleSignInOptions = new GoogleSignInOptions.Builder(
GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail();
// Check server client id for OAuth, so GoogleSignInAccount.getIdToken(); is non-null
String serverClientId = getFragment().getServerClientId();
if(serverClientId != null){
googleSignInOptions.requestIdToken(serverClientId);
}
return googleSignInOptions.build();
} else {
return super.getOptionsFor(api);
}
}
示例2
public GoogleApiClientImpl(Context context, Looper looper, AccountInfo accountInfo,
Map<Api, Api.ApiOptions> apis,
Set<ConnectionCallbacks> connectionCallbacks,
Set<OnConnectionFailedListener> connectionFailedListeners, int clientId) {
this.context = context;
this.looper = looper;
this.handler = new Handler(looper);
this.accountInfo = accountInfo;
this.apis.putAll(apis);
this.connectionCallbacks.addAll(connectionCallbacks);
this.connectionFailedListeners.addAll(connectionFailedListeners);
this.clientId = clientId;
for (Api api : apis.keySet()) {
apiConnections.put(api, api.getBuilder().build(context, looper,
apis.get(api), accountInfo, baseConnectionCallbacks,
baseConnectionFailedListener));
}
}
示例3
protected RxLocationBaseOnSubscribe(@NonNull RxLocation rxLocation, Long timeout, TimeUnit timeUnit) {
this.ctx = rxLocation.ctx;
this.services = new Api[]{ LocationServices.API, ActivityRecognition.API };
this.scopes = null;
if (timeout != null && timeUnit != null) {
this.timeoutTime = timeout;
this.timeoutUnit = timeUnit;
} else {
this.timeoutTime = rxLocation.timeoutTime;
this.timeoutUnit = rxLocation.timeoutUnit;
}
}
示例4
protected RxLocationBaseOnSubscribe(@NonNull Context ctx, @NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] services, Scope[] scopes) {
this.ctx = ctx;
this.services = services;
this.scopes = scopes;
timeoutTime = null;
timeoutUnit = null;
}
示例5
@Override
public void addApi(@NonNull Api<? extends Api.ApiOptions.NotRequiredOptions> value) {
if (mGoogleApiClient != null)
mGoogleApiClient.disconnect();
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(mContext).addApi(LocationServices.API).enableAutoManage((FragmentActivity) mContext, new Random().nextInt(Integer.MAX_VALUE), this).
addConnectionCallbacks(this).addOnConnectionFailedListener(this);
if (!value.getName().equalsIgnoreCase(LocationServices.API.getName())) {
addApi(value);
}
mGoogleApiClient = builder.build();
if (!servicesConnected())
mGoogleApiClient.connect();
}
示例6
@Override
public void addApi(@NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] value) {
if (mGoogleApiClient != null)
mGoogleApiClient.disconnect();
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(mContext).addApi(LocationServices.API).enableAutoManage((FragmentActivity) mContext, new Random().nextInt(Integer.MAX_VALUE), this).
addConnectionCallbacks(this).addOnConnectionFailedListener(this);
for (Api<? extends Api.ApiOptions.NotRequiredOptions> options : value) {
if (!options.getName().equalsIgnoreCase(LocationServices.API.getName())) {
builder.addApi(options);
}
}
mGoogleApiClient = builder.build();
if (!servicesConnected())
mGoogleApiClient.connect();
}
示例7
@Override
public void addApi(@NonNull Api<? extends Api.ApiOptions.NotRequiredOptions> value) {
if (mGoogleApiClient != null)
mGoogleApiClient.disconnect();
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this).addApi(LocationServices.API).enableAutoManage(this, new Random().nextInt(Integer.MAX_VALUE), this).
addConnectionCallbacks(this).addOnConnectionFailedListener(this);
if (!value.getName().equalsIgnoreCase(LocationServices.API.getName())) {
addApi(value);
}
mGoogleApiClient = builder.build();
if (!servicesConnected())
mGoogleApiClient.connect();
}
示例8
@Override
public void addApi(@NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] value) {
if (mGoogleApiClient != null)
mGoogleApiClient.disconnect();
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this).addApi(LocationServices.API).enableAutoManage(this, new Random().nextInt(Integer.MAX_VALUE), this).
addConnectionCallbacks(this).addOnConnectionFailedListener(this);
for (Api<? extends Api.ApiOptions.NotRequiredOptions> options : value) {
if (!options.getName().equalsIgnoreCase(LocationServices.API.getName())) {
builder.addApi(options);
}
}
mGoogleApiClient = builder.build();
if (!servicesConnected())
mGoogleApiClient.connect();
}
示例9
@Override
public void addApi(@NonNull Api<? extends Api.ApiOptions.NotRequiredOptions> value) {
if (mGoogleApiClient != null)
mGoogleApiClient.disconnect();
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(mContext).addApi(LocationServices.API).enableAutoManage((FragmentActivity) mContext, new Random().nextInt(Integer.MAX_VALUE), this).
addConnectionCallbacks(this).addOnConnectionFailedListener(this);
if (!value.getName().equalsIgnoreCase(LocationServices.API.getName())) {
addApi(value);
}
mGoogleApiClient = builder.build();
if (!servicesConnected())
mGoogleApiClient.connect();
}
示例10
@Override
public void addApi(@NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] value) {
if (mGoogleApiClient != null)
mGoogleApiClient.disconnect();
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(mContext).addApi(LocationServices.API).enableAutoManage((FragmentActivity) mContext, new Random().nextInt(Integer.MAX_VALUE), this).
addConnectionCallbacks(this).addOnConnectionFailedListener(this);
for (Api<? extends Api.ApiOptions.NotRequiredOptions> options : value) {
if (!options.getName().equalsIgnoreCase(LocationServices.API.getName())) {
builder.addApi(options);
}
}
mGoogleApiClient = builder.build();
if (!servicesConnected())
mGoogleApiClient.connect();
}
示例11
@Override
public void addApi(@NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] value) {
if (mGoogleApiClient != null)
mGoogleApiClient.disconnect();
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this).addApi(LocationServices.API).
addConnectionCallbacks(this).addOnConnectionFailedListener(this);
for (Api<? extends Api.ApiOptions.NotRequiredOptions> options : value) {
if (!options.getName().equalsIgnoreCase(LocationServices.API.getName())) {
builder.addApi(options);
}
}
mGoogleApiClient = builder.build();
if (!servicesConnected())
mGoogleApiClient.connect();
}
示例12
@Override
public void addApi(@NonNull Api<? extends Api.ApiOptions.NotRequiredOptions> value) {
if (mGoogleApiClient != null)
mGoogleApiClient.disconnect();
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this).addApi(LocationServices.API).
addConnectionCallbacks(this).addOnConnectionFailedListener(this);
if (!value.getName().equalsIgnoreCase(LocationServices.API.getName())) {
addApi(value);
}
mGoogleApiClient = builder.build();
if (!servicesConnected())
mGoogleApiClient.connect();
}
示例13
@Override
public void addApi(@NonNull Api<? extends Api.ApiOptions.NotRequiredOptions> value) {
if (mGoogleApiClient != null)
mGoogleApiClient.disconnect();
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this).addApi(LocationServices.API).enableAutoManage(this, new Random().nextInt(Integer.MAX_VALUE), this).
addConnectionCallbacks(this).addOnConnectionFailedListener(this);
if (!value.getName().equalsIgnoreCase(LocationServices.API.getName())) {
addApi(value);
}
mGoogleApiClient = builder.build();
if (!servicesConnected())
mGoogleApiClient.connect();
}
示例14
@Override
public void addApi(@NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] value) {
if (mGoogleApiClient != null)
mGoogleApiClient.disconnect();
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this).addApi(LocationServices.API).enableAutoManage(this, new Random().nextInt(Integer.MAX_VALUE), this).
addConnectionCallbacks(this).addOnConnectionFailedListener(this);
for (Api<? extends Api.ApiOptions.NotRequiredOptions> options : value) {
if (!options.getName().equalsIgnoreCase(LocationServices.API.getName())) {
builder.addApi(options);
}
}
mGoogleApiClient = builder.build();
if (!servicesConnected())
mGoogleApiClient.connect();
}
示例15
@Override
public void addApi(@NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] value) {
if (mGoogleApiClient != null)
mGoogleApiClient.disconnect();
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this).addApi(LocationServices.API).
addConnectionCallbacks(this).addOnConnectionFailedListener(this);
for (Api<? extends Api.ApiOptions.NotRequiredOptions> options : value) {
if (!options.getName().equalsIgnoreCase(LocationServices.API.getName())) {
builder.addApi(options);
}
}
mGoogleApiClient = builder.build();
if (!servicesConnected())
mGoogleApiClient.connect();
}
示例16
@Override
public void addApi(@NonNull Api<? extends Api.ApiOptions.NotRequiredOptions> value) {
if (mGoogleApiClient != null)
mGoogleApiClient.disconnect();
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this).addApi(LocationServices.API).
addConnectionCallbacks(this).addOnConnectionFailedListener(this);
if (!value.getName().equalsIgnoreCase(LocationServices.API.getName())) {
addApi(value);
}
mGoogleApiClient = builder.build();
if (!servicesConnected())
mGoogleApiClient.connect();
}
示例17
private void buildGoogleApiClient() {
Log.d(TAG, "buildGoogleApiClient: " + mModules);
// Can't build a GoogleApiClient with no APIs
if (mModules.size() == 0) {
Log.w(TAG, "No APIs, not building GoogleApiClient.");
return;
}
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(getActivity())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this);
for (GacModule<?> api : mModules.values()) {
for (Api apiObj : api.getApis()) {
// Add Api with options, if possible
Api.ApiOptions.HasOptions options = api.getOptionsFor(apiObj);
if (options != null) {
builder.addApi(apiObj, options);
} else {
builder.addApi(apiObj);
}
}
for (Scope scopeObj : api.getScopes()) {
builder.addScope(scopeObj);
}
}
mGoogleApiClient = builder.build();
}
示例18
@Override
public ApiConnection build(Context context, Looper looper,
Api.ApiOptions.NoOptions options,
AccountInfo accountInfo, GoogleApiClient.ConnectionCallbacks callbacks,
GoogleApiClient.OnConnectionFailedListener connectionFailedListener) {
return new LocationClientImpl(context, callbacks, connectionFailedListener);
}
示例19
protected GoogleApiClient createApiClient(ApiClientConnectionCallbacks apiClientConnectionCallbacks) {
GoogleApiClient.Builder apiClientBuilder = getApiClientBuilder();
for (Api<? extends Api.ApiOptions.NotRequiredOptions> service : services) {
apiClientBuilder.addApi(service);
}
if (scopes != null) {
for (Scope scope : scopes) {
apiClientBuilder.addScope(scope);
}
}
apiClientBuilder.addConnectionCallbacks(apiClientConnectionCallbacks);
apiClientBuilder.addOnConnectionFailedListener(apiClientConnectionCallbacks);
GoogleApiClient apiClient = apiClientBuilder.build();
apiClientConnectionCallbacks.setClient(apiClient);
return apiClient;
}
示例20
protected RxLocationFlowableOnSubscribe(@NonNull Context ctx, @NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] services, Scope[] scopes) {
super(ctx, services, scopes);
}
示例21
protected RxLocationMaybeOnSubscribe(@NonNull Context ctx, @NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] services, Scope[] scopes) {
super(ctx, services, scopes);
}
示例22
GoogleApiClientFlowable(Context ctx, Api<? extends Api.ApiOptions.NotRequiredOptions>[] apis, Scope[] scopes) {
super(ctx, apis, scopes);
}
示例23
@SafeVarargs
public static Flowable<GoogleApiClient> create(@NonNull Context context, @NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>... apis) {
return Flowable.create(new GoogleApiClientFlowable(context, apis, null), BackpressureStrategy.LATEST);
}
示例24
public static Flowable<GoogleApiClient> create(@NonNull Context context, @NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] apis, Scope[] scopes) {
return Flowable.create(new GoogleApiClientFlowable(context, apis, scopes), BackpressureStrategy.LATEST);
}
示例25
protected RxLocationSingleOnSubscribe(@NonNull Context ctx, @NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] services, Scope[] scopes) {
super(ctx, services, scopes);
}
示例26
public Api.ApiOptions.HasOptions getOptionsFor(Api<? extends Api.ApiOptions> api) {
return null;
}
示例27
@Override
public List<Api> getApis() {
return Arrays.asList(new Api[]{Auth.CREDENTIALS_API});
}
示例28
@Override
public List<Api> getApis() {
return Arrays.asList(new Api[]{Auth.GOOGLE_SIGN_IN_API});
}
示例29
@Override
public List<Api> getApis() {
return Arrays.asList(new Api[]{
AppInvite.API
});
}
示例30
public ApiConnection getApiConnection(Api api) {
return apiConnections.get(api);
}