Skip to content

Instantly share code, notes, and snippets.

View Bradleycorn's full-sized avatar

Brad Ball Bradleycorn

View GitHub Profile
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
val isLandscape = newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE
if (isLandscape) {
supportActionBar?.hide()
supportActionBar?.setDisplayShowTitleEnabled(false)
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN)
} else { // turn OFF full screen
supportActionBar?.show()
@Bradleycorn
Bradleycorn / NetworkLayer.kt
Last active June 26, 2020 20:34
Example of abstracting Java based network responses, since they can always have null values
/**
A class that makes api calls to the backend, process responses, and returns proper data models
*/
class NetworkLayer(val api: CdiApi) {
fun fetchProgramData(track: String, race: Number): List<ProgramEntry> {
// Get a ProgramResponse object (the network model) back from the api
val response: ProgramResponse = api.fetchProgram(track, race)
@Bradleycorn
Bradleycorn / Theme.kt
Last active November 26, 2021 18:10
An Example Theme for Jetpack Compose that uses the built-in Material Theme, but adds a single extra color, "Tertiary".
package net.bradball.android.androidapptemplate.ui.theme
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.graphics.Color
private val DarkColorPalette = AppColors(
materialColors = darkColors(
primary = purple200,