Skip to content

Instantly share code, notes, and snippets.

View blipinsk's full-sized avatar
:shipit:
barteklipinski.com

Bartek Lipinski blipinsk

:shipit:
barteklipinski.com
View GitHub Profile
@blipinsk
blipinsk / ControllableAppBarLayout.java
Last active September 15, 2020 11:32
An extension of Android AppBarLayout, that allows to programatically change the CollapsibleToolbarLayout state
/**
* Copyright 2015 Bartosz Lipinski
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@blipinsk
blipinsk / Component.kt
Last active July 22, 2019 05:30
Dagger NPE issue: [Kotlin + Generics + Abstract classes]
package com.barteklipinski.example.daggernpe
import dagger.Component
import javax.inject.Singleton
@Singleton
@Component(
modules = [Module::class]
)
interface Component {
@blipinsk
blipinsk / ScaledAndroidDelays.kt
Created April 24, 2019 22:13
Scaled delays, for synchronising coroutines with Android animations
import android.app.Activity
import android.os.Build
import android.provider.Settings
import kotlinx.coroutines.delay
public suspend fun transitionDelay(timeMillis: Long, activity: Activity) {
val transitionAnimationScale =
if (Build.VERSION.SDK_INT >= 17) {
Settings.Global.getFloat(
activity.contentResolver,
@blipinsk
blipinsk / DebouncingOnClickListener.java
Last active January 8, 2018 15:45
[Medium] Butterknife's DebouncingOnClickListener as interface
public interface DebouncingOnClickListener extends View.OnClickListener {
Enabled enabled = new Enabled(true);
Runnable ENABLE_AGAIN = () -> enabled.set(true);
void doClick(View v);
@Override
default void onClick(View v) {
@blipinsk
blipinsk / BindingViewHolder.java
Last active October 13, 2017 09:28
The easiest way to use ViewDataBinding with RecyclerView.ViewHolder
/*
* Copyright 2017 Bartosz Lipinski
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@blipinsk
blipinsk / DebouncingOnClickListener.java
Last active September 30, 2017 08:11
[Medium] Butterknife's DebouncingOnClickListener as abstract class
public abstract class DebouncingOnClickListener implements View.OnClickListener {
static boolean enabled = true;
private static final Runnable ENABLE_AGAIN = new Runnable() {
@Override
public void run() {
enabled = true;
}
};
@blipinsk
blipinsk / OrderedRobolectricTestRunner.java
Created January 25, 2017 16:37
A Robolectric Test Runner (can easily be just a regular JUnit Runner) that can execute test methods in specific order.
/*
* Copyright 2017 Bartosz Lipinski
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software