191197049c458f07092b31501d2ed512180b13d58Chiao Cheng/* 291197049c458f07092b31501d2ed512180b13d58Chiao Cheng * Copyright (C) 2011 The Android Open Source Project 391197049c458f07092b31501d2ed512180b13d58Chiao Cheng * 491197049c458f07092b31501d2ed512180b13d58Chiao Cheng * Licensed under the Apache License, Version 2.0 (the "License"); 591197049c458f07092b31501d2ed512180b13d58Chiao Cheng * you may not use this file except in compliance with the License. 691197049c458f07092b31501d2ed512180b13d58Chiao Cheng * You may obtain a copy of the License at 791197049c458f07092b31501d2ed512180b13d58Chiao Cheng * 891197049c458f07092b31501d2ed512180b13d58Chiao Cheng * http://www.apache.org/licenses/LICENSE-2.0 991197049c458f07092b31501d2ed512180b13d58Chiao Cheng * 1091197049c458f07092b31501d2ed512180b13d58Chiao Cheng * Unless required by applicable law or agreed to in writing, software 1191197049c458f07092b31501d2ed512180b13d58Chiao Cheng * distributed under the License is distributed on an "AS IS" BASIS, 1291197049c458f07092b31501d2ed512180b13d58Chiao Cheng * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1391197049c458f07092b31501d2ed512180b13d58Chiao Cheng * See the License for the specific language governing permissions and 1491197049c458f07092b31501d2ed512180b13d58Chiao Cheng * limitations under the License 1591197049c458f07092b31501d2ed512180b13d58Chiao Cheng */ 1691197049c458f07092b31501d2ed512180b13d58Chiao Cheng 1791197049c458f07092b31501d2ed512180b13d58Chiao Chengpackage com.android.dialer.util; 1891197049c458f07092b31501d2ed512180b13d58Chiao Cheng 1991197049c458f07092b31501d2ed512180b13d58Chiao Chengimport android.app.LoaderManager.LoaderCallbacks; 2091197049c458f07092b31501d2ed512180b13d58Chiao Chengimport android.content.Context; 2191197049c458f07092b31501d2ed512180b13d58Chiao Chengimport android.content.Loader; 2291197049c458f07092b31501d2ed512180b13d58Chiao Chengimport android.os.Bundle; 2391197049c458f07092b31501d2ed512180b13d58Chiao Cheng 2491197049c458f07092b31501d2ed512180b13d58Chiao Cheng/** 2591197049c458f07092b31501d2ed512180b13d58Chiao Cheng * A {@link Loader} only used to make use of the {@link android.app.Fragment#setStartDeferred} 2691197049c458f07092b31501d2ed512180b13d58Chiao Cheng * feature from an old-style fragment which doesn't use {@link Loader}s to load data. 2791197049c458f07092b31501d2ed512180b13d58Chiao Cheng * 2891197049c458f07092b31501d2ed512180b13d58Chiao Cheng * This loader never delivers results. A caller fragment must destroy it when deferred fragments 2991197049c458f07092b31501d2ed512180b13d58Chiao Cheng * should be started. 3091197049c458f07092b31501d2ed512180b13d58Chiao Cheng */ 3191197049c458f07092b31501d2ed512180b13d58Chiao Chengpublic class EmptyLoader extends Loader<Object> { 3291197049c458f07092b31501d2ed512180b13d58Chiao Cheng public EmptyLoader(Context context) { 3391197049c458f07092b31501d2ed512180b13d58Chiao Cheng super(context); 3491197049c458f07092b31501d2ed512180b13d58Chiao Cheng } 3591197049c458f07092b31501d2ed512180b13d58Chiao Cheng 3691197049c458f07092b31501d2ed512180b13d58Chiao Cheng /** 3791197049c458f07092b31501d2ed512180b13d58Chiao Cheng * {@link LoaderCallbacks} which just generates {@link EmptyLoader}. {@link #onLoadFinished} 3891197049c458f07092b31501d2ed512180b13d58Chiao Cheng * and {@link #onLoaderReset} are no-op. 3991197049c458f07092b31501d2ed512180b13d58Chiao Cheng */ 4091197049c458f07092b31501d2ed512180b13d58Chiao Cheng public static class Callback implements LoaderCallbacks<Object> { 4191197049c458f07092b31501d2ed512180b13d58Chiao Cheng private final Context mContext; 4291197049c458f07092b31501d2ed512180b13d58Chiao Cheng 4391197049c458f07092b31501d2ed512180b13d58Chiao Cheng public Callback(Context context) { 4491197049c458f07092b31501d2ed512180b13d58Chiao Cheng mContext = context.getApplicationContext(); 4591197049c458f07092b31501d2ed512180b13d58Chiao Cheng } 4691197049c458f07092b31501d2ed512180b13d58Chiao Cheng 4791197049c458f07092b31501d2ed512180b13d58Chiao Cheng @Override 4891197049c458f07092b31501d2ed512180b13d58Chiao Cheng public Loader<Object> onCreateLoader(int id, Bundle args) { 4991197049c458f07092b31501d2ed512180b13d58Chiao Cheng return new EmptyLoader(mContext); 5091197049c458f07092b31501d2ed512180b13d58Chiao Cheng } 5191197049c458f07092b31501d2ed512180b13d58Chiao Cheng 5291197049c458f07092b31501d2ed512180b13d58Chiao Cheng @Override 5391197049c458f07092b31501d2ed512180b13d58Chiao Cheng public void onLoadFinished(Loader<Object> loader, Object data) { 5491197049c458f07092b31501d2ed512180b13d58Chiao Cheng } 5591197049c458f07092b31501d2ed512180b13d58Chiao Cheng 5691197049c458f07092b31501d2ed512180b13d58Chiao Cheng @Override 5791197049c458f07092b31501d2ed512180b13d58Chiao Cheng public void onLoaderReset(Loader<Object> loader) { 5891197049c458f07092b31501d2ed512180b13d58Chiao Cheng } 5991197049c458f07092b31501d2ed512180b13d58Chiao Cheng } 6091197049c458f07092b31501d2ed512180b13d58Chiao Cheng} 61