This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import okhttp3.OkHttpClient | |
import retrofit2.Retrofit | |
class ApiClient { | |
companion object { | |
fun <T> create(service: Class<T>): T { | |
val client = OkHttpClient.Builder() | |
.addInterceptor(CustomInterceptor()) | |
.build() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import okhttp3.Interceptor | |
import okhttp3.Response | |
class CustomInterceptor : Interceptor { | |
override fun intercept(chain: Interceptor.Chain): Response { | |
val url = chain.request().url().newBuilder() | |
.addQueryParameter("client_id", "some_id") | |
.addQueryParameter("client_secret", "some_key") | |
.build() | |
val request = chain.request().newBuilder() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
// 有能なアノテーションが使える | |
compile 'com.android.support:support-annotations:22.2.0' | |
// テストのみで使用 | |
androidTestCompile 'com.android.support.test:runner:0.5' | |
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.rhythnn.droidsunset | |
import android.app.Activity | |
import android.support.test.runner.AndroidJUnit4 | |
import android.support.test.rule.ActivityTestRule | |
import android.support.test.espresso.Espresso.onView | |
import android.support.test.espresso.Espresso.onData | |
import android.support.test.espresso.action.ViewActions.click | |
import android.support.test.espresso.matcher.ViewMatchers.* | |
import android.support.test.espresso.assertion.ViewAssertions.matches |
NewerOlder