下面列出了怎么用android.widget.BaseExpandableListAdapter的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* 离线地图下载回调方法
*/
@Override
public void onDownload(int status, int completeCode, String downName) {
//只有与服务绑定了才更新Activity的进度
if (isServiceBound && mBinder != null) {
groupPosition = mBinder.groupPosition;
childPosition = mBinder.childPosition;
if (groupPosition == 0 || groupPosition == 1 || groupPosition == 2) {
cityMap.get(groupPosition).get(childPosition).setState(status);
} else {
if (childPosition == 0) {
for (int i = 0; i < cityMap.get(groupPosition).size(); i++) {
cityMap.get(groupPosition).get(i).setState(status);//
}
} else {
cityMap.get(groupPosition).get(childPosition).setState(status);
}
}
this.completeCode = completeCode;
((BaseExpandableListAdapter) adapter).notifyDataSetChanged();
}
}
/**
* Provides the visible child views.
* The map key is the group position.
* The map values are the visible child views.
*
* @param expandableListView the listview
* @param adapter the linked adapter
* @return visible views map
*/
public static Map<Integer, List<Integer>> getVisibleChildViews(ExpandableListView expandableListView, BaseExpandableListAdapter adapter) {
Map<Integer, List<Integer>> map = new HashMap<>();
long firstPackedPosition = expandableListView.getExpandableListPosition(expandableListView.getFirstVisiblePosition());
int firstGroupPosition = ExpandableListView.getPackedPositionGroup(firstPackedPosition);
int firstChildPosition = ExpandableListView.getPackedPositionChild(firstPackedPosition);
long lastPackedPosition = expandableListView.getExpandableListPosition(expandableListView.getLastVisiblePosition());
int lastGroupPosition = ExpandableListView.getPackedPositionGroup(lastPackedPosition);
int lastChildPosition = ExpandableListView.getPackedPositionChild(lastPackedPosition);
for (int groupPos = firstGroupPosition; groupPos <= lastGroupPosition; groupPos++) {
List<Integer> list = new ArrayList<>();
int startChildPos = (groupPos == firstGroupPosition) ? firstChildPosition : 0;
int endChildPos = (groupPos == lastGroupPosition) ? lastChildPosition : adapter.getChildrenCount(groupPos) - 1;
for (int index = startChildPos; index <= endChildPos; index++) {
list.add(index);
}
map.put(groupPos, list);
}
return map;
}
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
super.handleMessage(msg);
switch (msg.what) {
case UPDATE_LIST:
if (mContentViewPage.getCurrentItem() == 0) {
((BaseExpandableListAdapter) adapter)
.notifyDataSetChanged();
} else {
mDownloadedAdapter.notifyDataChange();
}
break;
case SHOW_MSG:
// Toast.makeText(OfflineMapActivity_Old.this, (String) msg.obj,
// Toast.LENGTH_SHORT).show()
ToastUtil.showShortToast(OfflineMapActivity_Old.this, (String)msg.obj);
break;
case DISMISS_INIT_DIALOG:
initDialog.dismiss();
handler.sendEmptyMessage(UPDATE_LIST);
break;
case SHOW_INIT_DIALOG:
if (initDialog != null) {
initDialog.show();
}
break;
default:
break;
}
}
@Override
public void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags)
{
int position = cursor.getPosition();
// set list title
TextView title = (TextView) view.findViewById(android.R.id.title);
if (title != null)
{
title.setText(getTitle(cursor, view.getContext()));
}
// set list elements
TextView text2 = (TextView) view.findViewById(android.R.id.text2);
int childrenCount = adapter.getChildrenCount(position);
if (text2 != null && ((ExpandableGroupDescriptorAdapter) adapter).childCursorLoaded(position))
{
Resources res = view.getContext().getResources();
text2.setText(res.getQuantityString(R.plurals.number_of_tasks, childrenCount, childrenCount));
}
// show/hide divider
View divider = view.findViewById(R.id.divider);
if (divider != null)
{
divider.setVisibility((flags & FLAG_IS_EXPANDED) != 0 && childrenCount > 0 ? View.VISIBLE : View.GONE);
}
View colorbar = view.findViewById(R.id.colorbar1);
if (colorbar != null)
{
colorbar.setVisibility(View.GONE);
}
}
@Override
public void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags)
{
int position = cursor.getPosition();
// set list title
TextView title = (TextView) view.findViewById(android.R.id.title);
if (title != null)
{
title.setText(getTitle(cursor, view.getContext()));
}
// set list elements
TextView text2 = (TextView) view.findViewById(android.R.id.text2);
int childrenCount = adapter.getChildrenCount(position);
if (text2 != null && ((ExpandableGroupDescriptorAdapter) adapter).childCursorLoaded(position))
{
Resources res = view.getContext().getResources();
text2.setText(res.getQuantityString(R.plurals.number_of_tasks, childrenCount, childrenCount));
}
// show/hide divider
View divider = view.findViewById(R.id.divider);
if (divider != null)
{
divider.setVisibility((flags & FLAG_IS_EXPANDED) != 0 && childrenCount > 0 ? View.VISIBLE : View.GONE);
}
View colorbar = view.findViewById(R.id.colorbar1);
if (colorbar != null)
{
colorbar.setVisibility(View.GONE);
}
}
protected BaseExpandableListAdapter createAdapter() {
return new ExpandableMyListAdapter(getActivity(), mData);
}
@Override
public void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags)
{
TextView title = getView(view, android.R.id.title);
boolean isClosed = cursor.getInt(13) > 0;
resetFlingView(view);
if (title != null)
{
String text = cursor.getString(5);
title.setText(text);
if (isClosed)
{
title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
else
{
title.setPaintFlags(title.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
}
}
setDueDate(getView(view, R.id.task_due_date), null, INSTANCE_DUE_ADAPTER.get(cursor), isClosed);
View divider = getView(view, R.id.divider);
if (divider != null)
{
divider.setVisibility((flags & FLAG_IS_LAST_CHILD) != 0 ? View.GONE : View.VISIBLE);
}
// display priority
int priority = TaskFieldAdapters.PRIORITY.get(cursor);
View priorityView = getView(view, R.id.task_priority_view_medium);
priorityView.setBackgroundResource(android.R.color.transparent);
priorityView.setVisibility(View.VISIBLE);
if (priority > 0 && priority < 5)
{
priorityView.setBackgroundResource(R.color.priority_red);
}
if (priority == 5)
{
priorityView.setBackgroundResource(R.color.priority_yellow);
}
if (priority > 5 && priority <= 9)
{
priorityView.setBackgroundResource(R.color.priority_green);
}
new ProgressBackgroundView(getView(view, R.id.percentage_background_view))
.update(new NullSafe<>(TaskFieldAdapters.PERCENT_COMPLETE.get(cursor)));
setColorBar(view, cursor);
setDescription(view, cursor);
setOverlay(view, cursor.getPosition(), cursor.getCount());
}
@Override
public void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags)
{
int position = cursor.getPosition();
// set list title
TextView title = (TextView) view.findViewById(android.R.id.title);
if (title != null)
{
title.setText(getTitle(cursor, view.getContext()));
}
// set list account
TextView text1 = (TextView) view.findViewById(android.R.id.text1);
if (text1 != null)
{
text1.setText(cursor.getString(3));
}
// set list elements
TextView text2 = (TextView) view.findViewById(android.R.id.text2);
int childrenCount = adapter.getChildrenCount(position);
if (text2 != null && ((ExpandableGroupDescriptorAdapter) adapter).childCursorLoaded(position))
{
Resources res = view.getContext().getResources();
text2.setText(res.getQuantityString(R.plurals.number_of_tasks, childrenCount, childrenCount));
}
// show/hide divider
View divider = view.findViewById(R.id.divider);
if (divider != null)
{
divider.setVisibility((flags & FLAG_IS_EXPANDED) != 0 && childrenCount > 0 ? View.VISIBLE : View.GONE);
}
View colorbar1 = view.findViewById(R.id.colorbar1);
View colorbar2 = view.findViewById(R.id.colorbar2);
View quickAddTask = view.findViewById(R.id.quick_add_task);
if (quickAddTask != null)
{
quickAddTask.setOnClickListener(quickAddClickListener);
quickAddTask.setTag(cursor.getLong(cursor.getColumnIndex(TaskLists._ID)));
}
if ((flags & FLAG_IS_EXPANDED) != 0)
{
if (colorbar1 != null)
{
colorbar1.setBackgroundColor(TaskFieldAdapters.LIST_COLOR.get(cursor));
colorbar1.setVisibility(View.VISIBLE);
}
if (colorbar2 != null)
{
colorbar2.setVisibility(View.GONE);
}
// show quick add and hide task count
if (quickAddTask != null)
{
quickAddTask.setVisibility(View.VISIBLE);
}
if (text2 != null)
{
text2.setVisibility(View.GONE);
}
}
else
{
if (colorbar1 != null)
{
colorbar1.setVisibility(View.INVISIBLE);
}
if (colorbar2 != null)
{
colorbar2.setBackgroundColor(TaskFieldAdapters.LIST_COLOR.get(cursor));
colorbar2.setVisibility(View.VISIBLE);
}
// hide quick add and show task count
if (quickAddTask != null)
{
quickAddTask.setVisibility(View.GONE);
}
if (text2 != null)
{
text2.setVisibility(View.VISIBLE);
}
}
}
@Override
public void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags)
{
TextView title = getView(view, android.R.id.title);
boolean isClosed = cursor.getInt(13) > 0;
resetFlingView(view);
if (title != null)
{
String text = cursor.getString(5);
title.setText(text);
if (isClosed)
{
title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
else
{
title.setPaintFlags(title.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
}
}
setDueDate(getView(view, R.id.task_due_date), getView(view, R.id.task_due_image), INSTANCE_DUE_ADAPTER.get(cursor),
isClosed);
TextView startDateField = getView(view, R.id.task_start_date);
if (startDateField != null)
{
Time startDate = INSTANCE_START_ADAPTER.get(cursor);
if (startDate != null)
{
startDateField.setVisibility(View.VISIBLE);
startDateField.setText(new DateFormatter(view.getContext()).format(startDate, DateFormatContext.LIST_VIEW));
// format time
startDateField.setTextAppearance(view.getContext(), R.style.task_list_due_text);
ImageView icon = getView(view, R.id.task_start_image);
if (icon != null)
{
icon.setVisibility(View.VISIBLE);
}
}
else
{
startDateField.setText("");
}
}
View divider = getView(view, R.id.divider);
if (divider != null)
{
divider.setVisibility((flags & FLAG_IS_LAST_CHILD) != 0 ? View.GONE : View.VISIBLE);
}
// display priority
int priority = TaskFieldAdapters.PRIORITY.get(cursor);
View priorityView = getView(view, R.id.task_priority_view_medium);
priorityView.setBackgroundResource(android.R.color.transparent);
priorityView.setVisibility(View.VISIBLE);
if (priority > 0 && priority < 5)
{
priorityView.setBackgroundResource(R.color.priority_red);
}
if (priority == 5)
{
priorityView.setBackgroundResource(R.color.priority_yellow);
}
if (priority > 5 && priority <= 9)
{
priorityView.setBackgroundResource(R.color.priority_green);
}
new ProgressBackgroundView(getView(view, R.id.percentage_background_view))
.update(new NullSafe<>(TaskFieldAdapters.PERCENT_COMPLETE.get(cursor)));
setColorBar(view, cursor);
setDescription(view, cursor);
setOverlay(view, cursor.getPosition(), cursor.getCount());
}
@Override
public void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags)
{
TextView title = getView(view, android.R.id.title);
boolean isClosed = cursor.getInt(13) > 0;
resetFlingView(view);
if (title != null)
{
String text = cursor.getString(5);
title.setText(text);
if (isClosed)
{
title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
else
{
title.setPaintFlags(title.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
}
}
setDueDate(getView(view, R.id.task_due_date), null, INSTANCE_DUE_ADAPTER.get(cursor), isClosed);
View divider = getView(view, R.id.divider);
if (divider != null)
{
divider.setVisibility((flags & FLAG_IS_LAST_CHILD) != 0 ? View.GONE : View.VISIBLE);
}
// display priority
int priority = TaskFieldAdapters.PRIORITY.get(cursor);
View priorityView = getView(view, R.id.task_priority_view_medium);
priorityView.setBackgroundResource(android.R.color.transparent);
priorityView.setVisibility(View.VISIBLE);
if (priority > 0 && priority < 5)
{
priorityView.setBackgroundResource(R.color.priority_red);
}
if (priority == 5)
{
priorityView.setBackgroundResource(R.color.priority_yellow);
}
if (priority > 5 && priority <= 9)
{
priorityView.setBackgroundResource(R.color.priority_green);
}
new ProgressBackgroundView(getView(view, R.id.percentage_background_view))
.update(new NullSafe<>(TaskFieldAdapters.PERCENT_COMPLETE.get(cursor)));
setColorBar(view, cursor);
setDescription(view, cursor);
setOverlay(view, cursor.getPosition(), cursor.getCount());
}
@Override
public void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags)
{
int position = cursor.getPosition();
// set list title
TextView title = (TextView) view.findViewById(android.R.id.title);
if (title != null)
{
title.setText(getTitle(cursor, view.getContext()));
}
// set list elements
TextView text2 = (TextView) view.findViewById(android.R.id.text2);
int childrenCount = adapter.getChildrenCount(position);
if (text2 != null && ((ExpandableGroupDescriptorAdapter) adapter).childCursorLoaded(position))
{
Resources res = view.getContext().getResources();
text2.setText(res.getQuantityString(R.plurals.number_of_tasks, childrenCount, childrenCount));
}
// show/hide divider
View divider = view.findViewById(R.id.divider);
if (divider != null)
{
divider.setVisibility((flags & FLAG_IS_EXPANDED) != 0 && childrenCount > 0 ? View.VISIBLE : View.GONE);
}
View colorbar1 = view.findViewById(R.id.colorbar1);
View colorbar2 = view.findViewById(R.id.colorbar2);
View quickAddTask = view.findViewById(R.id.quick_add_task);
if (quickAddTask != null)
{
quickAddTask.setOnClickListener(quickAddClickListener);
quickAddTask.setTag(cursor.getInt(2 /* max priority of this section */));
}
if ((flags & FLAG_IS_EXPANDED) != 0)
{
if (colorbar1 != null)
{
colorbar1.setBackgroundColor(cursor.getInt(2));
colorbar1.setVisibility(View.VISIBLE);
}
if (colorbar2 != null)
{
colorbar2.setVisibility(View.GONE);
}
// show quick add and hide task count
if (quickAddTask != null)
{
quickAddTask.setVisibility(View.VISIBLE);
}
if (text2 != null)
{
text2.setVisibility(View.GONE);
}
}
else
{
if (colorbar1 != null)
{
colorbar1.setVisibility(View.INVISIBLE);
}
if (colorbar2 != null)
{
colorbar2.setBackgroundColor(cursor.getInt(2));
colorbar2.setVisibility(View.VISIBLE);
}
// hide quick add and show task count
if (quickAddTask != null)
{
quickAddTask.setVisibility(View.GONE);
}
if (text2 != null)
{
text2.setVisibility(View.VISIBLE);
}
}
}
@Override
public void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags)
{
TextView title = getView(view, android.R.id.title);
boolean isClosed = cursor.getInt(13) > 0;
resetFlingView(view);
if (title != null)
{
String text = cursor.getString(5);
title.setText(text);
if (isClosed)
{
title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
else
{
title.setPaintFlags(title.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
}
}
setDueDate(getView(view, R.id.task_due_date), null, INSTANCE_DUE_ADAPTER.get(cursor), isClosed);
View divider = getView(view, R.id.divider);
if (divider != null)
{
divider.setVisibility((flags & FLAG_IS_LAST_CHILD) != 0 ? View.GONE : View.VISIBLE);
}
// display priority
int priority = TaskFieldAdapters.PRIORITY.get(cursor);
View priorityView = getView(view, R.id.task_priority_view_medium);
priorityView.setBackgroundResource(android.R.color.transparent);
priorityView.setVisibility(View.VISIBLE);
if (priority > 0 && priority < 5)
{
priorityView.setBackgroundResource(R.color.priority_red);
}
if (priority == 5)
{
priorityView.setBackgroundResource(R.color.priority_yellow);
}
if (priority > 5 && priority <= 9)
{
priorityView.setBackgroundResource(R.color.priority_green);
}
new ProgressBackgroundView(getView(view, R.id.percentage_background_view))
.update(new NullSafe<>(TaskFieldAdapters.PERCENT_COMPLETE.get(cursor)));
setColorBar(view, cursor);
setDescription(view, cursor);
setOverlay(view, cursor.getPosition(), cursor.getCount());
}
@Override
public void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags)
{
int position = cursor.getPosition();
// set list title
TextView title = (TextView) view.findViewById(android.R.id.title);
if (title != null)
{
title.setText(getTitle(cursor, view.getContext()));
}
// set list elements
TextView text2 = (TextView) view.findViewById(android.R.id.text2);
int childrenCount = adapter.getChildrenCount(position);
if (text2 != null && ((ExpandableGroupDescriptorAdapter) adapter).childCursorLoaded(position))
{
Resources res = view.getContext().getResources();
text2.setText(res.getQuantityString(R.plurals.number_of_tasks, childrenCount, childrenCount));
}
// show/hide divider
View divider = view.findViewById(R.id.divider);
if (divider != null)
{
divider.setVisibility((flags & FLAG_IS_EXPANDED) != 0 && childrenCount > 0 ? View.VISIBLE : View.GONE);
}
View colorbar1 = view.findViewById(R.id.colorbar1);
View colorbar2 = view.findViewById(R.id.colorbar2);
if ((flags & FLAG_IS_EXPANDED) != 0)
{
if (colorbar1 != null)
{
colorbar1.setBackgroundColor(cursor.getInt(2));
colorbar1.setVisibility(View.GONE);
}
if (colorbar2 != null)
{
colorbar2.setVisibility(View.GONE);
}
}
else
{
if (colorbar1 != null)
{
colorbar1.setVisibility(View.GONE);
}
if (colorbar2 != null)
{
colorbar2.setBackgroundColor(cursor.getInt(2));
colorbar2.setVisibility(View.GONE);
}
}
}
@Override
public void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags)
{
TextView title = getView(view, android.R.id.title);
boolean isClosed = cursor.getInt(13) > 0;
resetFlingView(view);
if (title != null)
{
String text = cursor.getString(5);
title.setText(text);
if (isClosed)
{
title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
else
{
title.setPaintFlags(title.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
}
}
setDueDate(getView(view, R.id.task_due_date), null, INSTANCE_DUE_ADAPTER.get(cursor), isClosed);
View divider = getView(view, R.id.divider);
if (divider != null)
{
divider.setVisibility((flags & FLAG_IS_LAST_CHILD) != 0 ? View.GONE : View.VISIBLE);
}
// display priority
int priority = TaskFieldAdapters.PRIORITY.get(cursor);
View priorityView = getView(view, R.id.task_priority_view_medium);
priorityView.setBackgroundResource(android.R.color.transparent);
priorityView.setVisibility(View.VISIBLE);
if (priority > 0 && priority < 5)
{
priorityView.setBackgroundResource(R.color.priority_red);
}
if (priority == 5)
{
priorityView.setBackgroundResource(R.color.priority_yellow);
}
if (priority > 5 && priority <= 9)
{
priorityView.setBackgroundResource(R.color.priority_green);
}
new ProgressBackgroundView(getView(view, R.id.percentage_background_view))
.update(new NullSafe<>(TaskFieldAdapters.PERCENT_COMPLETE.get(cursor)));
setColorBar(view, cursor);
setDescription(view, cursor);
setOverlay(view, cursor.getPosition(), cursor.getCount());
}
@SuppressLint("NewApi")
@Override
public void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags)
{
TextView title = getView(view, android.R.id.title);
boolean isClosed = TaskFieldAdapters.IS_CLOSED.get(cursor);
resetFlingView(view);
if (title != null)
{
String text = TaskFieldAdapters.TITLE.get(cursor);
// float score = TaskFieldAdapters.SCORE.get(cursor);
title.setText(text);
if (isClosed)
{
title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
else
{
title.setPaintFlags(title.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
}
}
setDueDate(getView(view, R.id.task_due_date), null, INSTANCE_DUE_ADAPTER.get(cursor), isClosed);
View divider = getView(view, R.id.divider);
if (divider != null)
{
divider.setVisibility((flags & FLAG_IS_LAST_CHILD) != 0 ? View.GONE : View.VISIBLE);
}
// display priority
int priority = TaskFieldAdapters.PRIORITY.get(cursor);
View priorityView = getView(view, R.id.task_priority_view_medium);
priorityView.setBackgroundResource(android.R.color.transparent);
priorityView.setVisibility(View.VISIBLE);
if (priority > 0 && priority < 5)
{
priorityView.setBackgroundResource(R.color.priority_red);
}
if (priority == 5)
{
priorityView.setBackgroundResource(R.color.priority_yellow);
}
if (priority > 5 && priority <= 9)
{
priorityView.setBackgroundResource(R.color.priority_green);
}
new ProgressBackgroundView(getView(view, R.id.percentage_background_view))
.update(new NullSafe<>(TaskFieldAdapters.PERCENT_COMPLETE.get(cursor)));
setColorBar(view, cursor);
setDescription(view, cursor);
setOverlay(view, cursor.getPosition(), cursor.getCount());
}
@Override
public void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags)
{
long now = System.currentTimeMillis();
int position = cursor.getPosition();
// set list title
String groupTitle = getTitle(cursor, view.getContext());
TextView title = (TextView) view.findViewById(android.R.id.title);
if (title != null)
{
title.setText(groupTitle);
}
// set search time
TextView text1 = (TextView) view.findViewById(android.R.id.text1);
if (text1 != null)
{
text1.setText(DateUtils.getRelativeTimeSpanString(
cursor.getLong(cursor.getColumnIndex(SearchHistoryDatabaseHelper.SearchHistoryColumns.TIMESTAMP)), now, DateUtils.MINUTE_IN_MILLIS));
}
// set list elements
TextView text2 = (TextView) view.findViewById(android.R.id.text2);
int childrenCount = adapter.getChildrenCount(position);
if (text2 != null && ((ExpandableGroupDescriptorAdapter) adapter).childCursorLoaded(position))
{
Resources res = view.getContext().getResources();
text2.setText(res.getQuantityString(R.plurals.number_of_tasks, childrenCount, childrenCount));
}
// show/hide divider
View divider = view.findViewById(R.id.divider);
if (divider != null)
{
divider.setVisibility((flags & FLAG_IS_EXPANDED) != 0 && childrenCount > 0 ? View.VISIBLE : View.GONE);
}
View colorbar1 = view.findViewById(R.id.colorbar1);
View colorbar2 = view.findViewById(R.id.colorbar2);
if (colorbar1 != null)
{
colorbar1.setVisibility(View.GONE);
}
if (colorbar2 != null)
{
colorbar2.setVisibility(View.GONE);
}
View removeSearch = view.findViewById(R.id.quick_add_task);
if (removeSearch != null)
{
((ImageView) removeSearch).setImageResource(R.drawable.content_remove);
removeSearch.setOnClickListener(removeListener);
GroupTag tag = (GroupTag) removeSearch.getTag();
Long groupId = cursor.getLong(cursor.getColumnIndex(SearchHistoryColumns._ID));
if (tag == null || tag.groupId != groupId)
{
removeSearch.setTag(new GroupTag(groupTitle, groupId));
}
}
if ((flags & FLAG_IS_EXPANDED) != 0)
{
if (removeSearch != null)
{
removeSearch.setVisibility(View.VISIBLE);
}
if (text2 != null)
{
text2.setVisibility(View.GONE);
}
}
else
{
if (removeSearch != null)
{
removeSearch.setVisibility(View.GONE);
}
if (text2 != null)
{
text2.setVisibility(View.VISIBLE);
}
}
// TODO: swap styles instead of modifying the font style
boolean isHistoric = cursor.getInt(cursor.getColumnIndex(SearchHistoryColumns.HISTORIC)) > 0;
Typeface oldtypeface = title.getTypeface();
title.setTypeface(oldtypeface, swapStyle(isHistoric, oldtypeface));
// set history icon
ImageView icon = (ImageView) view.findViewById(android.R.id.icon);
icon.setImageResource(R.drawable.ic_history);
icon.setVisibility(isHistoric ? View.VISIBLE : View.INVISIBLE);
}
/**
* Populate a view in an {@link ExpandableListView}.
*
* @param view
* The {@link View} to populate.
* @param cursor
* A {@link Cursor} that points to the current data item.
* @param adapter
* The {@link BaseExpandableListAdapter}.
* @param flags
* Some flags that give additional information about the view. Any combination of {@link #FLAG_IS_EXPANDED} or {@link #FLAG_IS_LAST_CHILD}.
*/
void populateView(View view, Cursor cursor, BaseExpandableListAdapter adapter, int flags);