Browse files

First commit

  • Loading branch information...
0 parents commit de8edeba51c90efa98389bd671eb59bd32ed1466 @seansouthern committed Aug 28, 2012
Showing with 2,925 additions and 0 deletions.
  1. +10 −0 .classpath
  2. +33 −0 .project
  3. +12 −0 .settings/org.eclipse.jdt.core.prefs
  4. +35 −0 AndroidManifest.xml
  5. BIN assets/abtv2.db
  6. BIN assets/abtv3.db
  7. BIN bin/AnchorageBusTimes.apk
  8. BIN bin/AnchorageBusTracker.apk
  9. +35 −0 bin/AndroidManifest.xml
  10. BIN bin/classes.dex
  11. BIN bin/classes/com/seansouthern/anchoragebustimes/BuildConfig.class
  12. BIN bin/classes/com/seansouthern/anchoragebustimes/FavoritesList$1.class
  13. BIN bin/classes/com/seansouthern/anchoragebustimes/FavoritesList.class
  14. BIN bin/classes/com/seansouthern/anchoragebustimes/MySQLiteHelper.class
  15. BIN bin/classes/com/seansouthern/anchoragebustimes/R$array.class
  16. BIN bin/classes/com/seansouthern/anchoragebustimes/R$attr.class
  17. BIN bin/classes/com/seansouthern/anchoragebustimes/R$drawable.class
  18. BIN bin/classes/com/seansouthern/anchoragebustimes/R$id.class
  19. BIN bin/classes/com/seansouthern/anchoragebustimes/R$layout.class
  20. BIN bin/classes/com/seansouthern/anchoragebustimes/R$menu.class
  21. BIN bin/classes/com/seansouthern/anchoragebustimes/R$string.class
  22. BIN bin/classes/com/seansouthern/anchoragebustimes/R$style.class
  23. BIN bin/classes/com/seansouthern/anchoragebustimes/R.class
  24. BIN bin/classes/com/seansouthern/anchoragebustimes/RouteList$1.class
  25. BIN bin/classes/com/seansouthern/anchoragebustimes/RouteList.class
  26. BIN bin/classes/com/seansouthern/anchoragebustimes/StopsList$1.class
  27. BIN bin/classes/com/seansouthern/anchoragebustimes/StopsList$2.class
  28. BIN bin/classes/com/seansouthern/anchoragebustimes/StopsList$3.class
  29. BIN bin/classes/com/seansouthern/anchoragebustimes/StopsList.class
  30. BIN bin/classes/com/seansouthern/anchoragebustimes/TimesLoader.class
  31. BIN bin/classes/com/seansouthern/anchoragebustimes/TimesTable.class
  32. BIN bin/classes/com/seansouthern/anchoragebustimes/main$1.class
  33. BIN bin/classes/com/seansouthern/anchoragebustimes/main$2.class
  34. BIN bin/classes/com/seansouthern/anchoragebustimes/main$3.class
  35. BIN bin/classes/com/seansouthern/anchoragebustimes/main.class
  36. BIN bin/classes/com/seansouthern/anchoragebustimes/map$1.class
  37. BIN bin/classes/com/seansouthern/anchoragebustimes/map$2.class
  38. BIN bin/classes/com/seansouthern/anchoragebustimes/map$3.class
  39. BIN bin/classes/com/seansouthern/anchoragebustimes/map$4$1.class
  40. BIN bin/classes/com/seansouthern/anchoragebustimes/map$4.class
  41. BIN bin/classes/com/seansouthern/anchoragebustimes/map$BusRefresher.class
  42. BIN bin/classes/com/seansouthern/anchoragebustimes/map$LatLonPoint.class
  43. BIN bin/classes/com/seansouthern/anchoragebustimes/map$LineCoords.class
  44. BIN bin/classes/com/seansouthern/anchoragebustimes/map$LineOverlay.class
  45. BIN bin/classes/com/seansouthern/anchoragebustimes/map$MapTimesLoader.class
  46. BIN bin/classes/com/seansouthern/anchoragebustimes/map$MapTimesTable.class
  47. BIN bin/classes/com/seansouthern/anchoragebustimes/map$SpinnerItemListener.class
  48. BIN bin/classes/com/seansouthern/anchoragebustimes/map.class
  49. +3 −0 bin/jarlist.cache
  50. BIN bin/res/drawable/abt.png
  51. BIN bin/res/drawable/abth.png
  52. BIN bin/res/drawable/abtl.png
  53. BIN bin/res/drawable/busmarker.png
  54. BIN bin/res/drawable/double_bus.png
  55. BIN bin/res/drawable/marker.png
  56. BIN bin/resources.ap_
  57. +6 −0 gen/com/seansouthern/anchoragebustimes/BuildConfig.java
  58. +65 −0 gen/com/seansouthern/anchoragebustimes/R.java
  59. BIN libs/jsoup-1.6.2.jar
  60. BIN libs/overlaymanager-1.0.1.jar
  61. +3 −0 lint.xml
  62. +40 −0 proguard.cfg
  63. +11 −0 project.properties
  64. BIN res/drawable/abt.png
  65. BIN res/drawable/abth.png
  66. BIN res/drawable/abtl.png
  67. BIN res/drawable/busmarker.png
  68. +18 −0 res/drawable/button_bg_selected.xml
  69. +14 −0 res/drawable/button_bg_selector.xml
  70. +18 −0 res/drawable/button_bg_unselected.xml
  71. BIN res/drawable/double_bus.png
  72. BIN res/drawable/marker.png
  73. +10 −0 res/drawable/tab_bg_selected.xml
  74. +14 −0 res/drawable/tab_bg_selector.xml
  75. +10 −0 res/drawable/tab_bg_unselected.xml
  76. +7 −0 res/drawable/tab_text_selector.xml
  77. +10 −0 res/layout/list_item.xml
  78. +27 −0 res/layout/main.xml
  79. +65 −0 res/layout/map.xml
  80. +17 −0 res/layout/tabs_bg.xml
  81. +10 −0 res/menu/favorites_menu.xml
  82. +5 −0 res/menu/main_menu.xml
  83. +7 −0 res/values/dialogStyle.xml
  84. +24 −0 res/values/strings.xml
  85. +111 −0 src/com/seansouthern/anchoragebustimes/MySQLiteHelper.java
  86. +636 −0 src/com/seansouthern/anchoragebustimes/main.java
  87. +1,669 −0 src/com/seansouthern/anchoragebustimes/map.java
