Android Open Source - GTFSOffline timestopdesc Array Adapter

From Project

Back to project page GTFSOffline.


The source code is released under:

GNU General Public License

If you think the Android project GTFSOffline listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

 * Copyright 2011 Giles Malet.//  w w w.  j  a v  a 2s .c  o m
 * Modified 2013 Wilson Brenna.
 * This file is part of GTFSOffline.
 * GTFSOffline 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, either version 3 of the License, or
 * (at your option) any later version.
 * GTFSOffline is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with GTFSOffline.  If not, see <>.

 * An adapter that is used when drawing the main window list of details.
package com.wbrenna.gtfsoffline;

import java.util.ArrayList;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class timestopdescArrayAdapter extends ArrayAdapter <String[]> /*<ArrayList<String[]>>*/ {
  //private static final String TAG = "timestopdescAdapter";

  private final ArrayList<String[]> mDetails;
  private final LayoutInflater mInflater;
  private final int mLayout;

  public timestopdescArrayAdapter(FragmentActivity context, int layout, ArrayList<String[]> details) {
    super(context, layout, details);
    // Log.v(TAG, "timestopdescArrayAdapter()");

    mDetails = details;
    mInflater = LayoutInflater.from(context);
    mLayout = layout;

  static class ViewHolder {
    TextView stoptime; //this is the distance to the stop (not labeled well!)
    TextView label;  //this is stop_id - now changed to Short Route Name
    TextView value; // this is stop_name + stop_id
    TextView tripheader; //this is the trip header
    TextView departsin; //the time until it departs
    TextView tripid; //a hidden trip id
    TextView dbname; //a hidden database name so Fav knows where to search

  public View getView(int position, View view, ViewGroup parent) {
    // Log.v(TAG, "getview(): position " + position);
    ViewHolder holder;

    // Reuse the convertView if we already have one.... Android will create
    // only enough to fill the screen.
    if (view == null) {
      view = mInflater.inflate(mLayout, parent, false);
      // Log.d(TAG, "new view " + view);

      // Save the view when we look them up.
      holder = new ViewHolder();
      holder.stoptime = (TextView) view.findViewById(;
      holder.label = (TextView) view.findViewById(;
      holder.value = (TextView) view.findViewById(;
      holder.tripheader = (TextView) view.findViewById(;
      holder.departsin = (TextView) view.findViewById(;
      holder.tripid = (TextView) view.findViewById(;
      holder.dbname = (TextView) view.findViewById(;
    } else {
      // Log.d(TAG, "reusing view " + view);
      holder = (ViewHolder) view.getTag();

    if (mDetails.size() >= position) {
      if (mDetails.get(position).length > 7)
                //add the stop ID to the stop name
        holder.value.setText(mDetails.get(position)[2] + " - " + mDetails.get(position)[1]);
    return view;

Java Source Code List