OSDN Git Service

07e4e69dda13c854a5133a3dc564ac4fc8c8c9e4
[android-x86/packages-apps-Eleven.git] / src / com / cyngn / eleven / ui / fragments / profile / LastAddedFragment.java
1 /*
2  * Copyright (C) 2012 Andrew Neal Licensed under the Apache License, Version 2.0
3  * (the "License"); you may not use this file except in compliance with the
4  * License. You may obtain a copy of the License at
5  * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
6  * or agreed to in writing, software distributed under the License is
7  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8  * KIND, either express or implied. See the License for the specific language
9  * governing permissions and limitations under the License.
10  */
11
12 package com.cyngn.eleven.ui.fragments.profile;
13
14 import android.app.Activity;
15 import android.os.Bundle;
16 import android.support.v4.content.Loader;
17
18 import com.cyngn.eleven.Config;
19 import com.cyngn.eleven.R;
20 import com.cyngn.eleven.loaders.LastAddedLoader;
21 import com.cyngn.eleven.model.Song;
22 import com.cyngn.eleven.sectionadapter.SectionCreator;
23 import com.cyngn.eleven.sectionadapter.SectionListContainer;
24 import com.cyngn.eleven.ui.activities.BaseActivity;
25 import com.cyngn.eleven.ui.fragments.ISetupActionBar;
26 import com.cyngn.eleven.utils.MusicUtils;
27 import com.cyngn.eleven.widgets.NoResultsContainer;
28
29 /**
30  * This class is used to display all of the songs the user put on their device
31  * within the last four weeks.
32  *
33  * @author Andrew Neal (andrewdneal@gmail.com)
34  */
35 public class LastAddedFragment extends BasicSongFragment implements ISetupActionBar {
36
37     /**
38      * LoaderCallbacks identifier
39      */
40     private static final int LOADER = 0;
41
42     /**
43      * {@inheritDoc}
44      */
45     @Override
46     public Loader<SectionListContainer<Song>> onCreateLoader(final int id, final Bundle args) {
47         LastAddedLoader loader = new LastAddedLoader(getActivity());
48         return new SectionCreator<Song>(getActivity(), loader, null);
49     }
50
51     @Override
52     public int getLoaderId() {
53         return LOADER;
54     }
55
56     @Override
57     public void playAll(int position) {
58         MusicUtils.playSmartPlaylist(getActivity(), position,
59                 Config.SmartPlaylistType.LastAdded);
60     }
61
62     @Override
63     public void setupNoResultsContainer(NoResultsContainer empty) {
64         super.setupNoResultsContainer(empty);
65
66         empty.setMainText(R.string.empty_last_added_main);
67         empty.setSecondaryText(R.string.empty_last_added);
68     }
69
70     @Override
71     public void setupActionBar() {
72         ((BaseActivity)getActivity()).setupActionBar(R.string.playlist_last_added);
73     }
74 }