android:layout_marginRight="@dimen/default_margin" />
<TextView
+ android:id="@+id/search_item_mime_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left|center_vertical"
+ android:singleLine="true"
+ android:layout_marginRight="3dp"
+ android:textAppearance="@style/secondary_text_appearance" />
+
+ <TextView
android:id="@+id/search_item_parent_dir"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
TextView mTvName;
TextView mTvParentDir;
RelevanceView mWgRelevance;
+ TextView mMimeType;
}
/**
CharSequence mName;
String mParentDir;
Float mRelevance;
+ MimeTypeHelper.MimeTypeCategory mimeTypeCategory;
}
private DataHolder[] mData;
private static final int RESOURCE_ITEM_PARENT_DIR = R.id.search_item_parent_dir;
//The resource of the item relevance
private static final int RESOURCE_ITEM_RELEVANCE = R.id.search_item_relevance;
+ //The resource of the item mime type
+ private static final int RESOURCE_ITEM_MIME_TYPE = R.id.search_item_mime_type;
/**
* Constructor of <code>SearchResultAdapter</code>.
} else {
this.mData[i].mRelevance = null;
}
+ this.mData[i].mimeTypeCategory = MimeTypeHelper.getCategory(getContext(), fso);
}
}
//Check to reuse view
View v = convertView;
+
if (v == null) {
//Create the view holder
LayoutInflater li =
- (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = li.inflate(this.mItemViewResourceId, parent, false);
ViewHolder viewHolder = new SearchResultAdapter.ViewHolder();
- viewHolder.mIvIcon = (ImageView)v.findViewById(RESOURCE_ITEM_ICON);
- viewHolder.mTvName = (TextView)v.findViewById(RESOURCE_ITEM_NAME);
- viewHolder.mTvParentDir = (TextView)v.findViewById(RESOURCE_ITEM_PARENT_DIR);
- viewHolder.mWgRelevance = (RelevanceView)v.findViewById(RESOURCE_ITEM_RELEVANCE);
- v.setTag(viewHolder);
+ viewHolder.mIvIcon = (ImageView) v.findViewById(RESOURCE_ITEM_ICON);
+ viewHolder.mTvName = (TextView) v.findViewById(RESOURCE_ITEM_NAME);
+ viewHolder.mTvParentDir = (TextView) v.findViewById(RESOURCE_ITEM_PARENT_DIR);
+ viewHolder.mWgRelevance = (RelevanceView) v.findViewById(RESOURCE_ITEM_RELEVANCE);
+ viewHolder.mMimeType = (TextView) v.findViewById(RESOURCE_ITEM_MIME_TYPE);
// Apply the current theme
Theme theme = ThemeManager.getCurrentTheme(getContext());
theme.setTextColor(
getContext(), viewHolder.mTvParentDir, "text_color"); //$NON-NLS-1$
}
+ v.setTag(viewHolder);
}
//Retrieve data holder
final DataHolder dataHolder = this.mData[position];
//Retrieve the view holder
- ViewHolder viewHolder = (ViewHolder)v.getTag();
+ ViewHolder viewHolder = (ViewHolder) v.getTag();
//Set the data
-
if (convertView != null) {
mIconHolder.cancelLoad(viewHolder.mIvIcon);
}
}
viewHolder.mWgRelevance.setVisibility(
dataHolder.mRelevance != null ? View.VISIBLE : View.GONE);
-
+ if (dataHolder.mimeTypeCategory != MimeTypeHelper.MimeTypeCategory.NONE) {
+ viewHolder.mMimeType.setVisibility(View.VISIBLE);
+ viewHolder.mMimeType.setText(dataHolder.mimeTypeCategory.name());
+ } else {
+ viewHolder.mMimeType.setVisibility(View.GONE);
+ }
//Return the view
return v;
}
-
}