Skip to content

Instantly share code, notes, and snippets.

View rcmkt's full-sized avatar

Dmitry Berdnikov rcmkt

  • Moscow
View GitHub Profile
@chris-horner
chris-horner / Transitions.kt
Created December 21, 2017 12:38
Extension function forcing a shared element to run in a ViewGroup overlay.
fun Transition.sharedElementsInOverlay(container: ViewGroup, start: View, end: View): Transition =
addListener(object : Transition.TransitionListener {
val endParent = end.parent as ViewGroup
val endOriginalPosition = endParent.indexOfChild(end)
override fun onTransitionStart(transition: Transition) {
start.visibility = View.GONE
container.overlay.add(start)
container.overlay.add(end)
}
@alex-shpak
alex-shpak / Interceptor.java
Last active June 14, 2024 02:40
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON