Skip to content

Instantly share code, notes, and snippets.

View pahill's full-sized avatar
👩‍🎤

Pamela Hill pahill

👩‍🎤
View GitHub Profile
data class StaffMember(val name: String, val position: String)
interface StaffLister {
fun findAllStaffMembers(): List<StaffMember>
}
class StaffListerImpl : StaffLister {
override fun findAllStaffMembers(): List<StaffMember> {
return listOf(
StaffMember(
abstract class NetworkBoundResource<ResultType, RequestType> (private val appExecutors: AppExecutors) {
//LiveData that represents the resource, implemented in the base class
val result: MutableLiveData<Resource<ResultType>> = MutableLiveData()
//Called to get the cached data from the database
@WorkerThread
abstract fun loadFromDb(): ResultType?
//Called with the data in the database to determine when it was fetched
//from the network
Text(text = "The Fellowship of the Ring", style = MaterialTheme.typography.h1, modifier = Modifier.padding(horizontal = 16.dp, vertical = 4.dp))
Text(text = "The Two Towers", style = MaterialTheme.typography.h1, modifier = Modifier.padding(horizontal = 16.dp, vertical = 4.dp))
@Composable
fun NetflixClone(movie: Movie){
...
}
ViewCompat.setAccessibilityDelegate(
fab, object : AccessibilityDelegateCompat() {
override fun onInitializeAccessibilityNodeInfo(
host: View,
info: AccessibilityNodeInfoCompat
) {
super.onInitializeAccessibilityNodeInfo(host, info)
info.addAction(AccessibilityActionCompat(
ACTION_CLICK,
"add new SparkCat”)
findViewById<FloatingActionButton>(R.id.fab).setOnClickListener {
view ->
addNewFavourite()
view.announceForAccessibility("Added new favourite")
}
<androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:contentDescription="Eliza: Beautiful long-haired grey"
app:srcCompat="@drawable/eliza" />
<ImageView
android:contentDescription="Alexander: Cute tortoiseshell"
app:srcCompat="@drawable/alexander" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
<androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:contentDescription="Eliza: Beautiful long-haired grey"
app:srcCompat="@drawable/eliza" />
<ImageView
android:contentDescription="Alexander: Cute tortoiseshell"
app:srcCompat="@drawable/alexander" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
<TextView
android:id="@+id/name_label"
android:text="Name:"
android:labelFor="@id/cat_name" />
<TextView
android:id="@+id/cat_name"
android:text="Eliza" />