/* * Copyright (C) 2015 Naman Dwivedi * * Licensed under the GNU General Public License v3 * * This is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. */ package com.naman14.timber.fragments; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentStatePagerAdapter; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.naman14.timber.R; import com.naman14.timber.dataloaders.ArtistLoader; import com.naman14.timber.lastfmapi.LastFmClient; import com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener; import com.naman14.timber.lastfmapi.models.ArtistQuery; import com.naman14.timber.lastfmapi.models.LastfmArtist; import com.naman14.timber.models.Artist; import com.naman14.timber.subfragments.ArtistTagFragment; import com.naman14.timber.utils.Constants; import com.naman14.timber.widgets.MultiViewPager; public class ArtistBioFragment extends Fragment { long artistID = -1; public static ArtistBioFragment newInstance(long id) { ArtistBioFragment fragment = new ArtistBioFragment(); Bundle args = new Bundle(); args.putLong(Constants.ARTIST_ID, id); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { artistID = getArguments().getLong(Constants.ARTIST_ID); } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate( R.layout.fragment_artist_bio, container, false); Artist artist = ArtistLoader.getArtist(getActivity(), artistID); LastFmClient.getInstance(getActivity()).getArtistInfo(new ArtistQuery(artist.name), new ArtistInfoListener() { @Override public void artistInfoSucess(LastfmArtist artist) { } @Override public void artistInfoFailed() { } }); final MultiViewPager pager = (MultiViewPager) rootView.findViewById(R.id.tagspager); final FragmentStatePagerAdapter adapter = new FragmentStatePagerAdapter(getActivity().getSupportFragmentManager()) { @Override public int getCount() { return 20; } @Override public Fragment getItem(int position) { return ArtistTagFragment.newInstance(position); } }; pager.setAdapter(adapter); return rootView; } }