예제 #1
0
  private void loadBackGround() {
    Song song = CloudifyController.getInstance().currentSelection;

    if (song instanceof SpotifySong) {
      SpotifySong sSong = (SpotifySong) song;
      Picasso.with(getContext())
          .load(sSong.getTrack().getAlbum().getImages()[0].getUrl())
          .into(target);
    } else {
      Album album = CloudifyController.getInstance().getAlbum(song.albumId);
      Picasso.with(getContext()).load(album.getUri()).into(target);
    }
  }
예제 #2
0
  public class PlaceSlidesFragmentAdapter extends FragmentPagerAdapter
      implements IAlbumArtPagerAdapter {

    private int mCount = CloudifyController.getInstance().currentPlaylistSongs.size();

    public PlaceSlidesFragmentAdapter(FragmentManager fm) {
      super(fm);
    }

    @Override
    public Fragment getItem(int position) {
      AlbumArtSlideFragment frag = new AlbumArtSlideFragment();
      Bundle b = new Bundle();
      b.putInt("index", position);
      frag.setArguments(b);
      return frag;
    }

    @Override
    public int getCount() {
      return mCount;
    }

    @Override
    public int getIconResId(int index) {

      return CloudifyController.getInstance().currentPlaylistSongs.get(index).id;
    }
  }
예제 #3
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (vGroup == null) {
      vGroup = (ViewGroup) inflater.inflate(R.layout.fragment_media_player, null, false);
      ivBackGround = (ImageView) vGroup.findViewById(R.id.ivBackGround);
      vpAlbumArtPager = (ViewPager) vGroup.findViewById(R.id.vpAlbumArtPager);
      mSeekBar = (SeekBar) vGroup.findViewById(R.id.mSeekBar);
      lytMain = (RelativeLayout) vGroup.findViewById(R.id.lytMain);
      // ivAlbumArt = (ImageView) vGroup.findViewById(R.id.ivAlbumArt);
      tvSongName = (TextView) vGroup.findViewById(R.id.tvTitle);
      tvArtist = (TextView) vGroup.findViewById(R.id.tvArtist);
      btnForward = (ImageButton) vGroup.findViewById(R.id.btnForward);
      btnBack = (ImageButton) vGroup.findViewById(R.id.btnBack);
      setUpVisualizerAndSeekBar();
      btnForward.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              mediaPlayerListener.onNextSong(true);
              setUpViews();
              setViewPagerToCurrentIndex();
            }
          });

      loadBackGround();

      btnBack.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              mediaPlayerListener.onPreviousSong(true);
              setUpViews();
              setViewPagerToCurrentIndex();
            }
          });
      mAdapter = new PlaceSlidesFragmentAdapter(getChildFragmentManager());
      vpAlbumArtPager.setAdapter(mAdapter);

      vpAlbumArtPager.setPageMargin(-150);
      vpAlbumArtPager.offsetTopAndBottom(-50);
      vpAlbumArtPager.setPageTransformer(false, new ZoomOutPageTransformer());
      vpAlbumArtPager.setHorizontalFadingEdgeEnabled(true);
      vpAlbumArtPager.setFadingEdgeLength(100);

      vpAlbumArtPager.addOnPageChangeListener(this);

      lastPage = CloudifyController.getInstance().getSongIndex();
      vpAlbumArtPager.setCurrentItem(lastPage);
    }
    return vGroup;
  }
예제 #4
0
  public void setUpViews() {
    song = CloudifyController.getInstance().currentSelection;

    if (song instanceof SpotifySong) {
      tvSongName.setText(((SpotifySong) song).getTrack().getName());
      ArrayList<Artists> artists = ((SpotifySong) song).getTrack().getArtists();
      if (artists.size() > 0) tvArtist.setText(artists.get(0).getName());
    } else {

      tvSongName.setText(song.name);
      tvArtist.setText(song.artist);
    }
    loadBackGround();
  }
예제 #5
0
    @Override
    public int getIconResId(int index) {

      return CloudifyController.getInstance().currentPlaylistSongs.get(index).id;
    }
예제 #6
0
 /**
  * Sets the viewpager to the correct index. Only gets called when you want to manually set
  * viewpager index When the viewpager is swiped it also changes the song but is not in need of a
  * view refresh, it will naturally already be ont he correct album art.
  */
 private void setViewPagerToCurrentIndex() {
   vpAlbumArtPager.setCurrentItem(CloudifyController.getInstance().getSongIndex());
 }