Back to project page keepmoving.
The source code is released under:
GNU General Public License
If you think the Android project keepmoving listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package it.rainbowbreeze.keepmoving.ui; /*from w ww . jav a2s .c o m*/ import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; import java.util.HashMap; import it.rainbowbreeze.keepmoving.R; import it.rainbowbreeze.keepmoving.common.Utils; import it.rainbowbreeze.keepmoving.domain.GeoPoint; import it.rainbowbreeze.keepmoving.domain.GeoPointTypes; /** * This file is part of KeepMoving. KeepMoving is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation, version 2. * <p/> * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * <p/> * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * <p/> * Copyright Alfredo Morresi * <p/> * Created by Alfredo "Rainbowbreeze" Morresi on 02/07/14. */ /** * List Adapter to show path steps */ public class StepsArrayAdapter extends ArrayAdapter<GeoPoint> { private final LayoutInflater mLayoutInflater; private final static HashMap<GeoPointTypes, Integer> mTypeIconMap; static { mTypeIconMap = new HashMap<GeoPointTypes, Integer>(); mTypeIconMap.put(GeoPointTypes.Bus, R.drawable.type_bus); mTypeIconMap.put(GeoPointTypes.Car, R.drawable.type_car); mTypeIconMap.put(GeoPointTypes.Foot, R.drawable.type_walk); mTypeIconMap.put(GeoPointTypes.Other, R.drawable.type_other); mTypeIconMap.put(GeoPointTypes.Train, R.drawable.type_train); mTypeIconMap.put(GeoPointTypes.Tube, R.drawable.type_tube); } public StepsArrayAdapter(Context context) { super(context, 0); mLayoutInflater = LayoutInflater.from(context); } @Override public View getView(int position, View convertView, ViewGroup parent) { if (null == convertView) { convertView = mLayoutInflater.inflate(R.layout.vw_step, null); Holder holder = new Holder(); holder.imgType = (ImageView) convertView.findViewById(R.id.step_lblType); holder.lblName = (TextView) convertView.findViewById(R.id.step_lblName); holder.lblLength = (TextView) convertView.findViewById(R.id.step_lblLenght); holder.lblStartingTime = (TextView) convertView.findViewById(R.id.step_lblStartingTime); convertView.setTag(holder); } Holder holder = (Holder) convertView.getTag(); GeoPoint point = getItem(position); holder.imgType.setImageResource(mTypeIconMap.get(point.getType())); holder.lblName.setText(point.getName()); if (point.isValidForAllTime()) { holder.lblStartingTime.setText("--"); } else { holder.lblStartingTime.setText(Utils.getTimeFromTimestamp(point.getValidTime())); } holder.lblLength.setText(point.getLenght() + convertView.getContext().getString(R.string.step_minutesShort)); return convertView; } private static class Holder { public ImageView imgType; public TextView lblName; public TextView lblLength; public TextView lblStartingTime; } }