// Path: app/src/main/java/com/music/ting/model/DrawerListBean.java
// public class DrawerListBean {
// 
//     private String title;
//     private int titleImageId;
// 
//     public DrawerListBean(String title, int titleImageId){
//         this.title = title;
//         this.titleImageId = titleImageId;
//     }
//     public void setTitle(String title) {
//         this.title = title;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public void setTitleImageId(int titleImageId){
//         this.titleImageId = titleImageId;
//     }
//     public int getTitleImageId(){
//         return titleImageId;
//     }
// }
// 
// Path: app/src/main/java/com/music/ting/ui/fragment/SongsListFragment.java
// public class SongsListFragment extends Fragment {
// 
//     private ListView songListView;
//     private SwipeRefreshLayout songSwipe;
//     private View view;
//     private List<Songs> songsList = new ArrayList<Songs>();
// 
//     @Override
//     public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//         view = inflater.inflate(R.layout.fragment_songs_list,container,false);
// 
//         songListView = (ListView) view.findViewById(R.id.songs_list);
//         songSwipe = (SwipeRefreshLayout) view.findViewById(R.id.song_swipe);
// 
//         //给刷新控件一个颜色
//         songSwipe.setColorSchemeColors(R.color.colorPrimary, R.color.colorPrimary,
//                 R.color.colorPrimary,R.color.colorPrimary);
//         //刚进入到界面设置刷新控件正在刷新
//         songSwipe.post(new Runnable() {
//             @Override
//             public void run() {
//                 songSwipe.setRefreshing(true);
//             }
//         });
//         //加载数据
//         initData(20);
//         /**
//          * 刷新控件监听事件
//          */
//         songSwipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
//             @Override
//             public void onRefresh() {
//                 initData(20);
//             }
//         });
// 
// 
//         songListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//             @Override
//             public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// 
//                 Intent intent = new Intent(view.getContext(), CommentActivity.class);
//                 intent.putExtra("Songs",songsList.get(position));
//                 startActivity(intent);
//             }
//         });
// 
//         return view;
//     }
// 
//     /**
//      * 初始化数据
//      */
//     public void initData(final int songCount){
//         final GsonRequest<List<Songs>> request = TingAPI.getSongsRequest(songCount);
// 
//         final Response.Listener<List<Songs>> response = new Response.Listener<List<Songs>>() {
//             @Override
//             public void onResponse(List<Songs> songs) {
//                 songsList = songs;
//                 songListView.setAdapter(new SongsListAdapter(view.getContext(),
//                         R.layout.item_songs_list,songsList));
//                 songSwipe.setRefreshing(false);
//             }
//         };
//         request.setSuccessListener(response);
//         RequestManager.addRequest(request, null);
//     }
// }


import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.music.ting.R;
import com.music.ting.adapter.DrawerListAdapter;
import com.music.ting.model.DrawerListBean;
import com.music.ting.ui.fragment.LocalSongsFragment;
import com.music.ting.ui.fragment.SongsListFragment;
import java.util.ArrayList;
import java.util.List;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initToolbar();

        SongsListFragment fragment = new SongsListFragment();
        getSupportFragmentManager().beginTransaction().add(R.id.container, fragment)
                .show(fragment).commit();

        mDrawerLayout = (DrawerLayout) findViewById(R.id.ting_drawer);
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        //创建返回键，并实现打开关/闭监听
        mDrawerToggle = new ActionBarDrawerToggle(this,mDrawerLayout,toolbar,
                R.string.open,R.string.close){
            @Override
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
            }
            @Override
            public void onDrawerClosed(View drawerView) {
                super.onDrawerClosed(drawerView);
            }
        };

        mDrawerToggle.syncState();
        mDrawerLayout.setDrawerListener(mDrawerToggle);

        drawerLayout = (LinearLayout) findViewById(R.id.drawer_layout);

