If you think the Android project PlayerHater listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*******************************************************************************
* Copyright 2013 Chris Rhoden, Rebecca Nesson, Public Radio Exchange
* /*www.java2s.com*/
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/package org.prx.playerhater.songs;
import org.prx.playerhater.Song;
import android.net.Uri;
import android.os.Bundle;
publicclass Songs {
privatestaticfinal String TITLE = "title";
privatestaticfinal String ARTIST = "artist";
privatestaticfinal String ALBUM = "album";
privatestaticfinal String ALBUMART = "album_art";
privatestaticfinal String URI = "uri";
privatestaticfinal String EXTRA = "extra";
publicstatic Bundle toBundle(Song song) {
Bundle bundle = new Bundle();
bundle.putString(TITLE, song.getTitle());
bundle.putString(ARTIST, song.getArtist());
bundle.putString(ALBUM, song.getAlbumTitle());
bundle.putParcelable(ALBUMART, song.getAlbumArt());
bundle.putParcelable(URI, song.getUri());
bundle.putBundle(EXTRA, song.getExtra());
return bundle;
}
publicstatic Song fromBundle(Bundle bundle) {
returnnew UnbundledSong(bundle);
}
privatestaticclass UnbundledSong implements Song {
privatefinal String mTitle, mArtist, mAlbum;
privatefinal Uri mUri, mAlbumArt;
privatefinal Bundle mExtra;
public UnbundledSong(Bundle bundle) {
mTitle = bundle.getString(TITLE);
mArtist = bundle.getString(ARTIST);
mAlbum = bundle.getString(ALBUM);
mUri = bundle.getParcelable(URI);
mAlbumArt = bundle.getParcelable(ALBUMART);
mExtra = bundle.getBundle(EXTRA);
}
@Override
public String getTitle() {
return mTitle;
}
@Override
public String getArtist() {
return mArtist;
}
@Override
public String getAlbumTitle() {
return mAlbum;
}
@Override
public Uri getAlbumArt() {
return mAlbumArt;
}
@Override
public Uri getUri() {
return mUri;
}
@Override
public Bundle getExtra() {
return mExtra;
}
}
}