// Path: app/src/main/java/com/zsorg/neteasecloudmusic/fragments/MusicFragment.java
// public class MusicFragment extends Fragment implements ViewPager.OnPageChangeListener {
// 
//     @BindView(R.id.music_tab)
//     TabLayout mTabLayout;
//     @BindView(R.id.music_viewpager)
//     ViewPager mViewpager;
// 
//     private MusicPagerAdapter mAdapter;
//     private int mCurrentPosition=0;
// 
//     public MusicFragment() {
//         // Required empty public constructor
//     }
// 
//     /**
//      * Use this factory method to create a new instance of
//      * this fragment using the provided parameters.
//      *
//      * @return A new instance of fragment MusicFragment.
//      */
//     public static MusicFragment newInstance() {
//         return new MusicFragment();
//     }
// 
//     @Override
//     public void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//     }
// 
//     @Override
//     public void onResume() {
//         super.onResume();
//         Fragment fragment = null;
//         if (null!=mAdapter) {
//             fragment = mAdapter.getItem(mCurrentPosition);
//         }
//         if (null!=fragment) {
//             fragment.onResume();
//         }
//     }
// 
//     @Override
//     public View onCreateView(LayoutInflater inflater, ViewGroup container,
//                              Bundle savedInstanceState) {
//         // Inflate the layout for this fragment
//         View view = inflater.inflate(R.layout.fragment_music, container, false);
//         ButterKnife.bind(this, view);
// 
//         Log.e("tag", "onCreateView");
//         mAdapter = new MusicPagerAdapter(view, getChildFragmentManager());
//         mViewpager.setAdapter(mAdapter);
//         mViewpager.addOnPageChangeListener(this);
//         mTabLayout.setupWithViewPager(mViewpager);
// 
//         return view;
//     }
// 
//     @Override
//     public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
// 
//     }
// 
//     @Override
//     public void onPageSelected(int position) {
//         mCurrentPosition = position;
//         mAdapter.getItem(mCurrentPosition).onResume();
//     }
// 
//     @Override
//     public void onPageScrollStateChanged(int state) {
// 
//     }
// 
//     /**
//      * This interface must be implemented by activities that contain this
//      * fragment to allow an interaction in this fragment to be communicated
//      * to the activity and potentially other fragments contained in that
//      * activity.
//      * <p>
//      * See the Android Training lesson <a href=
//      * "http://developer.android.com/training/basics/fragments/communicating.html"
//      * >Communicating with Other Fragments</a> for more information.
//      */
//     public interface OnFragmentInteractionListener {
//         // TODO: Update argument type and name
//         void onFragmentInteraction(Uri uri);
//     }
// }
// 
// Path: app/src/main/java/com/zsorg/neteasecloudmusic/fragments/PlayListFragment.java
// public class PlayListFragment extends Fragment implements IPlaylistView, OnItemCLickListener {
// 
//     private PlaylistAdapter mAdapter;
//     private PlaylistPresenter mPresenter;
// 
//     public PlayListFragment() {
//     }
// 
//     @SuppressWarnings("unused")
//     public static PlayListFragment newInstance() {
//         return new PlayListFragment();
//     }
// 
//     @Override
//     public void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
// 
//     }
// 
//     @Override
//     public void onResume() {
//         super.onResume();
//         mPresenter.requestList();
//     }
// 
//     @Override
//     public View onCreateView(LayoutInflater inflater, ViewGroup container,
//                              Bundle savedInstanceState) {
//         View view = inflater.inflate(R.layout.fragment_play_list, container, false);
// 
//         // Set the adapter
//         if (view instanceof RecyclerView) {
//             Context context = view.getContext();
//             RecyclerView recyclerView = (RecyclerView) view;
//             recyclerView.setLayoutManager(new LinearLayoutManager(context));
//             recyclerView.addItemDecoration(LineItemDecorator.getInstance());
//             mAdapter = new PlaylistAdapter(getActivity().getLayoutInflater());
//             mAdapter.setOnItemClickListener(this);
//             mAdapter.addHeaderView(inflater.inflate(R.layout.play_list_header,null));
//             recyclerView.setAdapter(mAdapter);
//             mPresenter = new PlaylistPresenter(this);
//         }
//         return view;
//     }
// 
//     @Override
//     public void showItems(List<MusicBean> list) {
//         if (null != mAdapter && null != list) {
//             mAdapter.setDatas(list);
//             mAdapter.notifyDataSetChanged();
//         }
//     }
// 
//     @Override
//     public void onItemClick(View view, int position) {
//         if (position>0) {
//             MusicBean bean = mAdapter.getDataAtPosition(position);
//             MusicListActivity.startMusicList(getContext(), bean.getName(),mPresenter.loadPlaylist((int) bean.getDuration()));
//         }
//     }
// }


import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import com.zsorg.neteasecloudmusic.fragments.MusicFragment;
import com.zsorg.neteasecloudmusic.fragments.PlayListFragment;
import java.util.ArrayList;
package com.zsorg.neteasecloudmusic.adapters;




/**
 * Created by piyel_000 on 2017/1/2.
 */

public class MainAdapter extends FragmentPagerAdapter implements IFragmentAdapter {


    private final ArrayList<Fragment> mList;

