@Override public View getView(final int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater inflater = getLayoutInflater(); v = inflater.inflate(net.osmand.plus.R.layout.download_index_list_item, parent, false); } final View row = v; TextView item = (TextView) row.findViewById(R.id.download_item); TextView description = (TextView) row.findViewById(R.id.download_descr); IndexItem e = getItem(position); item.setText( e.getVisibleDescription(DownloadIndexActivity.this) + "\n" + e.getVisibleName()); // $NON-NLS-1$ description.setText(e.getDate() + "\n" + e.getSize() + " MB"); CheckBox ch = (CheckBox) row.findViewById(R.id.check_download_item); ch.setChecked(entriesToDownload.containsKey(e.getFileName())); ch.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { final CheckBox ch = (CheckBox) v.findViewById(R.id.check_download_item); ch.setChecked(!ch.isChecked()); DownloadIndexActivity.this.onListItemClick( getListView(), row, position, getItemId(position)); } }); if (indexFileNames != null) { String sfName = convertServerFileNameToLocal(e.getFileName()); if (!indexFileNames.containsKey(sfName)) { item.setTextColor(Color.WHITE); } else { if (e.getDate() != null) { if (e.getDate().equals(indexFileNames.get(sfName))) { item.setTextColor(Color.GREEN); } else { item.setTextColor(Color.BLUE); } } else { item.setTextColor(Color.GREEN); } } } return row; }
@Override public View getChildView( final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater inflater = getLayoutInflater(); v = inflater.inflate(net.osmand.plus.R.layout.download_index_list_item, parent, false); } final View row = v; TextView item = (TextView) row.findViewById(R.id.download_item); TextView description = (TextView) row.findViewById(R.id.download_descr); IndexItem e = (IndexItem) getChild(groupPosition, childPosition); item.setText( (e.getVisibleDescription(DownloadIndexActivity.this) + "\n" + e.getVisibleName()) .trim()); //$NON-NLS-1$ description.setText(e.getDate() + "\n" + e.getSize() + " MB"); CheckBox ch = (CheckBox) row.findViewById(R.id.check_download_item); ch.setChecked(entriesToDownload.containsKey(e.getFileName())); ch.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { final CheckBox ch = (CheckBox) v.findViewById(R.id.check_download_item); ch.setChecked(!ch.isChecked()); DownloadIndexActivity.this.onChildClick( getListView(), row, groupPosition, childPosition, getChildId(groupPosition, childPosition)); } }); if (indexFileNames != null) { String sfName = convertServerFileNameToLocal(e.getFileName()); if (!indexFileNames.containsKey(sfName)) { item.setTextColor(getResources().getColor(R.color.index_unknown)); } else { if (e.getDate() != null) { if (e.getDate().equals(indexActivatedFileNames.get(sfName))) { item.setText( item.getText() + "\n" + getResources().getString(R.string.local_index_installed) + " : " + indexActivatedFileNames.get(sfName)); item.setTextColor(getResources().getColor(R.color.act_index_uptodate)); // GREEN } else if (e.getDate().equals(indexFileNames.get(sfName))) { item.setText( item.getText() + "\n" + getResources().getString(R.string.local_index_installed) + " : " + indexFileNames.get(sfName)); item.setTextColor( getResources().getColor(R.color.deact_index_uptodate)); // DARK_GREEN } else if (indexActivatedFileNames.containsKey(sfName)) { item.setText( item.getText() + "\n" + getResources().getString(R.string.local_index_installed) + " : " + indexActivatedFileNames.get(sfName)); item.setTextColor( getResources().getColor(R.color.act_index_updateable)); // LIGHT_BLUE } else { item.setText( item.getText() + "\n" + getResources().getString(R.string.local_index_installed) + " : " + indexFileNames.get(sfName)); item.setTextColor( getResources().getColor(R.color.deact_index_updateable)); // DARK_BLUE } } else { item.setTextColor(getResources().getColor(R.color.act_index_uptodate)); } } } return row; }