1 /* 2 * Copyright (C) 2010 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 package com.android.quicksearchbox; 17 18 import android.content.ComponentName; 19 import android.database.Cursor; 20 21 import com.android.quicksearchbox.google.GoogleSource; 22 23 import java.util.Collection; 24 25 public class CursorBackedSourceResult extends CursorBackedSuggestionCursor 26 implements SourceResult { 27 28 private final GoogleSource mSource; 29 CursorBackedSourceResult(GoogleSource source, String userQuery)30 public CursorBackedSourceResult(GoogleSource source, String userQuery) { 31 this(source, userQuery, null); 32 } 33 CursorBackedSourceResult(GoogleSource source, String userQuery, Cursor cursor)34 public CursorBackedSourceResult(GoogleSource source, String userQuery, Cursor cursor) { 35 super(userQuery, cursor); 36 mSource = source; 37 } 38 getSource()39 public GoogleSource getSource() { 40 return mSource; 41 } 42 43 @Override getSuggestionSource()44 public GoogleSource getSuggestionSource() { 45 return mSource; 46 } 47 48 @Override getSuggestionIntentComponent()49 public ComponentName getSuggestionIntentComponent() { 50 return mSource.getIntentComponent(); 51 } 52 isSuggestionShortcut()53 public boolean isSuggestionShortcut() { 54 return false; 55 } 56 isHistorySuggestion()57 public boolean isHistorySuggestion() { 58 return false; 59 } 60 61 @Override toString()62 public String toString() { 63 return mSource + "[" + getUserQuery() + "]"; 64 } 65 66 @Override getExtras()67 public SuggestionExtras getExtras() { 68 if (mCursor == null) return null; 69 return CursorBackedSuggestionExtras.createExtrasIfNecessary(mCursor, getPosition()); 70 } 71 getExtraColumns()72 public Collection<String> getExtraColumns() { 73 if (mCursor == null) return null; 74 return CursorBackedSuggestionExtras.getExtraColumns(mCursor); 75 } 76 77 }