+ public int getItemViewType(int position) {
+ if (position == mFrequentSeparatorPos) {
+ // We don't want the separator view to be recycled.
+ return IGNORE_ITEM_VIEW_TYPE;
+ }
+ return super.getItemViewType(position);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (!mDataValid) {
+ throw new IllegalStateException(
+ "this should only be called when the cursor is valid");
+ }
+
+ // Handle the separator specially
+ if (position == mFrequentSeparatorPos) {
+ LayoutInflater inflater =
+ (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ TextView view = (TextView) inflater.inflate(R.layout.list_separator, parent, false);
+ view.setText(R.string.favoritesFrquentSeparator);
+ return view;
+ }
+
+ if (!mCursor.moveToPosition(getRealPosition(position))) {
+ throw new IllegalStateException("couldn't move cursor to position " + position);
+ }
+
+ View v;
+ if (convertView == null) {
+ v = newView(mContext, mCursor, parent);
+ } else {
+ v = convertView;
+ }
+ bindView(v, mContext, mCursor);
+ return v;
+ }
+
+ @Override