** link **
- change 1
- change 2
** any additional useful context or info **
class MainActivity : AppCompatActivity(), ViewModelListener { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
val binding = DataBindingUtil.setContentView<ActivityMainBinding>(this, R.layout.activity_main).bindData { | |
viewModel = MainViewModel("hello", 5, this@MainActivity) | |
} | |
} |
// I would typically place this adapter in main/_BindingAdapters.kt | |
// The gist tool won't allow that filename structure | |
// | |
@BindingAdapter("mainSubtitleText") | |
fun setText(view: TextView, value:Int) { | |
view.text = view.context.getString(R.string.main_subtitle_format, value) | |
} | |
@BindingAdapter("textColor") | |
fun setTextColor(view: TextView, @ColorRes resId: Int) = view.setTextColor(ContextCompat.getColor(view.context, resId)) |
/** | |
* Provides a [ViewDataBinding] object of the declared type by | |
* calling [DataBindingUtil.setContentView] with the property owning [Activity] and the specified | |
* layout resource id | |
*/ | |
class ActivityBindingProvider<out T : ViewDataBinding>( | |
@LayoutRes private val layoutRes: Int) : ReadOnlyProperty<Activity, T> { | |
private var binding : T? = null |
@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) { |
// | |
// 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 { |
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 |
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 { |
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) { |
typealias SnackFinishedListener = () -> Unit | |
typealias SnackActionListener = () -> Unit | |
/** | |
* Representation of [Snackbar] data that can be exposed by a view model, observed, and bound to | |
* the current UI | |
*/ | |
sealed class SnackData | |
/** |