diff --git a/app/src/main/java/com/example/junwon/finalproject/ActorListFragment.java b/app/src/main/java/com/example/junwon/finalproject/ActorListFragment.java new file mode 100644 index 0000000000000000000000000000000000000000..5ef766b0339d815a27fbf811655ea6482100c154 --- /dev/null +++ b/app/src/main/java/com/example/junwon/finalproject/ActorListFragment.java @@ -0,0 +1,243 @@ +package com.example.junwon.finalproject; + +import android.app.Fragment; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.ListView; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.w3c.dom.Text; + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import me.grantland.widget.AutofitTextView; + +/** + * Created by Jun Won on 2017-12-08. + */ + +public class ActorListFragment extends Fragment { + + View view; + ListView mListView; + int movie_id; + String character; + String name; + String profile_path; + int actor_id; + String credit_id; + int gender; + Bitmap bit; + List<ActorInfo> ActorList = new ArrayList<>(); + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { + view = inflater.inflate(R.layout.collection_fragment, container, false); + mListView = (ListView) view.findViewById(R.id.collection_listview); + setListViewScrollable(); + getMovieIdFromBundle(); + getActorListData(); + mListView.setFocusable(false); + return view; + } + + /** + * Make listview scrollable when in the scrollview + */ + private void setListViewScrollable() { + mListView.setOnTouchListener(new ListView.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + int action = event.getAction(); + switch (action) { + case MotionEvent.ACTION_DOWN: + // Disallow ScrollView to intercept touch events. + v.getParent().requestDisallowInterceptTouchEvent(true); + break; + + case MotionEvent.ACTION_UP: + // Allow ScrollView to intercept touch events. + v.getParent().requestDisallowInterceptTouchEvent(false); + break; + } + + // Handle ListView touch events. + v.onTouchEvent(event); + return true; + } + }); + } + + /** + * Get data from bundle in the previous fragment replacing + */ + + private void getMovieIdFromBundle() { + Bundle bundle = getArguments(); + movie_id = bundle.getInt("movie_id"); + } + + /** + * get data of actor list and show it to the frame + */ + public void getActorListData() { + new AsyncTask() { + + @Override + protected Object doInBackground(Object[] params) { + try { + JSONObject JsonObject = new JSONObject(HttpRequest.get("http://api.themoviedb.org/3/movie/" + movie_id + "/casts", + true, "api_key", MainActivity.getApi_key()).body()); + JSONArray JsonArray = JsonObject.getJSONArray("cast"); + for (int i = 0; i < JsonArray.length(); i++) { + JSONObject cast_JsonObject = JsonArray.getJSONObject(i); + character = cast_JsonObject.getString("character"); + credit_id = cast_JsonObject.getString("credit_id"); + gender = cast_JsonObject.getInt("gender"); + actor_id = cast_JsonObject.getInt("id"); + name = cast_JsonObject.getString("name"); + profile_path = cast_JsonObject.getString("profile_path"); + bit = getBitmap("http://image.tmdb.org/t/p/w185" + profile_path); + ActorInfo actorInfo = new ActorInfo(character, credit_id, gender, actor_id, name, bit); + ActorList.add(actorInfo); + } + } catch (JSONException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + + @Override + protected void onPostExecute(Object o) { + CustomAdapter customAdapter = new CustomAdapter(); + mListView.setAdapter(customAdapter); + mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { + ActorInfo actorInfo = ActorList.get(position); + Bundle bundle = new Bundle(); + bundle.putInt("person_id", actorInfo.actor_id); + Fragment fragment = new DetailedActorFragment(); + fragment.setArguments(bundle); + getFragmentManager().beginTransaction().replace(R.id.main_frame, fragment).addToBackStack(null).commit(); + } + }); + } + }.execute(); + } + + /** + * get bitmap image from the link indicated + * + * @param actual_link link to get the image + * @return bitmap image + * @throws IOException exception for IO + */ + + private Bitmap getBitmap(String actual_link) throws IOException { + URL urlConnection = new URL(actual_link); + HttpURLConnection connection = (HttpURLConnection) urlConnection.openConnection(); + connection.connect(); + InputStream input = connection.getInputStream(); + return BitmapFactory.decodeStream(input); + } + + /** + * private class about actor info + */ + + + private class ActorInfo { + + String character; + String name; + Bitmap bitmap; + int actor_id; + String credit_id; + int gender; + + /** + * Constructor of Actor Info + * + * @param character character string + * @param credit_id credit id string + * @param gender gender as integer + * @param actor_id int as actor id + * @param name name as string + * @param bitmap bitmap as Bitmap file + */ + + public ActorInfo(String character, String credit_id, int gender, int actor_id, String name, Bitmap bitmap) { + this.character = character; + this.name = name; + this.actor_id = actor_id; + this.credit_id = credit_id; + this.gender = gender; + this.bitmap = bitmap; + } + } + + /** + * custom adapter about listview + */ + + private class CustomAdapter extends BaseAdapter { + + @Override + public int getCount() { + return ActorList.size(); + } + + @Override + public Object getItem(int position) { + return ActorList.get(position); + } + + @Override + public long getItemId(int position) { + return 0; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + convertView = getActivity().getLayoutInflater().inflate(R.layout.actor_list_fragment, null); + AutofitTextView actor_character = (AutofitTextView) convertView.findViewById(R.id.actor_character); + AutofitTextView actor_name = (AutofitTextView) convertView.findViewById(R.id.actor_name); + AutofitTextView actor_gender = (AutofitTextView) convertView.findViewById(R.id.actor_gender); + + ImageView actor_image = (ImageView) convertView.findViewById(R.id.actor_image); + + ActorInfo actorInfo = ActorList.get(position); + actor_character.setText("Character: " + actorInfo.character); + actor_name.setText("Name: " + actorInfo.name); + int gender = actorInfo.gender; + if (gender == 1) { + actor_gender.setText("Gender: F"); + } else { + actor_gender.setText("Gender: M"); + } + actor_image.setImageBitmap(actorInfo.bitmap); + return convertView; + } + } +} diff --git a/app/src/main/java/com/example/junwon/finalproject/CacheBitmapImage.java b/app/src/main/java/com/example/junwon/finalproject/CacheBitmapImage.java new file mode 100644 index 0000000000000000000000000000000000000000..8a91856376288b2a6665d4ff862cf45b87cfd025 --- /dev/null +++ b/app/src/main/java/com/example/junwon/finalproject/CacheBitmapImage.java @@ -0,0 +1,52 @@ +package com.example.junwon.finalproject; + +import android.graphics.Bitmap; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by Jun Won on 2017-12-09. + */ + +public class CacheBitmapImage { + + static Map<Integer, Bitmap> cacheImage = new HashMap(); + + /** + * function that put the image bitmap into the class + * + * @param movie_id movie id to get from hashmap + * @param bitmap image to put in hashmap + */ + + public static void putImage(int movie_id, Bitmap bitmap) { + cacheImage.put(movie_id, bitmap); + } + + /** + * boolean function that checks if it is in cache map + * + * @param movie_id movie id to check if it is in hashmap + * @return true if it is in hash, false if it is not + */ + static boolean isInCache(int movie_id) { + if (cacheImage.get(movie_id) == null) + return false; + return true; + } + + /** + * get bimap from hashmap + * + * @param movie_id movie id to get it from hashmap + * @return bitmap returning of its key + */ + + static Bitmap getImage(int movie_id) { + return cacheImage.get(movie_id); + } + +} diff --git a/app/src/main/java/com/example/junwon/finalproject/DetailedActorFragment.java b/app/src/main/java/com/example/junwon/finalproject/DetailedActorFragment.java new file mode 100644 index 0000000000000000000000000000000000000000..8fc037ba6a7fc2417841a2888ded7f51cc9a3dbd --- /dev/null +++ b/app/src/main/java/com/example/junwon/finalproject/DetailedActorFragment.java @@ -0,0 +1,186 @@ +package com.example.junwon.finalproject; + +import android.app.Fragment; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.constraint.solver.Cache; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Jun Won on 2017-12-10. + */ + +public class DetailedActorFragment extends Fragment { + + View view; + int person_id; + ImageView actorPoster; + TextView actorGender; + TextView actorBirthday; + TextView actorPlaceOfBirth; + TextView actorDetailName; + TextView actorDetailBiography; + TextView actorDetailHomepage; + ActorInfo actorInfo; + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { + view = inflater.inflate(R.layout.custom_actor_fragment, container, false); + getPersonId(); + saveAllVariables(); + getDataAndSetToText(); + setHasOptionsMenu(true); + return view; + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + menu.clear(); + super.onCreateOptionsMenu(menu, inflater); + } + + /** + * getting person id from bundle + */ + private void getPersonId() { + Bundle bundle = getArguments(); + person_id = bundle.getInt("person_id"); + } + + /** + * get data from json file and set it to text in the frame + */ + + private void getDataAndSetToText() { + new AsyncTask() { + + @Override + protected void onPostExecute(Object o) { + actorPoster.setImageBitmap(actorInfo.bitmap); + if (actorInfo.gender == 1) { + actorGender.setText("Gender: F"); + } else { + actorGender.setText("Gender: M"); + } + actorBirthday.setText("Birthday: " + actorInfo.birthday); + actorPlaceOfBirth.setText("Place of Birth: " + actorInfo.place_of_birth); + actorDetailName.setText(actorInfo.name); + actorDetailBiography.setText(actorInfo.biography); + actorDetailHomepage.setText("Homepage: " + actorInfo.homepage); + Fragment fragment = new DetailedActorMovieListFragment(); + Bundle bundle = new Bundle(); + bundle.putInt("person_id", person_id); + fragment.setArguments(bundle); + getFragmentManager().beginTransaction().replace(R.id.actor_detail_movielist, fragment).commit(); + } + + @Override + protected Object doInBackground(Object[] params) { + try { + JSONObject JsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/person/" + person_id, + true, "api_key", MainActivity.getApi_key()).body()); + String birthday = JsonObject.getString("birthday"); + int id = JsonObject.getInt("id"); + int gender = JsonObject.getInt("gender"); + String name = JsonObject.getString("name"); + String biography = JsonObject.getString("biography"); + String place_of_birth = JsonObject.getString("place_of_birth"); + String profile_path = JsonObject.getString("profile_path"); + String homepage = JsonObject.getString("homepage"); + Bitmap bitmap = null; + if (!CacheBitmapImage.isInCache(id)) { + bitmap = getBitmap("http://image.tmdb.org/t/p/w185" + profile_path); + CacheBitmapImage.putImage(id, bitmap); + } else { + bitmap = CacheBitmapImage.getImage(id); + } + actorInfo = new ActorInfo(birthday, id, gender, name, biography, place_of_birth, profile_path, homepage, bitmap); + } catch (JSONException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + }.execute(); + } + + /** + * get bitmap image from the link indicated + * + * @param actual_link link to get the image + * @return bitmap image + * @throws IOException exception for IO + */ + + private Bitmap getBitmap(String actual_link) throws IOException { + URL urlConnection = new URL(actual_link); + HttpURLConnection connection = (HttpURLConnection) urlConnection.openConnection(); + connection.connect(); + InputStream input = connection.getInputStream(); + return BitmapFactory.decodeStream(input); + } + + /** + * save all variables that requires in this frame + */ + + private void saveAllVariables() { + actorPoster = (ImageView) view.findViewById(R.id.detailed_actor_poster); + actorGender = (TextView) view.findViewById(R.id.actor_detail_gender); + actorBirthday = (TextView) view.findViewById(R.id.actor_detail_birthday); + actorPlaceOfBirth = (TextView) view.findViewById(R.id.actor_detail_placeofbirth); + actorDetailName = (TextView) view.findViewById(R.id.actor_detail_name); + actorDetailBiography = (TextView) view.findViewById(R.id.actor_detail_biography); + actorDetailHomepage = (TextView) view.findViewById(R.id.actor_detail_homepage); + } + + /** + * class that holds info of actors + */ + private class ActorInfo { + String birthday; + int id; + int gender; + String name; + String biography; + String place_of_birth; + String profile_path; + String homepage; + Bitmap bitmap; + + public ActorInfo(String birthday, int id, int gender, + String name, String biography, String place_of_birth, String profile_path, String homepage, Bitmap bitmap) { + this.birthday = birthday; + this.id = id; + this.gender = gender; + this.name = name; + this.biography = biography; + this.place_of_birth = place_of_birth; + this.profile_path = profile_path; + this.homepage = homepage; + this.bitmap = bitmap; + } + } +} diff --git a/app/src/main/java/com/example/junwon/finalproject/DetailedActorMovieListFragment.java b/app/src/main/java/com/example/junwon/finalproject/DetailedActorMovieListFragment.java new file mode 100644 index 0000000000000000000000000000000000000000..be1c1b981abd18e43cc74ad8c1523a03be535ec5 --- /dev/null +++ b/app/src/main/java/com/example/junwon/finalproject/DetailedActorMovieListFragment.java @@ -0,0 +1,252 @@ +package com.example.junwon.finalproject; + +import android.app.Fragment; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.TextView; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Jun Won on 2017-12-10. + */ + +public class DetailedActorMovieListFragment extends Fragment { + + View view; + int person_id; + List<ActorMovieListInfo> actorMovieListInfoList = new ArrayList<>(); + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { + view = inflater.inflate(R.layout.collection_fragment, container, false); + getPersonId(); + getDataAndSetText(); + return view; + } + + /** + * get person id from bundle + */ + private void getPersonId() { + Bundle bundle = getArguments(); + person_id = bundle.getInt("person_id"); + } + + /** + * let listview scrollable in the scrollview + * + * @param listView the listview to contribute to this function + */ + private void setListViewScrollable(ListView listView) { + listView.setOnTouchListener(new ListView.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + int action = event.getAction(); + switch (action) { + case MotionEvent.ACTION_DOWN: + // Disallow ScrollView to intercept touch events. + v.getParent().requestDisallowInterceptTouchEvent(true); + break; + + case MotionEvent.ACTION_UP: + // Allow ScrollView to intercept touch events. + v.getParent().requestDisallowInterceptTouchEvent(false); + break; + } + + // Handle ListView touch events. + v.onTouchEvent(event); + return true; + } + }); + } + + /** + * get data from json file and set it as a text or poster it + */ + + private void getDataAndSetText() { + new AsyncTask() { + + @Override + protected void onPostExecute(Object o) { + ListView listView = (ListView) view.findViewById(R.id.collection_listview); + CustomAdapter customAdapter = new CustomAdapter(); + listView.setAdapter(customAdapter); + listView.setFocusable(false); + setListViewScrollable(listView); + + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { + int movie_id = actorMovieListInfoList.get(position).id; + Bundle bundle = new Bundle(); + bundle.putInt("movie_id", movie_id); + Fragment fragment = new DetailedMovieFragment(); + fragment.setArguments(bundle); + getFragmentManager().beginTransaction().replace(R.id.main_frame, fragment).addToBackStack(null).commit(); + } + }); + } + + @Override + protected Object doInBackground(Object[] params) { + try { + JSONObject jsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/person/" + person_id + "/movie_credits", + true, "api_key", MainActivity.getApi_key()).body()); + JSONArray castArray = jsonObject.getJSONArray("cast"); + for (int i = 0; i < castArray.length(); i++) { + JSONObject JsonObject = castArray.getJSONObject(i); + String character = JsonObject.getString("character"); + String poster_path = JsonObject.getString("poster_path"); + int id = JsonObject.getInt("id"); + Bitmap bitmap = null; + if (!CacheBitmapImage.isInCache(id)) { + bitmap = getBitmap("http://image.tmdb.org/t/p/w185" + poster_path); + CacheBitmapImage.putImage(id, bitmap); + } else { + bitmap = CacheBitmapImage.getImage(id); + } + String title = JsonObject.getString("title"); + String release_date = JsonObject.getString("release_date"); + int vote_average = JsonObject.getInt("vote_average"); + ActorMovieListInfo actorMovieListInfo = new ActorMovieListInfo(character, bitmap, id, title, release_date, vote_average); + actorMovieListInfoList.add(actorMovieListInfo); + } + } catch (JSONException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + }.execute(); + } + + /** + * get bitmap image from the link indicated + * + * @param actual_link link to get the image + * @return bitmap image + * @throws IOException exception for IO + */ + + private Bitmap getBitmap(String actual_link) throws IOException { + URL urlConnection = new URL(actual_link); + HttpURLConnection connection = (HttpURLConnection) urlConnection.openConnection(); + connection.connect(); + InputStream input = connection.getInputStream(); + return BitmapFactory.decodeStream(input); + } + + /** + * class that holds info of its actor + */ + + private class ActorMovieListInfo { + + String character; + Bitmap bitmap; + int id; + String title; + String release_date; + int vote_average; + + /** + * constructor of its class setting all of its variables + */ + public ActorMovieListInfo(String character, Bitmap bitmap, int id, String title, String release_date, int vote_average) { + this.character = character; + this.bitmap = bitmap; + this.id = id; + this.title = title; + this.release_date = release_date; + this.vote_average = vote_average; + } + } + + /** + * custom adapter to apply as a listview + */ + + private class CustomAdapter extends BaseAdapter { + + ImageView poster; + TextView character; + TextView title; + TextView vote_average; + TextView release_date; + + @Override + public int getCount() { + return actorMovieListInfoList.size(); + } + + @Override + public Object getItem(int position) { + return actorMovieListInfoList.get(position); + } + + @Override + public long getItemId(int position) { + return 0; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + convertView = getActivity().getLayoutInflater().inflate(R.layout.custom_actor_movielist_fragment, null); + setAllVariables(convertView); + setDataToVariables(position); + return convertView; + } + + /** + * set the text or image as a given data + * @param position the position to get a hatch + */ + + private void setDataToVariables(int position) { + ActorMovieListInfo actorMovieListInfo = actorMovieListInfoList.get(position); + poster.setImageBitmap(actorMovieListInfo.bitmap); + character.setText(actorMovieListInfo.character); + title.setText(actorMovieListInfo.title); + vote_average.setText(String.valueOf(actorMovieListInfo.vote_average)); + release_date.setText(actorMovieListInfo.release_date); + } + + /** + * + * @param convertView + */ + + private void setAllVariables(View convertView) { + poster = (ImageView) convertView.findViewById(R.id.custom_actor_movielist_poster); + character = (TextView) convertView.findViewById(R.id.custom_actor_movielist_character); + title = (TextView) convertView.findViewById(R.id.custom_actor_movielist_title); + vote_average = (TextView) convertView.findViewById(R.id.custom_actor_movielist_vote_average); + release_date = (TextView) convertView.findViewById(R.id.custom_actor_movielist_release_date); + } + } +} diff --git a/app/src/main/java/com/example/junwon/finalproject/DetailedMovieFragment.java b/app/src/main/java/com/example/junwon/finalproject/DetailedMovieFragment.java index 51b518a746dea6b7b5f5d1197f44bc4f9d21451a..eee72e674e4587a294a7b4bdf45807b99ee8025c 100644 --- a/app/src/main/java/com/example/junwon/finalproject/DetailedMovieFragment.java +++ b/app/src/main/java/com/example/junwon/finalproject/DetailedMovieFragment.java @@ -24,6 +24,7 @@ import android.widget.Button; import android.widget.ImageView; import android.widget.ListView; import android.widget.RatingBar; +import android.widget.ScrollView; import android.widget.TextView; import android.widget.Toast; @@ -82,6 +83,7 @@ public class DetailedMovieFragment extends Fragment { int vote_average; String actual_link; private StorageReference mStorageRef; + ScrollView scrollView; @Nullable @Override @@ -93,9 +95,22 @@ public class DetailedMovieFragment extends Fragment { getActivity().setTitle("Movie information"); getMovieId(); getData(); + showCast(); return view; } + /** + * show casting info of its detailed movie + */ + + private void showCast() { + Fragment fragment = new ActorListFragment(); + Bundle bundle = new Bundle(); + bundle.putInt("movie_id",movie_id); + fragment.setArguments(bundle); + getFragmentManager().beginTransaction().replace(R.id.actor_frame,fragment).commit(); + } + /** * The function that writes down on the firebase */ @@ -129,155 +144,161 @@ public class DetailedMovieFragment extends Fragment { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_rate: - final AlertDialog.Builder mBuilder = new AlertDialog.Builder(getActivity()); - View mView = getActivity().getLayoutInflater().inflate(R.layout.menu_ratingbar, null); - RatingBar rating_bar = (RatingBar) mView.findViewById(R.id.menu_ratingbar); - final Button rate_button = (Button) mView.findViewById(R.id.rate_button); - final Button cancel_button = (Button) mView.findViewById(R.id.cancel_button); - - mBuilder.setView(mView); - final AlertDialog dialog = mBuilder.create(); - rating_bar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() { - @Override - public void onRatingChanged(RatingBar ratingBar, final float rating, boolean fromUser) { - rate_button.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - AsyncTask asynctask = new AsyncTask() { - @Override - protected void onPostExecute(Object o) { - dialog.dismiss(); - Toast.makeText(getActivity(), "Successfully Rated", - Toast.LENGTH_LONG).show(); - } - - @Override - protected Object doInBackground(Object[] params) { - Map<String, Float> map = new HashMap<>(); - map.put("value", 2 * rating); - String body = HttpRequest.post("https://api.themoviedb.org/3/movie/" + movie_id + "/rating", true, "api_key", - MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).form(map).body(); - System.out.println(body); - return null; - } - }.execute(); - } - }); - cancel_button.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.dismiss(); - } - }); - } - }); - dialog.show(); + doRatingProcess(); return true; case R.id.menu_delete_rate: - AsyncTask asynctask = new AsyncTask() { - @Override - protected void onPostExecute(Object o) { - Toast.makeText(getActivity(), "Successfully Deleted", - Toast.LENGTH_LONG).show(); - } - - @Override - protected Object doInBackground(Object[] params) { - HttpRequest.delete("https://api.themoviedb.org/3/movie/" + movie_id + "/rating", true, "api_key", - MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).created(); - return null; - } - }.execute(); + deleteRateProcess(); return true; case R.id.menu_favorite: - new AsyncTask() { - @Override - protected void onPostExecute(Object o) { - Toast.makeText(getActivity(), "Added to Favorite", - Toast.LENGTH_LONG).show(); - } - - @Override - protected Object doInBackground(Object[] params) { - Map<String, Object> map = new HashMap<>(); - map.put("media_type", "movie"); - map.put("media_id", movie_id); - map.put("favorite", true); - String body = HttpRequest.post("https://api.themoviedb.org/3/account/{account_id}/favorite", true, "api_key", - MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).form(map).body(); - System.out.println(body); - return null; - } - }.execute(); + DetermineFavorite(true); return true; case R.id.menu_watchlist: - new AsyncTask() { - @Override - protected void onPostExecute(Object o) { - Toast.makeText(getActivity(), "Added to My Watchlist", - Toast.LENGTH_LONG).show(); - } - - @Override - protected Object doInBackground(Object[] params) { - Map<String, Object> map = new HashMap<>(); - map.put("media_type", "movie"); - map.put("media_id", movie_id); - map.put("watchlist", true); - String body = HttpRequest.post("https://api.themoviedb.org/3/account/{account_id}/watchlist", true, "api_key", - MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).form(map).body(); - System.out.println(body); - return null; - } - }.execute(); + DetermineWatchlist(true); return true; case R.id.menu_delete_favorite: - new AsyncTask() { - @Override - protected void onPostExecute(Object o) { - Toast.makeText(getActivity(), "Deleted Favorite", - Toast.LENGTH_LONG).show(); - } - - @Override - protected Object doInBackground(Object[] params) { - Map<String, Object> map = new HashMap<>(); - map.put("media_type", "movie"); - map.put("media_id", movie_id); - map.put("favorite", false); - String body = HttpRequest.post("https://api.themoviedb.org/3/account/{account_id}/favorite", true, "api_key", - MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).form(map).body(); - System.out.println(body); - return null; - } - }.execute(); + DetermineFavorite(false); return true; case R.id.menu_delete_watchlist: - new AsyncTask() { - @Override - protected void onPostExecute(Object o) { - Toast.makeText(getActivity(), "Deleted My Watchlist", - Toast.LENGTH_LONG).show(); - } - - @Override - protected Object doInBackground(Object[] params) { - Map<String, Object> map = new HashMap<>(); - map.put("media_type", "movie"); - map.put("media_id", movie_id); - map.put("watchlist", false); - String body = HttpRequest.post("https://api.themoviedb.org/3/account/{account_id}/watchlist", true, "api_key", - MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).form(map).body(); - System.out.println(body); - return null; - } - }.execute(); + DetermineWatchlist(false); return true; default: return super.onOptionsItemSelected(item); } } + /** + * Determine the watchlist depend on the boolean function + * @param b boolean variable to determine + */ + + private void DetermineWatchlist(final boolean b) { + new AsyncTask() { + @Override + protected void onPostExecute(Object o) { + if(b) { + Toast.makeText(getActivity(), "Added to My Watchlist", + Toast.LENGTH_LONG).show(); + } else { + Toast.makeText(getActivity(), "Deleted My Watchlist", + Toast.LENGTH_LONG).show(); + } + } + + @Override + protected Object doInBackground(Object[] params) { + Map<String, Object> map = new HashMap<>(); + map.put("media_type", "movie"); + map.put("media_id", movie_id); + map.put("watchlist", b); + String body = HttpRequest.post("https://api.themoviedb.org/3/account/{account_id}/watchlist", true, "api_key", + MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).form(map).body(); + System.out.println(body); + return null; + } + }.execute(); + } + + /** + * Determine the favorite depend on the boolean function + * @param b boolean variable to determine + */ + + private void DetermineFavorite(final boolean b) { + new AsyncTask() { + @Override + protected void onPostExecute(Object o) { + if(b) { + Toast.makeText(getActivity(), "Added to Favorite", + Toast.LENGTH_LONG).show(); + } else { + Toast.makeText(getActivity(), "Deleted Favorite", + Toast.LENGTH_LONG).show(); + } + } + + @Override + protected Object doInBackground(Object[] params) { + Map<String, Object> map = new HashMap<>(); + map.put("media_type", "movie"); + map.put("media_id", movie_id); + map.put("favorite", b); + String body = HttpRequest.post("https://api.themoviedb.org/3/account/{account_id}/favorite", true, "api_key", + MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).form(map).body(); + System.out.println(body); + return null; + } + }.execute(); + } + + /** + * Deleting rating process + */ + private void deleteRateProcess() { + AsyncTask asynctask = new AsyncTask() { + @Override + protected void onPostExecute(Object o) { + Toast.makeText(getActivity(), "Successfully Deleted", + Toast.LENGTH_LONG).show(); + } + + @Override + protected Object doInBackground(Object[] params) { + HttpRequest.delete("https://api.themoviedb.org/3/movie/" + movie_id + "/rating", true, "api_key", + MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).created(); + return null; + } + }.execute(); + } + + /** + * Rate the current movie + */ + private void doRatingProcess() { + final AlertDialog.Builder mBuilder = new AlertDialog.Builder(getActivity()); + View mView = getActivity().getLayoutInflater().inflate(R.layout.menu_ratingbar, null); + RatingBar rating_bar = (RatingBar) mView.findViewById(R.id.menu_ratingbar); + final Button rate_button = (Button) mView.findViewById(R.id.rate_button); + final Button cancel_button = (Button) mView.findViewById(R.id.cancel_button); + + mBuilder.setView(mView); + final AlertDialog dialog = mBuilder.create(); + rating_bar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() { + @Override + public void onRatingChanged(RatingBar ratingBar, final float rating, boolean fromUser) { + rate_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + AsyncTask asynctask = new AsyncTask() { + @Override + protected void onPostExecute(Object o) { + dialog.dismiss(); + Toast.makeText(getActivity(), "Successfully Rated", + Toast.LENGTH_LONG).show(); + } + + @Override + protected Object doInBackground(Object[] params) { + Map<String, Float> map = new HashMap<>(); + map.put("value", 2 * rating); + String body = HttpRequest.post("https://api.themoviedb.org/3/movie/" + movie_id + "/rating", true, "api_key", + MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).form(map).body(); + System.out.println(body); + return null; + } + }.execute(); + } + }); + cancel_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialog.dismiss(); + } + }); + } + }); + dialog.show(); + } + /** * Getting movie ID from argument */ @@ -294,37 +315,7 @@ public class DetailedMovieFragment extends Fragment { AsyncTask asynctask = new AsyncTask() { @Override protected void onPostExecute(Object o) { - banner_image.setImageBitmap(banner_bitmap); - banner_image.setScaleType(ImageView.ScaleType.FIT_XY); - tagline_text.setText(tagline); - main_poster.setImageBitmap(poster_bitmap); - setPosterVideo(main_poster); - rating_bar.setRating(((float) vote_average) / 2); - String year = release_date.split("-")[0]; - detailed_title.setText(movie_title + " (" + year + ")"); - String genre_string = ""; - for (int i = 0; i < genre_array.size(); i++) { - genre_string += genre_array.get(i); - if (i != genre_array.size() - 1) { - genre_string += ", "; - } - } - detailed_genre.setText(genre_string); - String production_string = ""; - for (int i = 0; i < production_company_array.size(); i++) { - production_string += production_company_array.get(i); - if (i != production_company_array.size() - 1) { - production_string += ", "; - } - } - production_companies.setText(production_string); - overview.setText(overview_string); - Bundle bundle = new Bundle(); - bundle.putString("flag", "detailed_recommended"); - bundle.putInt("movie_id", movie_id); - Fragment fragment = new MovieListFragment(); - fragment.setArguments(bundle); - getFragmentManager().beginTransaction().add(R.id.detailed_recommended_frame, fragment).commit(); + setImageAndText(); writeDataToFirebase(); uploadBitmapImageToFirebase(); } @@ -340,7 +331,12 @@ public class DetailedMovieFragment extends Fragment { banner_bitmap = getBitmap(actual_link); link = jsonObject.getString("poster_path"); actual_link = "http://image.tmdb.org/t/p/w185" + link; - poster_bitmap = getBitmap(actual_link); + if(!CacheBitmapImage.isInCache(movie_id)) { + poster_bitmap = getBitmap(actual_link); + CacheBitmapImage.putImage(movie_id, poster_bitmap); + } else { + poster_bitmap = CacheBitmapImage.getImage(movie_id); + } JSONArray genre_jsonarray = jsonObject.getJSONArray("genres"); for (int i = 0; i < genre_jsonarray.length(); i++) { JSONObject genre_jsonobject = genre_jsonarray.getJSONObject(i); @@ -368,6 +364,43 @@ public class DetailedMovieFragment extends Fragment { }.execute(); } + /** + * the function that sets image and text in the view + */ + private void setImageAndText() { + banner_image.setImageBitmap(banner_bitmap); + banner_image.setScaleType(ImageView.ScaleType.FIT_XY); + tagline_text.setText(tagline); + main_poster.setImageBitmap(poster_bitmap); + setPosterVideo(main_poster); + rating_bar.setRating(((float) vote_average) / 2); + String year = release_date.split("-")[0]; + detailed_title.setText(movie_title + " (" + year + ")"); + String genre_string = ""; + for (int i = 0; i < genre_array.size(); i++) { + genre_string += genre_array.get(i); + if (i != genre_array.size() - 1) { + genre_string += ", "; + } + } + detailed_genre.setText(genre_string); + String production_string = ""; + for (int i = 0; i < production_company_array.size(); i++) { + production_string += production_company_array.get(i); + if (i != production_company_array.size() - 1) { + production_string += ", "; + } + } + production_companies.setText(production_string); + overview.setText(overview_string); + Bundle bundle = new Bundle(); + bundle.putString("flag", "detailed_recommended"); + bundle.putInt("movie_id", movie_id); + Fragment fragment = new MovieListFragment(); + fragment.setArguments(bundle); + getFragmentManager().beginTransaction().add(R.id.detailed_recommended_frame, fragment).commit(); + } + /** * Upload the poster image to the FireBase */ @@ -461,6 +494,7 @@ public class DetailedMovieFragment extends Fragment { overview = (AutofitTextView) view.findViewById(R.id.overview); tagline_text = (TextView) view.findViewById(R.id.tagline); production_companies = (AutofitTextView) view.findViewById(R.id.production_companies); + scrollView = (ScrollView) view.findViewById(R.id.scrollView); } } diff --git a/app/src/main/java/com/example/junwon/finalproject/MainActivity.java b/app/src/main/java/com/example/junwon/finalproject/MainActivity.java index 93496991e1d6985ea34ada6fd5dbcbf7f41899aa..d9bcdc0591626418c32e87e3d070a2d81ec7e911 100644 --- a/app/src/main/java/com/example/junwon/finalproject/MainActivity.java +++ b/app/src/main/java/com/example/junwon/finalproject/MainActivity.java @@ -35,7 +35,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On private NavigationView navigationView; private Toolbar mToolbar; private final static String api_key = "7a3ab68737e6c2d44b1c27c3d1b90f0a"; - private String request_token = "d19a2da47e00634e9b751d571cd04f35ca700d90"; private final static String session_id = "e61370e64733ae8adad24c5772016227b799667c"; private static Bitmap bitmap = null; public Map<Integer, String> genre_map = new HashMap<>(); diff --git a/app/src/main/java/com/example/junwon/finalproject/MovieListFragment.java b/app/src/main/java/com/example/junwon/finalproject/MovieListFragment.java index 659910abe0d215d4637c1a17b434dd1db5517832..29794f9b8be4ebc7b1cb886a113a86f4c12b2346 100644 --- a/app/src/main/java/com/example/junwon/finalproject/MovieListFragment.java +++ b/app/src/main/java/com/example/junwon/finalproject/MovieListFragment.java @@ -13,6 +13,7 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListView; @@ -83,13 +84,45 @@ public class MovieListFragment extends Fragment { flag = bundle.getString("flag"); collection_listview = (ListView) view.findViewById(R.id.collection_listview); progrssBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyle); - + setListViewScrollable(); getMyListSetUp(); putOptionScrollListener(); setHasOptionsMenu(true); + collection_listview.setFocusable(false); return view; } + /** + * In the scrollview, listview does not work scrolling, so it needs to be done by this function + */ + + private void setListViewScrollable() { + collection_listview.setOnTouchListener(new ListView.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + int action = event.getAction(); + switch (action) { + case MotionEvent.ACTION_DOWN: + // Disallow ScrollView to intercept touch events. + v.getParent().requestDisallowInterceptTouchEvent(true); + break; + + case MotionEvent.ACTION_UP: + // Allow ScrollView to intercept touch events. + v.getParent().requestDisallowInterceptTouchEvent(false); + break; + } + + // Handle ListView touch events. + v.onTouchEvent(event); + return true; + } + }); + } + + /** + * This is the function that get more data as page goes down + */ private void putOptionScrollListener() { collection_listview.setOnScrollListener(new AbsListView.OnScrollListener() { @@ -112,6 +145,10 @@ public class MovieListFragment extends Fragment { this.currentTotalItemCount = totalItemCount; } + /** + * when scrolling is completed, it needs to load more data + */ + private void isScrollCompleted() { if (currentFirstVisibleItem + currentVisibleItemCount == currentTotalItemCount && this.currentScrollState == SCROLL_STATE_IDLE) { if (!isLoading) { @@ -122,6 +159,10 @@ public class MovieListFragment extends Fragment { } } + /** + * the function that loads more data + */ + private void loadMoreData() { switch (flagInt) { @@ -177,40 +218,8 @@ public class MovieListFragment extends Fragment { @Override protected Object doInBackground(Object[] params) { try { - JSONObject FavoriteJsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/account/{account_id}/favorite/movies", - true, "api_key", MainActivity.getApi_key(), "session_id", MainActivity.getSession_id(), - "sort_by", "created_at.desc").body()); - - int total_pages = FavoriteJsonObject.getInt("total_pages"); - for (int j = 1; j <= total_pages; j++) { - FavoriteJsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/account/{account_id}/favorite/movies", - true, "api_key", MainActivity.getApi_key(), "session_id", MainActivity.getSession_id(), - "sort_by", "created_at.desc", "page", j).body()); - - JSONArray FavoriteResult = FavoriteJsonObject.getJSONArray("results"); - for (int i = 0; i < FavoriteResult.length(); i++) { - JSONObject jsonObject = FavoriteResult.getJSONObject(i); - favorite_movie_id.add(jsonObject.getInt("id")); - } - } - - JSONObject WatchJsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/account/{account_id}/watchlist/movies", - true, "api_key", MainActivity.getApi_key(), "session_id", MainActivity.getSession_id(), - "sort_by", "created_at.desc").body()); - - total_pages = WatchJsonObject.getInt("total_pages"); - for (int j = 1; j <= total_pages; j++) { - - WatchJsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/account/{account_id}/watchlist/movies", - true, "api_key", MainActivity.getApi_key(), "session_id", MainActivity.getSession_id(), - "sort_by", "created_at.desc", "page", j).body()); - - JSONArray WatchResult = WatchJsonObject.getJSONArray("results"); - for (int i = 0; i < WatchResult.length(); i++) { - JSONObject jsonObject = WatchResult.getJSONObject(i); - watchlist_movie_id.add(jsonObject.getInt("id")); - } - } + HandlingFavoriteJsonObject(); + HandlingWatchlistJsonObject(); } catch (JSONException e) { e.printStackTrace(); @@ -220,6 +229,58 @@ public class MovieListFragment extends Fragment { }.execute(); } + /** + * Get Watchlist Json data according to its page number + * + * @throws JSONException JSONException for getting data + */ + + private void HandlingWatchlistJsonObject() throws JSONException { + int total_pages; + JSONObject WatchJsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/account/{account_id}/watchlist/movies", + true, "api_key", MainActivity.getApi_key(), "session_id", MainActivity.getSession_id(), + "sort_by", "created_at.desc").body()); + + total_pages = WatchJsonObject.getInt("total_pages"); + for (int j = 1; j <= total_pages; j++) { + + WatchJsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/account/{account_id}/watchlist/movies", + true, "api_key", MainActivity.getApi_key(), "session_id", MainActivity.getSession_id(), + "sort_by", "created_at.desc", "page", j).body()); + + JSONArray WatchResult = WatchJsonObject.getJSONArray("results"); + for (int i = 0; i < WatchResult.length(); i++) { + JSONObject jsonObject = WatchResult.getJSONObject(i); + watchlist_movie_id.add(jsonObject.getInt("id")); + } + } + } + + /** + * Get Favorite Json data according to its page number + * + * @throws JSONException JSONException for getting data + */ + + private void HandlingFavoriteJsonObject() throws JSONException { + JSONObject FavoriteJsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/account/{account_id}/favorite/movies", + true, "api_key", MainActivity.getApi_key(), "session_id", MainActivity.getSession_id(), + "sort_by", "created_at.desc").body()); + + int total_pages = FavoriteJsonObject.getInt("total_pages"); + for (int j = 1; j <= total_pages; j++) { + FavoriteJsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/account/{account_id}/favorite/movies", + true, "api_key", MainActivity.getApi_key(), "session_id", MainActivity.getSession_id(), + "sort_by", "created_at.desc", "page", j).body()); + + JSONArray FavoriteResult = FavoriteJsonObject.getJSONArray("results"); + for (int i = 0; i < FavoriteResult.length(); i++) { + JSONObject jsonObject = FavoriteResult.getJSONObject(i); + favorite_movie_id.add(jsonObject.getInt("id")); + } + } + } + /** * Obtaining data for ListView */ @@ -263,48 +324,23 @@ public class MovieListFragment extends Fragment { private void dataObtainingHandler() { try { JSONObject jsonObject = null; - if (flag.equals("upcoming")) { - jsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/movie/upcoming", - true, "api_key", MainActivity.getApi_key(), "page", upComingPageNum).body()); - flagInt = 1; - } else if (flag.equals("my_watchlist")) { - jsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/account/{account_id}/watchlist/movies", - true, "api_key", MainActivity.getApi_key(), "session_id", MainActivity.getSession_id(), - "sort_by", "created_at.desc", "page", myWatchListPageNum).body()); - flagInt = 2; - } else if (flag.equals("detailed_recommended")) { - Bundle bundle = getArguments(); - int detailed_movie_id = bundle.getInt("movie_id"); - jsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/movie/" + detailed_movie_id + "/recommendations", - true, "api_key", MainActivity.getApi_key(), "page", detailedRecommendedPageNum).body()); - flagInt = 3; - } else if (flag.equals("rated")) { - jsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/account/{account_id}/rated/movies", - true, "api_key", MainActivity.getApi_key(), "session_id", MainActivity.getSession_id(), - "sort_by", "created_at.desc", "page", ratedPageNum).body()); - flagInt = 4; - } else if (flag.equals("search")) { - Bundle bundle = getArguments(); - String text = bundle.getString("text"); - jsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/search/movie", - true, "api_key", MainActivity.getApi_key(), "query", text, "page", searchPageNum).body()); - flagInt = 5; - } else if (flag.equals("favorite")) { - jsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/account/{account_id}/favorite/movies", - true, "api_key", MainActivity.getApi_key(), "session_id", MainActivity.getSession_id(), - "sort_by", "created_at.desc", "page", favoritePageNum).body()); - flagInt = 6; - } + jsonObject = getJsonObjectDependOnFlag(jsonObject); if (!flag.equals("recent")) { JSONArray result_array = jsonObject.getJSONArray("results"); for (int i = 0; i < result_array.length(); i++) { JSONObject result_object = result_array.getJSONObject(i); String link = result_object.getString("poster_path"); String actual_link = "http://image.tmdb.org/t/p/w185" + link; - Bitmap myBitmap = getBitmap(actual_link); + int det_id = result_object.getInt("id"); + Bitmap myBitmap = null; + if (!CacheBitmapImage.isInCache(det_id)) { + myBitmap = getBitmap(actual_link); + CacheBitmapImage.putImage(det_id, myBitmap); + } else { + myBitmap = CacheBitmapImage.getImage(det_id); + } poster.add(myBitmap); movie_id.add(result_object.getInt("id")); - int det_id = result_object.getInt("id"); setWatchAndFavoriteArray(det_id); title.add(result_object.getString("title")); vote_average.add(result_object.getInt("vote_average")); @@ -326,6 +362,50 @@ public class MovieListFragment extends Fragment { } } + /** + * the function that gets json data depend on the flag + * + * @param jsonObject jsonobject to get returned + * @return jsonObject getting returned + * @throws JSONException JsonException in case + */ + + private JSONObject getJsonObjectDependOnFlag(JSONObject jsonObject) throws JSONException { + if (flag.equals("upcoming")) { + jsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/movie/upcoming", + true, "api_key", MainActivity.getApi_key(), "page", upComingPageNum).body()); + flagInt = 1; + } else if (flag.equals("my_watchlist")) { + jsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/account/{account_id}/watchlist/movies", + true, "api_key", MainActivity.getApi_key(), "session_id", MainActivity.getSession_id(), + "sort_by", "created_at.desc", "page", myWatchListPageNum).body()); + flagInt = 2; + } else if (flag.equals("detailed_recommended")) { + Bundle bundle = getArguments(); + int detailed_movie_id = bundle.getInt("movie_id"); + jsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/movie/" + detailed_movie_id + "/recommendations", + true, "api_key", MainActivity.getApi_key(), "page", detailedRecommendedPageNum).body()); + flagInt = 3; + } else if (flag.equals("rated")) { + jsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/account/{account_id}/rated/movies", + true, "api_key", MainActivity.getApi_key(), "session_id", MainActivity.getSession_id(), + "sort_by", "created_at.desc", "page", ratedPageNum).body()); + flagInt = 4; + } else if (flag.equals("search")) { + Bundle bundle = getArguments(); + String text = bundle.getString("text"); + jsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/search/movie", + true, "api_key", MainActivity.getApi_key(), "query", text, "page", searchPageNum).body()); + flagInt = 5; + } else if (flag.equals("favorite")) { + jsonObject = new JSONObject(HttpRequest.get("https://api.themoviedb.org/3/account/{account_id}/favorite/movies", + true, "api_key", MainActivity.getApi_key(), "session_id", MainActivity.getSession_id(), + "sort_by", "created_at.desc", "page", favoritePageNum).body()); + flagInt = 6; + } + return jsonObject; + } + /** * The function that selected recent on the database */ @@ -368,7 +448,7 @@ public class MovieListFragment extends Fragment { title.add((String) map.get("movie_title")); vote_average.add(((Long) map.get("vote_average")).intValue()); released_date.add((String) map.get("release_date")); - int det_id = ((Long) map.get("movie_id")).intValue(); + final int det_id = ((Long) map.get("movie_id")).intValue(); movie_id.add(det_id); setWatchAndFavoriteArray(det_id); ArrayList<String> inner_genre_array = new ArrayList<>(); @@ -384,7 +464,12 @@ public class MovieListFragment extends Fragment { @Override protected Object doInBackground(Object[] params) { try { - myBitmap = getBitmap((String) map.get("poster_link")); + if (!CacheBitmapImage.isInCache(det_id)) { + myBitmap = getBitmap((String) map.get("poster_link")); + CacheBitmapImage.putImage(det_id, myBitmap); + } else { + myBitmap = CacheBitmapImage.getImage(det_id); + } } catch (IOException e) { e.printStackTrace(); } @@ -570,6 +655,20 @@ public class MovieListFragment extends Fragment { ArrayList<ArrayList<String>> new_genre_array = new ArrayList<>(); ArrayList<String> new_released_date = new ArrayList<>(); ArrayList<Integer> new_movie_id = new ArrayList<>(); + setVariablesToDerivedData(new_poster, new_title, new_vote_average, new_genre_array, new_released_date, new_movie_id); + } + + /** + * Setting Variables to the given derived data + * @param new_poster ArrayList to put the poster + * @param new_title ArrayList to put the title + * @param new_vote_average ArrayList to put the vote average + * @param new_genre_array ArrayList to put the genre array + * @param new_released_date ArrayList to put the release date + * @param new_movie_id ArrayList to put the movie id + */ + + private void setVariablesToDerivedData(ArrayList<Bitmap> new_poster, ArrayList<String> new_title, ArrayList<Integer> new_vote_average, ArrayList<ArrayList<String>> new_genre_array, ArrayList<String> new_released_date, ArrayList<Integer> new_movie_id) { for (int i = 0; i < index_list.size(); i++) { new_poster.add(poster.get(index_list.get(i))); new_title.add(title.get(index_list.get(i))); @@ -646,19 +745,9 @@ public class MovieListFragment extends Fragment { @Override protected Object doInBackground(Object[] params) { if (watchlist_array.get(position)) { - Map<String, Object> map = new HashMap<>(); - map.put("media_type", "movie"); - map.put("media_id", movieId); - map.put("watchlist", false); - String body = HttpRequest.post("https://api.themoviedb.org/3/account/{account_id}/watchlist", true, "api_key", - MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).form(map).body(); + WatchListHandling(movieId, false); } else { - Map<String, Object> map = new HashMap<>(); - map.put("media_type", "movie"); - map.put("media_id", movieId); - map.put("watchlist", true); - String body = HttpRequest.post("https://api.themoviedb.org/3/account/{account_id}/watchlist", true, "api_key", - MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).form(map).body(); + WatchListHandling(movieId, true); } watchlist_array.set(position, !watchlist_array.get(position)); return null; @@ -679,19 +768,9 @@ public class MovieListFragment extends Fragment { @Override protected Object doInBackground(Object[] params) { if (favorite_array.get(position)) { - Map<String, Object> map = new HashMap<>(); - map.put("media_type", "movie"); - map.put("media_id", movieId); - map.put("favorite", false); - String body = HttpRequest.post("https://api.themoviedb.org/3/account/{account_id}/favorite", true, "api_key", - MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).form(map).body(); + FavoriteHandling(movieId, false); } else { - Map<String, Object> map = new HashMap<>(); - map.put("media_type", "movie"); - map.put("media_id", movieId); - map.put("favorite", true); - String body = HttpRequest.post("https://api.themoviedb.org/3/account/{account_id}/favorite", true, "api_key", - MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).form(map).body(); + FavoriteHandling(movieId, true); } favorite_array.set(position, !favorite_array.get(position)); return null; @@ -701,6 +780,41 @@ public class MovieListFragment extends Fragment { }); } + /** + * Handling watchlist as a refactoring + * + * @param movieId movie id to put + * @param b boolean variable to put if it is true or not + */ + + private void FavoriteHandling(int movieId, boolean b) { + Map<String, Object> map = new HashMap<>(); + map.put("media_type", "movie"); + map.put("media_id", movieId); + map.put("favorite", b); + String body = HttpRequest.post("https://api.themoviedb.org/3/account/{account_id}/favorite", true, "api_key", + MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).form(map).body(); + } + + /** + * Handling watchlist as a refactoring + * + * @param movieId movie id to put + * @param b boolean variable to put if it is true or not + */ + + private void WatchListHandling(int movieId, boolean b) { + Map<String, Object> map = new HashMap<>(); + map.put("media_type", "movie"); + map.put("media_id", movieId); + map.put("watchlist", b); + String body = HttpRequest.post("https://api.themoviedb.org/3/account/{account_id}/watchlist", true, "api_key", + MainActivity.getApi_key(), "session_id", MainActivity.getSession_id()).form(map).body(); + } + + /** + * The function that set the menu as the following command + */ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { diff --git a/app/src/main/res/layout/actor_list_fragment.xml b/app/src/main/res/layout/actor_list_fragment.xml new file mode 100644 index 0000000000000000000000000000000000000000..f5e9f43803d06b015255b9b8a59d396da0fb16eb --- /dev/null +++ b/app/src/main/res/layout/actor_list_fragment.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="100dp" + android:orientation="vertical"> + + <ImageView + android:id="@+id/actor_image" + android:layout_width="100dp" + android:layout_height="100dp" + android:layout_weight="1" /> + + <LinearLayout + android:id="@+id/linearLayout4" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_alignParentTop="true" + android:layout_toEndOf="@+id/actor_image" + android:layout_toRightOf="@+id/actor_image" + android:orientation="vertical"> + + <me.grantland.widget.AutofitTextView + android:id="@+id/actor_character" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:maxLines="1" + android:text="TextView" + android:textSize="25sp" /> + + <me.grantland.widget.AutofitTextView + android:id="@+id/actor_name" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:maxLines="1" + android:text="TextView" + android:textSize="25sp" /> + + <me.grantland.widget.AutofitTextView + android:id="@+id/actor_gender" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:maxLines="1" + android:text="TextView" + android:textSize="25sp" /> + + </LinearLayout> + +</RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/collection_fragment.xml b/app/src/main/res/layout/collection_fragment.xml index 7cb8a1558e75329204fd728456b4b7cf3855e069..9a6b88892dee959910103e90ddc4907029666daf 100644 --- a/app/src/main/res/layout/collection_fragment.xml +++ b/app/src/main/res/layout/collection_fragment.xml @@ -4,7 +4,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/list_grad" - android:orientation="vertical"> + android:orientation="vertical" + android:id="@+id/collection_fragment_container"> <ListView diff --git a/app/src/main/res/layout/custom_actor_fragment.xml b/app/src/main/res/layout/custom_actor_fragment.xml new file mode 100644 index 0000000000000000000000000000000000000000..04ee227fdcff552125e869b6221e0b845071c950 --- /dev/null +++ b/app/src/main/res/layout/custom_actor_fragment.xml @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="utf-8"?> +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:background="@color/cardview_dark_background" + android:theme="@style/ThemeOverlay.AppCompat.Dark"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <ImageView + android:id="@+id/detailed_actor_poster" + android:layout_width="100dp" + android:layout_height="150dp" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_alignParentTop="true" + android:layout_marginLeft="15dp" + android:layout_marginStart="15dp" + android:layout_marginTop="15dp" + app:srcCompat="@mipmap/ic_launcher" /> + + <TextView + android:id="@+id/textView" + android:layout_width="130dp" + android:layout_height="wrap_content" + android:layout_alignLeft="@+id/detailed_actor_poster" + android:layout_alignStart="@+id/detailed_actor_poster" + android:layout_below="@+id/detailed_actor_poster" + android:layout_marginTop="15dp" + android:text="Known for: Acting" /> + + <TextView + android:id="@+id/actor_detail_gender" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignEnd="@+id/textView" + android:layout_alignLeft="@+id/textView" + android:layout_alignRight="@+id/textView" + android:layout_alignStart="@+id/textView" + android:layout_below="@+id/textView" + android:text="TextView" /> + + <TextView + android:id="@+id/actor_detail_birthday" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignEnd="@+id/actor_detail_gender" + android:layout_alignLeft="@+id/actor_detail_gender" + android:layout_alignRight="@+id/actor_detail_gender" + android:layout_alignStart="@+id/actor_detail_gender" + android:layout_below="@+id/actor_detail_gender" + android:text="TextView" /> + + <TextView + android:id="@+id/actor_detail_placeofbirth" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignEnd="@+id/actor_detail_birthday" + android:layout_alignLeft="@+id/actor_detail_birthday" + android:layout_alignRight="@+id/actor_detail_birthday" + android:layout_alignStart="@+id/actor_detail_birthday" + android:layout_below="@+id/actor_detail_birthday" + android:text="TextView" /> + + <TextView + android:id="@+id/actor_detail_name" + android:layout_width="200dp" + android:layout_height="wrap_content" + android:layout_alignLeft="@+id/actor_detail_biography" + android:layout_alignParentTop="true" + android:layout_alignStart="@+id/actor_detail_biography" + android:layout_marginTop="15dp" + android:text="TextView" + android:textStyle="bold" /> + + <TextView + android:id="@+id/actor_detail_biography" + android:layout_width="200dp" + android:layout_height="wrap_content" + android:layout_alignBottom="@+id/actor_detail_placeofbirth" + android:layout_alignParentEnd="true" + android:layout_alignParentRight="true" + android:layout_below="@+id/actor_detail_name" + android:layout_marginEnd="16dp" + android:layout_marginRight="16dp" + android:layout_marginTop="13dp" + android:text="TextView" /> + + <TextView + android:id="@+id/actor_detail_homepage" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignEnd="@+id/actor_detail_placeofbirth" + android:layout_alignLeft="@+id/actor_detail_placeofbirth" + android:layout_alignRight="@+id/actor_detail_placeofbirth" + android:layout_alignStart="@+id/actor_detail_placeofbirth" + android:layout_below="@+id/actor_detail_placeofbirth" + android:text="TextView" /> + + </RelativeLayout> + + <FrameLayout + android:id="@+id/actor_detail_movielist" + android:layout_width="match_parent" + android:layout_height="300dp" + android:layout_marginLeft="15dp" + android:layout_marginRight="15dp" + android:layout_marginTop="15dp"> + + </FrameLayout> + </LinearLayout> +</ScrollView> \ No newline at end of file diff --git a/app/src/main/res/layout/custom_actor_movielist_fragment.xml b/app/src/main/res/layout/custom_actor_movielist_fragment.xml new file mode 100644 index 0000000000000000000000000000000000000000..bf12e0c98f6e8c50c79eae346bf0ca3ce2ee3cb1 --- /dev/null +++ b/app/src/main/res/layout/custom_actor_movielist_fragment.xml @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:orientation="vertical" android:layout_width="match_parent" + android:layout_height="match_parent"> + + <ImageView + android:id="@+id/custom_actor_movielist_poster" + android:layout_width="100dp" + android:layout_height="100dp" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_alignParentTop="true" + app:srcCompat="@mipmap/ic_launcher" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="100dp" + android:layout_alignParentTop="true" + android:layout_toEndOf="@+id/custom_actor_movielist_poster" + android:layout_toRightOf="@+id/custom_actor_movielist_poster" + android:orientation="vertical"> + + <TextView + android:id="@+id/custom_actor_movielist_character" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_toEndOf="@+id/custom_actor_movielist_poster" + android:layout_toRightOf="@+id/custom_actor_movielist_poster" + android:text="TextView" + android:layout_weight="1"/> + + <TextView + android:id="@+id/custom_actor_movielist_title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@+id/custom_actor_movielist_character" + android:layout_toEndOf="@+id/custom_actor_movielist_poster" + android:layout_toRightOf="@+id/custom_actor_movielist_poster" + android:text="TextView" + android:layout_weight="1"/> + + <TextView + android:id="@+id/custom_actor_movielist_vote_average" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@+id/custom_actor_movielist_title" + android:layout_toEndOf="@+id/custom_actor_movielist_poster" + android:layout_toRightOf="@+id/custom_actor_movielist_poster" + android:text="TextView" + android:layout_weight="1"/> + + <TextView + android:id="@+id/custom_actor_movielist_release_date" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@+id/custom_actor_movielist_vote_average" + android:layout_toEndOf="@+id/custom_actor_movielist_poster" + android:layout_toRightOf="@+id/custom_actor_movielist_poster" + android:text="TextView" + android:layout_weight="1"/> + </LinearLayout> + +</RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/detailed_movie_fragment.xml b/app/src/main/res/layout/detailed_movie_fragment.xml index 4f61e29c6c550913dd594c42a1bd0b63e008cc68..9ace04112610698fb17a7ce2f6f7b65ace6f27ee 100644 --- a/app/src/main/res/layout/detailed_movie_fragment.xml +++ b/app/src/main/res/layout/detailed_movie_fragment.xml @@ -1,149 +1,187 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/holo_purple" android:orientation="vertical" - android:theme="@style/ThemeOverlay.AppCompat.Dark"> + android:theme="@style/ThemeOverlay.AppCompat.Dark" + android:nestedScrollingEnabled="false" + android:overScrollMode="never" + android:scrollbars="none" + android:id="@+id/detailed_movie_fragment_frame"> - <RelativeLayout + + <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout - android:id="@+id/linearLayout2" - android:layout_width="match_parent" - android:layout_height="100dp" - android:layout_alignEnd="@+id/linearLayout3" - android:layout_alignLeft="@+id/linearLayout3" - android:layout_alignRight="@+id/linearLayout3" - android:layout_alignStart="@+id/linearLayout3" - android:layout_below="@+id/linearLayout3" - android:layout_marginTop="10dp" - android:orientation="vertical"> - - - <TextView - android:id="@+id/textView3" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="Overview" /> - - <me.grantland.widget.AutofitTextView - android:id="@+id/overview" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:maxLines="5" - android:text="TextView" /> - </LinearLayout> - - <TextView - android:id="@+id/tagline" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_alignParentStart="true" - android:layout_alignParentTop="true" - android:layout_marginLeft="15dp" - android:text="TextView" /> - - <LinearLayout - android:id="@+id/linearLayout3" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_alignEnd="@+id/linearLayout" - android:layout_alignLeft="@+id/main_poster" - android:layout_alignRight="@+id/linearLayout" - android:layout_alignStart="@+id/main_poster" - android:layout_centerVertical="true" - android:orientation="vertical"> + android:orientation="vertical" + android:id="@+id/scrollViewLinearLayout"> - - <TextView - android:id="@+id/textView10" + <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="Production Companies" /> - - <me.grantland.widget.AutofitTextView - android:id="@+id/production_companies" + android:orientation="vertical"> + + <TextView + android:id="@+id/tagline" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_alignParentTop="true" + android:layout_marginLeft="15dp" + android:text="TextView" /> + + <ImageView + android:id="@+id/banner_image" + android:layout_width="match_parent" + android:layout_height="150dp" + android:layout_below="@+id/tagline" + android:layout_centerHorizontal="true" + app:srcCompat="@mipmap/ic_launcher" /> + + <ImageView + android:id="@+id/main_poster" + android:layout_width="100dp" + android:layout_height="150dp" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_alignParentTop="true" + android:layout_marginLeft="15dp" + android:layout_marginTop="100dp" + app:srcCompat="@mipmap/ic_launcher" /> + + <LinearLayout + android:id="@+id/linearLayout2" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@+id/main_poster" + android:layout_marginLeft="15dp" + android:layout_marginRight="15dp" + android:layout_marginTop="10dp" + android:orientation="vertical"> + + <TextView + android:id="@+id/textView3" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Overview" /> + + <me.grantland.widget.AutofitTextView + android:id="@+id/overview" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:maxLines="5" + android:text="TextView" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/linearLayout" + android:layout_width="match_parent" + android:layout_height="100dp" + android:layout_alignBottom="@+id/main_poster" + android:layout_below="@+id/banner_image" + android:layout_marginLeft="15dp" + android:layout_marginRight="15dp" + android:layout_toEndOf="@+id/main_poster" + android:layout_toRightOf="@+id/main_poster" + android:orientation="vertical"> + + <RatingBar + android:id="@+id/rating_bar" + style="?android:attr/ratingBarStyleSmall" + android:layout_width="wrap_content" + android:layout_height="20dp" + android:isIndicator="true" + android:numStars="5" + android:rating="5" /> + + <me.grantland.widget.AutofitTextView + android:id="@+id/detail_title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:maxLines="1" + android:text="TextView" + android:textSize="30sp" /> + + <me.grantland.widget.AutofitTextView + android:id="@+id/detail_genre" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:maxLines="1" + android:text="TextView" + app:sizeToFit="true" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/linearLayout3" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_below="@+id/linearLayout2" + android:layout_marginLeft="15dp" + android:layout_marginRight="15dp" + android:layout_marginTop="10dp" + android:orientation="vertical"> + + <TextView + android:id="@+id/textView10" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Production Companies" /> + + <me.grantland.widget.AutofitTextView + android:id="@+id/production_companies" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:maxLines="2" + android:text="TextView" /> + </LinearLayout> + + </RelativeLayout> + + <FrameLayout + android:id="@+id/detailed_recommended_frame" android:layout_width="match_parent" - android:layout_height="match_parent" - android:maxLines="2" - android:text="TextView" /> - </LinearLayout> - - <LinearLayout - android:id="@+id/linearLayout" - android:layout_width="match_parent" - android:layout_height="100dp" - android:layout_alignBottom="@+id/main_poster" - android:layout_below="@+id/banner_image" - android:layout_marginLeft="15dp" - android:layout_marginRight="15dp" - android:layout_toEndOf="@+id/main_poster" - android:layout_toRightOf="@+id/main_poster" - android:orientation="vertical"> - - <RatingBar - android:id="@+id/rating_bar" - style="?android:attr/ratingBarStyleSmall" - android:layout_width="wrap_content" - android:layout_height="20dp" - android:isIndicator="true" - android:numStars="5" - android:rating="5" /> - - <me.grantland.widget.AutofitTextView - android:id="@+id/detail_title" + android:layout_height="500dp" + android:layout_alignEnd="@+id/linearLayout2" + android:layout_alignLeft="@+id/linearLayout2" + android:layout_alignParentBottom="true" + android:layout_alignRight="@+id/linearLayout2" + android:layout_alignStart="@+id/linearLayout2" + android:layout_below="@+id/linearLayout2" + android:orientation="horizontal" + android:layout_marginTop="10dp" + android:layout_marginLeft="15dp" + android:layout_marginRight="15dp"></FrameLayout> + + <FrameLayout + android:id="@+id/actor_frame" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:maxLines="1" - android:text="TextView" - android:textSize="30sp" /> + android:layout_height="500dp" + android:layout_alignEnd="@+id/linearLayout2" + android:layout_alignLeft="@+id/linearLayout2" + android:layout_alignParentBottom="true" + android:layout_alignRight="@+id/linearLayout2" + android:layout_alignStart="@+id/linearLayout2" + android:layout_below="@+id/linearLayout2" + android:orientation="horizontal" + android:layout_marginTop="20dp" + android:layout_marginLeft="15dp" + android:layout_marginRight="15dp"></FrameLayout> - <me.grantland.widget.AutofitTextView - android:id="@+id/detail_genre" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:maxLines="1" - android:text="TextView" - app:sizeToFit="true" /> </LinearLayout> - <ImageView - android:id="@+id/banner_image" - android:layout_width="match_parent" - android:layout_height="150dp" - android:layout_below="@+id/tagline" - android:layout_centerHorizontal="true" - app:srcCompat="@mipmap/ic_launcher" /> - - <ImageView - android:id="@+id/main_poster" - android:layout_width="100dp" - android:layout_height="150dp" - android:layout_alignParentLeft="true" - android:layout_alignParentStart="true" - android:layout_alignParentTop="true" - android:layout_marginLeft="15dp" - android:layout_marginTop="100dp" - app:srcCompat="@mipmap/ic_launcher" /> - - <FrameLayout - android:id="@+id/detailed_recommended_frame" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="horizontal" - android:layout_alignLeft="@+id/linearLayout2" - android:layout_alignStart="@+id/linearLayout2" - android:layout_alignRight="@+id/linearLayout2" - android:layout_alignEnd="@+id/linearLayout2" - android:layout_below="@+id/linearLayout2" - android:layout_alignParentBottom="true"></FrameLayout> - - </RelativeLayout> - -</RelativeLayout> \ No newline at end of file + + </ScrollView> + +</LinearLayout> \ No newline at end of file diff --git a/app/src/test/java/com/example/junwon/finalproject/ExampleUnitTest.java b/app/src/test/java/com/example/junwon/finalproject/ExampleUnitTest.java index dda6bad91ac662649e4f0e12b3a5de2662889e6e..40428ebbf9078d35cff24e6cb13cbf11bad02441 100644 --- a/app/src/test/java/com/example/junwon/finalproject/ExampleUnitTest.java +++ b/app/src/test/java/com/example/junwon/finalproject/ExampleUnitTest.java @@ -23,6 +23,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import static junit.framework.TestCase.assertEquals; + /** * Example local unit test, which will execute on the development machine (host). * @@ -148,4 +150,22 @@ public class ExampleUnitTest { System.out.println("doRecentWork: " + "Integer" + map2.get("b")); } } + + @Test + public void testActorDataInfo() { + String body = HttpRequest.get("http://api.themoviedb.org/3/movie/49521/casts", true, "api_key", api_key).body(); + System.out.println(body); + } + + @Test + public void testCharacterDataInfo() { + String body = HttpRequest.get("https://api.themoviedb.org/3/person/73968/movie_credits", true, "api_key", api_key).body(); + System.out.println(body); + } + + @Test + public void testActorDetailInfo() { + String body = HttpRequest.get("https://api.themoviedb.org/3/person/73968", true, "api_key", api_key).body(); + System.out.println(body); + } } \ No newline at end of file diff --git a/manual testplan.docx b/manual testplan.docx index c584f80b5a79ae8c0d3eee3cda9238d153c31570..b867de0080cd911229371d3d9561c73f765f8ab3 100644 Binary files a/manual testplan.docx and b/manual testplan.docx differ diff --git a/rubric.docx b/rubric.docx index ba2dcd97e6eead5d7679ef101e640652736ff75e..901323b74dfd79e581c84774b3e2421d86e9f340 100644 Binary files a/rubric.docx and b/rubric.docx differ