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.
14 package com.cyanogenmod.eleven.ui.fragments.profile;
16 import android.os.Bundle;
17 import android.support.v4.content.Loader;
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;
32 * This class is used to display all of the songs the user put on their device
33 * within the last four weeks.
35 * @author Andrew Neal (andrewdneal@gmail.com)
37 public class LastAddedFragment extends SmartPlaylistFragment implements ISetupActionBar {
43 public Loader<SectionListContainer<Song>> onCreateLoader(final int id, final Bundle args) {
44 // show the loading progress bar
45 mLoadingEmptyContainer.showLoading();
47 LastAddedLoader loader = new LastAddedLoader(getActivity());
48 return new SectionCreator<Song>(getActivity(), loader, null);
52 public void setupNoResultsContainer(NoResultsContainer empty) {
53 super.setupNoResultsContainer(empty);
55 empty.setMainText(R.string.empty_last_added_main);
56 empty.setSecondaryText(R.string.empty_last_added);
60 public void setupActionBar() {
61 ((BaseActivity)getActivity()).setupActionBar(R.string.playlist_last_added);
65 protected long getFragmentSourceId() {
66 return Config.SmartPlaylistType.LastAdded.mId;
69 protected SmartPlaylistType getSmartPlaylistType() {
70 return Config.SmartPlaylistType.LastAdded;
74 protected int getShuffleTitleId() { return R.string.menu_shuffle_last_added; }
77 protected int getClearTitleId() { return R.string.clear_last_added; }
80 protected void clearList() { MusicUtils.clearLastAdded(getActivity()); }