Glide and Image Display Codelab Flashcards

1
Q

What four things does Glide do with an image?

What two things does Glide need?

A

Glide is used to

  • download
  • buffer
  • decode
  • cache images.

Glide needs

  • the url of the image
  • an ImageView to display the image
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the implementation for the Glide dependency?

A

implementation “com.github.bumptech.glide:glide:$version_glide”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define a function that loads an image from its url to an ImageView

A

fun bindImage(imgView: ImageView, imgUrl: String?) {
imgUrl?.let {
val imgUri = imgUrl.toUri().buildUpon().scheme(“https”).build()
Glide.with(imgView.context)
.load(imgUri)
.apply(RequestOptions()
.placeholder(R.drawable.loading_animation)
.error(R.drawable.ic_broken_image)
)
.into(imgView)
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the codelabs strategy for handling loading / error states on the UI?

A
  1. Create an enum for LOADING, ERROR, DONE
  2. Use a LiveData to track the status
  3. Update the network calls in the ViewModel to set the LiveData when the status changes
  4. Create a binding adapter that changes an ImageView based on the status
  5. Add an ImageView that can be substituted in for the RecyclerView when in LOADING / ERROR state.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

In addition to ^variable^, what needs to go in the data element of a layout xml in order to perform logic using another class (e.g. set a view to View.VISIBLE or View.GONE)?

How do you then define the View’s visibility value in the xml?

A

^data^
^variable
name=”property”
type=”com.example.android.marsrealestate.network.MarsProperty” /^
^import type=”android.view.View” /^
^/data^

android:visibility=”@{property.rental ? View.GONE : View.VISIBLE}”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you display one ImageView over the top of another?

A

Wrap both in a FrameLayout.

The topmost ImageView in code will appear as the bottommost layer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What parameter can be passed to a CRUD function calling an endpoint that applies “?filter=value”?

A

@Query(“filter”) type:String

type can be an enum value based on available endpoint filters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly