/**
  * @param mContext
  * @param genre_id
  * @param default_name
  * @return genre name
  */
 public static String getGenreName(Context mContext, long genre_id, boolean default_name) {
   String where = BaseColumns._ID + "=" + genre_id;
   String[] cols = new String[] {GenresColumns.NAME};
   Uri uri = Genres.EXTERNAL_CONTENT_URI;
   Cursor cursor = mContext.getContentResolver().query(uri, cols, where, null, null);
   if (cursor == null) {
     return MediaStore.UNKNOWN_STRING;
   }
   if (cursor.getCount() <= 0) {
     if (default_name) return mContext.getString(R.string.unknown);
     else return MediaStore.UNKNOWN_STRING;
   } else {
     cursor.moveToFirst();
     String name = cursor.getString(0);
     cursor.close();
     if (name == null || MediaStore.UNKNOWN_STRING.equals(name)) {
       if (default_name) return mContext.getString(R.string.unknown);
       else return MediaStore.UNKNOWN_STRING;
     }
     return name;
   }
 }
  static void updateNowPlaying(Activity a) {
    View nowPlayingView = a.findViewById(R.id.nowplaying);
    if (nowPlayingView == null) {
      return;
    }
    try {
      boolean withtabs = false;
      Intent intent = a.getIntent();
      if (intent != null) {
        withtabs = intent.getBooleanExtra("withtabs", false);
      }
      if (true && MusicUtils.sService != null && MusicUtils.sService.getAudioId() != -1) {
        TextView title = (TextView) nowPlayingView.findViewById(R.id.title);
        TextView artist = (TextView) nowPlayingView.findViewById(R.id.artist);
        title.setText(MusicUtils.sService.getTrackName());
        String artistName = MusicUtils.sService.getArtistName();
        if (MediaStore.UNKNOWN_STRING.equals(artistName)) {
          artistName = a.getString(R.string.unknown_artist_name);
        }
        artist.setText(artistName);
        // mNowPlayingView.setOnFocusChangeListener(mFocuser);
        // mNowPlayingView.setOnClickListener(this);
        nowPlayingView.setVisibility(View.VISIBLE);
        nowPlayingView.setOnClickListener(
            new View.OnClickListener() {

              public void onClick(View v) {
                Context c = v.getContext();
                c.startActivity(new Intent(c, MediaPlaybackActivity.class));
              }
            });
        return;
      }
    } catch (RemoteException ex) {
    }
    nowPlayingView.setVisibility(View.GONE);
  }
Exemple #3
0
 public static boolean isUnknownArtist(final TrackInfo info) {
   if (info == null) return true;
   return TextUtils.isEmpty(info.artist) || MediaStore.UNKNOWN_STRING.equals(info.artist);
 }
Exemple #4
0
 public static boolean isUnknownAlbum(final AlbumInfo info) {
   if (info == null) return true;
   return TextUtils.isEmpty(info.album) || MediaStore.UNKNOWN_STRING.equals(info.album);
 }