コード例 #1
0
 @Override
 public boolean onChildClick(
     ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
   LocalIndexInfo item = listAdapter.getChild(groupPosition, childPosition);
   item.setExpanded(!item.isExpanded());
   if (item.isExpanded()) {
     descriptionLoader = new LoadLocalIndexDescriptionTask();
     descriptionLoader.execute(item);
   }
   if (selectionMode) {
     selectedItems.add(item);
   }
   listAdapter.notifyDataSetInvalidated();
   return true;
 }
コード例 #2
0
    @Override
    public View getChildView(
        int groupPosition,
        int childPosition,
        boolean isLastChild,
        View convertView,
        ViewGroup parent) {
      View v = convertView;
      final LocalIndexInfo child = (LocalIndexInfo) getChild(groupPosition, childPosition);
      if (v == null) {
        LayoutInflater inflater = getLayoutInflater();
        v = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false);
      }
      TextView viewName = ((TextView) v.findViewById(R.id.local_index_name));
      viewName.setText(child.getName());
      if (child.isNotSupported()) {
        viewName.setTextColor(Color.RED);
      } else if (child.isCorrupted()) {
        viewName.setTextColor(Color.MAGENTA);
      } else if (child.isLoaded()) {
        viewName.setTextColor(Color.GREEN);
      } else {
        viewName.setTextColor(Color.LTGRAY);
      }
      if (child.getSize() >= 0) {
        String size;
        if (child.getSize() > 100) {
          size = formatMb.format(new Object[] {(float) child.getSize() / (1 << 10)});
        } else {
          size = child.getSize() + " Kb";
        }
        ((TextView) v.findViewById(R.id.local_index_size)).setText(size);
      } else {
        ((TextView) v.findViewById(R.id.local_index_size)).setText("");
      }
      TextView descr = ((TextView) v.findViewById(R.id.local_index_descr));
      if (child.isExpanded()) {
        descr.setVisibility(View.VISIBLE);
        descr.setText(child.getDescription());
      } else {
        descr.setVisibility(View.GONE);
      }
      final CheckBox checkbox = (CheckBox) v.findViewById(R.id.check_local_index);
      checkbox.setVisibility(selectionMode ? View.VISIBLE : View.GONE);
      if (selectionMode) {
        checkbox.setChecked(selectedItems.contains(child));
        checkbox.setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                if (checkbox.isChecked()) {
                  selectedItems.add(child);
                } else {
                  selectedItems.remove(child);
                }
              }
            });
      }

      return v;
    }