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.google; 17 18 import com.android.quicksearchbox.R; 19 import com.android.quicksearchbox.Source; 20 import com.android.quicksearchbox.SourceResult; 21 import com.android.quicksearchbox.SuggestionExtras; 22 23 import android.content.ComponentName; 24 import android.database.DataSetObserver; 25 26 import java.util.Collection; 27 28 public abstract class AbstractGoogleSourceResult implements SourceResult { 29 30 private final Source mSource; 31 private final String mUserQuery; 32 private int mPos = 0; 33 AbstractGoogleSourceResult(Source source, String userQuery)34 public AbstractGoogleSourceResult(Source source, String userQuery) { 35 mSource = source; 36 mUserQuery = userQuery; 37 } 38 getCount()39 public abstract int getCount(); 40 getSuggestionQuery()41 public abstract String getSuggestionQuery(); 42 getSource()43 public Source getSource() { 44 return mSource; 45 } 46 close()47 public void close() { 48 } 49 getPosition()50 public int getPosition() { 51 return mPos; 52 } 53 getUserQuery()54 public String getUserQuery() { 55 return mUserQuery; 56 } 57 moveTo(int pos)58 public void moveTo(int pos) { 59 mPos = pos; 60 } 61 moveToNext()62 public boolean moveToNext() { 63 int size = getCount(); 64 if (mPos >= size) { 65 // Already past the end 66 return false; 67 } 68 mPos++; 69 return mPos < size; 70 } 71 registerDataSetObserver(DataSetObserver observer)72 public void registerDataSetObserver(DataSetObserver observer) { 73 } 74 unregisterDataSetObserver(DataSetObserver observer)75 public void unregisterDataSetObserver(DataSetObserver observer) { 76 } 77 getSuggestionText1()78 public String getSuggestionText1() { 79 return getSuggestionQuery(); 80 } 81 getSuggestionSource()82 public Source getSuggestionSource() { 83 return mSource; 84 } 85 isSuggestionShortcut()86 public boolean isSuggestionShortcut() { 87 return false; 88 } 89 getShortcutId()90 public String getShortcutId() { 91 return null; 92 } 93 getSuggestionFormat()94 public String getSuggestionFormat() { 95 return null; 96 } 97 getSuggestionIcon1()98 public String getSuggestionIcon1() { 99 return String.valueOf(R.drawable.magnifying_glass); 100 } 101 getSuggestionIcon2()102 public String getSuggestionIcon2() { 103 return null; 104 } 105 getSuggestionIntentAction()106 public String getSuggestionIntentAction() { 107 return mSource.getDefaultIntentAction(); 108 } 109 getSuggestionIntentComponent()110 public ComponentName getSuggestionIntentComponent() { 111 return mSource.getIntentComponent(); 112 } 113 getSuggestionIntentDataString()114 public String getSuggestionIntentDataString() { 115 return null; 116 } 117 getSuggestionIntentExtraData()118 public String getSuggestionIntentExtraData() { 119 return null; 120 } 121 getSuggestionLogType()122 public String getSuggestionLogType() { 123 return null; 124 } 125 getSuggestionText2()126 public String getSuggestionText2() { 127 return null; 128 } 129 getSuggestionText2Url()130 public String getSuggestionText2Url() { 131 return null; 132 } 133 isSpinnerWhileRefreshing()134 public boolean isSpinnerWhileRefreshing() { 135 return false; 136 } 137 isWebSearchSuggestion()138 public boolean isWebSearchSuggestion() { 139 return true; 140 } 141 isHistorySuggestion()142 public boolean isHistorySuggestion() { 143 return false; 144 } 145 getExtras()146 public SuggestionExtras getExtras() { 147 return null; 148 } 149 getExtraColumns()150 public Collection<String> getExtraColumns() { 151 return null; 152 } 153 } 154