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