Skip to content

Instantly share code, notes, and snippets.

View Sanjay-Prajapati's full-sized avatar
🎯
Focusing

sanjay prajapati Sanjay-Prajapati

🎯
Focusing
  • Ahmedabad, Gujarat, India
View GitHub Profile
@Sanjay-Prajapati
Sanjay-Prajapati / Dependency for hilt and Rxjava
Last active June 15, 2021 12:06
Gist for Network Module creation using Hilt in java
//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation "com.squareup.okhttp3:logging-interceptor:4.9.1"
//Rx
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.12'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.6.1'
@Sanjay-Prajapati
Sanjay-Prajapati / LogoutInterceptor.kt
Last active January 8, 2019 10:27
Retrofit2 custom interceptor that parse the response from API. After that we can check status and based on that returns a same copy that other classes can consume.
import com.google.gson.Gson
import okhttp3.Interceptor
import okhttp3.Response
import okhttp3.ResponseBody
import org.json.JSONException
/**
* Logout Interceptor.
* Here i extend the BaseActivity to navigate user to another screen. i need runOnUIThread to execute navigateToLogin() method.