Skip to content

Commit 18b30a3

Browse files
committed
add release date field
1 parent 8c981ba commit 18b30a3

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

app/src/main/java/io/maritimus/sofaexpert/DetailActivity.java

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ protected void onCreate(Bundle savedInstanceState) {
2727
((TextView)findViewById(R.id.movie_title)).setText(movie.title);
2828
((TextView)findViewById(R.id.movie_rating)).setText(movie.getRating());
2929
((TextView)findViewById(R.id.movie_overview)).setText(movie.overview);
30+
((TextView)findViewById(R.id.movie_release_date)).setText(movie.release_date);
31+
3032

3133
Uri posterUri = movie.buildPosterUri(getString(R.string.api_poster_default_size));
3234
Picasso.with(this)

app/src/main/java/io/maritimus/sofaexpert/model/Movie.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,26 @@ public class Movie {
1414
public static final String KEY_POSTER_PATH = "poster_path";
1515
public static final String KEY_VOTE_AVERAGE = "vote_average";
1616
public static final String KEY_VOTE_COUNT = "vote_count";
17+
public static final String KEY_RELEASE_DATE = "release_date";
1718

1819
public final long id;
1920
public final String title;
2021
public final String overview;
2122
public final String poster_path;
2223
public final double vote_average;
2324
public final long vote_count;
25+
public final String release_date;
2426

2527
public Movie(long id,
2628
String title, String overview, String poster_path,
27-
double vote_average, long vote_count) {
29+
double vote_average, long vote_count, String release_date) {
2830
this.id = id;
2931
this.title = title;
3032
this.overview = overview;
3133
this.poster_path = poster_path;
3234
this.vote_average = vote_average;
3335
this.vote_count = vote_count;
36+
this.release_date = release_date;
3437
}
3538

3639
public Movie(Bundle bundle) {
@@ -40,7 +43,8 @@ public Movie(Bundle bundle) {
4043
bundle.getString(KEY_OVERVIEW),
4144
bundle.getString(KEY_POSTER_PATH),
4245
bundle.getDouble(KEY_VOTE_AVERAGE),
43-
bundle.getLong(KEY_VOTE_COUNT)
46+
bundle.getLong(KEY_VOTE_COUNT),
47+
bundle.getString(KEY_RELEASE_DATE)
4448
);
4549
}
4650

@@ -57,6 +61,8 @@ public Bundle toBundle() {
5761
bundle.putString(KEY_POSTER_PATH, poster_path);
5862
bundle.putDouble(KEY_VOTE_AVERAGE, vote_average);
5963
bundle.putLong(KEY_VOTE_COUNT, vote_count);
64+
bundle.putString(KEY_RELEASE_DATE, release_date);
65+
6066

6167
return bundle;
6268
}
@@ -69,7 +75,8 @@ public static Movie fromJson(JSONObject jsonObject) throws JSONException {
6975
jsonObject.getString(KEY_OVERVIEW),
7076
jsonObject.getString(KEY_POSTER_PATH),
7177
jsonObject.getDouble(KEY_VOTE_AVERAGE),
72-
jsonObject.getLong(KEY_VOTE_COUNT)
78+
jsonObject.getLong(KEY_VOTE_COUNT),
79+
jsonObject.getString(KEY_RELEASE_DATE)
7380
);
7481
}
7582

app/src/main/res/layout/fragment_detail.xml

+23-3
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@
2727

2828
<TextView
2929
android:id="@+id/movie_title"
30-
android:text=""
3130
android:layout_width="wrap_content"
3231
android:layout_height="wrap_content"
3332
style="@style/TextAppearance.AppCompat.Title" />
3433

3534
<TextView
3635
android:id="@+id/movie_rating"
37-
android:text=""
3836
android:layout_width="wrap_content"
3937
android:layout_height="wrap_content"
4038
style="@style/TextAppearance.AppCompat.Large" />
@@ -45,9 +43,31 @@
4543
android:layout_height="@dimen/poster_height"
4644
android:padding="16dp" />
4745

46+
<LinearLayout
47+
android:orientation="horizontal"
48+
android:layout_width="match_parent"
49+
android:layout_height="wrap_content"
50+
android:layout_alignBottom="@+id/scrollView"
51+
android:layout_centerHorizontal="true"
52+
android:layout_marginBottom="16dp"
53+
android:gravity="center">
54+
55+
<TextView
56+
android:layout_width="wrap_content"
57+
android:layout_height="wrap_content"
58+
android:text="@string/label_movie_release_date"
59+
android:id="@+id/movie_release_date_label"
60+
style="@style/Base.TextAppearance.AppCompat.Medium" />
61+
62+
<TextView
63+
android:layout_width="wrap_content"
64+
android:layout_height="wrap_content"
65+
android:id="@+id/movie_release_date"
66+
style="@style/Base.TextAppearance.AppCompat.Medium" />
67+
</LinearLayout>
68+
4869
<TextView
4970
android:id="@+id/movie_overview"
50-
android:text=""
5171
android:layout_width="fill_parent"
5272
android:layout_height="wrap_content"
5373
style="@style/TextAppearance.AppCompat.Medium" />

app/src/main/res/values/strings.xml

+3
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@
2525
<string name="api_key">cfb1decdd632391492006dbbfbb3e73b</string>
2626
<string name="api_poster_default_size">w154</string>
2727

28+
<!-- labels -->
29+
<string name="label_movie_release_date">Release date:</string>
30+
2831
</resources>

0 commit comments

Comments
 (0)