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
| // for any errors that should be handled before being handed off to RxJava. | |
| // In other words global error logic. | |
| // An example might be 401 when not logging in | |
| import okhttp3.Interceptor | |
| import okhttp3.Response | |
| class ErrorInterceptor: Interceptor { | |
| override fun intercept(chain: Interceptor.Chain?): Response { |
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
| // Dagger 1 example | |
| @Module( | |
| complete = false, | |
| library = true | |
| ) | |
| public final class ApiModule { | |
| @Provides | |
| @Singleton | |
| Retrofit provideRetrofit(Gson gson, Application app) { | |
| return new Retrofit.Builder() |
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
| import java.io.IOException; | |
| import java.lang.annotation.Annotation; | |
| import java.lang.reflect.Type; | |
| import io.reactivex.Completable; | |
| import io.reactivex.Observable; | |
| import io.reactivex.ObservableSource; | |
| import io.reactivex.Single; | |
| import io.reactivex.SingleSource; | |
| import io.reactivex.annotations.NonNull; |
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
| package com.miller.futurechat | |
| import android.content.Context | |
| import android.util.Log | |
| import android.widget.ImageView | |
| import com.bumptech.glide.Glide | |
| import com.bumptech.glide.signature.ObjectKey | |
| import io.reactivex.Single | |
| import io.reactivex.android.schedulers.AndroidSchedulers | |
| import io.reactivex.disposables.CompositeDisposable |
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
| <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> | |
| <!-- Customize your theme here. --> | |
| <item name="colorPrimary">@color/colorPrimary</item> | |
| <item name="colorPrimaryDark">@color/colorPrimaryDark</item> | |
| <item name="colorAccent">@color/colorAccent</item> | |
| <item name="drawerArrowStyle">@style/AppTheme.DrawerArrowStyle</item> | |
| <item name="android:textSize">14sp</item> | |
| </style> | |
| <style name="AppTheme.DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle"> |
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
| recyclerMessages.addOnLayoutChangeListener { v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom -> | |
| if (bottom < oldBottom) { | |
| recyclerMessages.smoothScrollToPosition(0) | |
| } | |
| } |
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
| abstract class BaseRecyclerAdapter<Item, ViewBinding : ViewDataBinding>( | |
| callBack: DiffUtil.ItemCallback<Item> | |
| ) : ListAdapter<Item, BaseViewHolder<ViewBinding>>( | |
| AsyncDifferConfig.Builder<Item>(callBack) | |
| .setBackgroundThreadExecutor(Executors.newSingleThreadExecutor()) | |
| .build() | |
| ) { | |
| override fun submitList(list: List<Item>?) { | |
| super.submitList(ArrayList<Item>(list ?: listOf())) |
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
| /** | |
| * You can edit, run, and share this code. | |
| * play.kotlinlang.org | |
| */ | |
| import kotlinx.coroutines.* | |
| import kotlinx.coroutines.flow.* | |
| import kotlin.system.* | |
| fun test1() { | |
| var time = 0L |
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
| class AuthenticateInterceptor( | |
| private val dataStorage: DataStorage, | |
| private val authService: AuthService | |
| ) : Interceptor { | |
| | |
| override fun intercept(chain: Chain): Response { | |
| val newRequest = buildAuthorizedRequest(chain) | |
| val response = chain.proceed(newRequest) | |
| | |
| return if (response.code == CODE_TOKEN_EXPIRED) { |
OlderNewer