10 .classpath
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry exported="true" kind="lib" path="libs/jsoup-1.6.2.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/overlaymanager-1.0.1.jar"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
33 .project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>AnchorageBusTimes</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
12 .settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Fri Aug 03 14:07:30 AKDT 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
35 AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.seansouthern.anchoragebustimes"
+ android:versionCode="10"
+ android:versionName="1.3.5" >
+
+ <uses-permission android:name="android.permission.INTERNET"></uses-permission>
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
+ <uses-permission android:name="android.permission.VIBRATE"></uses-permission>
+
+ <uses-sdk android:minSdkVersion="4" />
+
+ <application
+ android:icon="@drawable/abt"
+ android:label="@string/app_name" >
+ <uses-library android:name="com.google.android.maps" />
+ <activity
+ android:name=".main"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.NoTitleBar">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity
+ android:name=".map"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.NoTitleBar">
+ </activity>
+
+ </application>
+
+</manifest>
BIN assets/abtv2.db
Binary file not shown.
BIN assets/abtv3.db
Binary file not shown.
BIN bin/AnchorageBusTimes.apk
Binary file not shown.
BIN bin/AnchorageBusTracker.apk
Binary file not shown.
35 bin/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.seansouthern.anchoragebustimes"
+ android:versionCode="10"
+ android:versionName="1.3.5" >
+
+ <uses-permission android:name="android.permission.INTERNET"></uses-permission>
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
+ <uses-permission android:name="android.permission.VIBRATE"></uses-permission>
+
+ <uses-sdk android:minSdkVersion="4" />
+
+ <application
+ android:icon="@drawable/abt"
+ android:label="@string/app_name" >
+ <uses-library android:name="com.google.android.maps" />
+ <activity
+ android:name=".main"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.NoTitleBar">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity
+ android:name=".map"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.NoTitleBar">
+ </activity>
+
+ </application>
+
+</manifest>
BIN bin/classes.dex
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/BuildConfig.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/FavoritesList$1.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/FavoritesList.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/MySQLiteHelper.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/R$array.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/R$attr.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/R$drawable.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/R$id.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/R$layout.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/R$menu.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/R$string.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/R$style.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/R.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/RouteList$1.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/RouteList.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/StopsList$1.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/StopsList$2.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/StopsList$3.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/StopsList.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/TimesLoader.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/TimesTable.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/main$1.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/main$2.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/main$3.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/main.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/map$1.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/map$2.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/map$3.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/map$4$1.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/map$4.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/map$BusRefresher.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/map$LatLonPoint.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/map$LineCoords.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/map$LineOverlay.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/map$MapTimesLoader.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/map$MapTimesTable.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/map$SpinnerItemListener.class
Binary file not shown.
BIN bin/classes/com/seansouthern/anchoragebustimes/map.class
Binary file not shown.
3 bin/jarlist.cache
@@ -0,0 +1,3 @@
+# cache for current jar dependecy. DO NOT EDIT.
+# format is <lastModified> <length> <SHA-1> <path>
+# Encoding is UTF-8
BIN bin/res/drawable/abt.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN bin/res/drawable/abth.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN bin/res/drawable/abtl.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN bin/res/drawable/busmarker.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN bin/res/drawable/double_bus.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN bin/res/drawable/marker.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN bin/resources.ap_
Binary file not shown.
6 gen/com/seansouthern/anchoragebustimes/BuildConfig.java
@@ -0,0 +1,6 @@
+/** Automatically generated file. DO NOT MODIFY */
+package com.seansouthern.anchoragebustimes;
+
+public final class BuildConfig {
+ public final static boolean DEBUG = true;
+}
65 gen/com/seansouthern/anchoragebustimes/R.java
@@ -0,0 +1,65 @@
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package com.seansouthern.anchoragebustimes;
+
+public final class R {
+ public static final class array {
+ public static final int routes_array=0x7f060000;
+ }
+ public static final class attr {
+ }
+ public static final class drawable {
+ public static final int abt=0x7f020000;
+ public static final int abth=0x7f020001;
+ public static final int abtl=0x7f020002;
+ public static final int busmarker=0x7f020003;
+ public static final int button_bg_selected=0x7f020004;
+ public static final int button_bg_selector=0x7f020005;
+ public static final int button_bg_unselected=0x7f020006;
+ public static final int double_bus=0x7f020007;
+ public static final int marker=0x7f020008;
+ public static final int tab_bg_selected=0x7f020009;
+ public static final int tab_bg_selector=0x7f02000a;
+ public static final int tab_bg_unselected=0x7f02000b;
+ public static final int tab_text_selector=0x7f02000c;
+ }
+ public static final class id {
+ public static final int about=0x7f08000d;
+ public static final int buttons_helper=0x7f080005;
+ public static final int clear=0x7f08000c;
+ public static final int control_box=0x7f080002;
+ public static final int delete=0x7f08000b;
+ public static final int label=0x7f080003;
+ public static final int left_button=0x7f080006;
+ public static final int list_item=0x7f080000;
+ public static final int mapview=0x7f080008;
+ public static final int right_button=0x7f080007;
+ public static final int spinner=0x7f080004;
+ public static final int tabsLayout=0x7f080009;
+ public static final int tabsText=0x7f08000a;
+ public static final int top_container=0x7f080001;
+ }
+ public static final class layout {
+ public static final int list_item=0x7f030000;
+ public static final int main=0x7f030001;
+ public static final int map=0x7f030002;
+ public static final int tabs_bg=0x7f030003;
+ }
+ public static final class menu {
+ public static final int favorites_menu=0x7f070000;
+ public static final int main_menu=0x7f070001;
+ }
+ public static final class string {
+ public static final int MAPS_API_KEY=0x7f050001;
+ public static final int app_name=0x7f050000;
+ public static final int routes_prompt=0x7f050002;
+ }
+ public static final class style {
+ public static final int dialogStyle=0x7f040000;
+ }
+}
BIN libs/jsoup-1.6.2.jar
Binary file not shown.
BIN libs/overlaymanager-1.0.1.jar
Binary file not shown.
3 lint.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lint>
+</lint>
40 proguard.cfg
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
11 project.properties
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=Google Inc.:Google APIs:10
BIN res/drawable/abt.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN res/drawable/abth.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN res/drawable/abtl.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN res/drawable/busmarker.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 res/drawable/button_bg_selected.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <gradient
+ android:startColor="#A8A8A8"
+ android:centerColor="#7F7F7F"
+ android:endColor="#696969"
+ android:angle="-90"
+ />
+
+ <padding android:left="0dp"
+ android:top="0dp"
+ android:right="0dp"
+ android:bottom="0dp"
+ />
+
+ <corners android:radius="4dp"/>
+</shape>
14 res/drawable/button_bg_selector.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- Active tab -->
+ <item android:state_selected="true" android:state_focused="false"
+ android:state_pressed="false" android:drawable="@drawable/button_bg_selected" />
+ <!-- Inactive tab -->
+ <item android:state_selected="false" android:state_focused="false"
+ android:state_pressed="false" android:drawable="@drawable/button_bg_unselected" />
+ <!-- Pressed tab -->
+ <item android:state_pressed="true" android:drawable="@android:color/transparent" />
+ <!-- Selected tab (using d-pad) -->
+ <item android:state_focused="true" android:state_selected="true"
+ android:state_pressed="false" android:drawable="@android:color/transparent" />
+</selector>
18 res/drawable/button_bg_unselected.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <gradient
+ android:startColor="#5C5C5C"
+ android:centerColor="#424242"
+ android:endColor="#222222"
+ android:angle="-90"
+ />
+
+ <padding android:left="0dp"
+ android:top="0dp"
+ android:right="0dp"
+ android:bottom="0dp"
+ />
+
+ <corners android:radius="4dp"/>
+</shape>
BIN res/drawable/double_bus.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN res/drawable/marker.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 res/drawable/tab_bg_selected.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <gradient
+ android:startColor="#A8A8A8"
+ android:centerColor="#7F7F7F"
+ android:endColor="#696969"
+ android:angle="-90"
+ />
+</shape>
14 res/drawable/tab_bg_selector.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- Active tab -->
+ <item android:state_selected="true" android:state_focused="false"
+ android:state_pressed="false" android:drawable="@drawable/tab_bg_selected" />
+ <!-- Inactive tab -->
+ <item android:state_selected="false" android:state_focused="false"
+ android:state_pressed="false" android:drawable="@drawable/tab_bg_unselected" />
+ <!-- Pressed tab -->
+ <item android:state_pressed="true" android:drawable="@android:color/transparent" />
+ <!-- Selected tab (using d-pad) -->
+ <item android:state_focused="true" android:state_selected="true"
+ android:state_pressed="false" android:drawable="@android:color/transparent" />
+</selector>
10 res/drawable/tab_bg_unselected.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <gradient
+ android:startColor="#5C5C5C"
+ android:centerColor="#424242"
+ android:endColor="#222222"
+ android:angle="-90"
+ />
+</shape>
7 res/drawable/tab_text_selector.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_selected="true" android:color="@android:color/white" />
+ <item android:state_focused="true" android:color="@android:color/white" />
+ <item android:state_pressed="true" android:color="@android:color/white" />
+ <item android:color="#f8f8f8" />
+</selector>
10 res/layout/list_item.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:typeface="monospace"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:padding="15dp"
+ android:textSize="16sp"
+ android:gravity="center"
+ android:id="@+id/list_item">
+</TextView>
27 res/layout/main.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/tabhost"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_marginBottom="-5dp"
+ android:screenOrientation="portrait" >
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical" >
+
+ <TabWidget
+ android:id="@android:id/tabs"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" />
+
+ <FrameLayout
+ android:id="@android:id/tabcontent"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="2dip" >
+ </FrameLayout>
+ </LinearLayout>
+</TabHost>
65 res/layout/map.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/top_container"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:padding="2dip" >
+
+ <RelativeLayout
+ android:id="@+id/control_box"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:id="@+id/label"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:text="@string/routes_prompt" />
+
+ <Spinner
+ android:id="@+id/spinner"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/label"
+ android:prompt="@string/routes_prompt" />
+ </RelativeLayout>
+
+ <View
+ android:id="@+id/buttons_helper"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_centerHorizontal="true" />
+
+ <TextView
+ android:id="@+id/left_button"
+ android:layout_width="fill_parent"
+ android:layout_height="45dip"
+ android:layout_alignParentBottom="true"
+ android:layout_marginTop="2dip"
+ android:layout_marginRight="2dip"
+ android:layout_toLeftOf="@id/buttons_helper"
+ android:gravity="center"
+ android:background="@drawable/button_bg_selector" />
+
+ <TextView
+ android:id="@+id/right_button"
+ android:layout_width="fill_parent"
+ android:layout_height="45dip"
+ android:layout_alignParentBottom="true"
+ android:layout_marginTop="2dip"
+ android:layout_marginLeft="2dip"
+ android:layout_toRightOf="@id/buttons_helper"
+ android:gravity="center"
+ android:background="@drawable/button_bg_selector" />
+
+ <com.google.android.maps.MapView
+ android:id="@+id/mapview"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_above="@id/left_button"
+ android:layout_below="@id/control_box"
+ android:apiKey="@string/MAPS_API_KEY"
+ android:clickable="true" />
+
+</RelativeLayout>
17 res/layout/tabs_bg.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/tabsLayout" android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:padding="12dip"
+ android:gravity="center"
+ android:orientation="vertical"
+ android:background="@drawable/tab_bg_selector">
+
+ <TextView
+ android:id="@+id/tabsText"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:textSize="15dip"
+ android:textColor="@drawable/tab_text_selector"
+ />
+ </LinearLayout>
10 res/menu/favorites_menu.xml
@@ -0,0 +1,10 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item
+ android:id="@+id/delete"
+ android:title="Delete Selection"
+ />
+ <item
+ android:id="@+id/clear"
+ android:title="Clear All Favorites"
+ />
+</menu>
5 res/menu/main_menu.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/about"
+ android:title="About" />
+</menu>
7 res/values/dialogStyle.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <style name="dialogStyle" parent="@android:style/Theme.Dialog">
+ <item name="android:background">#383838</item>
+ <item name="android:minHeight">250dp</item>
+ </style>
+</resources>
24 res/values/strings.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Anchorage Bus Times</string>
+ <string name="MAPS_API_KEY">03leX7NA3JHJzRLkU3IAshBLhSglEhVf0FBVc4A</string>
+ <string name="routes_prompt">Select a Route and Direction</string>
+ <string-array name="routes_array">
+ <item>1 - CROSSTOWN</item>
+ <item>2 - LAKE OTIS</item>
+ <item>3C - NORTHERN LIGHTS</item>
+ <item>3N - NORTHERN LIGHTS</item>
+ <item>7 - SPENARD</item>
+ <item>7A - SPENARD</item>
+ <item>8 - NORTHWAY</item>
+ <item>9 - ARCTIC</item>
+ <item>13 - SR CTR HOSPITALS UAA</item>
+ <item>14 - GOVT HILL</item>
+ <item>15 - 15TH AVE/DEBARR</item>
+ <item>36 - 36TH AVE/WEST ANCH</item>
+ <item>45 - MOUNTAIN VIEW</item>
+ <item>60 - OLD SEWARD</item>
+ <item>75 - TUDOR</item>
+ <item>102 - EAGLE RIVER EXPRESS</item>
+ </string-array>
+</resources>
111 src/com/seansouthern/anchoragebustimes/MySQLiteHelper.java
@@ -0,0 +1,111 @@
+package com.seansouthern.anchoragebustimes;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import android.content.Context;
+import android.database.SQLException;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteException;
+import android.database.sqlite.SQLiteOpenHelper;
+
+public class MySQLiteHelper extends SQLiteOpenHelper{
+
+ private static String DATABASE_PATH = "/data/data/com.seansouthern.anchoragebustimes/databases/";
+ private static final String DATABASE_NAME = "abtv3.db";
+ private static final Integer DATABASE_VERSION = 3;
+
+ static SQLiteDatabase ABTDatabase;
+ private final Context myContext;
+
+
+ public MySQLiteHelper(Context context) {
+ super(context, DATABASE_NAME, null, DATABASE_VERSION);
+ this.myContext = context;
+ }
+
+ public void createDatabase() throws IOException{
+ boolean dbExist = checkDataBase();
+
+ if(dbExist){
+ //Do Nothing
+ }
+ else{
+ this.getReadableDatabase();
+ try {
+ //this.close();
+ copyDataBase();
+ }
+ catch(IOException e){
+ throw new Error("Error copying database!");
+ }
+ }
+ }
+
+ //Return true if db exists, false otherwise
+ public boolean checkDataBase(){
+ SQLiteDatabase checkDB = null;
+ try{
+ String myPath = DATABASE_PATH + DATABASE_NAME;
+ checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
+ }catch(SQLiteException e){
+ //database does't exist yet.
+ }
+ if(checkDB != null){
+ checkDB.close();
+ }
+ return checkDB != null;
+ }
+
+ private void copyDataBase() throws IOException{
+
+ //Open your local db as the input stream
+ InputStream myInput = myContext.getAssets().open(DATABASE_NAME);
+
+ // Path to the just created empty db
+ String outFileName = DATABASE_PATH + DATABASE_NAME;
+
+ //Open the empty db as the output stream
+ OutputStream myOutput = new FileOutputStream(outFileName);
+
+ //transfer bytes from the inputfile to the outputfile
+ byte[] buffer = new byte[1024];
+ int length;
+ while ((length = myInput.read(buffer))>0){
+ myOutput.write(buffer, 0, length);
+ }
+
+ //Close the streams
+ myOutput.flush();
+ myOutput.close();
+ myInput.close();
+
+ }
+
+ public void openDataBase() throws SQLException{
+ //Open the database
+ String myPath = DATABASE_PATH + DATABASE_NAME;
+ ABTDatabase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
+ }
+
+ @Override
+ public synchronized void close() {
+ if(ABTDatabase != null)
+ ABTDatabase.close();
+ super.close();
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+
+ }
+
+}
+
636 src/com/seansouthern/anchoragebustimes/main.java
@@ -0,0 +1,636 @@
+package com.seansouthern.anchoragebustimes;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.view.ContextMenu;
+import android.view.ContextMenu.ContextMenuInfo;
+import android.view.Gravity;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.ProgressBar;
+import android.widget.ScrollView;
+import android.widget.SimpleCursorAdapter;
+import android.widget.TabHost;
+import android.widget.TabHost.OnTabChangeListener;
+import android.widget.TableLayout;
+import android.widget.TableRow;
+import android.widget.TextView;
+import android.widget.Toast;
+import android.app.Activity;
+import android.app.TabActivity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.graphics.Color;
+import android.widget.TabHost.TabContentFactory;
+import com.seansouthern.anchoragebustimes.R;
+
+// The main activity, it extends TabActivity for the tab functionality
+// and some shortcut functions like getTabHost()
+public class main extends TabActivity {
+
+ // These three variables are required for the initial database setup.
+ MySQLiteHelper myDbHelper = null;
+ Cursor cursor = null;
+ static SQLiteDatabase db = null;
+
+ // These vars are used to direct tab switching behavior
+ public static String ROUTE_NUM = "0";
+ public static String STOP_NUM = "0";
+ public static String TAB_FLAG = "";
+ public static boolean FAV_FLAG = false;
+
+ // A Regex pattern that looks for any amount of numbers at the beginning of a string
+ public static Pattern p = Pattern.compile("^\\d+");
+
+
+ // The onCreate function is a very important part of an activity's
+ // life. It's where most everything is created and set into motion.
+ // Here we are creating tabs and defining navigation.
+ @Override
+ public void onCreate(Bundle savedInstanceState){
+ super.onCreate(savedInstanceState);
+
+ // This pulls the layout xml file named 'main' and presents it
+ // This is a required function, everything else alters this pulled layout
+ setContentView(R.layout.main);
+
+ final TabHost tabHost = getTabHost();
+
+ TabHost.TabSpec spec;
+
+ // This is used as the content of the Map tab
+ Intent mapIntent = new Intent().setClass(this, map.class);
+
+
+ // Setup Bus Times tab, add it to TabHost
+ spec = tabHost.newTabSpec("busTimes").setIndicator(createTabView(this, "Bus Times")
+ ).setContent(new TabContentFactory(){
+ public View createTabContent(String arg0){
+ RouteList routeList = new RouteList(main.this, getPreferences(MODE_PRIVATE));
+ return routeList;
+ }
+ });
+ tabHost.addTab(spec);
+
+
+ // Setup Favorite Stops tab, add it to TabHost
+ spec = tabHost.newTabSpec("favStops").setIndicator(createTabView(this, "Favorites")
+ ).setContent(new TabContentFactory(){
+ public View createTabContent(String arg0){
+ FavoritesList favsList = new FavoritesList(main.this, getPreferences(MODE_PRIVATE));
+ return favsList;
+ }
+ });
+ tabHost.addTab(spec);
+
+ // Setup Maps tab, add it to TabHost
+ spec = tabHost.newTabSpec("mapActivity").setIndicator(createTabView(getBaseContext(), "Map")).setContent(mapIntent);
+ tabHost.addTab(spec);
+
+ // Tab Navigation! This was a painful chunk of code to hammer out.
+ // It's basically a big flow chart dictating what clicking a tab will do under
+ // certain circumstances. Tab Switching was sending you to unintuitive places
+ // and this solves that. Note the use of FLAGs and view tags.
+ // TODO: Rewrite tab navigation if tree into more readable switch statements
+ tabHost.setOnTabChangedListener(new OnTabChangeListener(){
+ public void onTabChanged(String tabId) {
+ if(tabId == "favStops"){
+ main.FAV_FLAG = false;
+ if(tabHost.findViewWithTag("StopsList") != null){
+ tabHost.findViewWithTag("StopsList").setVisibility(View.GONE);
+ }
+ if(tabHost.findViewWithTag("TimesTable") != null){
+ tabHost.findViewWithTag("TimesTable").setVisibility(View.GONE);
+ }
+ if(tabHost.findViewWithTag("RouteList") != null){
+ tabHost.findViewWithTag("RouteList").setVisibility(View.GONE);
+ }
+ ((FavoritesList) tabHost.findViewWithTag("FavoritesList")).grabFavorites(getPreferences(MODE_PRIVATE));
+ }
+ if(tabId == "busTimes"){
+ if(tabHost.findViewWithTag("FavoritesList") != null){
+ tabHost.findViewWithTag("FavoritesList").setVisibility(View.GONE);
+ main.FAV_FLAG = false;
+ }
+ if(TAB_FLAG == "RouteList"){
+ RouteList newList = new RouteList(main.this, getPreferences(MODE_PRIVATE));
+ tabHost.getTabContentView().removeAllViews();
+ tabHost.getTabContentView().addView(newList);
+ tabHost.getTabContentView().invalidate();
+ }
+ if(TAB_FLAG == "StopsList" || TAB_FLAG == "TimesTable"){
+ if(FAV_FLAG = true){}
+ StopsList newList = new StopsList(main.this, ROUTE_NUM, getPreferences(MODE_PRIVATE));
+ tabHost.getTabContentView().removeAllViews();
+ tabHost.getTabContentView().addView(newList);
+ tabHost.getTabContentView().invalidate();
+ }
+ }
+ if(tabId == "mapActivity"){
+ if(tabHost.findViewWithTag("StopsList") != null){
+ tabHost.findViewWithTag("StopsList").setVisibility(View.GONE);
+ }
+ if(tabHost.findViewWithTag("TimesTable") != null){
+ tabHost.findViewWithTag("TimesTable").setVisibility(View.GONE);
+ }
+ if(tabHost.findViewWithTag("RouteList") != null){
+ tabHost.findViewWithTag("RouteList").setVisibility(View.GONE);
+ }
+ if(tabHost.findViewWithTag("FavoritesList") != null){
+ tabHost.findViewWithTag("FavoritesList").setVisibility(View.GONE);
+ }
+ }
+ }
+ });
+
+
+ // Silly Database Initialization Hoodoo
+ // I'm using a neat hack to get a persistent database onto the users device.
+ myDbHelper = new MySQLiteHelper(this);
+ try {
+ myDbHelper.createDatabase();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ db = myDbHelper.getReadableDatabase();
+
+
+ //End onCreate
+ }
+
+ // Inflates the main menu accessed by pressing the menu button
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.main_menu, menu);
+ return true;
+ }
+
+ // Menu for Bus Times Tabs
+ // Under construction
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.about:
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+
+ // Create new Tab Indicator View from layout xml, for style purposes
+ public static View createTabView(final Context context, final String text) {
+ View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);
+ TextView tv = (TextView) view.findViewById(R.id.tabsText);
+ tv.setText(text);
+ return view;
+ }
+
+ // Favorites list context menu builder
+ @Override
+ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo){
+ super.onCreateContextMenu(menu, v, menuInfo);
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.favorites_menu, menu);
+ }
+
+ // Logic for the Favorite Stops long click contextual Menu
+ @Override
+ public boolean onContextItemSelected(MenuItem item){
+ AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
+ switch (item.getItemId()) {
+ case R.id.delete:
+ String listItemText = (String) ((TextView)info.targetView).getText();
+ SharedPreferences faves1 = getPreferences(MODE_PRIVATE);
+ SharedPreferences.Editor editor1 = faves1.edit();
+ editor1.remove(listItemText);
+ editor1.commit();
+ ((FavoritesList) info.targetView.getParent()).grabFavorites(faves1);
+ return true;
+ case R.id.clear:
+ SharedPreferences faves2 = getPreferences(MODE_PRIVATE);
+ SharedPreferences.Editor editor2 = faves2.edit();
+ editor2.clear();
+ editor2.commit();
+ ((FavoritesList) info.targetView.getParent()).grabFavorites(faves2);
+ default:
+ return super.onContextItemSelected(item);
+ }
+ }
+
+ // Dictate Back button navigation and list setup
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event){
+ if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0){
+ TabHost tabHost = getTabHost();
+ Object childTag = tabHost.getTabContentView().getChildAt(0).getTag();
+ if(childTag == "RouteList"){
+ finish();
+ }
+ else if(childTag == "StopsList"){
+ if(tabHost.getCurrentTab() == 1){
+ super.finish();
+ }
+ else{
+ RouteList newList = new RouteList(this, getPreferences(MODE_PRIVATE));
+ tabHost.getTabContentView().removeAllViews();
+ tabHost.getTabContentView().addView(newList);
+ tabHost.getTabContentView().invalidate();
+ }
+ }
+ else if(childTag == "TimesTable"){
+ if(FAV_FLAG == true){
+ FAV_FLAG = false;
+ tabHost.setCurrentTab(1);
+ FavoritesList newList = new FavoritesList(this, getPreferences(MODE_PRIVATE));
+ tabHost.getTabContentView().removeAllViews();
+ tabHost.getTabContentView().addView(newList);
+ tabHost.getTabContentView().invalidate();
+ FAV_FLAG = false;
+ }
+ else{
+ TAB_FLAG = "StopsList";
+ tabHost.setCurrentTab(0);
+ StopsList newList = new StopsList(this, ROUTE_NUM, getPreferences(MODE_PRIVATE));
+ tabHost.getTabContentView().removeAllViews();
+ tabHost.getTabContentView().addView(newList);
+ tabHost.getTabContentView().invalidate();
+ }
+ }
+ else if(childTag == "FavoritesList"){
+ super.finish();
+ }
+ else{
+ super.finish();
+ }
+ return true;
+ }
+ return super.onKeyDown(keyCode, event);
+ }
+
+ // Cleans up after the database hoodoo, necessary
+ // It's Very Important to close the cursor, db and dbhelper in this order.
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ if (cursor != null){
+ cursor.close();
+ }
+ if (db != null){
+ db.close();
+ }
+ if (myDbHelper != null){
+ myDbHelper.close();
+ }
+ }
+
+}
+
+class RouteList extends ListView{
+ public RouteList(Context context, SharedPreferences favStops) {
+ super(context);
+ this.setClicker(favStops);
+ this.setLongClickable(false);
+ this.setTag("RouteList");
+ main.TAB_FLAG = "RouteList";
+ this.grabRoutes();
+ this.setVisibility(View.VISIBLE);
+ }
+
+ public void grabRoutes(){
+ final List<String> routes = Arrays.asList("1 - CROSSTOWN", "2 - LAKE OTIS", "3 - NORTHERN LIGHTS", "7 - SPENARD",
+ "8 - NORTHWAY", "9 - ARCTIC", "13 - SR CTR HOSPITALS UAA", "14 - GOVT HILL", "15 - 15TH AVE/DEBARR",
+ "36 - 36TH AVE/WEST ANCH", "45 - MOUNTAIN VIEW", "60 - OLD SEWARD", "75 - TUDOR", "102 - EAGLE RIVER EXPRESS");
+
+ ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(), R.layout.list_item, routes);
+ this.setAdapter(adapter);
+ }
+
+ public void setClicker(final SharedPreferences favStops){
+ this.setOnItemClickListener(new OnItemClickListener(){
+ public void onItemClick(AdapterView<?> parent, View view, int position,
+ long id) {
+ String item = (String) ((TextView)view).getText();
+ Matcher m = main.p.matcher(item);
+ if (m.find()) {
+ final String num = m.group(0);
+ if(m.group(0) != null){
+ main.ROUTE_NUM = num;
+ StopsList newList = new StopsList(getContext(), num, favStops);
+ TabHost tabHost = ((TabActivity) parent.getContext()).getTabHost();
+ tabHost.getTabContentView().removeAllViews();
+ tabHost.getTabContentView().addView(newList);
+ tabHost.getTabContentView().invalidate();
+ parent.setVisibility(View.GONE);
+ }
+ }
+ }
+ });
+ }
+
+}
+
+class StopsList extends ListView{
+ public StopsList(Context context, String routeNum, SharedPreferences favStops) {
+ super(context);
+ this.setClicker();
+ this.setLongClicker(favStops);
+ this.setTag("StopsList");
+ this.grabStops(routeNum);
+ this.setVisibility(View.VISIBLE);
+ main.TAB_FLAG = "StopsList";
+ main.ROUTE_NUM = routeNum;
+ }
+
+ public void grabStops(String routeNum) {
+ String[] columns = {"_id", "num", "addr", "routes"};
+ String where = "routes LIKE '%, " + routeNum + ",%'";
+ Cursor cursor = main.db.query("stops", columns, where, null, null, null, null);
+ String[] from = new String[] {"num", "addr"};
+ int[] to = new int[] {R.id.list_item, R.id.list_item};
+ SimpleCursorAdapter adapter = new SimpleCursorAdapter(getContext(), R.layout.list_item, cursor, from, to);
+ adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
+ public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
+ String num = cursor.getString(cursor.getColumnIndex("num"));
+ String addr = cursor.getString(cursor.getColumnIndex("addr"));
+ String combined = num + " Addr: " + addr;
+ TextView tv = (TextView) view;
+ tv.setText(combined);
+ return true;
+ }
+ });
+ this.setAdapter(adapter);
+ }
+
+ public void setClicker(){
+ this.setOnItemClickListener(new OnItemClickListener(){
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id){
+ String item = (String) ((TextView)view).getText();
+ Matcher m = main.p.matcher(item);
+ if (m.find()) {
+ item = m.group(0);
+ }
+ if(item != null){
+ main.FAV_FLAG = false;
+ main.STOP_NUM = item;
+ TableLayout timesTable = new TimesTable(getContext(), item);
+ ScrollView sv = new ScrollView(getContext());
+ sv.addView(timesTable);
+ sv.setTag("TimesTable");
+ TabHost tabHost = ((TabActivity) parent.getContext()).getTabHost();
+ tabHost.getTabContentView().removeAllViews();
+ tabHost.getTabContentView().addView(sv);
+ tabHost.getTabContentView().invalidate();
+ parent.setVisibility(View.GONE);
+ }
+ }
+ });
+ }
+
+ public void setLongClicker(final SharedPreferences favStops){
+ this.setOnItemLongClickListener(new OnItemLongClickListener(){
+ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id){
+ String item = (String) ((TextView) view).getText();
+ if(item != null) {
+ SharedPreferences.Editor editor = favStops.edit();
+ Cursor cursor = (Cursor) parent.getItemAtPosition(position);
+ String stopName = cursor.getInt(cursor.getColumnIndex("num")) + " - " +
+ cursor.getString(cursor.getColumnIndex("addr"));
+ editor.putString(stopName, stopName);
+ editor.commit();
+ Toast.makeText(getContext(), stopName + " added to Favorites", Toast.LENGTH_SHORT).show();
+ }
+ return true;
+ }
+ });
+ }
+
+}
+
+class FavoritesList extends ListView{
+ public FavoritesList(Context context, SharedPreferences stops){
+ super(context);
+ this.grabFavorites(stops);
+ ((Activity) context).registerForContextMenu(this);
+ this.setClicker();
+ this.setTag("FavoritesList");
+ this.setVisibility(View.VISIBLE);
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void grabFavorites(SharedPreferences stops){
+ Collection<?> mapFin = stops.getAll().values();
+ final ArrayList<String> favStops = new ArrayList(mapFin);
+ ArrayAdapter<String> fsAdapter = new ArrayAdapter<String>(getContext(), R.layout.list_item, favStops);
+ this.setAdapter(fsAdapter);
+ }
+
+ public void setClicker(){
+ this.setOnItemClickListener(new OnItemClickListener(){
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id){
+ String item = (String) ((TextView)view).getText();
+ Matcher m = main.p.matcher(item);
+ if (m.find()) {
+ item = m.group(0);
+ }
+ if(item != null){
+ main.FAV_FLAG = true;
+ TableLayout timesTable = new TimesTable(getContext(), item);
+ ScrollView sv = new ScrollView(getContext());
+ sv.addView(timesTable);
+ sv.setTag("TimesTable");
+ TabHost tabHost = ((TabActivity) parent.getContext()).getTabHost();
+ tabHost.setCurrentTab(0);
+ tabHost.getTabContentView().removeAllViews();
+ tabHost.getTabContentView().addView(sv);
+ tabHost.getTabContentView().invalidate();
+ parent.setVisibility(View.GONE);
+ main.FAV_FLAG = true;
+ }
+ }
+ });
+ }
+
+}
+
+class TimesLoader extends AsyncTask<String, Integer, Document>{
+ Context context;
+ TimesTable timesTable;
+ ProgressBar waitSpinner;
+
+ public TimesLoader(Context context, TimesTable timesTable) {
+ this.context = context;
+ this.timesTable = timesTable;
+
+ TableRow.LayoutParams params = new TableRow.LayoutParams();
+ params.gravity = Gravity.CENTER;
+ params.weight = 0;
+ params.span = 2;
+
+ waitSpinner = new ProgressBar(context, null, android.R.attr.progressBarStyle);
+ waitSpinner.setLayoutParams(params);
+ }
+
+ @Override
+ protected void onProgressUpdate(Integer... values){
+ super.onProgressUpdate(values);
+ if(values[0] == 0){
+ TableRow row = new TableRow(context);
+ row.addView(waitSpinner);
+ timesTable.addView(row);
+ }
+ else if(values[0] == -1){
+ TextView tv = new TextView(context);
+ tv.setText("The network is not responding. Are you connected to the internet?");
+ timesTable.addView(tv);
+ }
+ }
+
+ @Override
+ protected Document doInBackground(String... stopNum) {
+ Document page = null;
+ publishProgress(0);
+ try {
+ page = Jsoup.connect("http://bustracker.muni.org/InfoPoint/map/GetStopHtml.ashx?vehicleId=" + stopNum[0]).get();
+ } catch (IOException e) {
+ e.printStackTrace();
+ publishProgress(-1);
+ }
+ return page;
+ }
+
+ @Override
+ protected void onPostExecute(Document page){
+ super.onPostExecute(page);
+ if(page != null){
+ // It might be dangerous to remove the Loading Wheel by assuming it's position
+ // but if it's not there than something's gone seriously wrong.
+ if(timesTable.getChildAt(3) != null){
+ timesTable.removeViewAt(3);
+ }
+ Elements elems = page.body().select("h3, h1, td, div");
+ TableRow infoRow = new TableRow(context);
+ TableRow timeRow = new TableRow(context);
+ int flag = 0;
+
+ for(Element src : elems){
+ if(src.nodeName().equals("td") && flag == 0 || flag == 1 ){
+ TextView tv = new TextView(context);
+ tv.setText(src.text());
+ if(flag == 1){
+ tv.setGravity(Gravity.RIGHT);
+ }
+ infoRow.addView(tv);
+ flag++;
+ }
+ else if(src.nodeName().equals("td") && flag == 2){
+ TextView tv = new TextView(context);
+ tv.setText(src.text());
+ TableRow.LayoutParams rowSpanLayout = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
+ rowSpanLayout.span = 2;
+
+ tv.setGravity(Gravity.CENTER);
+ timeRow.addView(tv, rowSpanLayout);
+ timesTable.addView(infoRow);
+ infoRow = new TableRow(context);
+ timesTable.addView(timeRow);
+ timeRow = new TableRow(context);
+
+ View spacerThin = new View(context);
+ spacerThin.setBackgroundColor(Color.LTGRAY);
+ spacerThin.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 1));
+ timesTable.addView(spacerThin);
+
+ flag++;
+ }
+ else if(src.nodeName().equals("td") && flag == 3){
+ flag = 0;
+ }
+ }
+
+ if(page.text().equals("Stop departure data is too old.") || timesTable.getChildCount() == 0){
+ TextView tv = new TextView(context);
+ tv.setText("No upcoming departures.");
+ infoRow.addView(tv);
+ timesTable.addView(infoRow);
+ }
+ }
+ }
+
+}
+
+class TimesTable extends TableLayout{
+ public TimesTable(Context context, String stopNum) {
+ super(context);
+ super.setTag("TimesTable");
+ if(main.FAV_FLAG == false){
+ main.TAB_FLAG = "TimesTable";
+ }
+ else{
+ main.FAV_FLAG = false;
+ }
+
+ makeHeader(stopNum);
+ setVisibility(View.VISIBLE);
+
+ grabTimes(stopNum);
+ setVisibility(View.VISIBLE);
+
+ }
+
+ public void makeHeader(String stopNum){
+ this.removeAllViews();
+ this.setStretchAllColumns(true);
+
+ String[] columns = {"_id", "num", "addr"};
+ String where = "num LIKE '" + stopNum + "'";
+ Cursor cursor = main.db.query("stops", columns, where, null, null, null, null);
+ cursor.moveToFirst();
+ String addr = cursor.getString(cursor.getColumnIndex("addr"));
+
+ TextView headerStopNum = new TextView(getContext());
+ headerStopNum.setText("Stop " + stopNum);
+ this.addView(headerStopNum);
+
+ TextView headerAddr = new TextView(getContext());
+ headerAddr.setText(addr);
+ this.addView(headerAddr);
+
+ View spacerThick = new View(getContext());
+ spacerThick.setBackgroundColor(Color.LTGRAY);
+ spacerThick.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 4));
+ this.addView(spacerThick);
+
+ }
+
+ public void grabTimes(String stopNum){
+ TimesLoader timesLoader = new TimesLoader(getContext(), this);
+ timesLoader.execute(stopNum);
+ }
+
+}
1,669 src/com/seansouthern/anchoragebustimes/map.java
@@ -0,0 +1,1669 @@
+package com.seansouthern.anchoragebustimes;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Parser;
+import org.jsoup.select.Elements;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.Point;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.Handler;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
+import android.widget.ArrayAdapter;
+import android.widget.ProgressBar;
+import android.widget.ScrollView;
+import android.widget.Spinner;
+import android.widget.TableLayout;
+import android.widget.TableRow;
+import android.widget.TextView;
+import android.widget.Toast;
+import android.os.Vibrator;
+
+import com.google.android.maps.GeoPoint;
+import com.google.android.maps.MapActivity;
+import com.google.android.maps.MapView;
+import com.google.android.maps.Overlay;
+import com.google.android.maps.Projection;
+
+import de.android1.overlaymanager.ManagedOverlay;
+import de.android1.overlaymanager.ManagedOverlayGestureDetector;
+import de.android1.overlaymanager.ManagedOverlayGestureDetector.OnOverlayGestureListener;
+import de.android1.overlaymanager.ManagedOverlayItem;
+import de.android1.overlaymanager.OverlayManager;
+import de.android1.overlaymanager.ZoomEvent;
+
+
+public class map extends MapActivity{
+
+ LineCoords lc = new LineCoords();
+ public static String route = null;
+
+ MySQLiteHelper myDbHelper = null;
+ Cursor cursor = null;
+ SQLiteDatabase db = null;
+ OverlayManager overlayManager;
+ ManagedOverlay stopOverlay;
+ ManagedOverlay busOverlay;
+ TimerTask doAsyncTask;
+
+ private Projection projection;
+
+ public static String REGEX_PATTERN = "^\\d+";
+ public static Pattern p = Pattern.compile(REGEX_PATTERN);
+
+ Map<String, List<String>> directionsMap = new HashMap<String, List<String>>();
+
+
+ @Override
+ public void onCreate(Bundle savedInstanceState){
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.map);
+
+ List<String> dirs1 = new ArrayList<String>();
+ dirs1.add("1 MULDOON");
+ dirs1.add("1 DIMOND CENTER");
+ directionsMap.put("1", dirs1);
+
+ List<String> dirs2 = new ArrayList<String>();
+ dirs2.add("2 DIMOND CENTER");
+ dirs2.add("2 DOWNTOWN");
+ directionsMap.put("2", dirs2);
+
+ List<String> dirs3 = new ArrayList<String>();
+ dirs3.add("3C DOWNTOWN");
+ dirs3.add("3N DOWNTOWN");
+ dirs3.add("3C CENTENNIAL");
+ dirs3.add("3N MULDOON");
+ directionsMap.put("3", dirs3);
+
+ List<String> dirs7 = new ArrayList<String>();
+ dirs7.add("7 DIMOND CENTER");
+ dirs7.add("7 DOWNTOWN");
+ directionsMap.put("7", dirs7);
+
+ List<String> dirs7A = new ArrayList<String>();
+ dirs7A.add("7A DIMOND CENTER");
+ dirs7A.add("7A DOWNTOWN");
+ directionsMap.put("7A", dirs7A);
+
+ List<String> dirs8 = new ArrayList<String>();
+ dirs8.add("8 DOWNTOWN");
+ dirs8.add("8 MULDOON");
+ directionsMap.put("8", dirs8);
+
+ List<String> dirs9 = new ArrayList<String>();
+ dirs9.add("9 DIMOND CENTER");
+ dirs9.add("9 DOWNTOWN");
+ directionsMap.put("9", dirs9);
+
+ List<String> dirs13 = new ArrayList<String>();
+ dirs13.add("13 DOWNTOWN");
+ dirs13.add("13 MULDOON");
+ directionsMap.put("13", dirs13);
+
+ List<String> dirs14 = new ArrayList<String>();
+ dirs14.add("14 DOWNTOWN");
+ directionsMap.put("14", dirs14);
+
+ List<String> dirs15 = new ArrayList<String>();
+ dirs15.add("15 DOWNTOWN");
+ dirs15.add("15 MULDOON");
+ directionsMap.put("15", dirs15);
+
+ List<String> dirs36 = new ArrayList<String>();
+ dirs36.add("36 DOWNTOWN");
+ dirs36.add("36 APU");
+ directionsMap.put("36", dirs36);
+
+ List<String> dirs45 = new ArrayList<String>();
+ dirs45.add("45 ANMC");
+ dirs45.add("45 DOWNTOWN");
+ directionsMap.put("45", dirs45);
+
+ List<String> dirs60 = new ArrayList<String>();
+ dirs60.add("60 DOWNTOWN");
+ dirs60.add("60 HUFFMAN");
+ directionsMap.put("60", dirs60);
+
+ List<String> dirs75 = new ArrayList<String>();
+ dirs75.add("75 DOWNTOWN");
+ dirs75.add("75 TIKAHTNU");
+ directionsMap.put("75", dirs75);
+
+ List<String> dirs102 = new ArrayList<String>();
+ dirs102.add("102 ANMC");
+ dirs102.add("102 EAGLE RIVER");
+ dirs102.add("102 PETERS CREEK");
+ directionsMap.put("102", dirs102);
+
+
+
+ MapView mapView = (MapView) findViewById(R.id.mapview);
+ mapView.setBuiltInZoomControls(true);
+
+ SharedPreferences sp = getPreferences(MODE_PRIVATE);
+ route = sp.getString("LAST_MAP_ROUTE", "1");
+
+ Spinner spinner = (Spinner) findViewById(R.id.spinner);
+ ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
+ this, R.array.routes_array, android.R.layout.simple_spinner_item);
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ spinner.setAdapter(adapter);
+
+ final TextView leftButton = (TextView) findViewById(R.id.left_button);
+ leftButton.setText(directionsMap.get(route).get(0));
+
+ final TextView rightButton = (TextView) findViewById(R.id.right_button);
+ //This will be null for route14, account for it
+ rightButton.setText(directionsMap.get(route).get(1));
+ //Route 102, 7 and 3 need to be accounted for
+
+ leftButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ String direction = (String) ((TextView) v).getText();
+ if(stopOverlay != null){
+ if(!v.isSelected()){
+ v.setSelected(true);
+ rightButton.setSelected(false);
+ overlayManager.removeOverlay(stopOverlay);
+ overlayManager.createOverlay("route" + route, getResources().getDrawable(R.drawable.marker));
+ stopOverlay = overlayManager.getOverlay("route" + route);
+ stopOverlay.addAll(grabStopCoordsByDirection(route, direction));
+ stopOverlay.setOnOverlayGestureListener(mogDetector);
+ overlayManager.populate();
+ }
+ else{
+ v.setSelected(false);
+ overlayManager.removeOverlay(stopOverlay);
+ overlayManager.createOverlay("route" + route, getResources().getDrawable(R.drawable.marker));
+ stopOverlay = overlayManager.getOverlay("route" + route);
+ stopOverlay.addAll(grabStopCoordsByDirection(route, "ALL"));
+ stopOverlay.setOnOverlayGestureListener(mogDetector);
+ overlayManager.populate();
+ }
+ }
+ }
+
+ });
+
+ rightButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ String direction = (String) ((TextView) v).getText();
+ if(!v.isSelected()){
+ v.setSelected(true);
+ leftButton.setSelected(false);
+ overlayManager.removeOverlay(stopOverlay);
+ overlayManager.createOverlay("route" + route, getResources().getDrawable(R.drawable.marker));
+ stopOverlay = overlayManager.getOverlay("route" + route);
+ stopOverlay.addAll(grabStopCoordsByDirection(route, direction));
+ stopOverlay.setOnOverlayGestureListener(mogDetector);
+ overlayManager.populate();
+ }
+ else{
+ v.setSelected(false);
+ overlayManager.removeOverlay(stopOverlay);
+ overlayManager.createOverlay("route" + route, getResources().getDrawable(R.drawable.marker));
+ stopOverlay = overlayManager.getOverlay("route" + route);
+ stopOverlay.addAll(grabStopCoordsByDirection(route, "ALL"));
+ stopOverlay.setOnOverlayGestureListener(mogDetector);
+ overlayManager.populate();
+ }
+ }
+ });
+
+ @SuppressWarnings("rawtypes")
+ ArrayAdapter spinAdap = (ArrayAdapter) spinner.getAdapter();
+ for(int i = 0; i < spinAdap.getCount(); i++){
+ Matcher m = p.matcher(spinAdap.getItem(i).toString());
+ if (m.find()) {
+ if(m.group().equals(route)){
+ spinner.setSelection(i);
+ }
+ }
+ }
+
+ spinner.setOnItemSelectedListener(new SpinnerItemListener());
+
+ myDbHelper = new MySQLiteHelper(this);
+ try {
+ myDbHelper.createDatabase();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ db = myDbHelper.getReadableDatabase();
+
+ //Start map off at center of Anchorage
+ GeoPoint centerOfAnchorage = new LatLonPoint(61.157016,-149.861265);
+ mapView.getController().animateTo(centerOfAnchorage);
+ mapView.getController().setZoom(12);
+
+ overlayManager = new OverlayManager(this, mapView);
+ stopOverlay = overlayManager.createOverlay("route" + route, getResources().getDrawable(R.drawable.marker));
+ stopOverlay.addAll(grabStopCoordsByDirection(route, "1 MULDOON"));
+ stopOverlay.setOnOverlayGestureListener(mogDetector);
+ overlayManager.populate();
+
+ busOverlay = overlayManager.createOverlay("route" + route + "bus", getResources().getDrawable(R.drawable.busmarker));
+ ManagedOverlay.boundToCenter(getResources().getDrawable(R.drawable.busmarker));
+ busOverlay.addAll(grabBusCoords(route));
+ toCallAsync(route);
+ overlayManager.populate();
+
+ projection = mapView.getProjection();
+
+
+
+ }
+
+ @Override
+ public void onPause(){
+ super.onPause();
+ doAsyncTask.cancel();
+ }
+
+ @Override
+ public void onResume(){
+ super.onResume();
+ toCallAsync(route);
+ }
+
+ public void toCallAsync(final String routeNum) {
+ final Handler handler = new Handler();
+ Timer timer = new Timer();
+ if(doAsyncTask != null){
+ doAsyncTask.cancel();
+ }
+ doAsyncTask = new TimerTask() {
+ @Override
+ public void run() {
+ handler.post(new Runnable(){
+ public void run() {
+ try {
+ BusRefresher performBackgroundTask = new BusRefresher();
+ performBackgroundTask.execute(routeNum);
+ }
+ catch (Exception e) {
+ }
+ }
+ });
+ }
+ };
+ timer.schedule(doAsyncTask, 0,20000);
+ }
+
+ OnOverlayGestureListener mogDetector = new ManagedOverlayGestureDetector.OnOverlayGestureListener(){
+ public boolean onDoubleTap(MotionEvent arg0, ManagedOverlay arg1,
+ GeoPoint arg2, ManagedOverlayItem arg3) {
+ return false;
+ }
+
+ public void onLongPress(MotionEvent arg0, ManagedOverlay arg1) {
+
+ }
+
+ public void onLongPressFinished(MotionEvent arg0,
+ ManagedOverlay arg1, GeoPoint arg2, ManagedOverlayItem arg3) {
+ if(arg3 != null){
+ String stopNum = arg3.getTitle().substring(5);
+ String stopAddr = arg3.getSnippet();
+ String stopName = stopNum + " - " + stopAddr;
+ SharedPreferences favoriteStops = getSharedPreferences("main", MODE_PRIVATE);
+ SharedPreferences.Editor editor = favoriteStops.edit();
+ editor.putString(stopName, stopName);
+ editor.commit();
+ Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
+ v.vibrate(150);
+ // TODO: Should be a popup&fadeout footer, Toasts suck
+ Toast.makeText(map.this, stopName + " added to Favorites", Toast.LENGTH_SHORT).show();
+
+ }
+ }
+
+ public boolean onScrolled(MotionEvent arg0, MotionEvent arg1,
+ float arg2, float arg3, ManagedOverlay arg4) {
+ return false;
+ }
+
+ public boolean onSingleTap(MotionEvent arg0, ManagedOverlay arg1,
+ GeoPoint arg2, ManagedOverlayItem arg3) {
+ if(arg3 != null){
+ Dialog dialog = new Dialog(map.this, R.style.dialogStyle);
+ dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
+ String stopNum = arg3.getTitle().substring(5);
+ MapTimesTable dialogTable = new MapTimesTable(map.this, stopNum);
+ ScrollView sv = new ScrollView(map.this);
+ sv.addView(dialogTable);
+ dialog.setContentView(sv);
+ dialog.show();
+ return true;
+ }
+ return false;
+ }
+
+ public boolean onZoom(ZoomEvent arg0, ManagedOverlay arg1) {
+ return false;
+ }
+ };
+
+ class MapTimesLoader extends AsyncTask<String, Integer, Document>{
+ Context context;
+ MapTimesTable timesTable;
+ ProgressBar waitSpinner;
+
+ public MapTimesLoader(Context context, MapTimesTable timesTable) {
+ this.context = context;
+ this.timesTable = timesTable;
+
+ TableRow.LayoutParams params = new TableRow.LayoutParams();
+ params.gravity = Gravity.CENTER;
+ params.weight = 0;
+ params.span = 2;
+
+ waitSpinner = new ProgressBar(context, null, android.R.attr.progressBarStyle);
+ waitSpinner.setLayoutParams(params);
+ }
+
+ @Override
+ protected void onProgressUpdate(Integer... values){
+ super.onProgressUpdate(values);
+ if(values[0] == 0){
+ TableRow row = new TableRow(context);
+ row.addView(waitSpinner);
+ timesTable.addView(row);
+ }
+ if(values[0] == -1){
+ TextView tv = new TextView(context);
+ tv.setText("The network is not responding. Are you connected to the internet?");
+ timesTable.addView(tv);
+ }
+ }
+
+ @Override
+ protected Document doInBackground(String... stopNum) {
+ Document page = null;
+ publishProgress(0);
+ try {
+ page = Jsoup.connect("http://bustracker.muni.org/InfoPoint/map/GetStopHtml.ashx?vehicleId=" + stopNum[0]).get();
+ } catch (IOException e) {
+ e.printStackTrace();
+ publishProgress(-1);
+ }
+ return page;
+ }
+
+ @Override
+ protected void onPostExecute(Document page){
+ super.onPostExecute(page);
+ if(page != null){
+ // It might be dangerous to remove the Loading Wheel by assuming it's position
+ // but if it's not there than something's gone seriously wrong.
+ if(timesTable.getChildAt(3) != null){
+ timesTable.removeViewAt(3);
+ }
+ Elements elems = page.body().select("h3, h1, td, div");
+ TableRow infoRow = new TableRow(context);
+ TableRow timeRow = new TableRow(context);
+ int flag = 0;
+
+ for(Element src : elems){
+ if(src.nodeName().equals("td") && flag == 0 || flag == 1 ){
+ TextView tv = new TextView(context);
+ tv.setText(src.text());
+ if(flag == 1){
+ tv.setGravity(Gravity.RIGHT);
+ }
+ infoRow.addView(tv);
+ flag++;
+ }
+ else if(src.nodeName().equals("td") && flag == 2){
+ TextView tv = new TextView(context);
+ tv.setText(src.text());
+ TableRow.LayoutParams rowSpanLayout = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
+ rowSpanLayout.span = 2;
+
+ tv.setGravity(Gravity.CENTER);
+ timeRow.addView(tv, rowSpanLayout);
+ timesTable.addView(infoRow);
+ infoRow = new TableRow(context);
+ timesTable.addView(timeRow);
+ timeRow = new TableRow(context);
+
+ View spacerThin = new View(context);
+ spacerThin.setBackgroundColor(Color.LTGRAY);
+ spacerThin.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 1));
+ timesTable.addView(spacerThin);
+
+ flag++;
+ }
+ else if(src.nodeName().equals("td") && flag == 3){
+ flag = 0;
+ }
+ }
+
+ if(page.text().equals("Stop departure data is too old.") || timesTable.getChildCount() == 0){
+ TextView tv = new TextView(context);
+ tv.setText("No upcoming departures.");
+ infoRow.addView(tv);
+ timesTable.addView(infoRow);
+ }
+ }
+
+ }
+
+ }
+
+ class MapTimesTable extends TableLayout{
+ public MapTimesTable(Context context, String stopNum) {
+ super(context);
+ makeHeader(stopNum);
+ grabMapTimes(stopNum);
+ setVisibility(View.VISIBLE);
+ }
+
+ public void makeHeader(String stopNum){
+ this.removeAllViews();
+ this.setStretchAllColumns(true);
+
+ String[] columns = {"_id", "num", "addr"};
+ String where = "num LIKE '" + stopNum + "'";
+ Cursor cursor = db.query("stops", columns, where, null, null, null, null);
+ startManagingCursor(cursor);
+ cursor.moveToFirst();
+ String addr = cursor.getString(cursor.getColumnIndex("addr"));
+
+ TextView headerStopNum = new TextView(map.this);
+ headerStopNum.setText("Stop " + stopNum);
+ headerStopNum.setTextSize(20);
+ headerStopNum.setGravity(Gravity.CENTER);
+ this.addView(headerStopNum);
+
+ TextView headerAddr = new TextView(map.this);
+ headerAddr.setText(addr);
+ headerAddr.setTextSize(20);
+ headerAddr.setGravity(Gravity.CENTER);
+ this.addView(headerAddr);
+
+ View spacerThick = new View(map.this);
+ spacerThick.setBackgroundColor(Color.LTGRAY);
+ spacerThick.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 4));
+ this.addView(spacerThick);
+
+ }
+
+ public void grabMapTimes(String stopNum){
+ MapTimesLoader timesLoader = new MapTimesLoader(getContext(), this);
+ timesLoader.execute(stopNum);
+ }
+ }
+
+ // Required by the MapActivity, unsure of it's exact purpose...
+ @Override
+ protected boolean isRouteDisplayed(){
+ return false;
+ }