Android Open Source - proximo Route






From Project

Back to project page proximo.

License

The source code is released under:

Copyright (c) 2010 Evan Martin. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *...

If you think the Android project proximo 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 (c) 2010 Evan Martin.  All rights reserved.
// Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
/*  w ww . j a va  2 s  .  c  o m*/
package org.neugierig.proximo;

import android.app.*;
import android.content.*;
import android.os.Bundle;
import android.widget.*;
import android.view.*;

public class Route extends ListActivity implements AsyncBackendHelper.Delegate {
  private String mRouteId;
  private String mRouteName;
  private ProximoBus.Run[] mRuns;
  private AsyncBackendHelper mBackendHelper;

  private class RunsQuery implements AsyncBackend.Query {
    final String mRouteId;
    RunsQuery(String routeId) {
      mRouteId = routeId;
    }
    public Object runQuery(Backend backend) throws Exception {
      return backend.fetchRunsOnRoute(mRouteId);
    }
  }

  @Override
  public void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceState);

    mRouteId = getIntent().getExtras().getString(ViewState.ROUTE_ID_KEY);
    mRouteName = getIntent().getExtras().getString(ViewState.ROUTE_NAME_KEY);

    ListAdapter adapter = new ArrayAdapter<String>(
        this,
        android.R.layout.simple_list_item_1,
        new String[] {});
    setListAdapter(adapter);

    mBackendHelper = new AsyncBackendHelper(this, this);
    mBackendHelper.start(new RunsQuery(mRouteId));
  }

  @Override
  protected Dialog onCreateDialog(int id) {
    return mBackendHelper.onCreateDialog(id);
  }

  @Override
  public void onAsyncResult(Object data) {
    mRuns = (ProximoBus.Run[]) data;
    ListAdapter adapter = new ArrayAdapter<ProximoBus.Run>(
        this,
        android.R.layout.simple_list_item_1,
        mRuns);
    setListAdapter(adapter);
  }

  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    ProximoBus.Run run = mRuns[position];
    Intent intent = new Intent(this, Stops.class);
    intent.putExtra(ViewState.ROUTE_NAME_KEY, mRouteName);
    intent.putExtra(ViewState.ROUTE_ID_KEY, mRouteId);
    intent.putExtra(ViewState.RUN_NAME_KEY, run.displayName);
    intent.putExtra(ViewState.RUN_ID_KEY, run.id);
    startActivity(intent);
  }
}




Java Source Code List

org.neugierig.proximo.AsyncBackendHelper.java
org.neugierig.proximo.AsyncBackend.java
org.neugierig.proximo.Backend.java
org.neugierig.proximo.Database.java
org.neugierig.proximo.ProximoBus.java
org.neugierig.proximo.Route.java
org.neugierig.proximo.Routes.java
org.neugierig.proximo.SplitListAdapter.java
org.neugierig.proximo.StarDBAdapter.java
org.neugierig.proximo.Stop.java
org.neugierig.proximo.Stops.java
org.neugierig.proximo.UpdateService.java
org.neugierig.proximo.ViewState.java