├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── compiler.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── boonya │ │ └── ben │ │ └── callingwebservice │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── boonya │ │ │ └── ben │ │ │ └── callingwebservice │ │ │ ├── Const.kt │ │ │ ├── StarWarSpeciesApplication.kt │ │ │ ├── api │ │ │ ├── Apis.kt │ │ │ └── Swapi.kt │ │ │ ├── di │ │ │ ├── ApiModule.kt │ │ │ ├── AppComponent.kt │ │ │ ├── ComponentInjector.kt │ │ │ └── SpeciesRepositoryModule.kt │ │ │ ├── model │ │ │ ├── Species.kt │ │ │ └── SpeciesList.kt │ │ │ └── species │ │ │ ├── SpeciesActivity.kt │ │ │ ├── SpeciesListAdapter.kt │ │ │ ├── SpeciesListViewModel.kt │ │ │ ├── SpeciesRepository.kt │ │ │ ├── SpeciesRepositoryImpl.kt │ │ │ └── SpeciesViewHolder.kt │ └── res │ │ ├── layout │ │ ├── activity_species.xml │ │ └── species_item.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── boonya │ └── ben │ └── callingwebservice │ ├── ExampleUnitTest.java │ └── SpeciesListViewModelTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenBoonya/calling-webservice/b026e47865a4a60c384c2b242930f5e1d73f5736/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # calling-webservice 2 | This repository is created as a sample project for this blog post. 3 | 4 | https://blog.oozou.com/calling-web-service-with-android-architecture-component-8de864800a93 5 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | apply plugin: 'kotlin-kapt' 5 | 6 | android { 7 | compileSdkVersion 27 8 | buildToolsVersion '27.0.3' 9 | defaultConfig { 10 | applicationId "boonya.ben.callingwebservice" 11 | minSdkVersion 15 12 | targetSdkVersion 27 13 | versionCode 1 14 | versionName "1.0" 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(dir: 'libs', include: ['*.jar']) 27 | androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { 28 | exclude group: 'com.android.support', module: 'support-annotations' 29 | }) 30 | 31 | implementation 'com.android.support:appcompat-v7:27.1.1' 32 | implementation 'com.android.support:design:27.1.1' 33 | implementation 'com.android.support:cardview-v7:27.1.1' 34 | implementation 'com.android.support.constraint:constraint-layout:1.1.2' 35 | implementation 'com.squareup.retrofit2:retrofit:2.3.0' 36 | implementation 'com.squareup.retrofit2:converter-gson:2.3.0' 37 | implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-experimental-adapter:1.0.0' 38 | implementation 'android.arch.lifecycle:runtime:1.1.1' 39 | implementation 'android.arch.lifecycle:extensions:1.1.1' 40 | 41 | //test library 42 | testImplementation 'junit:junit:4.12' 43 | testImplementation 'org.mockito:mockito-core:2.12.0' 44 | testImplementation 'android.arch.core:core-testing:1.1.1' 45 | 46 | // dependency injection 47 | implementation 'com.google.dagger:dagger:2.15' 48 | compileOnly 'javax.annotation:jsr250-api:1.0' 49 | kapt "com.google.dagger:dagger-compiler:2.15" 50 | 51 | //kotlin 52 | implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" 53 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 54 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.23.4' 55 | 56 | annotationProcessor 'android.arch.lifecycle:compiler:1.1.1' 57 | } 58 | repositories { 59 | mavenCentral() 60 | } 61 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/oozou/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/boonya/ben/callingwebservice/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("boonya.ben.callingwebservice", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/Const.kt: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice 2 | 3 | /** 4 | * Created by oozou on 7/20/2017 AD. 5 | */ 6 | class Const { 7 | companion object { 8 | val BASE_URL = "http://swapi.co/api/" 9 | } 10 | } -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/StarWarSpeciesApplication.kt: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice 2 | 3 | import android.app.Application 4 | import boonya.ben.callingwebservice.di.ComponentInjector 5 | 6 | /** 7 | * Created by oozou on 7/20/2017 AD. 8 | */ 9 | class StarWarSpeciesApplication : Application() { 10 | 11 | override fun onCreate() { 12 | super.onCreate() 13 | 14 | ComponentInjector.init() 15 | } 16 | } -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/api/Apis.kt: -------------------------------------------------------------------------------- 1 | package com.ben.boonya.architecturecomponentdemo.common.api 2 | 3 | import com.google.gson.GsonBuilder 4 | import retrofit2.Retrofit 5 | import retrofit2.converter.gson.GsonConverterFactory 6 | 7 | /** 8 | * Created by Boonya Kitpitak on 6/16/17. 9 | */ 10 | object Apis { 11 | public fun getStarWarApi(): Swapi { 12 | val gson = GsonBuilder ().create() 13 | val retrofit = Retrofit.Builder() 14 | .baseUrl("http://swapi.co/api/") 15 | .addConverterFactory(GsonConverterFactory.create(gson)) 16 | .build() 17 | return retrofit.create(Swapi::class.java) 18 | } 19 | } -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/api/Swapi.kt: -------------------------------------------------------------------------------- 1 | package com.ben.boonya.architecturecomponentdemo.common.api 2 | 3 | import boonya.ben.callingwebservice.model.SpeciesList 4 | import retrofit2.Call 5 | import retrofit2.http.GET 6 | import retrofit2.http.Path 7 | import retrofit2.http.Query 8 | 9 | /** 10 | * Created by Boonya Kitpitak on 6/16/17. 11 | */ 12 | interface Swapi { 13 | @GET("species/") 14 | fun getSpecies(): Call 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/di/ApiModule.kt: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice.di 2 | 3 | import com.ben.boonya.architecturecomponentdemo.common.api.Swapi 4 | import com.google.gson.GsonBuilder 5 | import dagger.Module 6 | import dagger.Provides 7 | import retrofit2.Retrofit 8 | import retrofit2.converter.gson.GsonConverterFactory 9 | import javax.inject.Singleton 10 | 11 | /** 12 | * Created by oozou on 7/20/2017 AD. 13 | */ 14 | @Module 15 | class ApiModule(val baseUrl: String) { 16 | @Provides @Singleton 17 | fun provideApiService(): Swapi { 18 | val gson = GsonBuilder().create() 19 | 20 | return Retrofit.Builder() 21 | .baseUrl(baseUrl) 22 | .addConverterFactory(GsonConverterFactory.create(gson)) 23 | .build().create(Swapi::class.java) 24 | } 25 | } -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/di/AppComponent.kt: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice.di 2 | 3 | import boonya.ben.callingwebservice.species.SpeciesListViewModel 4 | import dagger.Component 5 | import javax.inject.Singleton 6 | 7 | /** 8 | * Created by oozou on 7/20/2017 AD. 9 | */ 10 | 11 | @Singleton 12 | @Component( 13 | modules = arrayOf( 14 | ApiModule::class, 15 | SpeciesRepositoryModule::class 16 | ) 17 | ) 18 | interface AppComponent { 19 | 20 | fun inject(speciesListViewModel: SpeciesListViewModel) 21 | 22 | } -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/di/ComponentInjector.kt: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice.di 2 | 3 | import boonya.ben.callingwebservice.Const 4 | 5 | class ComponentInjector { 6 | 7 | companion object { 8 | 9 | lateinit var component: AppComponent 10 | 11 | fun init() { 12 | component = DaggerAppComponent.builder() 13 | .apiModule(ApiModule(Const.BASE_URL)) 14 | .speciesRepositoryModule(SpeciesRepositoryModule()) 15 | .build() 16 | } 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/di/SpeciesRepositoryModule.kt: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice.di 2 | 3 | import boonya.ben.callingwebservice.species.SpeciesRepository 4 | import boonya.ben.callingwebservice.species.SpeciesRepositoryImpl 5 | import com.ben.boonya.architecturecomponentdemo.common.api.Swapi 6 | import dagger.Module 7 | import dagger.Provides 8 | import javax.inject.Singleton 9 | 10 | /** 11 | * Created by oozou on 7/20/2017 AD. 12 | */ 13 | @Module 14 | class SpeciesRepositoryModule { 15 | 16 | @Provides @Singleton 17 | fun providePostRepository(apiService: Swapi): SpeciesRepository = SpeciesRepositoryImpl(apiService) 18 | } -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/model/Species.kt: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice.model 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | /** 6 | * Created by oozou on 7/12/2017 AD. 7 | */ 8 | data class Species(val name : String, val classification : String, val language : String, @SerializedName("average_lifespan") val lifeSpan : String) -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/model/SpeciesList.kt: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice.model 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | /** 6 | * Created by oozou on 7/12/2017 AD. 7 | */ 8 | data class SpeciesList(@SerializedName("results") val speciesList: List, val next: String?) -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/species/SpeciesActivity.kt: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice.species 2 | 3 | import android.arch.lifecycle.* 4 | import android.support.v7.app.AppCompatActivity 5 | import android.os.Bundle 6 | import android.support.design.widget.Snackbar 7 | import android.support.v7.widget.LinearLayoutManager 8 | import android.view.View 9 | import boonya.ben.callingwebservice.R 10 | import boonya.ben.callingwebservice.di.ComponentInjector 11 | import boonya.ben.callingwebservice.model.Species 12 | import kotlinx.android.synthetic.main.activity_species.* 13 | 14 | class SpeciesActivity : AppCompatActivity(), LifecycleRegistryOwner { 15 | 16 | private val registry = LifecycleRegistry(this) 17 | private lateinit var viewModel: SpeciesListViewModel 18 | private lateinit var adapter: SpeciesListAdapter 19 | 20 | override fun getLifecycle(): LifecycleRegistry = registry 21 | 22 | override fun onCreate(savedInstanceState: Bundle?) { 23 | super.onCreate(savedInstanceState) 24 | setContentView(R.layout.activity_species) 25 | setSupportActionBar(toolbar) 26 | title = "STARWAR SPECIES" 27 | viewModel = createViewModel() 28 | adapter = SpeciesListAdapter(viewModel) 29 | rvSpecies.apply { 30 | setHasFixedSize(true) 31 | layoutManager = LinearLayoutManager(this@SpeciesActivity) 32 | adapter = this@SpeciesActivity.adapter 33 | } 34 | attachObserver() 35 | viewModel.getSpecies() 36 | } 37 | 38 | private fun attachObserver() { 39 | viewModel.isLoading.observe(this, Observer { 40 | it?.let { showLoadingDialog(it) } 41 | }) 42 | viewModel.apiError.observe(this, Observer { 43 | it?.let { Snackbar.make(rvSpecies, it.localizedMessage, Snackbar.LENGTH_LONG).show() } 44 | }) 45 | viewModel.speciesResponse.observe(this, Observer> { 46 | it?.let { adapter.notifyDataSetChanged() } 47 | }) 48 | 49 | } 50 | 51 | private fun createViewModel(): SpeciesListViewModel = 52 | ViewModelProviders.of(this).get(SpeciesListViewModel::class.java).also { 53 | ComponentInjector.component.inject(it) 54 | } 55 | 56 | private fun showLoadingDialog(show: Boolean) { 57 | if (show) progressBar.visibility = View.VISIBLE else progressBar.visibility = View.GONE 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/species/SpeciesListAdapter.kt: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice.species 2 | 3 | import android.support.v7.widget.RecyclerView 4 | import android.view.LayoutInflater 5 | import android.view.ViewGroup 6 | import boonya.ben.callingwebservice.R 7 | 8 | /** 9 | * Created by oozou on 7/12/2017 AD. 10 | */ 11 | class SpeciesListAdapter(var speciesListViewModel: SpeciesListViewModel) : RecyclerView.Adapter() { 12 | 13 | override fun onBindViewHolder(holder: SpeciesViewHolder, position: Int) { 14 | speciesListViewModel.getSpeciesAt(position)?.let { 15 | holder.apply { 16 | name.text = it.name 17 | classification.text = it.classification 18 | language.text = it.language 19 | lifeSpan.text = it.lifeSpan 20 | } 21 | } 22 | } 23 | 24 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SpeciesViewHolder { 25 | return SpeciesViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.species_item, parent, false)) 26 | } 27 | 28 | override fun getItemCount(): Int { 29 | return speciesListViewModel.getSpeciesSize() 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/species/SpeciesListViewModel.kt: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice.species 2 | 3 | import android.arch.lifecycle.MutableLiveData 4 | import android.arch.lifecycle.ViewModel 5 | import boonya.ben.callingwebservice.model.Species 6 | import javax.inject.Inject 7 | 8 | /** 9 | * Created by oozou on 7/12/2017 AD. 10 | */ 11 | class SpeciesListViewModel : ViewModel() { 12 | 13 | @Inject 14 | lateinit var repository: SpeciesRepository 15 | 16 | var isLoading = MutableLiveData() 17 | 18 | var apiError = MutableLiveData() 19 | 20 | var speciesResponse = MutableLiveData>() 21 | 22 | fun getSpecies() { 23 | isLoading.value = true 24 | repository.getSpecies( 25 | { 26 | speciesResponse.value = it 27 | isLoading.value = false 28 | }, 29 | 30 | { 31 | apiError.value = it 32 | isLoading.value = false 33 | }) 34 | } 35 | 36 | 37 | /** 38 | * Adapter Callback 39 | */ 40 | 41 | fun getSpeciesAt(position: Int): Species? { 42 | if (position < getSpeciesSize()) { 43 | return speciesResponse.value?.get(position) 44 | } else { 45 | return null 46 | } 47 | } 48 | 49 | fun getSpeciesSize(): Int { 50 | speciesResponse.value?.let { 51 | return it.size 52 | } 53 | return 0 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/species/SpeciesRepository.kt: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice.species 2 | 3 | import boonya.ben.callingwebservice.model.Species 4 | 5 | /** 6 | * Created by oozou on 7/20/2017 AD. 7 | */ 8 | interface SpeciesRepository { 9 | 10 | fun getSpecies(successHandler: (List?) -> Unit, failureHandler: (Throwable?) -> Unit) 11 | 12 | } -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/species/SpeciesRepositoryImpl.kt: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice.species 2 | 3 | import boonya.ben.callingwebservice.model.Species 4 | import boonya.ben.callingwebservice.model.SpeciesList 5 | import com.ben.boonya.architecturecomponentdemo.common.api.Swapi 6 | import retrofit2.Call 7 | import retrofit2.Callback 8 | import retrofit2.Response 9 | 10 | /** 11 | * Created by oozou on 7/12/2017 AD. 12 | */ 13 | 14 | class SpeciesRepositoryImpl(val apiService: Swapi) : SpeciesRepository { 15 | 16 | override fun getSpecies(successHandler: (List?) -> Unit, failureHandler: (Throwable?) -> Unit) { 17 | apiService.getSpecies().enqueue(object : Callback { 18 | override fun onResponse(call: Call?, response: Response?) { 19 | response?.body()?.let { 20 | successHandler(it.speciesList) 21 | } 22 | } 23 | 24 | override fun onFailure(call: Call?, t: Throwable?) { 25 | failureHandler(t) 26 | } 27 | }) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/boonya/ben/callingwebservice/species/SpeciesViewHolder.kt: -------------------------------------------------------------------------------- 1 | package boonya.ben.callingwebservice.species 2 | 3 | import android.support.v7.widget.RecyclerView 4 | import android.view.View 5 | import android.widget.TextView 6 | import boonya.ben.callingwebservice.R 7 | 8 | /** 9 | * Created by oozou on 7/12/2017 AD. 10 | */ 11 | class SpeciesViewHolder(view: View) : RecyclerView.ViewHolder(view) { 12 | val name by lazy { view.findViewById(R.id.name) as TextView } 13 | val classification by lazy { view.findViewById(R.id.classification) as TextView } 14 | val language by lazy { view.findViewById(R.id.language) as TextView } 15 | val lifeSpan by lazy { view.findViewById(R.id.lifeSpan) as TextView } 16 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_species.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 22 | 23 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/species_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 18 | 19 | 25 | 26 | 32 | 33 | 39 | 40 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenBoonya/calling-webservice/b026e47865a4a60c384c2b242930f5e1d73f5736/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenBoonya/calling-webservice/b026e47865a4a60c384c2b242930f5e1d73f5736/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenBoonya/calling-webservice/b026e47865a4a60c384c2b242930f5e1d73f5736/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenBoonya/calling-webservice/b026e47865a4a60c384c2b242930f5e1d73f5736/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenBoonya/calling-webservice/b026e47865a4a60c384c2b242930f5e1d73f5736/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenBoonya/calling-webservice/b026e47865a4a60c384c2b242930f5e1d73f5736/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenBoonya/calling-webservice/b026e47865a4a60c384c2b242930f5e1d73f5736/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenBoonya/calling-webservice/b026e47865a4a60c384c2b242930f5e1d73f5736/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenBoonya/calling-webservice/b026e47865a4a60c384c2b242930f5e1d73f5736/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenBoonya/calling-webservice/b026e47865a4a60c384c2b242930f5e1d73f5736/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CallingWebService 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 16 | 17 |