Skip to content

Instantly share code, notes, and snippets.

David Ferrand dadouf

Block or report user

Report or block dadouf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dadouf
dadouf / HeightWrappingViewPager.kt
Created Jun 2, 2020
ViewPager that wraps its content's height
View HeightWrappingViewPager.kt
import android.content.Context
import android.support.v4.view.ViewPager
import android.util.AttributeSet
internal class HeightWrappingViewPager @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null)
: ViewPager(context, attrs) {
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
var heightMeasureSpecModif = heightMeasureSpec
@dadouf
dadouf / MockitoKotlinHelpers.kt
Last active Feb 25, 2020
Mockito+Kotlin: set mocks to throw unchecked exceptions
View MockitoKotlinHelpers.kt
import org.mockito.BDDMockito
// Use just like a normal .willThrow:
// ```
// given(api.fetch()).willThrowUnchecked(Exception("First error"), Exception("Second error"))
// ```
fun <T> BDDMockito.BDDMyOngoingStubbing<T>.willThrowUnchecked(vararg throwables: Throwable) {
var invocationNumber = 0
this.willAnswer {
You can’t perform that action at this time.