- http://stackoverflow.com/questions/804115 (
rebase
vsmerge
). - https://www.atlassian.com/git/tutorials/merging-vs-rebasing (
rebase
vsmerge
) - https://www.atlassian.com/git/tutorials/undoing-changes/ (
reset
vscheckout
vsrevert
) - http://stackoverflow.com/questions/2221658 (HEAD^ vs HEAD~) (See
git rev-parse
) - http://stackoverflow.com/questions/292357 (
pull
vsfetch
) - http://stackoverflow.com/questions/39651 (
stash
vsbranch
) - http://stackoverflow.com/questions/8358035 (
reset
vscheckout
vsrevert
) - http://stackoverflow.com/questions/5798930 (
git reset
vsgit rm --cached
)
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
@Provides | |
@Singleton | |
fun provideTokenInterceptor():TokenInterceptor { | |
return TokenInterceptor() | |
} | |
@Provides | |
@Singleton | |
fun provideTokenAuthenticator(@ApplicationContext context: Context):TokenAutheticator { | |
return TokenAutheticator(context) |
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
// Include in BaseActivity | |
val logoutReceiver = object : BroadcastReceiver() { | |
override fun onReceive(context: Context?, intent: Intent?) { | |
Toast.makeText( | |
this@BaseActivity, | |
getString(R.string.session_expired), | |
Toast.LENGTH_SHORT | |
).show() | |
FirebaseAuth.getInstance().signOut() | |
LoginActivity.start(this@BaseActivity) |
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
@Singleton | |
class TokenInterceptor : Interceptor { | |
override fun intercept(chain: Interceptor.Chain): Response { | |
var request = chain.request() | |
try { | |
if (request.url.encodedPath.contains("/login") && request.method.equals("POST")) { | |
return chain.proceed(request) | |
} |
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
@Singleton | |
class TokenAutheticator @Inject constructor( | |
@ApplicationContext private val context: Context | |
) : Authenticator { | |
override fun authenticate(route: Route?, response: Response): Request? { | |
if (!response.isSuccessful) { | |
val localBroadcastManager = LocalBroadcastManager.getInstance(context) | |
val intent = Intent(Keys.ACTION_LOGOUT) | |
localBroadcastManager.sendBroadcast(intent) |
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
bLogin.setOnClickListener { | |
Timber.d("email %s and password %s", email, password) | |
auth.signInWithEmailAndPassword(email, password) | |
.addOnCompleteListener(this@LoginActivity) { task -> | |
if (task.isSuccessful) { | |
Timber.d("signInWithEmail:success") | |
val user = auth.currentUser | |
updateUI(user) | |
} else { | |
task.exception?.printStackTrace() |
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
. |