private void refreshShortcuts(SuggestionCursor promoted) { if (DBG) Log.d(TAG, "refreshShortcuts(" + promoted + ")"); for (int i = 0; i < promoted.getCount(); ++i) { promoted.moveTo(i); if (promoted.isSuggestionShortcut()) { getShortcuts().refresh(promoted); } } }
public void run() { Log.d(TAG, "ShortcutRefreshTask id: " + hashCode()); // TODO: Add latency tracking and logging. SuggestionCursor refreshed = mSource.refreshShortcut(mShortcutId, mExtraData); // Close cursor if empty and pass null as the refreshed cursor if (refreshed != null && refreshed.getCount() == 0) { refreshed.close(); refreshed = null; } markShortcutRefreshed(mSource, mShortcutId); mListener.onShortcutRefreshed(mSource, mShortcutId, refreshed); }
protected SuggestionPosition getCurrentSuggestions(SuggestionsAdapter<?> adapter, long id) { SuggestionPosition pos = adapter.getSuggestion(id); if (pos == null) { return null; } SuggestionCursor suggestions = pos.getCursor(); int position = pos.getPosition(); if (suggestions == null) { return null; } int count = suggestions.getCount(); if (position < 0 || position >= count) { Log.w(TAG, "Invalid suggestion position " + position + ", count = " + count); return null; } suggestions.moveTo(position); return pos; }
public int getCount() { return mCursor == null ? 0 : mCursor.getCount(); }