Skip to content

Instantly share code, notes, and snippets.

View n8ebel's full-sized avatar
🏠
Working from home

Nate Ebel n8ebel

🏠
Working from home
View GitHub Profile
@n8ebel
n8ebel / file_system_watching.scenarios
Last active August 25, 2020 21:33
Collection of gradle-profiler scenarios for benchmarking Android builds
//
// Non-abi change
//
1_non_abi_change {
title = "Non-api change to :location module"
tasks = [":app:assembleEnvQADebug"]
apply-non-abi-change-to = "location/src/main/java/com/premise/android/data/location/AndroidLocationProvider.java"
}
2_non_abi_change {
@n8ebel
n8ebel / gist:8d35aff899d583765304d80572931433
Created December 4, 2019 00:59
GitHub repository_dispatch curl command
curl -H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token <personal access token with repo access>" \
--request POST \
--data '{"event_type": "process-layouts"}' \
https://api.github.com/repos/pixiteapps/pigment-android/dispatches
@n8ebel
n8ebel / pull_request_template.md
Created June 7, 2019 21:32
Pull Request Template

Related To-Do

** link **

Proposed Changes

  • change 1
  • change 2

Additional Info

** any additional useful context or info **

@BindingAdapter("uiState")
fun setUiStateForLoading(progressView: ProgressBar, uiState: UIState) {
progressView.visibility = when (uiState) {
Loading -> View.VISIBLE
else -> View.GONE
}
}
@BindingAdapter("uiState")
fun setUiStateForLoadedContent(view: View, uiState: UIState) {
@n8ebel
n8ebel / MainActivity.kt
Created February 19, 2018 04:24
Blink Rainbow HAT LED for Android Things
class MainActivity : Activity() {
private val TAG = MainActivity::class.java.simpleName
private val blinkHandler = Handler()
private var redLED: Gpio? = null
private val blinkRunnable = object : Runnable {
override fun run() {
redLED?.also {
// Indicate the the screen should be closed
class ImageViewModel() : BaseViewModel() {
@BoundMethod
fun onExitFullscreenClicked() {
lifecycleState.set(FinishedOk)
}
}
// indicate that the screen should be finished and a result is returned
viewModel.lifecycleStatePub.subscribe { state ->
when (state) {
is Active -> {}
is FinishedOk, Cancelled -> finish()
is FinishedWithResult -> {
setResult(state.result, state.data)
finish()
}
is StartActivity -> {
val intent = Intent(this, state.target).apply {
@n8ebel
n8ebel / ViewModelLifecycleData.kt
Created January 25, 2018 04:35
Definition of ViewModel lifecycle states that are handled by our BaseActivity
// Lifecycle States
sealed class ViewModelLifecycleState
object Active : ViewModelLifecycleState()
object FinishedOk : ViewModelLifecycleState()
object Cancelled : ViewModelLifecycleState()
data class FinishedWithResult(
@n8ebel
n8ebel / BaseActivity.kt
Last active January 25, 2018 05:09
Activity subscription to a ViewModel SnackData PublishSubject
fun bindViewModel(root:View, viewModel: BaseViewModel) {
viewModel.snackPub.subscribe { snackData ->
showSnackbar(rootView, snackData)
}
}
/**
* Maps the passed [SnackData] to the appropriate UI representation of a [Snackbar]
*/
private fun showSnackbar(root: View, data: SnackData) {
val snackPub:PublishSubject<SnackData> = PublishSubject.create()