List of usage examples for com.google.api.client.googleapis.services GoogleClientRequestInitializer GoogleClientRequestInitializer
GoogleClientRequestInitializer
From source file:com.battlelancer.seriesguide.backend.CloudEndpointUtils.java
License:Apache License
/** * Updates the Google client builder to connect the appropriate server based * on whether LOCAL_ANDROID_RUN is true or false. * * @param builder//from w w w . jav a 2s.c om * Google client builder * @return same Google client builder */ public static <B extends AbstractGoogleClient.Builder> B updateBuilder(B builder) { if (LOCAL_ANDROID_RUN) { builder.setRootUrl(LOCAL_APP_ENGINE_SERVER_URL_FOR_ANDROID + "/_ah/api/"); } // only enable GZip when connecting to remote server final boolean enableGZip = builder.getRootUrl().startsWith("https:"); builder.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { public void initialize(AbstractGoogleClientRequest<?> request) throws IOException { if (!enableGZip) { request.setDisableGZipContent(true); } } }); return builder; }
From source file:com.dankift.orienteernfc.cloudbackend.CloudEndpointUtils.java
License:Apache License
/** * Updates the Google client builder to connect the appropriate server based * on whether LOCAL_ANDROID_RUN is true or false. * //from w w w .j a va 2s . co m * @param builder * Google client builder * @return same Google client builder */ public static <B extends AbstractGoogleClient.Builder> B updateBuilder(B builder) { if (LOCAL_ANDROID_RUN) { builder.setRootUrl(LOCAL_APP_ENGINE_SERVER_URL + "/_ah/api/"); //builder.setRootUrl("http://127.0.0.1:8888/_ah/api/"); } // only enable GZip when connecting to remote server final boolean enableGZip = builder.getRootUrl().startsWith("https:"); builder.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { public void initialize(AbstractGoogleClientRequest<?> request) throws IOException { if (!enableGZip) { request.setDisableGZipContent(true); } } }); return builder; }
From source file:com.dealbreaker.cloud.backend.core.CloudEndpointUtils.java
License:Apache License
/** * Updates the Google client builder to connect the appropriate server based * on whether LOCAL_ANDROID_RUN is true or false. * // w w w.j av a 2 s .c o m * @param builder Google client builder * @return same Google client builder */ public static <B extends AbstractGoogleClient.Builder> B updateBuilder(B builder) { if (LOCAL_ANDROID_RUN) { builder.setRootUrl(LOCAL_APP_ENGINE_SERVER_URL + "/_ah/api/"); } // only enable GZip when connecting to remote server final boolean enableGZip = builder.getRootUrl().startsWith("https:"); builder.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { @Override public void initialize(AbstractGoogleClientRequest<?> request) throws IOException { if (!enableGZip) { request.setDisableGZipContent(true); } } }); return builder; }
From source file:com.dmitrymalkovich.android.builditbigger.RetrieveJokeTask.java
License:Apache License
@Override protected String doInBackground(Void... params) { if (myApiService == null) { MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null) // options for running against local devappserver // - 10.0.2.2 is localhost's IP address in Android emulator // - turn off compression when running against local devappserver .setRootUrl("http://10.0.2.2:8080/_ah/api/") .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { @Override public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException { abstractGoogleClientRequest.setDisableGZipContent(true); }/*from w w w. j a v a 2s . c o m*/ }); myApiService = builder.build(); } try { return myApiService.randomJoke().execute().getData(); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); return ""; } }
From source file:com.dpsingh.JokesTask.java
License:Apache License
@Override protected String doInBackground(Void... params) { if (myApiService == null) { MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null) // options for running against local devappserver // - 10.0.2.2 is localhost's IP address in Android emulator // - turn off compression when running against local devappserver .setRootUrl("http://10.0.2.2:8080/_ah/api/") .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { @Override public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException { abstractGoogleClientRequest.setDisableGZipContent(true); }//from w w w.j av a 2 s .c o m }); myApiService = builder.build(); } try { return myApiService.getRandomJoke().execute().getData(); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); return ""; } }
From source file:com.ericrgon.CloudEndpointUtils.java
License:Apache License
/** * Updates the Google client builder to connect the appropriate server based * on whether LOCAL_ANDROID_RUN is true or false. * //from ww w .j a v a 2s.c o m * @param builder * Google client builder * @return same Google client builder */ public static <B extends AbstractGoogleClient.Builder> B updateBuilder(B builder) { if (LOCAL_ANDROID_RUN) { builder.setRootUrl(LOCAL_APP_ENGINE_SERVER_URL + "/_ah/api/"); } // only enable GZip when connecting to remote server final boolean enableGZip = builder.getRootUrl().startsWith("https:"); builder.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { public void initialize(AbstractGoogleClientRequest<?> request) throws IOException { if (!enableGZip) { request.setDisableGZipContent(true); } } }); return builder; }
From source file:com.ewintory.udacity.joker.taks.JokeAsyncTask.java
License:Apache License
@Override protected Pair<IOException, String> doInBackground(Void... params) { if (myApiService == null) { // Only do this once MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null) // .setRootUrl("https://bicentennial-joker.appspot.com/_ah/api/"); .setRootUrl("http://10.0.3.2:8080/_ah/api/") .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { @Override public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException { abstractGoogleClientRequest.setDisableGZipContent(true); }// ww w. j a v a 2 s . c o m }); // end options for devappserver myApiService = builder.build(); } try { Log.d(TAG, "Executing."); String joke = myApiService.tellJoke().execute().getData(); Log.d(TAG, "Executed."); return new Pair<>(null, joke); } catch (IOException ex) { return new Pair<>(ex, null); } }
From source file:com.github.socialc0de.gsw.android.tools.CloudEndpointBuilderHelper.java
License:Apache License
/** * Updates the Google client builder to connect the appropriate server based on whether * LOCAL_ANDROID_RUN is true or false.//from w w w. j av a 2s .co m * * @param builder Google client builder * @return same Google client builder */ public static <B extends AbstractGoogleClient.Builder> B updateBuilder(B builder) { if (LOCAL_ANDROID_RUN) { builder.setRootUrl(LOCAL_APP_ENGINE_SERVER_URL + "/_ah/api/"); } // only enable GZip when connecting to remote server final boolean enableGZip = builder.getRootUrl().startsWith("https:"); builder.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { @Override public void initialize(AbstractGoogleClientRequest<?> request) { if (!enableGZip) { request.setDisableGZipContent(true); } } }); return builder; }
From source file:com.google.sample.junk.CloudEndpointBuilderHelper.java
License:Open Source License
/** * */*from ww w .j a va2s.c o m*/ * * @return ShoppingAssistant endpoints to the GAE backend. */ static ShoppingAssistant getEndpoints() { // Create API handler ShoppingAssistant.Builder builder = new ShoppingAssistant.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), getRequestInitializer()).setRootUrl(Constants.ROOT_URL) .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { @Override public void initialize(final AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException { abstractGoogleClientRequest.setDisableGZipContent(true); } }); return builder.build(); }
From source file:com.google.samples.quickstart.signin.MainActivity.java
License:Open Source License
@Override protected String doInBackground(Pair<Context, String>... params) { context = params[0].first;//from w w w . j av a2 s.c o m email = params[0].second; credential = GoogleAccountCredential.usingAudience(context, "server:client_id:**************************.apps.googleusercontent.com"); credential.setSelectedAccountName(email); Log.d("credential", credential.getSelectedAccountName()); if (myApiService == null) { // Only do this once MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), credential) // options for running against local devappserver // - 10.0.2.2 is localhost's IP address in Android emulator // - turn off compression when running against local devappserver .setRootUrl("http://10.0.2.2:8080/_ah/api/") .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { @Override public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException { abstractGoogleClientRequest.setDisableGZipContent(true); } }); // end options for devappserver myApiService = builder.build(); } try { return myApiService.sayHi().execute().getData(); } catch (IOException e) { return e.getMessage(); } }