Skip to content

Instantly share code, notes, and snippets.

@illuzor illuzor/ActionBar.kt Secret
Created Jul 11, 2019

Embed
What would you like to do?
import androidx.annotation.IntDef
abstract class ActionBar {
// Создаём набор констант
companion object {
const val NAVIGATION_MODE_STANDARD = 0
const val NAVIGATION_MODE_LIST = 1
const val NAVIGATION_MODE_TABS = 2
}
// Определяем собственную аннотацию NavigationMode
// В @IntDef задаём константы
@Retention(AnnotationRetention.SOURCE)
@IntDef(NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS)
annotation class NavigationMode
// Помечаем параметр метода созданной аннотацией
fun setNavigationMode(@NavigationMode mode: Int) {
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.