OSDN Git Service

Correct some lint warnings
[android-x86/packages-apps-Eleven.git] / src / org / lineageos / 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 org.lineageos.eleven.ui.fragments.profile;
15
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;
21
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;
33
34 /**
35  * This class is used to display all of the songs the user put on their device
36  * within the last four weeks.
37  *
38  * @author Andrew Neal (andrewdneal@gmail.com)
39  */
40 public class LastAddedFragment extends SmartPlaylistFragment implements ISetupActionBar {
41
42     /**
43      * {@inheritDoc}
44      */
45     @Override
46     public Loader<SectionListContainer<Song>> onCreateLoader(final int id, final Bundle args) {
47         // show the loading progress bar
48         mLoadingEmptyContainer.showLoading();
49
50         LastAddedLoader loader = new LastAddedLoader(getActivity());
51         return new SectionCreator<>(getActivity(), loader, null);
52     }
53
54     @Override
55     public void setupNoResultsContainer(NoResultsContainer empty) {
56         super.setupNoResultsContainer(empty);
57
58         empty.setMainText(R.string.empty_last_added_main);
59         empty.setSecondaryText(R.string.empty_last_added);
60     }
61
62     @Override
63     public final View onCreateView(LayoutInflater inflater, ViewGroup container,
64             Bundle savedInstanceState) {
65         setupActionBar();
66         return super.onCreateView(inflater, container, savedInstanceState);
67     }
68
69     @Override
70     public void setupActionBar() {
71         ((BaseActivity)getActivity()).setupActionBar(R.string.playlist_last_added);
72         ((BaseActivity)getActivity()).setActionBarElevation(true);
73     }
74
75     @Override
76     protected long getFragmentSourceId() {
77         return Config.SmartPlaylistType.LastAdded.mId;
78     }
79
80     protected SmartPlaylistType getSmartPlaylistType() {
81         return Config.SmartPlaylistType.LastAdded;
82     }
83
84     @Override
85     protected int getShuffleTitleId() { return R.string.menu_shuffle_last_added; }
86
87     @Override
88     protected int getClearTitleId() { return R.string.clear_last_added; }
89
90     @Override
91     protected void clearList() { MusicUtils.clearLastAdded(getActivity()); }
92 }