Android Open Source - openmbta-android trans Adapter






From Project

Back to project page openmbta-android.

License

The source code is released under:

Copyright (c) 2014 Kaja Software Corporation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal...

If you think the Android project openmbta-android 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

package com.kaja.openmbta;
//from w ww  .  ja va2s .  c om
import android.content.Context;
import java.util.*;

import com.kaja.openmbta.transItem;

import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.widget.*;

public class transAdapter extends ArrayAdapter<transItem> {

    int resource;

    public transAdapter(Context _context, 
                               int _resource, 
                               List<transItem> _items) {
      super(_context, _resource, _items);
      resource = _resource;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
     View row=convertView;
    transHolder holder=null;
      transItem item = getItem(position);
        
        if (row==null) {    
           String sinflater = Context.LAYOUT_INFLATER_SERVICE;
              LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(sinflater);
          
          //LayoutInflater inflater=getLayoutInflater();
          
          row=inflater.inflate(resource, parent, false);
          holder=new transHolder(row);
          row.setTag(holder);
        }
        else {
          holder=(transHolder)row.getTag();
        }
        
        //holder.populateFrom(item.get(position));
        holder.populateFrom(item);
        
        return(row);

    }
    
    static class transHolder {
      private TextView name=null;
      private TextView desc=null;
      private ImageView icon=null;
      
      transHolder(View row) {
        name=(TextView)row.findViewById(R.id.title);
        desc=(TextView)row.findViewById(R.id.description);
        icon=(ImageView)row.findViewById(R.id.icon);
      }
      
      void populateFrom(transItem t) {
        name.setText(t.getName());
        desc.setText(t.getDesc());
    
        if (t.getType().toLowerCase().equals("subway")) {
          icon.setImageResource(R.drawable.subway);
        
        }
        else if (t.getType().toLowerCase().equals("bus")) {
          icon.setImageResource(R.drawable.bus);
        }
        else if (t.getType().equals("ybus")) {
          icon.setImageResource(R.drawable.bus);
        }
        else if (t.getType().toLowerCase().equals("boat")) {
          icon.setImageResource(R.drawable.boat);
        }
        else if (t.getType().toLowerCase().equals("commuter rail")) {
          icon.setImageResource(R.drawable.train);
        }
        else if (t.getType().toLowerCase().equals("train")) {
          icon.setImageResource(R.drawable.train);
        }
        else if (t.getType().equals("alert")) {
            icon.setImageResource(R.drawable.alert);
        }
        else if (t.getType().equals("tweet")) {
          icon.setImageResource(R.drawable.tweet);
      }
        else {
          icon.setImageResource(R.drawable.boat);
        }
      }
    }
  }




Java Source Code List

com.kaja.openmbta.JsonParser.java
com.kaja.openmbta.KajaItemizedOverlay.java
com.kaja.openmbta.MergeAdapter.java
com.kaja.openmbta.OpenMBTA.java
com.kaja.openmbta.RItemizedOverlay.java
com.kaja.openmbta.RoutesItemizedOverlay.java
com.kaja.openmbta.Routes.java
com.kaja.openmbta.ScheduleAdapter.java
com.kaja.openmbta.ScheduleItem.java
com.kaja.openmbta.ScheduleTab.java
com.kaja.openmbta.SplashScreen.java
com.kaja.openmbta.TransDetails.java
com.kaja.openmbta.WebViewer.java
com.kaja.openmbta.hashFile.java
com.kaja.openmbta.transAdapter.java
com.kaja.openmbta.transItem.java
com.readystatesoftware.mapviewballoons.BalloonItemizedOverlay.java
com.readystatesoftware.mapviewballoons.BalloonOverlayView.java