Class: Jaspion::Miya::Android::Retrofit

Inherits:
Jaspion::Miya::Android show all
Defined in:
lib/jaspion/miya/android/retrofit.rb

Overview

Represents an Android Retrofit template (square.github.io/retrofit/)

Instance Attribute Summary

Attributes inherited from Jaspion::Miya::Android

#package

Attributes inherited from Object

#children, #name, #type

Instance Method Summary collapse

Methods inherited from Jaspion::Miya::Android

#inflate_view, #ui?

Methods inherited from Object

available_classes, create, #fetch_child, #initialize, #push_child, #templates

Methods included from Class

#class_methods, #class_variables, #ui?

Constructor Details

This class inherits a constructor from Jaspion::Miya::Object

Instance Method Details

#importsObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/jaspion/miya/android/retrofit.rb', line 10

def imports
  %(
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.ResponseBody;
import com.squareup.okhttp.logging.HttpLoggingInterceptor;
import retrofit.Call;
import retrofit.Callback;
import retrofit.GsonConverterFactory;
import retrofit.Response;
import retrofit.Retrofit;
import #{name}RESTInterface;)
end

#instance_methodsObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jaspion/miya/android/retrofit.rb', line 27

def instance_methods
  %(
    protected void loadRetrofit() {
if (BuildConfig.DEBUG) {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BASIC);
    OkHttpClient httpClient = new OkHttpClient();
    httpClient.interceptors().add(logging);
}

this.#{name} = new Retrofit.Builder()
    .baseUrl(#{name}RESTInterface.BASE_URL)
    .addConverterFactory(GsonConverterFactory.create())
    .client(httpClient)
    .build();

this.#{name.uncapitalize}RESTInterface = retrofit.create(#{name}RESTInterface.class);
    })
end

#instance_variablesObject



23
24
25
# File 'lib/jaspion/miya/android/retrofit.rb', line 23

def instance_variables
  "    private #{name}RESTInterface #{name.uncapitalize}RESTInterface;"
end