// Path: app/src/main/java/com/music/ting/model/DrawerListBean.java
// public class DrawerListBean {
// 
//     private String title;
//     private int titleImageId;
// 
//     public DrawerListBean(String title, int titleImageId){
//         this.title = title;
//         this.titleImageId = titleImageId;
//     }
//     public void setTitle(String title) {
//         this.title = title;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public void setTitleImageId(int titleImageId){
//         this.titleImageId = titleImageId;
//     }
//     public int getTitleImageId(){
//         return titleImageId;
//     }
// }
// 
// Path: app/src/main/java/com/music/ting/ui/fragment/SongsListFragment.java
// public class SongsListFragment extends Fragment {
// 
//     private ListView songListView;
//     private SwipeRefreshLayout songSwipe;
//     private View view;
//     private List<Songs> songsList = new ArrayList<Songs>();
// 
//     @Override
//     public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//         view = inflater.inflate(R.layout.fragment_songs_list,container,false);
// 
//         songListView = (ListView) view.findViewById(R.id.songs_list);
//         songSwipe = (SwipeRefreshLayout) view.findViewById(R.id.song_swipe);
// 
//         //给刷新控件一个颜色
//         songSwipe.setColorSchemeColors(R.color.colorPrimary, R.color.colorPrimary,
//                 R.color.colorPrimary,R.color.colorPrimary);
//         //刚进入到界面设置刷新控件正在刷新
//         songSwipe.post(new Runnable() {
//             @Override
//             public void run() {
//                 songSwipe.setRefreshing(true);
//             }
//         });
//         //加载数据
//         initData(20);
//         /**
//          * 刷新控件监听事件
//          */
//         songSwipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
//             @Override
//             public void onRefresh() {
//                 initData(20);
//             }
//         });
// 
// 
//         songListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//             @Override
//             public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// 
//                 Intent intent = new Intent(view.getContext(), CommentActivity.class);
//                 intent.putExtra("Songs",songsList.get(position));
//                 startActivity(intent);
//             }
//         });
// 
//         return view;
//     }
// 
//     /**
//      * 初始化数据
//      */
//     public void initData(final int songCount){
//         final GsonRequest<List<Songs>> request = TingAPI.getSongsRequest(songCount);
// 
//         final Response.Listener<List<Songs>> response = new Response.Listener<List<Songs>>() {
//             @Override
//             public void onResponse(List<Songs> songs) {
//                 songsList = songs;
//                 songListView.setAdapter(new SongsListAdapter(view.getContext(),
//                         R.layout.item_songs_list,songsList));
//                 songSwipe.setRefreshing(false);
//             }
//         };
//         request.setSuccessListener(response);
//         RequestManager.addRequest(request, null);
//     }
// }


// Path: app/src/main/java/com/music/ting/ui/activity/MainActivity.java
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.music.ting.R;
import com.music.ting.adapter.DrawerListAdapter;
import com.music.ting.model.DrawerListBean;
import com.music.ting.ui.fragment.LocalSongsFragment;
import com.music.ting.ui.fragment.SongsListFragment;
import java.util.ArrayList;
import java.util.List;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initToolbar();

        SongsListFragment fragment = new SongsListFragment();
        getSupportFragmentManager().beginTransaction().add(R.id.container, fragment)
                .show(fragment).commit();

        mDrawerLayout = (DrawerLayout) findViewById(R.id.ting_drawer);
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        //创建返回键，并实现打开关/闭监听
        mDrawerToggle = new ActionBarDrawerToggle(this,mDrawerLayout,toolbar,
                R.string.open,R.string.close){
            @Override
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
            }
            @Override
            public void onDrawerClosed(View drawerView) {
                super.onDrawerClosed(drawerView);
            }
        };

        mDrawerToggle.syncState();
        mDrawerLayout.setDrawerListener(mDrawerToggle);

        drawerLayout = (LinearLayout) findViewById(R.id.drawer_layout);

        drawerListView = (ListView) findViewById(R.id.ting_drawer_list);
