1 /* 2 * Copyright (C) 2017 The Android Open Source 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 17 package com.android.settingslib.suggestions; 18 19 import android.content.Context; 20 import android.service.settings.suggestions.Suggestion; 21 import android.util.Log; 22 23 import com.android.settingslib.utils.AsyncLoaderCompat; 24 25 import java.util.List; 26 27 public class SuggestionLoaderCompat extends AsyncLoaderCompat<List<Suggestion>> { 28 29 public static final int LOADER_ID_SUGGESTIONS = 42; 30 private static final String TAG = "SuggestionLoader"; 31 32 private final SuggestionController mSuggestionController; 33 SuggestionLoaderCompat(Context context, SuggestionController controller)34 public SuggestionLoaderCompat(Context context, SuggestionController controller) { 35 super(context); 36 mSuggestionController = controller; 37 } 38 39 @Override onDiscardResult(List<Suggestion> result)40 protected void onDiscardResult(List<Suggestion> result) { 41 42 } 43 44 @Override loadInBackground()45 public List<Suggestion> loadInBackground() { 46 final List<Suggestion> data = mSuggestionController.getSuggestions(); 47 if (data == null) { 48 Log.d(TAG, "data is null"); 49 } else { 50 Log.d(TAG, "data size " + data.size()); 51 } 52 return data; 53 } 54 }