Android Open Source - lastfm-android-music-discovery Sections Pager Adapter






From Project

Back to project page lastfm-android-music-discovery.

License

The source code is released under:

Apache License

If you think the Android project lastfm-android-music-discovery 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

package com.mikeladze.musicdiscovery.base.adapter;
//from   w ww .  j  a va2 s  . c  om
import java.util.LinkedList;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.mikeladze.musicdiscovery.base.fragment.BaseTabFragment;

/**
 * This is a custom adapter to hold fragments for tabs.
 * 
 * @author Tim Mikeladze
 */
public class SectionsPagerAdapter extends FragmentPagerAdapter {
  
  private LinkedList<BaseTabFragment> fragments;
  
  /**
   * Instantiates a new sections pager adapter.
   * 
   * @param context the context
   * @param fragmentManager the fragment manager
   */
  public SectionsPagerAdapter(Context context, FragmentManager fragmentManager) {
    super(fragmentManager);
    fragments = new LinkedList<BaseTabFragment>();
  }
  
  /**
   * Adds the fragment.
   * 
   * @param f the f
   */
  public void addFragment(Fragment f) {
    fragments.add((BaseTabFragment) f);
  }
  
  @Override
  /**
   * Get the fragment at given position.
   */
  public BaseTabFragment getItem(int position) {
    return fragments.get(position);
  }
  
  @Override
  /**
   * Get title of the fragment.
   */
  public CharSequence getPageTitle(int position) {
    return fragments.get(position)
            .getTitle();
  }
  
  @Override
  /**
   * Get number of fragments in adapter.
   */
  public int getCount() {
    return fragments.size();
  }
}




Java Source Code List

com.mikeladze.musicdiscovery.album.activity.AlbumActivity.java
com.mikeladze.musicdiscovery.album.adapter.LastFMTrack.java
com.mikeladze.musicdiscovery.album.adapter.OnTrackClickListener.java
com.mikeladze.musicdiscovery.album.adapter.TrackListAdapter.java
com.mikeladze.musicdiscovery.album.fragment.AlbumInfoFragment.java
com.mikeladze.musicdiscovery.album.fragment.AlbumTracksFragment.java
com.mikeladze.musicdiscovery.artist.activity.ArtistActivity.java
com.mikeladze.musicdiscovery.artist.fragment.ArtistAlbumsFragment.java
com.mikeladze.musicdiscovery.artist.fragment.ArtistInfoFragment.java
com.mikeladze.musicdiscovery.artist.fragment.SimilarArtistsFragment.java
com.mikeladze.musicdiscovery.base.activity.BaseFragmentActivity.java
com.mikeladze.musicdiscovery.base.adapter.SectionsPagerAdapter.java
com.mikeladze.musicdiscovery.base.fragment.BaseTabFragment.java
com.mikeladze.musicdiscovery.base.fragment.ImageGridViewFragment.java
com.mikeladze.musicdiscovery.http.LastFMResult.java
com.mikeladze.musicdiscovery.http.RestClient.java
com.mikeladze.musicdiscovery.main.activity.MainActivity.java
com.mikeladze.musicdiscovery.main.fragment.HypedArtistsFragment.java
com.mikeladze.musicdiscovery.main.fragment.TopArtistsFragment.java
com.mikeladze.musicdiscovery.search.activity.SearchResultsActivity.java
com.mikeladze.musicdiscovery.search.adapter.SearchResultsAdapter.java
com.mikeladze.musicdiscovery.util.IntentUtils.java
com.mikeladze.musicdiscovery.view.gridview.DynamicImageView.java
com.mikeladze.musicdiscovery.view.gridview.ImageGridAdapter.java
com.mikeladze.musicdiscovery.view.gridview.loader.FileCache.java
com.mikeladze.musicdiscovery.view.gridview.loader.ImageLoader.java
com.mikeladze.musicdiscovery.view.gridview.loader.MemoryCache.java
com.mikeladze.musicdiscovery.view.gridview.loader.Utils.java