- http://stackoverflow.com/questions/804115 (
rebasevsmerge). - https://www.atlassian.com/git/tutorials/merging-vs-rebasing (
rebasevsmerge) - https://www.atlassian.com/git/tutorials/undoing-changes/ (
resetvscheckoutvsrevert) - http://stackoverflow.com/questions/2221658 (HEAD^ vs HEAD~) (See
git rev-parse) - http://stackoverflow.com/questions/292357 (
pullvsfetch) - http://stackoverflow.com/questions/39651 (
stashvsbranch) - http://stackoverflow.com/questions/8358035 (
resetvscheckoutvsrevert) - http://stackoverflow.com/questions/5798930 (
git resetvsgit rm --cached)
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| . |