Last active
October 3, 2019 17:24
-
-
Save cbedoy/21115f5d5b92bed36cb5a1a9412a3140 to your computer and use it in GitHub Desktop.
Common UTILS
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
abstract class BaseHolder(override val containerView: View) : RecyclerView.ViewHolder(containerView), | |
LayoutContainer { | |
abstract fun reload(source: Any) | |
} |
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
implementation 'com.github.bumptech.glide:glide:4.9.0' | |
kapt 'com.github.bumptech.glide:compiler:4.9.0' | |
implementation "android.arch.lifecycle:extensions:1.1.1" | |
implementation "android.arch.lifecycle:viewmodel:1.1.1" | |
implementation 'com.squareup.retrofit2:retrofit:2.6.1' | |
implementation 'com.squareup.retrofit2:converter-gson:2.6.1' | |
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' | |
implementation "androidx.navigation:navigation-fragment-ktx:2.1.0" | |
implementation "androidx.navigation:navigation-ui-ktx:2.1.0" | |
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.1' |
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
export ANDROID_HOME=$HOME/Library/Android/sdk | |
export PATH=$PATH:$ANDROID_HOME/emulator | |
export PATH=$PATH:$ANDROID_HOME/tools | |
export PATH=$PATH:$ANDROID_HOME/tools/bin | |
export PATH=$PATH:$ANDROID_HOME/platform-tools | |
source $HOME/.bash_profile | |
react-native run-android |
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
/** | |
* | |
* Created by bedoy on 2019-09-09. | |
*/ | |
object RetrofitHelper { | |
private val retrofit by lazy { | |
build() | |
} | |
private val client by lazy { | |
val logging = HttpLoggingInterceptor() | |
logging.level = HttpLoggingInterceptor.Level.BODY | |
OkHttpClient.Builder().addInterceptor { chain -> | |
val original = chain.request() | |
val request = original.newBuilder() | |
.header("key", "value") | |
//headers | |
.method(original.method(), original.body()) | |
.build() | |
chain.proceed(request) | |
}.addInterceptor( | |
logging | |
).build() | |
} | |
private fun build() : Retrofit { | |
return Retrofit.Builder() | |
.baseUrl("API_URL") | |
.addConverterFactory(GsonConverterFactory.create()) | |
.addCallAdapterFactory(CoroutineCallAdapterFactory()) | |
.build() | |
} | |
fun <S> createService(serviceClass: Class<S>): S { | |
return retrofit.create(serviceClass) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment