This file contains 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
private var hasInitParentDimensions = false | |
private var maxImageWidth: Int = 0 | |
private var maxImageHeight: Int = 0 | |
private var maxImageAspectRatio: Float = 1f | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH { | |
if (!hasInitParentDimensions) { | |
maxImageWidth = parent.width | |
maxImageHeight = parent.height | |
maxImageAspectRatio = maxImageWidth.toFloat() / maxImageHeight.toFloat() |
This file contains 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 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 |
This file contains 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 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 { |
NewerOlder