Ejemplo n.º 1
0
 /** Create a string, holding all movie records. */
 private String buildFileContents() {
   String NEW_LINE = System.getProperty("line.separator");
   StringBuilder result = new StringBuilder();
   for (Movie movie : fTable.values()) {
     appendTo(result, movie.getTitle(), DELIMITER);
     appendTo(result, movie.getDateViewed(), DELIMITER);
     appendTo(result, movie.getRating(), DELIMITER);
     appendTo(result, movie.getComment(), NEW_LINE);
   }
   return result.toString();
 }
Ejemplo n.º 2
0
  public void editMovie(int mID, String mTitle) {
    LinearLayout viewGroup = (LinearLayout) findViewById(R.id.popupLinearLayout);
    LayoutInflater layoutInflater =
        (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    editMovieLayout = layoutInflater.inflate(R.layout.edit_movie, viewGroup);

    selectedMovie = db.getMovie(mID);

    int popupDimensions = WindowManager.LayoutParams.MATCH_PARENT;

    TextView mName = (TextView) editMovieLayout.findViewById(R.id.editMovieName);
    mName.setText(mTitle);

    final RatingBar mRating = (RatingBar) editMovieLayout.findViewById(R.id.editRating);
    mRating.setRating(selectedMovie.getRating());

    // Creating the PopupWindow
    final PopupWindow popup = new PopupWindow();
    popup.setContentView(editMovieLayout);
    popup.setWidth(popupDimensions);
    popup.setHeight(popupDimensions);
    popup.setFocusable(true);
    // popup.setAnimationStyle(R.style.PopupWindowAnimation);

    // Displaying the popup at the specified location, + offsets.
    popup.showAtLocation(editMovieLayout, Gravity.CENTER, 0, 0);

    ImageButton close = (ImageButton) editMovieLayout.findViewById(R.id.close);
    close.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            popup.dismiss();
          }
        });

    Button save = (Button) editMovieLayout.findViewById(R.id.saveMovieButton);
    save.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            selectedMovie.setRating(mRating.getRating());
            db.updateMovie(selectedMovie);
            try {
              populateMyMovies(lv);
            } catch (ParseException e) {
              e.printStackTrace();
            }
            popup.dismiss();
          }
        });
  }
Ejemplo n.º 3
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;
    holder = new ViewHolder();
    if (view == null) {
      LayoutInflater vi =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      view = vi.inflate(R.layout.movie_item, parent, false);
      holder.poster = (ImageView) view.findViewById(R.id.poster);
      holder.title = (TextView) view.findViewById(R.id.title);
      holder.rating = (TextView) view.findViewById(R.id.rating);
      holder.critics_consensus = (TextView) view.findViewById(R.id.critics_consensus);
      holder.release_date = (TextView) view.findViewById(R.id.release_date);
      holder.rated = (TextView) view.findViewById(R.id.rated);
      holder.synopsis = (TextView) view.findViewById(R.id.synopsis);
      holder.year = (TextView) view.findViewById(R.id.year);
      holder.runtime = (TextView) view.findViewById(R.id.runtime);
      view.setTag(holder);
    } else {
      holder = (ViewHolder) view.getTag();
    }
    Movie movie = movieData.get(position);
    if (movie != null) {

      Typeface typeface =
          Typeface.createFromAsset(getContext().getAssets(), "fonts/robotocondensed-bold.ttf");
      holder.rating.setTypeface(typeface);
      holder.rating.setText("Rating: " + movie.getRating());
      holder.title.setText("Title: " + movie.getTitle());
      holder.title.setTag(movie.getTitle());
      Log.i("TAG", "" + holder.title.getTag());
      holder.poster.setImageBitmap(null);
      holder.critics_consensus.setText("consensus: " + movie.getCritics_consensus());
      holder.release_date.setText("date: " + movie.getRelease_date());
      holder.rated.setText("rated: " + movie.getRated());
      holder.synopsis.setText("synopsis: " + movie.getSynopsis());
      holder.year.setText("year: " + movie.getYear());
      holder.runtime.setText("runtime: " + movie.getRuntime());
      if (!movie.getPoster().equals("not found")) {
        new DownloadTask(holder, movie, manage).execute(movie.getPoster());
      }
    }
    return view;
  }
