2021-06-28 09:09:00 +02:00
|
|
|
package jp.juggler.subwaytooter.actmain
|
|
|
|
|
|
|
|
import jp.juggler.subwaytooter.ActMain
|
2021-06-23 06:14:25 +02:00
|
|
|
|
|
|
|
// スマホモードならラムダを実行する。タブレットモードならnullを返す
|
|
|
|
inline fun <R:Any?> ActMain.phoneOnly(code: (PhoneViews) -> R): R? = phoneViews?.let { code(it) }
|
|
|
|
|
|
|
|
// タブレットモードならラムダを実行する。スマホモードならnullを返す
|
|
|
|
inline fun <R:Any?> ActMain.tabOnly(code: (TabletViews) -> R): R? = tabletViews?.let { code(it) }
|
|
|
|
|
|
|
|
// スマホモードとタブレットモードでコードを切り替える
|
|
|
|
inline fun <R:Any?> ActMain.phoneTab(codePhone: (PhoneViews) -> R, codeTablet: (TabletViews) -> R): R {
|
|
|
|
phoneViews?.let { return codePhone(it) }
|
|
|
|
tabletViews?.let { return codeTablet(it) }
|
|
|
|
error("missing phoneViews/tabletViews")
|
|
|
|
}
|