    public MainAdapter(FragmentManager fm) {
        super(fm);
        mList = new ArrayList<>();
        mList.add(MusicFragment.newInstance());
// Path: app/src/main/java/com/zsorg/neteasecloudmusic/fragments/MusicFragment.java
// public class MusicFragment extends Fragment implements ViewPager.OnPageChangeListener {
// 
//     @BindView(R.id.music_tab)
//     TabLayout mTabLayout;
//     @BindView(R.id.music_viewpager)
//     ViewPager mViewpager;
// 
//     private MusicPagerAdapter mAdapter;
//     private int mCurrentPosition=0;
// 
//     public MusicFragment() {
//         // Required empty public constructor
//     }
// 
//     /**
//      * Use this factory method to create a new instance of
//      * this fragment using the provided parameters.
//      *
//      * @return A new instance of fragment MusicFragment.
//      */
//     public static MusicFragment newInstance() {
//         return new MusicFragment();
//     }
// 
//     @Override
//     public void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//     }
// 
//     @Override
//     public void onResume() {
//         super.onResume();
//         Fragment fragment = null;
//         if (null!=mAdapter) {
//             fragment = mAdapter.getItem(mCurrentPosition);
//         }
//         if (null!=fragment) {
//             fragment.onResume();
//         }
//     }
// 
//     @Override
//     public View onCreateView(LayoutInflater inflater, ViewGroup container,
//                              Bundle savedInstanceState) {
//         // Inflate the layout for this fragment
//         View view = inflater.inflate(R.layout.fragment_music, container, false);
//         ButterKnife.bind(this, view);
// 
//         Log.e("tag", "onCreateView");
//         mAdapter = new MusicPagerAdapter(view, getChildFragmentManager());
//         mViewpager.setAdapter(mAdapter);
//         mViewpager.addOnPageChangeListener(this);
//         mTabLayout.setupWithViewPager(mViewpager);
// 
//         return view;
//     }
// 
//     @Override
//     public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
// 
//     }
// 
//     @Override
//     public void onPageSelected(int position) {
//         mCurrentPosition = position;
//         mAdapter.getItem(mCurrentPosition).onResume();
//     }
// 
//     @Override
//     public void onPageScrollStateChanged(int state) {
// 
//     }
// 
//     /**
//      * This interface must be implemented by activities that contain this
//      * fragment to allow an interaction in this fragment to be communicated
//      * to the activity and potentially other fragments contained in that
//      * activity.
//      * <p>
//      * See the Android Training lesson <a href=
//      * "http://developer.android.com/training/basics/fragments/communicating.html"
//      * >Communicating with Other Fragments</a> for more information.
//      */
//     public interface OnFragmentInteractionListener {
//         // TODO: Update argument type and name
//         void onFragmentInteraction(Uri uri);
//     }
// }
// 
// Path: app/src/main/java/com/zsorg/neteasecloudmusic/fragments/PlayListFragment.java
// public class PlayListFragment extends Fragment implements IPlaylistView, OnItemCLickListener {
// 
//     private PlaylistAdapter mAdapter;
//     private PlaylistPresenter mPresenter;
// 
//     public PlayListFragment() {
//     }
// 
//     @SuppressWarnings("unused")
//     public static PlayListFragment newInstance() {
//         return new PlayListFragment();
//     }
// 
//     @Override
//     public void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
// 
//     }
// 
//     @Override
//     public void onResume() {
//         super.onResume();
//         mPresenter.requestList();
//     }
// 
//     @Override
//     public View onCreateView(LayoutInflater inflater, ViewGroup container,
//                              Bundle savedInstanceState) {
//         View view = inflater.inflate(R.layout.fragment_play_list, container, false);
// 
//         // Set the adapter
//         if (view instanceof RecyclerView) {
//             Context context = view.getContext();
//             RecyclerView recyclerView = (RecyclerView) view;
//             recyclerView.setLayoutManager(new LinearLayoutManager(context));
//             recyclerView.addItemDecoration(LineItemDecorator.getInstance());
//             mAdapter = new PlaylistAdapter(getActivity().getLayoutInflater());
//             mAdapter.setOnItemClickListener(this);
//             mAdapter.addHeaderView(inflater.inflate(R.layout.play_list_header,null));
//             recyclerView.setAdapter(mAdapter);
//             mPresenter = new PlaylistPresenter(this);
//         }
//         return view;
//     }
// 
//     @Override
//     public void showItems(List<MusicBean> list) {
//         if (null != mAdapter && null != list) {
//             mAdapter.setDatas(list);
//             mAdapter.notifyDataSetChanged();
//         }
//     }
// 
//     @Override
//     public void onItemClick(View view, int position) {
//         if (position>0) {
//             MusicBean bean = mAdapter.getDataAtPosition(position);
//             MusicListActivity.startMusicList(getContext(), bean.getName(),mPresenter.loadPlaylist((int) bean.getDuration()));
//         }
//     }
// }


// Path: app/src/main/java/com/zsorg/neteasecloudmusic/adapters/MainAdapter.java
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import com.zsorg.neteasecloudmusic.fragments.MusicFragment;
import com.zsorg.neteasecloudmusic.fragments.PlayListFragment;
import java.util.ArrayList;

package com.zsorg.neteasecloudmusic.adapters;




/**
 * Created by piyel_000 on 2017/1/2.
 */

public class MainAdapter extends FragmentPagerAdapter implements IFragmentAdapter {


    private final ArrayList<Fragment> mList;

    public MainAdapter(FragmentManager fm) {
        super(fm);
        mList = new ArrayList<>();
        mList.add(MusicFragment.newInstance());
        mList.add(PlayListFragment.newInstance());