コード例 #1
0
    @Override
    public View getChildView(
        final int groupPosition,
        final int childPosition,
        boolean isLastChild,
        View convertView,
        ViewGroup parent) {
      final Object child = getChild(groupPosition, childPosition);
      if (child instanceof IndexItem) {

        IndexItem item = (IndexItem) child;
        DownloadResourceGroup group = getGroupObj(groupPosition);
        ItemViewHolder viewHolder;
        if (convertView != null && convertView.getTag() instanceof ItemViewHolder) {
          viewHolder = (ItemViewHolder) convertView.getTag();
        } else {
          convertView =
              LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.two_line_with_images_list_item, parent, false);
          viewHolder = new ItemViewHolder(convertView, ctx);
          viewHolder.setShowRemoteDate(true);
          convertView.setTag(viewHolder);
        }
        if (mainGroup.getType() == DownloadResourceGroupType.REGION
            && group != null
            && group.getType() == DownloadResourceGroupType.REGION_MAPS) {
          viewHolder.setShowTypeInName(true);
          viewHolder.setShowTypeInDesc(false);
        } else if (group != null
            && (group.getType() == DownloadResourceGroupType.SRTM_HEADER
                || group.getType() == DownloadResourceGroupType.HILLSHADE_HEADER)) {
          viewHolder.setShowTypeInName(false);
          viewHolder.setShowTypeInDesc(false);
        } else {
          viewHolder.setShowTypeInDesc(true);
        }
        viewHolder.bindIndexItem(item, group);
      } else {
        DownloadResourceGroup group = (DownloadResourceGroup) child;
        DownloadGroupViewHolder viewHolder;
        if (convertView != null && convertView.getTag() instanceof DownloadGroupViewHolder) {
          viewHolder = (DownloadGroupViewHolder) convertView.getTag();
        } else {
          convertView =
              LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.simple_list_menu_item, parent, false);
          viewHolder = new DownloadGroupViewHolder(ctx, convertView);
          convertView.setTag(viewHolder);
        }
        viewHolder.bindItem(group);
      }

      return convertView;
    }
コード例 #2
0
 @Override
 public boolean onChildClick(
     ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
   Object child = listAdapter.getChild(groupPosition, childPosition);
   if (child instanceof DownloadResourceGroup) {
     String uniqueId = ((DownloadResourceGroup) child).getUniqueId();
     final DownloadResourceGroupFragment regionDialogFragment =
         DownloadResourceGroupFragment.createInstance(uniqueId);
     ((DownloadActivity) getActivity()).showDialog(getActivity(), regionDialogFragment);
     return true;
   } else if (child instanceof IndexItem) {
     IndexItem indexItem = (IndexItem) child;
     DownloadResourceGroup groupObj = listAdapter.getGroupObj(groupPosition);
     ItemViewHolder vh = (ItemViewHolder) v.getTag();
     OnClickListener ls =
         vh.getRightButtonAction(indexItem, vh.getClickAction(indexItem), groupObj);
     ls.onClick(v);
     return true;
   }
   return false;
 }