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 org.lineageos.eleven.ui.fragments.profile;
16 import android.os.Bundle;
17 import android.support.v4.content.Loader;
18 import android.view.LayoutInflater;
19 import android.view.View;
20 import android.view.ViewGroup;
22 import org.lineageos.eleven.Config;
23 import org.lineageos.eleven.Config.SmartPlaylistType;
24 import org.lineageos.eleven.R;
25 import org.lineageos.eleven.loaders.LastAddedLoader;
26 import org.lineageos.eleven.model.Song;
27 import org.lineageos.eleven.sectionadapter.SectionCreator;
28 import org.lineageos.eleven.sectionadapter.SectionListContainer;
29 import org.lineageos.eleven.ui.activities.BaseActivity;
30 import org.lineageos.eleven.ui.fragments.ISetupActionBar;
31 import org.lineageos.eleven.utils.MusicUtils;
32 import org.lineageos.eleven.widgets.NoResultsContainer;
35 * This class is used to display all of the songs the user put on their device
36 * within the last four weeks.
38 * @author Andrew Neal (andrewdneal@gmail.com)
40 public class LastAddedFragment extends SmartPlaylistFragment implements ISetupActionBar {
46 public Loader<SectionListContainer<Song>> onCreateLoader(final int id, final Bundle args) {
47 // show the loading progress bar
48 mLoadingEmptyContainer.showLoading();
50 LastAddedLoader loader = new LastAddedLoader(getActivity());
51 return new SectionCreator<>(getActivity(), loader, null);
55 public void setupNoResultsContainer(NoResultsContainer empty) {
56 super.setupNoResultsContainer(empty);
58 empty.setMainText(R.string.empty_last_added_main);
59 empty.setSecondaryText(R.string.empty_last_added);
63 public final View onCreateView(LayoutInflater inflater, ViewGroup container,
64 Bundle savedInstanceState) {
66 return super.onCreateView(inflater, container, savedInstanceState);
70 public void setupActionBar() {
71 ((BaseActivity)getActivity()).setupActionBar(R.string.playlist_last_added);
72 ((BaseActivity)getActivity()).setActionBarElevation(true);
76 protected long getFragmentSourceId() {
77 return Config.SmartPlaylistType.LastAdded.mId;
80 protected SmartPlaylistType getSmartPlaylistType() {
81 return Config.SmartPlaylistType.LastAdded;
85 protected int getShuffleTitleId() { return R.string.menu_shuffle_last_added; }
88 protected int getClearTitleId() { return R.string.clear_last_added; }
91 protected void clearList() { MusicUtils.clearLastAdded(getActivity()); }