Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c333579f authored by tibbi's avatar tibbi
Browse files

add a TabLayout extension for getting tab un/select events

parent c6f582d0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ buildscript {
        propMinSdkVersion = 16
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '3.13.18'
        propVersionName = '3.13.19'
        kotlin_version = '1.2.21'
        support_libs = '27.0.2'
    }
+17 −0
Original line number Diff line number Diff line
package com.simplemobiletools.commons.extensions

import android.support.design.widget.TabLayout

fun TabLayout.onTabSelectionChanged(tabUnselectedAction: (inactiveTab: TabLayout.Tab) -> Unit, tabSelectedAction: (activeTab: TabLayout.Tab) -> Unit) =
        setOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
            override fun onTabSelected(tab: TabLayout.Tab) {
                tabSelectedAction(tab)
            }

            override fun onTabUnselected(tab: TabLayout.Tab) {
                tabUnselectedAction(tab)
            }

            override fun onTabReselected(tab: TabLayout.Tab) {
            }
        })