aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprithugoswami <prithugoswami524@gmail.com>2019-05-01 15:23:25 +0530
committerprithugoswami <prithugoswami524@gmail.com>2019-05-01 15:23:25 +0530
commit7a9c8ae645526700d30e5320febf3cb669e43c68 (patch)
tree3e90abb3469751b951f7f4efe50cdd3bc0262683
parent5c24e7c4818bfb63a90b045f28102230f56817c1 (diff)
downloadtmdb-desktop-client-7a9c8ae645526700d30e5320febf3cb669e43c68.tar.gz
tmdb-desktop-client-7a9c8ae645526700d30e5320febf3cb669e43c68.zip
re-format the code and add image url
-rw-r--r--src/com/oocpro/tmdbdesktop/Constants.java1
-rw-r--r--src/com/oocpro/tmdbdesktop/tmdb/Movie.java17
2 files changed, 10 insertions, 8 deletions
diff --git a/src/com/oocpro/tmdbdesktop/Constants.java b/src/com/oocpro/tmdbdesktop/Constants.java
index 8b2a0ee..03719ee 100644
--- a/src/com/oocpro/tmdbdesktop/Constants.java
+++ b/src/com/oocpro/tmdbdesktop/Constants.java
@@ -2,5 +2,6 @@ package com.oocpro.tmdbdesktop;
public class Constants{
public static final String BASEURL="https://api.themoviedb.org/3";
+ public static final String IMG_URL="https://image.tmdb.org/t/p/w500";
public static final String API_KEY="b888b64c9155c26ade5659ea4dd60e64";
}
diff --git a/src/com/oocpro/tmdbdesktop/tmdb/Movie.java b/src/com/oocpro/tmdbdesktop/tmdb/Movie.java
index 9bbf32d..33141bf 100644
--- a/src/com/oocpro/tmdbdesktop/tmdb/Movie.java
+++ b/src/com/oocpro/tmdbdesktop/tmdb/Movie.java
@@ -1,13 +1,14 @@
-package com.oocpro.tmdbdesktop.Tmdb;
+package com.oocpro.tmdbdesktop.tmdb;
import com.oocpro.tmdbdesktop.Constants;
-import java.io.IOException;
+
import java.io.InputStream;
-import java.net.URL;
+import java.io.IOException;
import java.net.MalformedURLException;
-import java.util.List;
-import java.util.Iterator;
+import java.net.URL;
import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import org.json.*;
public class Movie{
@@ -23,10 +24,10 @@ public class Movie{
InputStream res = (InputStream)new URL(geturl).getContent();
JSONObject movie = new JSONObject(new JSONTokener(res));
- JSONArray ja_genres = movie.getJSONArray("genres");
- Iterator genres_itr = ja_genres.iterator();
-
genres = new ArrayList<String>();
+ Iterator genres_itr = movie.getJSONArray("genres").iterator();
+
+ // iterate through each genre and add it's `name` to the `genres` list
while(genres_itr.hasNext()){
JSONObject jo = (JSONObject)genres_itr.next();
genres.add(jo.getString("name"));