This source file includes following definitions.
- getView
- areAllItemsEnabled
- isEnabled
package org.chromium.content.browser.input;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckedTextView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
public class SelectPopupAdapter extends ArrayAdapter<SelectPopupItem> {
private List<SelectPopupItem> mItems;
private boolean mAreAllItemsEnabled;
public SelectPopupAdapter(Context context, int layoutResource,
List<SelectPopupItem> items) {
super(context, layoutResource, items);
mItems = new ArrayList<SelectPopupItem>(items);
mAreAllItemsEnabled = true;
for (int i = 0; i < mItems.size(); i++) {
if (mItems.get(i).getType() != PopupItemType.ENABLED) {
mAreAllItemsEnabled = false;
break;
}
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (position < 0 || position >= getCount()) return null;
convertView = super.getView(position, null, parent);
((TextView) convertView).setText(mItems.get(position).getLabel());
if (mItems.get(position).getType() != PopupItemType.ENABLED) {
if (mItems.get(position).getType() == PopupItemType.GROUP) {
if (convertView instanceof CheckedTextView) {
((CheckedTextView) convertView).setCheckMarkDrawable(null);
}
} else {
convertView.setEnabled(false);
}
}
return convertView;
}
@Override
public boolean areAllItemsEnabled() {
return mAreAllItemsEnabled;
}
@Override
public boolean isEnabled(int position) {
if (position < 0 || position >= getCount()) return false;
return mItems.get(position).getType() == PopupItemType.ENABLED;
}
}