Ejemplo n.º 4
0
 private static void getSQL(ArrayList<Movie> movies) {
   for (Movie m : movies) {
     System.out.println(
         "\nINSERT INTO \"ADMIN\".\"movie\" (\"title\", \"poster_link\", \"trailer_link\", \"rating\", \"actors\", \"genre\", \"description\", \"release_year\")\n"
             + "    VALUES ('"
             + m.getMovieName()
             + "',\n '"
             + m.getPosterLink()
             + "',\n '"
             + m.getTrailerLink()
             + "',\n "
             + m.getRating()
             + ",\n '"
             + m.getActors()
             + "',\n "
             + "(SELECT \"genre\".\"id\" FROM \"genre\" WHERE \"genre\".\"title\"='"
             + m.getGenre()
             + "'),\n '"
             + m.getMovieDescription()
             + "',\n '"
             + m.getMovieYear()
             + "');");
   }
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Bundle arguments = getArguments();
    if (arguments != null) {
      mMovie = arguments.getParcelable(DetailActivityFragment.DETAIL_MOVIE);
    }

    View rootView = inflater.inflate(R.layout.fragment_detail, container, false);

    mDetailLayout = (ScrollView) rootView.findViewById(R.id.detail_layout);

    if (mMovie != null) {
      mDetailLayout.setVisibility(View.VISIBLE);
    } else {
      mDetailLayout.setVisibility(View.INVISIBLE);
    }

    mImageView = (ImageView) rootView.findViewById(R.id.detail_image);

    mTitleView = (TextView) rootView.findViewById(R.id.detail_title);
    mOverviewView = (TextView) rootView.findViewById(R.id.detail_overview);
    mDateView = (TextView) rootView.findViewById(R.id.detail_date);
    mVoteAverageView = (TextView) rootView.findViewById(R.id.detail_vote_average);

    mTrailersView = (LinearListView) rootView.findViewById(R.id.detail_trailers);
    mReviewsView = (LinearListView) rootView.findViewById(R.id.detail_reviews);

    mReviewsCardview = (CardView) rootView.findViewById(R.id.detail_reviews_cardview);
    mTrailersCardview = (CardView) rootView.findViewById(R.id.detail_trailers_cardview);

    mTrailerAdapter = new TrailerAdapter(getActivity(), new ArrayList<Trailer>());
    mTrailersView.setAdapter(mTrailerAdapter);

    mTrailersView.setOnItemClickListener(
        new LinearListView.OnItemClickListener() {
          @Override
          public void onItemClick(LinearListView linearListView, View view, int position, long id) {
            Trailer trailer = mTrailerAdapter.getItem(position);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("http://www.youtube.com/watch?v=" + trailer.getKey()));
            startActivity(intent);
          }
        });

    mReviewAdapter = new ReviewAdapter(getActivity(), new ArrayList<Review>());
    mReviewsView.setAdapter(mReviewAdapter);

    if (mMovie != null) {

      String image_url = Utility.buildImageUrl(mMovie.getImage2());

      Glide.with(this).load(image_url).into(mImageView);

      mTitleView.setText(mMovie.getTitle());
      mOverviewView.setText(mMovie.getOverview());

      String movie_date = mMovie.getDate();

      SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
      try {
        String date =
            DateUtils.formatDateTime(
                getActivity(),
                formatter.parse(movie_date).getTime(),
                DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR);
        mDateView.setText(date);
      } catch (ParseException e) {
        e.printStackTrace();
      }

      mVoteAverageView.setText(Integer.toString(mMovie.getRating()));
    }

    return rootView;
  }
Ejemplo n.º 6
0
  private void populateMyMovies(ListView tLV) throws ParseException {
    List<Movie> movies = db.getAllMovies(sortStr, sortDir);

    List<Map<String, String>> list = new ArrayList<Map<String, String>>();

    if (movies.size() < 1) {

      toastMessage(MainActivity.this, getString(R.string.no_movie_notice));

    } else {

      for (Movie i : movies) {
        Map map = new HashMap();
        map.put("id", i.getId());
        map.put("title", i.getTitle());

        String target = i.getDateStr();
        DateFormat df = new SimpleDateFormat("EEE MMM dd kk:mm:ss z yyyy", Locale.ENGLISH);
        DateFormat newf = new SimpleDateFormat("EEE, MMM d, yyyy", Locale.ENGLISH);
        Date mDate = df.parse(target);
        String newDate = newf.format(mDate);

        map.put("date", newDate);
        map.put("rating", i.getRating());
        map.put("lat", String.valueOf(i.getVenue().getLat()));
        map.put("lng", String.valueOf(i.getVenue().getLng()));
        map.put("type", i.getVenue().getVenue_type());
        map.put("venue_name", i.getVenue().getVenue_name());
        list.add(map);
      }

      movieAdapter =
          new SimpleAdapter(
              this,
              list,
              R.layout.my_movies_layout,
              new String[] {"title", "date", "rating", "type"},
              new int[] {
                R.id.my_movie_title, R.id.my_movie_date, R.id.my_movie_rating, R.id.my_movie_icon
              });
      movieAdapter.setViewBinder(new MyMovieBinder());
      tLV.setAdapter(movieAdapter);
      tLV.setLongClickable(true);

      tLV.setOnItemClickListener(
          new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              Map item = (Map) parent.getAdapter().getItem(position);
              LatLng latlong =
                  new LatLng(
                      Double.valueOf(item.get("lat").toString()),
                      Double.valueOf(item.get("lng").toString()));

              mMap.clear();
              Marker marker =
                  mMap.addMarker(
                      new MarkerOptions()
                          .position(latlong)
                          .title(item.get("title").toString())
                          .snippet(item.get("venue_name").toString()));

              // Zoom in, animating the camera.
              mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latlong, 13), 800, null);
              marker.showInfoWindow();
            }
          });
    }
  }