Search in sources :

Example 1 with DirectoryList

use of com.googleapis.www.model.DirectoryList in project gce2retrofit by chiuki.

the class Discovery method main.

public static void main(String[] args) {
    Retrofit restAdapter = new Retrofit.Builder().baseUrl(API_URL).addConverterFactory(GsonConverterFactory.create()).build();
    Apis apis = restAdapter.create(Apis.class);
    try {
        Response<DirectoryList> response = apis.list(null, null).execute();
        System.out.println(response.body().kind);
    } catch (IOException e) {
        System.out.println(e.getMessage());
    }
}
Also used : Retrofit(retrofit2.Retrofit) Apis(com.googleapis.www.Apis) IOException(java.io.IOException) DirectoryList(com.googleapis.www.model.DirectoryList)

Example 2 with DirectoryList

use of com.googleapis.www.model.DirectoryList in project gce2retrofit by chiuki.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final TextView textView = new TextView(this);
    setContentView(textView);
    Retrofit restAdapter = new Retrofit.Builder().baseUrl(API_URL).addConverterFactory(GsonConverterFactory.create()).build();
    Apis apis = restAdapter.create(Apis.class);
    Call<DirectoryList> call = apis.list(null, null);
    call.enqueue(new Callback<DirectoryList>() {

        @Override
        public void onResponse(Call<DirectoryList> call, Response<DirectoryList> response) {
            textView.setText(response.body().kind);
        }

        @Override
        public void onFailure(Call<DirectoryList> call, Throwable t) {
            String msg = t.getMessage();
            if (TextUtils.isEmpty(msg)) {
                textView.setText(t.getClass().getSimpleName());
            }
        }
    });
}
Also used : Retrofit(retrofit2.Retrofit) Apis(com.googleapis.www.Apis) TextView(android.widget.TextView) DirectoryList(com.googleapis.www.model.DirectoryList)

Aggregations

Apis (com.googleapis.www.Apis)2 DirectoryList (com.googleapis.www.model.DirectoryList)2 Retrofit (retrofit2.Retrofit)2 TextView (android.widget.TextView)1 IOException (java.io.IOException)1