OSDN Git Service

0d01e5f9189d3cdf429e41ac40a5e28eddd76463
[android-x86/packages-apps-Eleven.git] / src / com / cyanogenmod / eleven / ui / fragments / phone / MusicBrowserFragment.java
1 /*
2 * Copyright (C) 2014 The CyanogenMod Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package com.cyanogenmod.eleven.ui.fragments.phone;
17
18 import android.os.Bundle;
19 import android.support.v4.app.Fragment;
20 import android.support.v4.app.LoaderManager;
21 import android.support.v4.app.LoaderManager.LoaderCallbacks;
22
23 /**
24  * This class is used for fragments under the {@link MusicBrowserFragment}
25  * Even though the containing view pager creates all the fragments, the loader
26  * does not load complete until the user navigates to that page.  To get around this
27  * we will use the containing fragment's loader manager
28  */
29 public abstract class MusicBrowserFragment extends Fragment {
30     public abstract int getLoaderId();
31
32     public LoaderManager getContainingLoaderManager() {
33         return getParentFragment().getLoaderManager();
34     }
35
36     protected void initLoader(Bundle args, LoaderCallbacks<? extends Object> callback) {
37         getContainingLoaderManager().initLoader(getLoaderId(), args, callback);
38     }
39
40     protected void restartLoader(Bundle args, LoaderCallbacks<? extends Object> callback) {
41         getContainingLoaderManager().restartLoader(getLoaderId(), args, callback);
42     }
43 }