Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation 'com.squareup.retrofit2:retrofit:2.8.2'
implementation 'com.sqeareup.retrofit2:converter-gson:2.7.1'
implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed dependency typo.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.retrofit2:converter-gson:2.8.2'
//Adding JSON dependencies
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/example/mymovieinfo/dto/Movie.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package com.example.mymovieinfo.dto

import com.google.gson.annotations.SerializedName

data class Movie(@SerializedName("rank")var rank: Int, @SerializedName("title")var title: String,
@SerializedName("country") var country: String, @SerializedName("boxOfficeGross")var boxOfficeGross: Double,
@SerializedName("openingWeekendGross")var openingWeekendGross: Double, @SerializedName("distributor")var distributor: String){
data class Movie(@SerializedName("Rank")var rank: Int, @SerializedName("Title")var title: String,
Copy link
Copy Markdown
Collaborator Author

@jdifrank jdifrank Mar 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SerializedName value should match JSON data feed
https://howtodoinjava.com/gson/gson-serializedname/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Are these the names in the feed, with that capitalization?

@SerializedName("Country_of_origin") var country: String, @SerializedName("Box_office_gross")var boxOfficeGross: Double,
@SerializedName("Opening_Weekend_Gross")var openingWeekendGross: Double, @SerializedName("Distributor")var distributor: String){

override fun toString(): String {
return title
return "$title"
Copy link
Copy Markdown
Collaborator Author

@jdifrank jdifrank Mar 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kotlin shortcut in case you ever wanted to return more than just the movie title
https://kotlinlang.org/docs/java-to-kotlin-idioms-strings.html#take-a-substring

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an extra step, if it's not actually a string. I'd leave it as it were, until more string details are needed.

}

} //End DataClass