Can now also add return route when adding a route

This commit is contained in:
Doug Keen 2011-07-11 12:19:21 -07:00
parent a249563b27
commit c6da0f6104
4 changed files with 19 additions and 5 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dougkeen.bart" android:versionCode="4"
package="com.dougkeen.bart" android:versionCode="5"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

View File

@ -19,8 +19,11 @@
<Spinner android:id="@+id/destination_spinner"
android:layout_below="@id/destination_label" android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<CheckBox android:id="@+id/return_checkbox"
android:layout_below="@id/destination_spinner" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:text="@string/also_add_return_route" />
<LinearLayout android:layout_height="wrap_content"
android:layout_width="fill_parent" android:layout_below="@id/destination_spinner"
android:layout_width="fill_parent" android:layout_below="@id/return_checkbox"
style="@style/ButtonBar" android:id="@+id/buttonBar"
android:orientation="horizontal">
<Button android:text="@string/save" android:layout_weight="1"

View File

@ -26,4 +26,5 @@
<string name="view_on_bart_site">View details on BART site</string>
<string name="could_not_connect">Could not connect to BART services. Please try
again later.</string>
<string name="also_add_return_route">Also add return route</string>
</resources>

View File

@ -10,6 +10,7 @@ import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.Toast;
@ -24,13 +25,12 @@ public class AddRouteActivity extends Activity {
setContentView(R.layout.add_favorite);
SpinnerAdapter originSpinnerAdapter = new ArrayAdapter<Station>(this,
R.layout.simple_spinner_item, Station.values());
R.layout.simple_spinner_item, Station.getStationList());
((Spinner) findViewById(R.id.origin_spinner))
.setAdapter(originSpinnerAdapter);
SpinnerAdapter destinationSpinnerAdapter = new ArrayAdapter<Station>(
this,
R.layout.simple_spinner_item, Station.values());
this, R.layout.simple_spinner_item, Station.getStationList());
((Spinner) findViewById(R.id.destination_spinner))
.setAdapter(destinationSpinnerAdapter);
@ -85,6 +85,16 @@ public class AddRouteActivity extends Activity {
Uri newUri = getContentResolver().insert(
Constants.FAVORITE_CONTENT_URI, values);
if (((CheckBox) findViewById(R.id.return_checkbox)).isChecked()) {
values = new ContentValues();
values.put(RoutesColumns.FROM_STATION.string,
destination.abbreviation);
values.put(RoutesColumns.TO_STATION.string, origin.abbreviation);
getContentResolver().insert(Constants.FAVORITE_CONTENT_URI, values);
}
setResult(RESULT_OK, (new Intent()).setAction(newUri.toString()));
finish();
}