Search in sources :

Example 11 with RestAdapter

use of retrofit.RestAdapter in project Rutgers-Course-Tracker by tevjef.

the class ClientModule method providesRMPClient.

@Provides
@Singleton
public RMPClient providesRMPClient(OkHttpClient client, Gson gson) {
    OkHttpClient okClient = client.clone();
    okClient.setConnectTimeout(CONNECT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    okClient.setReadTimeout(READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint("http://rutgersapp.tevindev.me:8080/").setLogLevel(RestAdapter.LogLevel.FULL).setConverter(new GsonConverter(gson)).setClient(new OkClient(okClient)).build();
    return new RMPClient(restAdapter.create(ClientService.class));
}
Also used : GsonConverter(retrofit.converter.GsonConverter) RMPClient(com.tevinjeffrey.rmp.client.RMPClient) OkHttpClient(com.squareup.okhttp.OkHttpClient) ClientService(com.tevinjeffrey.rmp.client.ClientService) OkClient(retrofit.client.OkClient) RestAdapter(retrofit.RestAdapter) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 12 with RestAdapter

use of retrofit.RestAdapter in project Hummingbird-for-Android by xiprox.

the class HummingbirdApi method setupServices.

private void setupServices() {
    RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(API_HOST_v1).setLogLevel(RestAdapter.LogLevel.FULL).build();
    service = restAdapter.create(HummingbirdService.class);
}
Also used : RestAdapter(retrofit.RestAdapter)

Example 13 with RestAdapter

use of retrofit.RestAdapter in project cw-omnibus by commonsguy.

the class SOTests method fetchQuestions.

@Test(timeout = 30000)
public void fetchQuestions() throws InterruptedException {
    RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint("https://api.stackexchange.com").build();
    StackOverflowInterface so = restAdapter.create(StackOverflowInterface.class);
    so.questions("android", new Callback<SOQuestions>() {

        @Override
        public void success(SOQuestions soQuestions, Response response) {
            questions = soQuestions;
            responseLatch.countDown();
        }

        @Override
        public void failure(RetrofitError error) {
            responseLatch.countDown();
        }
    });
    responseLatch.await();
    Assert.assertNotNull(questions);
    Assert.assertEquals(30, questions.items.size());
    for (Item item : questions.items) {
        Assert.assertNotNull(item.title);
        Assert.assertNotNull(item.link);
    }
}
Also used : Response(retrofit.client.Response) RestAdapter(retrofit.RestAdapter) RetrofitError(retrofit.RetrofitError) Test(org.junit.Test)

Example 14 with RestAdapter

use of retrofit.RestAdapter in project divide by HiddenStage.

the class AbstractWebManager method createRestAdapter.

private RestAdapter createRestAdapter(Config config) {
    RestAdapter.Builder builder = new RestAdapter.Builder();
    builder.setClient(new OkClient(config.client)).setEndpoint(config.serverUrl).setLogLevel(RestAdapter.LogLevel.FULL).setLog(new RestAdapter.Log() {

        @Override
        public void log(String s) {
            retrologger.debug(s);
        }
    }).setConverter(new GsonConverter(new Gson())).setRequestInterceptor(new RequestInterceptor() {

        @Override
        public void intercept(RequestFacade requestFacade) {
            onRequest(requestFacade);
        }
    }).setProfiler(new Profiler() {

        @Override
        public Object beforeCall() {
            return null;
        }

        @Override
        public void afterCall(RequestInformation requestInformation, long l, int i, Object o) {
            retrologger.error("afterCall(" + requestInformation.getRelativePath() + ":" + requestInformation.getMethod() + ": " + i + " : " + o);
            requestEventPublisher.onNext(new RequestObject(requestInformation, l, i, o));
        }
    });
    return builder.build();
}
Also used : GsonConverter(retrofit.converter.GsonConverter) OkClient(retrofit.client.OkClient) Gson(com.google.gson.Gson) RequestInterceptor(retrofit.RequestInterceptor) RequestFacade(retrofit.RequestInterceptor.RequestFacade) Profiler(retrofit.Profiler) RestAdapter(retrofit.RestAdapter)

Example 15 with RestAdapter

use of retrofit.RestAdapter in project divide by HiddenStage.

the class AuthServerHelper method buildTestService.

private TestService buildTestService(String url) {
    if (testService == null) {
        RestAdapter restAdapter = new RestAdapter.Builder().setClient(new OkClient()).setEndpoint(url).setLogLevel(RestAdapter.LogLevel.FULL).setLog(new RestAdapter.Log() {

            @Override
            public void log(String s) {
                System.out.println(s);
            }
        }).build();
        testService = restAdapter.create(TestService.class);
    }
    return testService;
}
Also used : OkClient(retrofit.client.OkClient) RestAdapter(retrofit.RestAdapter)

Aggregations

RestAdapter (retrofit.RestAdapter)16 View (android.view.View)3 ListView (android.widget.ListView)3 TextView (android.widget.TextView)3 Test (org.junit.Test)3 OkClient (retrofit.client.OkClient)3 ImageView (android.widget.ImageView)2 InterestingApi (com.kdubb.retrofitexamples.api.InterestingApi)2 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)2 RetrofitError (retrofit.RetrofitError)2 Response (retrofit.client.Response)2 GsonConverter (retrofit.converter.GsonConverter)2 Uri (android.net.Uri)1 WeekViewEvent (com.alamkanak.weekview.WeekViewEvent)1 MyJsonService (com.alamkanak.weekview.sample.apiclient.MyJsonService)1 Gson (com.google.gson.Gson)1 AsynchronousApi (com.kdubb.retrofitexamples.api.AsynchronousApi)1 SimpleApi (com.kdubb.retrofitexamples.api.SimpleApi)1 JacksonConverter (com.kdubb.retrofitexamples.converter.JacksonConverter)1 CustomChild (com.kdubb.retrofitexamples.domain.CustomChild)1