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
open class RotatableDialogFragment : DialogFragment() { | |
init { | |
retainInstance = true | |
} | |
// Fixes rotation bug with dialog fragments | |
override fun onDestroyView() { | |
if (retainInstance) { | |
dialog?.setDismissMessage(null) | |
} |
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
class StoppableRecyclerView(context: Context, attrs: AttributeSet?, defStyle: Int) | |
: RecyclerView(context, attrs, defStyle) { | |
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0) | |
constructor(context: Context) : this(context, null, 0) | |
override fun onInterceptTouchEvent(e: MotionEvent?): Boolean { | |
if(e?.action == MotionEvent.ACTION_DOWN) { | |
stopNestedScroll() |
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
view_pager.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() { | |
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { | |
// Interpolate all tab opacity values | |
for (index in 0 until tab_layout.tabCount) { | |
tab_layout.getTabAt(index)?.updateOpacity(position, positionOffset) | |
} | |
} | |
fun TabLayout.Tab.updateOpacity(position: Int, offset: Float) { | |
val diffTab = 1 - abs(position - this.position + offset) |