13e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert/* 23e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Copyright (C) 2009 The Android Open Source Project 33e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * 43e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License"); 53e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * you may not use this file except in compliance with the License. 63e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * You may obtain a copy of the License at 73e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * 83e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * http://www.apache.org/licenses/LICENSE-2.0 93e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * 103e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Unless required by applicable law or agreed to in writing, software 113e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * distributed under the License is distributed on an "AS IS" BASIS, 123e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * See the License for the specific language governing permissions and 143e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * limitations under the License. 153e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert */ 163e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 173e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringertpackage com.android.quicksearchbox; 183e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 193e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 203e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert/** 213e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * A pointer to a suggestion in a {@link SuggestionCursor}. 223e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * 233e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert */ 2493bd2e70b8b08da1ec37fd0e990dac05551d2e90Bjorn Bringertpublic class SuggestionPosition extends AbstractSuggestionWrapper { 253e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 263e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert private final SuggestionCursor mCursor; 273e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 283e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert private final int mPosition; 293e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 3094e8a2be78530170f50e7895a558bf8011bbf8e8Bryan Mawhinney public SuggestionPosition(SuggestionCursor cursor) { 3194e8a2be78530170f50e7895a558bf8011bbf8e8Bryan Mawhinney this(cursor, cursor.getPosition()); 3294e8a2be78530170f50e7895a558bf8011bbf8e8Bryan Mawhinney } 3394e8a2be78530170f50e7895a558bf8011bbf8e8Bryan Mawhinney 343e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert public SuggestionPosition(SuggestionCursor cursor, int suggestionPos) { 353e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert mCursor = cursor; 363e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert mPosition = suggestionPos; 373e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert } 383e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 397a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood public SuggestionCursor getCursor() { 407a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood return mCursor; 417a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood } 427a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood 433e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert /** 443e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Gets the suggestion cursor, moved to point to the right suggestion. 453e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert */ 46848fa7a19abedc372452073abaf52780c7b6d78dAmith Yamasani @Override 4793bd2e70b8b08da1ec37fd0e990dac05551d2e90Bjorn Bringert protected Suggestion current() { 483e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert mCursor.moveTo(mPosition); 493e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert return mCursor; 503e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert } 513e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 52ca78085bb2127559e6f55276a307bfa857018ecaBjorn Bringert public int getPosition() { 53ca78085bb2127559e6f55276a307bfa857018ecaBjorn Bringert return mPosition; 54ca78085bb2127559e6f55276a307bfa857018ecaBjorn Bringert } 55ca78085bb2127559e6f55276a307bfa857018ecaBjorn Bringert 56bf61e445cbe423cc2554b722b6dd38675015c36dBjorn Bringert @Override 57bf61e445cbe423cc2554b722b6dd38675015c36dBjorn Bringert public String toString() { 58bf61e445cbe423cc2554b722b6dd38675015c36dBjorn Bringert return mCursor + ":" + mPosition; 59bf61e445cbe423cc2554b722b6dd38675015c36dBjorn Bringert } 60bf61e445cbe423cc2554b722b6dd38675015c36dBjorn Bringert 613e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert} 62