コード例 #1
0
 protected Intent setupPlayIntent(SongRecord songRecord) {
   Intent intent = new Intent(getActivity(), PlayActivity.class);
   intent.putExtra(SONG_NAME, songRecord.getName());
   intent.putExtra(SONG_FILE, songRecord.getAddress());
   intent.putExtra(COVER_FILE, songRecord.getCover());
   intent.putExtra(SINGER, songRecord.getSinger());
   intent.putExtra(GENRE, songRecord.getGenre());
   intent.putExtra(LENGTH, songRecord.getLength());
   intent.putExtra(SOURCE, getActivity().getClass().getName());
   Logger.log(getActivity().getClass().getSimpleName(), 0);
   return intent;
 }
コード例 #2
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      if (convertView == null) {
        convertView = getActivity().getLayoutInflater().inflate(R.layout.song_item_fragment, null);
      }

      final SongRecord sr = getItem(position);
      final int sid = sr.getSid();

      TextView songNameView = (TextView) convertView.findViewById(R.id.item_name);
      songNameView.setText(sr.getName());

      TextView artistView = (TextView) convertView.findViewById(R.id.artist_name);
      artistView.setText(sr.getSinger());

      convertView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              // go to the play page of clicked song
              if (SongLab.get(getActivity()).readSong(sid) != null) {
                // song found in local, play it
                Intent intent = setupPlayIntent(sr);
                getActivity().startActivity(intent);
              } else {
                // song not found
                songNotFoundHandling(sr);
              }
            }
          });

      Button deleteButton = (Button) convertView.findViewById(R.id.delete_item_button);
      setupDeleteButton(deleteButton, sid);

      return convertView;
    }