AbstractPromoter.java revision af1ca2cc65a2c2fdf6f396126e235d64e4da0936
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; 17 18/** 19 * Abstract {@link Promoter} that uses a {@link SuggestionFilter} to choose shortcuts. 20 */ 21public abstract class AbstractPromoter implements Promoter { 22 23 private final SuggestionFilter mFilter; 24 private final Config mConfig; 25 26 protected AbstractPromoter(SuggestionFilter filter, Config config) { 27 mFilter = filter; 28 mConfig = config; 29 } 30 31 @Override 32 public abstract void pickPromoted( 33 Suggestions suggestions, int maxPromoted, ListSuggestionCursor promoted); 34 35 protected Config getConfig() { 36 return mConfig; 37 } 38 39 protected boolean accept(Suggestion s) { 40 if (mFilter != null) { 41 return mFilter.accept(s); 42 } else { 43 return true; 44 } 45 } 46 47} 48