Last major update: 25.08.2020
- Что такое авторизация/аутентификация
- Где хранить токены
- Как ставить куки ?
- Процесс логина
- Процесс рефреш токенов
- Кража токенов/Механизм контроля токенов
| import kotlinx.coroutines.experimental.DefaultDispatcher | |
| import kotlinx.coroutines.experimental.channels.ReceiveChannel | |
| import kotlinx.coroutines.experimental.channels.consumeEach | |
| import kotlinx.coroutines.experimental.channels.produce | |
| import kotlinx.coroutines.experimental.delay | |
| import kotlinx.coroutines.experimental.runBlocking | |
| import kotlin.coroutines.experimental.CoroutineContext | |
| fun <T> ReceiveChannel<T>.debounce( | |
| wait: Long = 300, |
| package me.vishna.kdebounce | |
| import android.support.v7.app.AppCompatActivity | |
| import android.os.Bundle | |
| import android.text.Editable | |
| import android.text.TextWatcher | |
| import android.widget.EditText | |
| import android.widget.TextView | |
| import kotlinx.coroutines.experimental.* | |
| import kotlinx.coroutines.experimental.android.UI |
| @Singleton | |
| public class RealmManager { | |
| private ThreadLocal<Realm> realms; | |
| @Inject | |
| public RealmManager() { | |
| realms = new ThreadLocal<>(); | |
| } | |
| public Realm openRealm() { |
This code helps using ObjectMapper with RealmSwift.
RealmSwift uses List<T> collection for "to many" relashionships and RealmOptional<T> for optional primitive types, but ObjectMapper can't map directly to List<T> and RealmOptional<T>.
With this operators you can properly define RealmSwift's relashionships and optional properties and use <- operator to map them.
import Foundation| /** | |
| * An RxJava-backed EventBus class that can support sending and receiving multiple event types. | |
| * | |
| * Based on https://gist.github.com/benjchristensen/04eef9ca0851f3a5d7bf | |
| */ | |
| public class EventBus<T> { | |
| private static EventBus<Object> INSTANCE; | |
| private List<T> events; |
| package com.example.columnspacing | |
| import android.graphics.Paint; | |
| import android.graphics.Rect; | |
| import android.support.v4.content.ContextCompat; | |
| import android.support.v7.widget.GridLayoutManager; | |
| import android.support.v7.widget.RecyclerView; | |
| import android.util.Log; | |
| import android.view.View; |
| public static Action1<Throwable> crashOnError() { | |
| final Throwable checkpoint = new Throwable(); | |
| return throwable -> { | |
| StackTraceElement[] stackTrace = checkpoint.getStackTrace(); | |
| StackTraceElement element = stackTrace[1]; // First element after `crashOnError()` | |
| String msg = String.format("onError() crash from subscribe() in %s.%s(%s:%s)", | |
| element.getClassName(), | |
| element.getMethodName(), | |
| element.getFileName(), | |
| element.getLineNumber()); |
| public class Pager<I, O> { | |
| private static final Observable FINISH_SEQUENCE = Observable.never(); | |
| private PublishSubject<Observable<I>> pages; | |
| private Observable<I> nextPage = finish(); | |
| private Subscription subscription = Subscriptions.empty(); | |
| private final PagingFunction<I> pagingFunction; | |
| private final Func1<I, O> pageTransformer; |