OSDN Git Service

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