private void fetch() { final String title = mActor != null ? mActor.name + " - " : mGenre != null ? mGenre.name + " - " : "" + "Movies"; DataResponse<ArrayList<Movie>> response = new DataResponse<ArrayList<Movie>>() { public void run() { if (value.size() > 0) { setTitle(title + " (" + value.size() + ")"); mList.setAdapter(new MovieAdapter(mActivity, value)); } else { setTitle(title); setNoDataMessage("No movies found.", R.drawable.icon_movie_dark); } } }; showOnLoading(); setTitle(title + "..."); if (mActor != null) { // movies with a certain actor mVideoManager.getMovies(response, mActor, mActivity.getApplicationContext()); } else if (mGenre != null) { // movies of a genre mVideoManager.getMovies(response, mGenre, mActivity.getApplicationContext()); } else { // all movies mVideoManager.getMovies(response, mActivity.getApplicationContext()); } }
public void onActivityPause() { if (mVideoManager != null) { mVideoManager.setController(null); mVideoManager.postActivity(); } if (mControlManager != null) { mControlManager.setController(null); } super.onActivityPause(); }
public void onActivityResume(Activity activity) { super.onActivityResume(activity); if (mVideoManager != null) { mVideoManager.setController(this); } if (mControlManager != null) { mControlManager.setController(this); } }
public void onActivityPause() { if (mVideoManager != null) { mVideoManager.setController(null); } if (mTvShowManager != null) { mTvShowManager.setController(null); } super.onActivityPause(); }
public void loadCover(final JewelView jewelView) { mVideoManager.getCover( new DataResponse<Bitmap>() { public void run() { if (value != null) { jewelView.setCover(value); } } }, mMovie, ThumbSize.BIG, null, mActivity.getApplicationContext(), false); }
public void onActivityPause() { mVideoManager.setController(null); mVideoManager.postActivity(); mControlManager.setController(null); }
public void updateMovieDetails( final Handler handler, final TextView numVotesView, final TextView studioView, final TextView plotView, final TextView parentalView, final Button trailerButton, final LinearLayout dataLayout) { mVideoManager.updateMovieDetails( new DataResponse<Movie>() { public void run() { final Movie movie = value; if (movie == null) { Log.w(TAG, "updateMovieDetails: value is null."); return; } numVotesView.setText(movie.numVotes > 0 ? " (" + movie.numVotes + " votes)" : ""); studioView.setText( movie.studio.size() == 0 ? NO_DATA : StringUtil.join(", ", movie.studio)); plotView.setText(movie.plot.equals("") ? NO_DATA : movie.plot); parentalView.setText(movie.rated.equals("") ? NO_DATA : movie.rated); if (movie.trailerUrl != null && !movie.trailerUrl.equals("")) { trailerButton.setEnabled(true); trailerButton.setOnClickListener( new OnClickListener() { public void onClick(View v) { mControlManager.playFile( new DataResponse<Boolean>() { public void run() { if (value) { Toast toast = Toast.makeText( mActivity, "Playing trailer for \"" + movie.getName() + "\"...", Toast.LENGTH_LONG); toast.show(); } } }, movie.trailerUrl, mActivity.getApplicationContext()); } }); } if (movie.actors != null) { final LayoutInflater inflater = mActivity.getLayoutInflater(); // int n = 0; for (Actor actor : movie.actors) { final View view = inflater.inflate(R.layout.actor_item, null); ((TextView) view.findViewById(R.id.actor_name)).setText(actor.name); ((TextView) view.findViewById(R.id.actor_role)).setText("as " + actor.role); ImageButton img = ((ImageButton) view.findViewById(R.id.actor_image)); mVideoManager.getCover( new DataResponse<Bitmap>() { public void run() { if (value != null) { handler.post( new Runnable() { public void run() { ((ImageButton) view.findViewById(R.id.actor_image)) .setImageBitmap(value); } }); } } }, actor, ThumbSize.SMALL, null, mActivity.getApplicationContext(), false); img.setTag(actor); img.setOnClickListener( new OnClickListener() { public void onClick(View v) { Intent nextActivity; Actor actor = (Actor) v.getTag(); nextActivity = new Intent(view.getContext(), ListActivity.class); nextActivity.putExtra( ListController.EXTRA_LIST_CONTROLLER, new MovieListController()); nextActivity.putExtra(ListController.EXTRA_ACTOR, actor); mActivity.startActivity(nextActivity); } }); img.setOnCreateContextMenuListener( new OnCreateContextMenuListener() { public void onCreateContextMenu( ContextMenu menu, View v, ContextMenuInfo menuInfo) { selectedAcotr = (Actor) v.getTag(); selectedView = v; menu.setHeaderTitle(selectedAcotr.getShortName()); menu.add(0, CAST_CONTEXT_IMDB, 1, "Open IMDb") .setOnMenuItemClickListener( new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { Intent intentIMDb = new Intent( Intent.ACTION_VIEW, Uri.parse( "imdb:///find?s=nm&q=" + selectedAcotr.getName())); if (selectedView .getContext() .getPackageManager() .resolveActivity( intentIMDb, PackageManager.MATCH_DEFAULT_ONLY) == null) { intentIMDb = new Intent( Intent.ACTION_VIEW, Uri.parse( "http://www.imdb.com/find?s=nm&q=" + selectedAcotr.getName())); } selectedView.getContext().startActivity(intentIMDb); return false; } }); } }); dataLayout.addView(view); // n++; } } } }, mMovie, mActivity.getApplicationContext()); }
public void onCreate(Activity activity, Handler handler, AbsListView list) { mVideoManager = ManagerFactory.getVideoManager(this); mTvShowManager = ManagerFactory.getTvManager(this); if (!isCreated()) { super.onCreate(activity, handler, list); final String sdError = ImportUtilities.assertSdCard(); mLoadCovers = sdError == null; if (!mLoadCovers) { Toast toast = Toast.makeText( activity, sdError + " Displaying place holders only.", Toast.LENGTH_LONG); toast.show(); } mFallbackBitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.person_black_small); setupIdleListener(); final String title = mType == TYPE_MOVIE ? "Movie " : mType == TYPE_TVSHOW ? "TV " : "" + "Actors"; DataResponse<ArrayList<Actor>> response = new DataResponse<ArrayList<Actor>>() { @SuppressLint("") public void run() { if (value.size() > 0) { setTitle(title + " (" + value.size() + ")"); ((ListView) mList).setAdapter(new ActorAdapter(mActivity, value)); } else { setTitle(title); setNoDataMessage("No actors found.", R.drawable.icon_artist_dark); } } }; mList.setOnKeyListener(new ListControllerOnKeyListener<Artist>()); showOnLoading(); setTitle(title + "..."); switch (mType) { case TYPE_MOVIE: mVideoManager.getMovieActors(response, mActivity.getApplicationContext()); break; case TYPE_TVSHOW: mTvShowManager.getTvShowActors(response, mActivity.getApplicationContext()); break; case TYPE_EPISODE: break; } mList.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (isLoading()) return; Intent nextActivity; final Actor actor = (Actor) mList.getAdapter().getItem(((OneLabelItemView) view).position); nextActivity = new Intent(view.getContext(), ListActivity.class); if (mType == TYPE_TVSHOW) nextActivity.putExtra( ListController.EXTRA_LIST_CONTROLLER, new TvShowListController()); else nextActivity.putExtra( ListController.EXTRA_LIST_CONTROLLER, new MovieListController()); nextActivity.putExtra(ListController.EXTRA_ACTOR, actor); mActivity.startActivity(nextActivity); } }); } }