public void onContextItemSelected(MenuItem item) {
   final Movie movie =
       (Movie)
           mList
               .getAdapter()
               .getItem(
                   ((FiveLabelsItemView) ((AdapterContextMenuInfo) item.getMenuInfo()).targetView)
                       .position);
   switch (item.getItemId()) {
     case ITEM_CONTEXT_PLAY:
       mControlManager.playFile(
           new DataResponse<Boolean>() {
             public void run() {
               if (value) {
                 mActivity.startActivity(new Intent(mActivity, NowPlayingActivity.class));
               }
             }
           },
           movie.getPath(),
           mActivity.getApplicationContext());
       break;
     case ITEM_CONTEXT_INFO:
       Intent nextActivity = new Intent(mActivity, MovieDetailsActivity.class);
       nextActivity.putExtra(ListController.EXTRA_MOVIE, movie);
       mActivity.startActivity(nextActivity);
       break;
     default:
       return;
   }
 }
Пример #2
0
 /**
  * Gets all movies from database
  *
  * @param sortBy Sort field, see SortType.*
  * @param sortOrder Sort order, must be either SortType.ASC or SortType.DESC.
  * @return Updated movie
  */
 public Movie updateMovieDetails(INotifiableManager manager, Movie movie) {
   StringBuilder sb = new StringBuilder();
   sb.append("SELECT c03, c01, c04, c18, c12, c19");
   sb.append(
       " FROM movie, files, path WHERE movie.idFile=files.idFile AND path.idPath=files.idPath AND movie.idmovie = ");
   sb.append(movie.getId());
   parseMovieDetails(mConnection.query("QueryVideoDatabase", sb.toString(), manager), movie);
   sb = new StringBuilder();
   sb.append("SELECT actors.idActor, strActor, strRole");
   sb.append(" FROM actors, actorlinkmovie");
   sb.append(" WHERE actors.idActor = actorlinkmovie.idActor");
   sb.append(" AND actorlinkmovie.idMovie =");
   sb.append(movie.getId());
   movie.actors = parseActorRoles(mConnection.query("QueryVideoDatabase", sb.toString(), manager));
   return movie;
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.moviedetails);

    // set display size
    final Display display = getWindowManager().getDefaultDisplay();
    ThumbSize.setScreenSize(display.getWidth(), display.getHeight());

    // remove nasty top fading edge
    FrameLayout topFrame = (FrameLayout) findViewById(android.R.id.content);
    topFrame.setForeground(null);

    final Movie movie = (Movie) getIntent().getSerializableExtra(ListController.EXTRA_MOVIE);
    mMovieDetailsController = new MovieDetailsController(this, movie);

    ((TextView) findViewById(R.id.titlebar_text)).setText(movie.getName());

    Log.i(
        "MovieDetailsActivity",
        "rating = " + movie.rating + ", index = " + ((int) Math.round(movie.rating % 10)) + ".");
    if (movie.rating > -1) {
      ((ImageView) findViewById(R.id.moviedetails_rating_stars))
          .setImageResource(sStarImages[(int) Math.round(movie.rating % 10)]);
    }
    ((TextView) findViewById(R.id.moviedetails_director))
        .setText(StringUtil.join(",  ", movie.director));
    ((TextView) findViewById(R.id.moviedetails_genre))
        .setText(StringUtil.join(" / ", movie.genres));
    ((TextView) findViewById(R.id.moviedetails_runtime)).setText(movie.runtime);
    ((TextView) findViewById(R.id.moviedetails_rating)).setText(String.valueOf(movie.rating));

    mMovieDetailsController.setupPlayButton((Button) findViewById(R.id.moviedetails_playbutton));
    mMovieDetailsController.loadCover((JewelView) findViewById(R.id.moviedetails_jewelcase));
    mMovieDetailsController.updateMovieDetails(
        new Handler(),
        (TextView) findViewById(R.id.moviedetails_rating_numvotes),
        (TextView) findViewById(R.id.moviedetails_studio),
        (TextView) findViewById(R.id.moviedetails_plot),
        (TextView) findViewById(R.id.moviedetails_parental),
        (Button) findViewById(R.id.moviedetails_trailerbutton),
        (LinearLayout) findViewById(R.id.moviedetails_datalayout));

    mConfigurationManager = ConfigurationManager.getInstance(this);
  }
Пример #4
0
 /**
  * Updates a movie object with some more details. Fields must be the following (in this order):
  *
  * <ol>
  *   <li><code>c03</code> (tagline)
  *   <li><code>c01</code> (plot)
  *   <li><code>c04</code> (number of votes)
  *   <li><code>c18</code> (studio)
  *   <li><code>c12</code> (parental rating)
  *   <li><code>c19</code> (trailer)
  * </ol>
  *
  * @param response
  * @param movie
  * @return Updated movie object
  */
 private Movie parseMovieDetails(String response, Movie movie) {
   String[] fields = response.split("<field>");
   try {
     movie.tagline = Connection.trim(fields[1]);
     movie.plot = Connection.trim(fields[2]);
     movie.numVotes = Connection.trimInt(fields[3]);
     movie.studio = Connection.trim(fields[4]);
     movie.rated = Connection.trim(fields[5]);
     movie.trailerUrl = Connection.trim(fields[6]);
   } catch (Exception e) {
     System.err.println("ERROR: " + e.getMessage());
     System.err.println("response = " + response);
     e.printStackTrace();
   }
   return movie;
 }
Пример #5
0
 /**
  * Returns a pre-resized movie cover. Pre-resizing is done in a way that the bitmap at least as
  * large as the specified size but not larger than the double.
  *
  * @param manager Postback manager
  * @param cover Cover object
  * @param size Minmal size to pre-resize to.
  * @return Thumbnail bitmap
  */
 public Bitmap getCover(INotifiableManager manager, ICoverArt cover, int size) {
   return getCover(
       manager, cover, size, Movie.getThumbUri(cover), Movie.getFallbackThumbUri(cover));
 }