Exemplo n.º 1
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      LayoutInflater vi =
          (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = vi.inflate(R.layout.episode_item, null);
    }

    Show show = getItem(position);
    if (show != null) {
      // Show title
      TextView title = (TextView) convertView.findViewById(R.id.show_title);
      if (title != null) {
        title.setText(show.getName());
      }

      // Last episode
      TextView last = (TextView) convertView.findViewById(R.id.last_ep);
      if (last != null) last.setText(Html.fromHtml("<b>Previous:</b> " + show.getLastEpisode()));

      // Next episode
      TextView next = (TextView) convertView.findViewById(R.id.next_ep);
      if (next != null) next.setText(Html.fromHtml("<b>Next:</b> " + show.getNextEpisode()));
    }
    return convertView;
  }
Exemplo n.º 2
0
 /**
  * Launches corresponding activity that was selected from the menu options.
  *
  * @param item menu item that was clicked
  * @return true if menu action was successful, false otherwise
  */
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case 0: // Remove show
       if (FavoriteShows.instance().deleteShow(s.getShowid()))
         Toast.makeText(getApplicationContext(), "Show removed!", Toast.LENGTH_SHORT).show();
       else
         Toast.makeText(
                 getApplicationContext(),
                 "Unable to remove show. Try again :(",
                 Toast.LENGTH_SHORT)
             .show();
       isTracked = false;
       return true;
     case 1: // Add show
       if (FavoriteShows.instance().addShow(s))
         Toast.makeText(getApplicationContext(), "Show added!", Toast.LENGTH_SHORT).show();
       else
         Toast.makeText(
                 getApplicationContext(), "Unable to add show. Try again :(", Toast.LENGTH_SHORT)
             .show();
       isTracked = true;
       return true;
     case 2: // Launch TVRage
       startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(s.getShowlink())));
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Exemplo n.º 3
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    List<Show> favShows = FavoriteShows.instance().getAll();

    if (!favShows.isEmpty()) {
      for (Show sho : favShows) {
        if (sho.getShowid().equals(this.s.getShowid())) {
          isTracked = true;
        }
      }
    }

    menu.add(0, 0, 0, "Remove show").setIcon(R.drawable.ic_menu_delete).setVisible(isTracked);
    menu.add(0, 1, 0, "Add show").setIcon(R.drawable.ic_menu_add).setVisible(!isTracked);
    menu.add(0, 2, 1, "View on TVRage").setIcon(R.drawable.ic_menu_browse);

    return true;
  }
Exemplo n.º 4
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Retrieve course object and associated semester.
    s = (Show) getIntent().getExtras().getSerializable("show");
    setContentView(R.layout.show);

    // Show details
    TextView showName = (TextView) findViewById(R.id.show_name);
    showName.setText(s.getName());

    TableLayout details = (TableLayout) findViewById(R.id.info_table);
    TextView classification = (TextView) details.findViewById(R.id.classi);
    classification.setText(s.getClassification());

    TextView genres = (TextView) details.findViewById(R.id.genres);
    genres.setText(s.getGenreString());

    TextView airs = (TextView) details.findViewById(R.id.airs);
    airs.setText(s.getAirInfo());

    TextView runtime = (TextView) details.findViewById(R.id.runtime);
    runtime.setText(s.getRuntime() + " min");

    // Episodes
    TableLayout eps = (TableLayout) findViewById(R.id.ep_table);
    TextView last = (TextView) eps.findViewById(R.id.lastEp);
    last.setText(s.getLastEpisode());

    TextView next = (TextView) eps.findViewById(R.id.nextEp);
    next.setText(s.getNextEpisode());

    ExpandableListView seas = (ExpandableListView) findViewById(R.id.season_list);
    mAdapter = new SeasonListAdapter();
    seas.setAdapter(mAdapter);
    seas.setOnChildClickListener(
        new OnChildClickListener() {
          public boolean onChildClick(ExpandableListView parent, View v, int s, int e, long id) {
            Intent browse =
                new Intent(
                    Intent.ACTION_VIEW,
                    Uri.parse(((SeasonListAdapter) mAdapter).getChild(s, e).getLink()));
            startActivity(browse);
            return true;
          }
        });
  }
Exemplo n.º 5
0
 public void launchURL(View v) {
   Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(s.getShowlink()));
   startActivity(browse);
 }