This commit is contained in:
macgregor 2012-10-25 20:15:46 +05:30
parent 89605e1bc5
commit 34909619dd
23 changed files with 1177 additions and 464 deletions

View File

View File

@ -1,24 +1,32 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.best.ui" package="com.best.ui"
android:versionCode="1" android:versionCode="5"
android:versionName="1.0"> android:versionName="3.0">
<application android:label="@string/app_name" <application android:label="@string/app_name"
android:icon="@drawable/bestlogo"> android:icon="@drawable/bestlogo">
<activity android:name="Best" android:theme="@style/Theme.Transparent" <activity android:name="Best" android:theme="@style/Theme.Transparent"
android:clearTaskOnLaunch="true" android:clearTaskOnLaunch="true" android:configChanges="orientation|keyboardHidden">
android:label="@string/app_name">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"></action> <action android:name="android.intent.action.MAIN"></action>
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="SplashScreen1" android:theme="@style/Theme.Transparent" android:clearTaskOnLaunch="true" > <activity android:name="MainTab" android:theme="@android:style/Theme.NoTitleBar" android:clearTaskOnLaunch="true" android:configChanges="orientation|keyboardHidden"/>
<activity android:name="SplashScreen1" android:theme="@style/Theme.Transparent" android:configChanges="orientation|keyboardHidden" android:clearTaskOnLaunch="true" >
</activity> </activity>
<activity android:name="Find" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.NoTitleBar" android:clearTaskOnLaunch="true"/> <activity android:name="Find" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.NoTitleBar" android:clearTaskOnLaunch="true"/>
<!--<activity android:name="NearTripRoute" android:theme="@android:style/Theme.NoTitleBar" android:clearTaskOnLaunch="true" />
<activity android:name="Routing" android:theme="@android:style/Theme.NoTitleBar" android:clearTaskOnLaunch="true" />-->
<activity android:name="Routes" android:theme="@android:style/Theme.NoTitleBar" android:clearTaskOnLaunch="true" /> <activity android:name="Routes" android:theme="@android:style/Theme.NoTitleBar" android:clearTaskOnLaunch="true" />
<activity android:name="Map" android:theme="@android:style/Theme.NoTitleBar" android:clearTaskOnLaunch="true" /> <activity android:name="Map" android:theme="@android:style/Theme.NoTitleBar" android:clearTaskOnLaunch="true" />
<activity android:name="ListLocation" android:theme="@android:style/Theme.Dialog" android:clearTaskOnLaunch="true" /> <activity android:name="ListLocation" android:theme="@android:style/Theme.Dialog" android:clearTaskOnLaunch="true" />
<activity android:name="Search" android:theme="@android:style/Theme.Dialog" android:clearTaskOnLaunch="true" />
<activity android:name="Buses" android:theme="@android:style/Theme.NoTitleBar" android:configChanges="orientation|keyboardHidden" android:clearTaskOnLaunch="true" />
<activity android:name="Stops" android:theme="@android:style/Theme.NoTitleBar" android:configChanges="orientation|keyboardHidden" android:clearTaskOnLaunch="true" />
<activity android:name="EmptyActivity" android:theme="@android:style/Theme.NoTitleBar" android:clearTaskOnLaunch="true" />
<!--<activity android:name="TabGroup1Activity"></activity>
<activity android:name="TabGroup2Activity"></activity>-->
</application> </application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />

View File

@ -8,5 +8,5 @@
Nikita:- Nikita:-
1. Reset max sdk version in AndroidManifest.xml in tag <uses-sdk>. Now it is set as API level 11. 1. Reset max sdk version in AndroidManifest.xml in tag <uses-sdk>. Now it is set as API level 11.
2. Nearby stops button face. 2. Nearby stops button face.
3. Off GPS when not required. 3. Off GPS when not required.
4.Map: Specify start and end bus stops

View File

@ -3,5 +3,5 @@
# #
pushd bin/ pushd bin/
/cygdrive/c/Program\ Files/Android/android-sdk-windows/platform-tools/adb.exe install chalobest-debug.apk /cygdrive/c/Program\ Files/Android/android-sdk-windows/platform-tools/adb.exe -s emulator-5554 install chalobest-debug.apk
popd popd

View File

@ -4,18 +4,19 @@
<item android:state_pressed="false"> <item android:state_pressed="false">
<shape> <shape>
<gradient <gradient
android:startColor="#ebebeb" android:startColor="#b6b4b6"
android:endColor="#b6b4b6" android:endColor="#b6b4b6"
android:centerColor="#ebebeb"
android:angle="270" /> android:angle="270" />
<stroke <stroke
android:width="1dp" android:width="2dp"
android:color="#b4b5b4" /> android:color="#b4b5b4" />
<corners <corners
android:radius="3dp" /> android:radius="25dp" />
<padding <padding
android:left="10dp" android:left="20dp"
android:top="10dp" android:top="10dp"
android:right="10dp" android:right="20dp"
android:bottom="10dp" /> android:bottom="10dp" />
</shape> </shape>
</item> </item>

View File

@ -1,10 +1,34 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector <selector
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false" <item android:state_pressed="true" >
android:drawable="@android:drawable/editbox_background" /> <shape>
<item android:state_pressed="true" <gradient
android:drawable="@drawable/focused_application_background_static" /> android:startColor="#ebebeb"
<item android:state_focused="true" android:endColor="#b6b4b6"
android:drawable="@drawable/focused_application_background_static" /> android:angle="270" />
<stroke
android:width="1dp"
android:color="#cc0000" />
</shape>
</item>
<item android:state_pressed="false" >
<shape>
<gradient
android:startColor="#ffffff"
android:endColor="#ffffff"
android:angle="270" />
</shape>
</item>
<item android:state_focused="true">
<shape>
<gradient
android:startColor="#ffffff"
android:endColor="#ffffff"
android:angle="270" />
<stroke
android:width="1dp"
android:color="#009900" />
</shape>
</item>
</selector> </selector>

View File

@ -2,22 +2,53 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rellayoutmain" android:id="@+id/rellayoutmain"
android:background="#efefef" android:background="#ffffff"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent">
<LinearLayout <!--<LinearLayout
android:id="@+id/titlelinearlayout" android:id="@+id/titlelinearlayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">-->
<ImageView <!--<ImageView
android:id="@+id/besthead" android:id="@+id/besthead"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:background="@drawable/bestheadbar"/> android:background="@drawable/bestheadbar"/>-->
<!-- <TextView
android:id="@+id/myroute"
android:layout_width="0dp"
android:layout_weight="0.25"
android:layout_height="35dp"
android:padding="10dp"
android:text="@+string/myroute"
android:background="#d2d2d2"
android:textColor="#070707"/>
<Button
android:id="@+id/buses"
android:layout_width="0dp"
android:layout_weight="0.25"
android:layout_height="35dp"
android:layout_gravity="right"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:background="@drawable/blue_button"
android:text="@+string/buses" />
<Button
android:id="@+id/stops"
android:layout_width="0dp"
android:layout_weight="0.25"
android:layout_height="35dp"
android:layout_gravity="right"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:background="@drawable/blue_button"
android:text="@+string/stops" />
</LinearLayout> </LinearLayout>-->
<!--<LinearLayout <!--<LinearLayout
android:id="@+id/titlelinearlayout" android:id="@+id/titlelinearlayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -62,54 +93,42 @@
android:src="@drawable/ic_minus_trans"/ android:src="@drawable/ic_minus_trans"/
</LinearLayout>--> </LinearLayout>-->
<ScrollView
android:id="@+id/ScrollView01" <LinearLayout
android:layout_width="fill_parent" android:id="@+id/explinearlayout"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:fillViewport="true" android:layout_height="wrap_content"
android:layout_below="@id/titlelinearlayout"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/mainlinearlayout" android:id="@+id/linearlayout1"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical"> android:layout_marginTop="10dp">
<EditText
android:id="@+id/fromtxt"
android:layout_width="0dp"
android:layout_weight="0.8"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/findfrom"
android:layout_marginLeft="5dp"
android:paddingLeft="10dp"
android:background="@drawable/edittext"
android:singleLine="true"
android:hint="@+string/sourceHint"/>
<ImageButton
style="@android:style/Widget.Button.Inset"
android:id="@+id/findfrom"
android:layout_width="0dp"
android:layout_weight="0.1"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/fromtxt"
android:background="@drawable/image_btn_pressd"
android:src="@drawable/magglass_tot_trans"/>
<LinearLayout <!-- <Button
android:id="@+id/explinearlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/linearlayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp">
<EditText
android:id="@+id/fromtxt"
android:layout_width="0dp"
android:layout_weight="0.7"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/findfrom"
android:layout_marginLeft="5dp"
android:paddingLeft="10dp"
android:background="@drawable/edittext"
android:singleLine="true"
android:hint="@+string/sourceHint"/>
<ImageButton
style="@android:style/Widget.Button.Inset"
android:id="@+id/findfrom"
android:layout_width="0dp"
android:layout_weight="0.1"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/fromtxt"
android:background="@drawable/image_btn_pressd"
android:src="@drawable/magglass_tot_trans"/>
<Button
android:id="@+id/nearFrom" android:id="@+id/nearFrom"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="0.1" android:layout_weight="0.1"
@ -121,38 +140,38 @@
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
android:background="@drawable/blue_button" android:background="@drawable/blue_button"
android:text="@+string/nearbyBtnText" /> android:text="@+string/nearbyBtnText" />-->
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/linearlayout2" android:id="@+id/linearlayout2"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_marginTop="15dp" android:layout_marginTop="5dp"
android:layout_below="@id/linearlayout1"> android:layout_below="@id/linearlayout1">
<EditText <EditText
android:id="@+id/totxt" android:id="@+id/totxt"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="0.7" android:layout_weight="0.8"
android:layout_height="30dp" android:layout_height="30dp"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:background="@drawable/edittext" android:background="@drawable/edittext"
android:layout_below="@id/fromtxt" android:layout_below="@id/fromtxt"
android:singleLine="true" android:singleLine="true"
android:hint="@+string/destinationHint"/> android:hint="@+string/destinationHint"/>
<ImageButton <ImageButton
android:id="@+id/findto" android:id="@+id/findto"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="0.1" android:layout_weight="0.1"
android:layout_height="35dp" android:layout_height="35dp"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:soundEffectsEnabled="true" android:soundEffectsEnabled="true"
android:layout_toRightOf="@id/totxt" android:layout_toRightOf="@id/totxt"
android:background="@drawable/image_btn_pressd" android:background="@drawable/image_btn_pressd"
android:src="@drawable/magglass_tot_trans"/> android:src="@drawable/magglass_tot_trans"/>
<Button <!--<Button
android:id="@+id/nearTo" android:id="@+id/nearTo"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="0.1" android:layout_weight="0.1"
@ -163,69 +182,149 @@
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
android:background="@drawable/blue_button" android:background="@drawable/blue_button"
android:text="@+string/nearbyBtnText" /> android:text="@+string/nearbyBtnText" />-->
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/linearlayout3" android:id="@+id/linearlayoutparent"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:gravity = "left"
android:gravity="center_horizontal" android:orientation="horizontal"
android:layout_marginTop="15dp" android:layout_marginTop="5dp"
android:layout_below="@id/linearlayout2"> android:layout_below="@id/linearlayout2">
<Button
android:id="@+id/findbus"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:gravity="center_horizontal"
android:soundEffectsEnabled="true"
android:background="@drawable/blue_button"
android:text="@+string/findBusText" />
</LinearLayout>
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/linearlayout4" android:id="@+id/linearlayout3"
android:layout_width="fill_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="0.85"
android:layout_marginTop="15dp" android:gravity = "right"
android:layout_below="@id/linearlayout3"> android:orientation="horizontal"
android:layout_height="wrap_content">
<Button
android:id="@+id/findbus"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:gravity = "right"
android:layout_alignParentRight="true"
android:textSize="14sp"
android:background="@drawable/blue_button"
android:text="@+string/search" />
</LinearLayout>
<TextView <TextView
android:id="@+id/txthead" android:id="@+id/txtpr"
android:layout_width="fill_parent" android:layout_width="0dp"
android:layout_height="40dp" android:layout_weight="0.15"
android:padding="10dp" android:gravity = "right"
android:text="@+string/busListHead" android:layout_height="35dp"
android:background="#d2d2d2" android:textColor="#070707"
android:textColor="#070707" android:visibility="invisible"/>
android:visibility="invisible"/> </LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/linearlayout4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_below="@id/explinearlayout">
<Button
android:id="@+id/expandable"
android:layout_width="fill_parent"
android:layout_height="20dp"
android:gravity="center"
android:background="@drawable/handle" />
</LinearLayout>
<ScrollView
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:layout_below="@id/linearlayout4">
<LinearLayout
android:id="@+id/mainlinearlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/linearlayout5" android:id="@+id/linearlayout5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp">
<TextView
android:id="@+id/txtprevious"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="40dp"
android:orientation="vertical" android:padding="10dp"
android:layout_below="@id/linearlayout4"> android:text="@+string/previoussearch"
android:background="#d2d2d2"
android:textColor="#070707"/>
</LinearLayout>
<LinearLayout
android:id="@+id/linearlayout6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@id/linearlayout5">
<com.best.ui.ExpandedListView <com.best.ui.ExpandedListView
android:id="@android:id/list" android:id="@android:id/list"
android:label="Buses"
android:background="#efefef"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="wrap_content"
android:scrollY="0dp" android:scrollY="0dp"
android:background="@drawable/listbackgrnd"
android:dividerHeight="0dp" android:dividerHeight="0dp"
android:scrollbarSize="0dp" android:scrollbarSize="0dp"
android:fastScrollEnabled="false" android:fastScrollEnabled="false"
android:scrollbars="none" android:scrollbars="none"
/> />
</LinearLayout> </LinearLayout>
<!--<TextView
android:id="@+id/txthead"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:padding="10dp"
android:text="@+string/busListHead"
android:background="#d2d2d2"
android:textColor="#070707"
android:visibility="invisible"/>-->
<LinearLayout
android:id="@+id/linearlayout7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_below="@id/linearlayout6">
<TextView
android:id="@+id/txtnearby"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:padding="10dp"
android:text="@+string/nearbytext"
android:background="#d2d2d2"
android:textColor="#070707"/>
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/linearlayout8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@id/linearlayout7">
<com.best.ui.ExpandedListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/listbackgrnd"
android:dividerHeight="0dp"
/>
</LinearLayout>
</LinearLayout>
</ScrollView > </ScrollView >
</RelativeLayout> </RelativeLayout>

View File

@ -67,17 +67,38 @@
<TextView <TextView
android:id="@+id/totaldist" android:id="@+id/totaldist"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="0.5" android:layout_weight="0.35"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:textSize="14sp" android:textSize="14sp"
android:paddingLeft="0dp" android:paddingLeft="0dp"
android:textColor="#5a5858"/> android:textColor="#5a5858"/>
<LinearLayout
android:id="@+id/innerlinearlayout"
android:layout_width="0dp"
android:layout_weight="0.3"
android:gravity="center"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/busBlue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/freq"
android:background="@null"/>
<TextView
android:id="@+id/bus_freq"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:paddingLeft="0dp"
android:textColor="#5a5858"/>
</LinearLayout>
<TextView <TextView
android:id="@+id/stopsno" android:id="@+id/stopsno"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="0.5" android:layout_weight="0.35"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:textSize="14sp" android:textSize="14sp"

View File

@ -5,4 +5,6 @@
android:drawable="@drawable/focused_application_background_static" /> android:drawable="@drawable/focused_application_background_static" />
<item android:state_focused="true" <item android:state_focused="true"
android:drawable="@drawable/focused_application_background_static" /> android:drawable="@drawable/focused_application_background_static" />
<item android:state_selected="true"
android:drawable="@drawable/focused_application_background_static" />
</selector> </selector>

View File

@ -2,6 +2,7 @@
<ScrollView <ScrollView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01" android:id="@+id/ScrollView01"
android:background="#ffffff"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
> >

View File

@ -5,7 +5,7 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="10dp" android:padding="10dp"
android:background="@android:drawable/editbox_background" android:background="@drawable/listbackgrnd"
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
<TextView <TextView
android:id="@+id/stopname" android:id="@+id/stopname"
@ -13,15 +13,16 @@
android:layout_weight="0.75" android:layout_weight="0.75"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="16sp" android:textSize="16sp"
android:gravity = "left"
android:textColor="#4a81af"> android:textColor="#4a81af">
</TextView> </TextView>
<TextView <TextView
android:id="@+id/dep" android:id="@+id/dep"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="0.25" android:layout_weight="0.25"
android:text = ""
android:gravity = "right"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center"
android:textSize="16sp"
android:textColor="#5a5858"> android:textColor="#5a5858">
</TextView> </TextView>
</LinearLayout> </LinearLayout>

View File

@ -4,7 +4,8 @@
android:label="Somelabel1" android:label="Somelabel1"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="10dp" android:padding="5dp"
android:gravity="center_vertical"
android:background="@drawable/listbackgrnd" android:background="@drawable/listbackgrnd"
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
@ -14,28 +15,47 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="0.8" android:layout_weight="0.8"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical">
android:background="@android:drawable/editbox_background">
<TextView <TextView
android:id="@+id/stopname" android:id="@+id/stopname"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="0.5" android:textSize="16sp"
android:gravity="center_vertical"
android:layout_weight="0.7"
android:textColor="#4a81af"/> android:textColor="#4a81af"/>
<TextView <LinearLayout
android:id="@+id/dist" android:id="@+id/innerlinearlayout1"
android:layout_width="fill_parent" android:label="Somelabel1"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="0.5" android:layout_width="fill_parent"
android:textColor="#5a5858" android:layout_weight="0.3"
android:layout_below="@+id/stopname"/> android:orientation="horizontal"
android:layout_below="@+id/stopname">
<TextView
android:id="@+id/stopRoad"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:textSize="14sp"
android:textColor="#5a5858"/>
<TextView
android:id="@+id/stopArea"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:textSize="14sp"
android:gravity="right"
android:textColor="#5a5858"/>
</LinearLayout>
</LinearLayout> </LinearLayout>
<Button <Button
android:id="@+id/map" android:id="@+id/map"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="0.2" android:layout_weight="0.2"
android:layout_height="50dp" android:layout_height="50dp"
android:text="Map" /> android:text="@string/txtMap" />
</LinearLayout> </LinearLayout>
<!--android:background="@android:drawable/editbox_background" android:layout_alignParentBottom="true" android:paddingTop="10dp"--> <!--android:background="@android:drawable/editbox_background" android:layout_alignParentBottom="true" android:paddingTop="10dp"-->

View File

@ -4,11 +4,82 @@
android:id="@+id/routeslayout" android:id="@+id/routeslayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:background="#efefef" android:background="#efefef"
android:orientation="vertical"
android:layout_height="fill_parent" > android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/listheader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/listheader1" android:id="@+id/listheader1"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="0dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/busBlue"
android:layout_width="0dp"
android:layout_weight="0.1"
android:gravity="left"
android:layout_height="wrap_content"
android:src="@drawable/bus_blue_small"
android:background="@null"/>
<TextView
android:id="@+id/_routename"
android:layout_width="0dp"
android:layout_weight="0.15"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="18sp"
android:paddingLeft="0dp"
android:textColor="#5a5858"/>
<TextView
android:id="@+id/_routelongname"
android:layout_width="0dp"
android:layout_weight="0.75"
android:layout_height="wrap_content"
android:gravity="left"
android:textSize="18sp"
android:paddingLeft="10dp"
android:textColor="#5a5858"/>
</LinearLayout>
<LinearLayout
android:id="@+id/listheader2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="0dp"
android:gravity="center"
android:orientation="horizontal"
android:layout_below="@id/listheader1">
<ImageView
android:id="@+id/busBlue"
android:layout_width="wrap_content"
android:gravity="right"
android:layout_height="wrap_content"
android:src="@drawable/freq"
android:background="@null"/>
<TextView
android:id="@+id/_freq"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:textSize="18sp"
android:paddingLeft="10dp"
android:textColor="#5a5858"/>
</LinearLayout>
</LinearLayout>
<!--<LinearLayout
android:id="@+id/listheader1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#d2d2d2" android:background="#d2d2d2"
android:padding="10dp"> android:padding="10dp">
<TextView <TextView
@ -16,17 +87,18 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="16sp" android:textSize="16sp"
android:text="Stop Name" android:text="@+string/StopNameHeading"
android:textColor="#070707"> android:textColor="#070707">
</TextView> </TextView>
</LinearLayout> </LinearLayout> -->
<LinearLayout <LinearLayout
android:id="@+id/linearlayout2" android:id="@+id/linearlayout2"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/listheader1"> android:layout_below="@id/listheader">
<ListView <ListView
android:id="@android:id/list" android:id="@+id/routeslist"
android:label="Buses" android:label="Buses"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent">

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/fullRoute" <item android:id="@+id/fullRoute"
android:icon="@drawable/ic_tab_newsel" android:icon="@drawable/ic_tab_sel"
android:title="Full Route" /> android:title="Full Route" />
<item android:id="@+id/map" <item android:id="@+id/map"
android:icon="@drawable/ic_tab_newsel" android:icon="@drawable/ic_tab_sel"
android:title="Map" /> android:title="Map" />
</menu> </menu>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/mnuexitmain" <item android:id="@+id/mnuexitmain"
android:icon="@drawable/ic_tab_newsel" android:icon="@drawable/ic_tab_sel"
android:title="Exit" /> android:title="Exit" />
</menu> </menu>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/map" <item android:id="@+id/map"
android:icon="@drawable/ic_tab_newsel" android:icon="@drawable/ic_tab_sel"
android:title="Map" /> android:title="Map" />
</menu> </menu>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">Best</string> <string name="app_name">ChaloBEST</string>
<string name="M_FIND_TAB_ID">find</string> <string name="M_FIND_TAB_ID">find</string>
<string name="M_ROUT_TAB_ID">route</string> <string name="M_ROUT_TAB_ID">route</string>
<string name="fromListTitle">Select Your Start Location</string> <string name="fromListTitle">Select Your Start Location</string>
@ -11,15 +11,30 @@
<string name="findBtnText">F</string> <string name="findBtnText">F</string>
<string name="nearbyBtnText">N</string> <string name="nearbyBtnText">N</string>
<string name="findBusText">Find Bus</string> <string name="findBusText">Find Bus</string>
<string name="busListHead">Buses Available</string> <string name="busListHead">Search Result</string>
<string name="inittext">Initializing Application for the first time...</string> <string name="inittext">Initializing Application for the first time...</string>
<string name="errMsgMoreChar">Please enter some more characters..</string> <string name="errMsgMoreChar">Please enter some more characters..</string>
<string name="errMsgEnterSrcLoc">Please enter some source location..</string> <string name="errMsgEnterSrcLoc">Please enter some source location..</string>
<string name="errMsgEnterDestLoc">Please enter some destination location..</string> <string name="errMsgEnterDestLoc">Please enter some destination location..</string>
<string name="errMsgEnterValidDest">Enter valid destination</string> <string name="errMsgEnterValidDest">Enter valid destination</string>
<string name="errMsgEnterValidSrc">Enter valid Source location</string> <string name="errMsgEnterValidSrc">Enter valid Source location</string>
<string name="errMsgNoStopsMatch">No matching stops found</string> <string name="errMsgNoStopsMatch">No matching stop found</string>
<string name="errMsgNoBusMatch">No matching Bus found</string>
<string name="errMsgNoNearbyStop">No stops found near by</string> <string name="errMsgNoNearbyStop">No stops found near by</string>
<string name="noLocation">No such Location</string> <string name="noLocation">No such Location</string>
<string name="errNoMap">Sorry, unable to show map at this time.</string> <string name="errNoMap">Sorry, unable to show map at this time.</string>
<string name="buses">Buses</string>
<string name="stops">Stops</string>
<string name="search">Find Routes</string>
<string name="myroute">My Route</string>
<string name="previoussearch">Previous Searches:</string>
<string name="nearbytext">Near by passing buses :</string>
<string name="txtSearchFor">Search for :</string>
<string name="StopNameHeading">Stop Name</string>
<string name="txtsearch">Search</string>
<string name="txtWorkInProgress">Work in progress...</string>
<string name="txtMap">Map</string>
<string name="txtSelectSource">Select as Source</string>
<string name="txtSelectDest">Select as Destination</string>
<string name="txtSmthingWentWrong">Sorry...Something went wrong...</string>
</resources> </resources>

View File

@ -37,7 +37,9 @@ import android.content.DialogInterface;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.best.data.DBHandle; import com.best.data.DBHandle;
import com.best.data.GTStore; import com.best.data.GTStore;
import com.best.data.GTStore_sqlite;
import com.best.util.TransitionEffect; import com.best.util.TransitionEffect;
import java.io.Serializable;
public class Best extends Activity public class Best extends Activity
{ {
@ -67,6 +69,8 @@ public class Best extends Activity
TransitionEffect.callOverridePendingTransition(this); TransitionEffect.callOverridePendingTransition(this);
me = this; me = this;
log("BEST: onCreate called");
getUpdatedPosition();
DBHandle.init( me ); DBHandle.init( me );
Intent intent = new Intent( ( Context )me,SplashScreen1.class ); Intent intent = new Intent( ( Context )me,SplashScreen1.class );
@ -74,16 +78,14 @@ public class Best extends Activity
LoadThread loadThread = new LoadThread( loadHandler ); LoadThread loadThread = new LoadThread( loadHandler );
loadThread.start(); loadThread.start();
} }
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
//getUpdatedPosition();
if( m_locationManager == null ) log("BEST: onResume called");
m_locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
getUpdatedPosition();
} }
public Handler loadHandler = new Handler() { public Handler loadHandler = new Handler() {
@ -94,8 +96,9 @@ public class Best extends Activity
if( allOK ) if( allOK )
{ {
GTStore_sqlite.init(me);
Intent intent = new Intent(); Intent intent = new Intent();
intent.setClass( me, Find.class); intent.setClass( me, MainTab.class);
startActivityForResult( intent, _activityRequestCode ); startActivityForResult( intent, _activityRequestCode );
} }
else else
@ -114,10 +117,9 @@ public class Best extends Activity
public void run() public void run()
{ {
//code to get all routes
Bundle dataBundle = new Bundle(); Bundle dataBundle = new Bundle();
dataBundle.putBoolean( "allOK", DBHandle.dbFileReady() ); dataBundle.putBoolean( "allOK", DBHandle.dbFileReady() );
//dataBundle.putBoolean( "allOK", true );
Message msg = _handler.obtainMessage(); Message msg = _handler.obtainMessage();
msg.setData( dataBundle ); msg.setData( dataBundle );
_handler.sendMessage( msg ); _handler.sendMessage( msg );
@ -150,12 +152,12 @@ public class Best extends Activity
public static void showError(Context context, CharSequence msg) public static void showError(Context context, CharSequence msg)
{ {
showMessage( context, msg, "Error" ); showMessage( context, msg, "Message" );
} }
public static void showError(Context context, int msg) public static void showError(Context context, int msg)
{ {
showMessage( context, msg, "Error" ); showMessage( context, msg, "Message" );
} }
public static void showMessage(Context context, CharSequence msg,String title) public static void showMessage(Context context, CharSequence msg,String title)
@ -201,24 +203,35 @@ public class Best extends Activity
/////////GPS /////////GPS
public static void getUpdatedPosition() public void getUpdatedPosition()
{ {
if( !m_position_updation_on ) try
{ {
m_latitude = ""; if( !m_position_updation_on )
m_longitude = ""; {
m_latitude = "";
m_longitude = "";
m_position_updation_on = true; m_position_updation_on = true;
//m_locationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 5000, 0, m_networkLocationListener );
m_locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 5000, 0, m_gpsLocationListener ); if( m_locationManager == null )
m_locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
m_locationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 5000, 0, m_networkLocationListener );
m_locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 5000, 0, m_gpsLocationListener );
}
} }
catch(Exception e)
{showMessage(this,e.toString(),"Error");}
} }
public static void cancelUpdatePosition() public static void cancelUpdatePosition()
{ {
log("GPS: Cancelling UPDATE POSITION");
m_position_updation_on = false; m_position_updation_on = false;
cancelNetWorkUpdatePosition(); cancelNetWorkUpdatePosition();
cancelGPSUpdatePosition(); cancelGPSUpdatePosition();
log("GPS: Canceled UPDATE POSITION");
} }
public static void cancelNetWorkUpdatePosition() public static void cancelNetWorkUpdatePosition()
@ -240,8 +253,10 @@ public class Best extends Activity
public void onProviderDisabled(String provider) { cancelGPSUpdatePosition(); } public void onProviderDisabled(String provider) { cancelGPSUpdatePosition(); }
@Override @Override
public void onLocationChanged(Location location) { public void onLocationChanged(Location location) {
try{ m_latitude = String.format("%9.6f", location.getLatitude()); }catch(Exception e){ m_latitude=""; } try{ m_latitude = String.format("%9.6f", location.getLatitude()); }catch(Exception e){ }
try{ m_longitude = String.format("%9.6f", location.getLongitude()); }catch(Exception e){ m_longitude=""; } try{ m_longitude = String.format("%9.6f", location.getLongitude()); }catch(Exception e){ }
log("Registered GPS LocationListener with values: Lat="+m_latitude+"--Long="+m_longitude);
//showMessage(me,"Registered GPS LocationListener with values: Lat="+m_latitude+"--Long="+m_longitude,"GPS");
cancelUpdatePosition(); cancelUpdatePosition();
} }
}; };
@ -255,17 +270,18 @@ public class Best extends Activity
public void onProviderDisabled(String provider) { cancelNetWorkUpdatePosition(); } public void onProviderDisabled(String provider) { cancelNetWorkUpdatePosition(); }
@Override @Override
public void onLocationChanged(Location location) { public void onLocationChanged(Location location) {
try{ m_latitude = String.format("%9.6f", location.getLatitude()); }catch(Exception e){ m_latitude=""; } try{ m_latitude = String.format("%9.6f", location.getLatitude()); }catch(Exception e){ }
try{ m_longitude = String.format("%9.6f", location.getLongitude()); }catch(Exception e){ m_longitude=""; } try{ m_longitude = String.format("%9.6f", location.getLongitude()); }catch(Exception e){ }
//showMessage(me,"Registered GPS LocationListener with values: Lat="+m_latitude+"--Long="+m_longitude,"GPS");
cancelUpdatePosition(); cancelUpdatePosition();
} }
}; };
public static boolean checkGPS(Context context) public static boolean checkGPS(Context context)
{ {
if( !m_locationManager.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) if( !m_locationManager.isProviderEnabled( LocationManager.GPS_PROVIDER ) && !m_locationManager.isProviderEnabled( LocationManager.NETWORK_PROVIDER ) )
{ {
showMessage( context, "GPS Service not working.Please check option for GPS in \"Location & Security settings\" is checked.", "Service" ); showMessage( context, "GPS/Network Service not working.Please check option for GPS in \"Location & Security settings\" is checked.", "Service" );
return( false ); return( false );
} }
return( true ); return( true );

View File

@ -26,8 +26,24 @@ public class ExpandedListView extends ListView {
if (getCount() != old_count) { if (getCount() != old_count) {
old_count = getCount(); old_count = getCount();
params = getLayoutParams(); params = getLayoutParams();
params.height = 0;
if( old_count > 0 ) if( old_count > 0 )
params.height = ( getCount() * getChildAt(0).getHeight() ) + 20; {
for(int i = 0; i < getCount(); i++)
{
System.out.println("===getCount()"+getCount()+"==="+i);
try{
params.height += getChildAt(i).getHeight();
}catch(Exception e){
System.out.println( "ERROR in getHeight:"+i );
params.height += 75;
}
}
params.height += 20;
//params.height = ( getCount() * getChildAt(0).getHeight() ) + 20;
System.out.println("====Child Height===="+getChildAt(0).getHeight());
System.out.println("====List View Height===="+params.height);
}
else else
params.height = 0; params.height = 0;
setLayoutParams(params); setLayoutParams(params);

View File

@ -52,24 +52,28 @@ import android.view.KeyEvent;
import android.view.View.OnKeyListener; import android.view.View.OnKeyListener;
import java.io.IOException; import java.io.IOException;
import java.util.Locale;
import android.os.Message; import android.os.Message;
import android.os.Handler; import android.os.Handler;
import android.os.Environment; import android.os.Environment;
import java.lang.Double; import java.lang.Double;
import android.text.Html;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color;
import com.best.data.GTStore; import com.best.data.GTStore;
import com.best.data.GTStore_sqlite;
import com.best.util.Funcs; import com.best.util.Funcs;
import com.best.util.TransitionEffect; import com.best.util.TransitionEffect;
import com.best.ui.Routing;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
public class Find extends ListActivity { public class Find extends Activity {
public static Activity me ;
public static Context m_context ;
public static ListActivity me;
public static Context m_context;
public static AttributeSet attr; public static AttributeSet attr;
public static LayoutInflater mInflater; public static LayoutInflater mInflater;
@ -86,16 +90,35 @@ public class Find extends ListActivity {
public static String[] stopLatitude; public static String[] stopLatitude;
public static String[] stopLongitude; public static String[] stopLongitude;
public static String[][] resultTemp; public static String[][] resultTemp;
public static String[][] nearByTripsInfo = null;
public static List<String[]> prevSearchList = new ArrayList<String[]>();
public static ArrayList<String[]> listOfTrips;
public static List<String> tripIdList;
public static List<String> routeNamesList ;
public static List<String> busHeadList ;
public static List<String> busFreqList ;
public static List<String> totalDistList ;
public static List<String> no_StopsList ;
public static int selPosition = 0; public static int selPosition = 0;
public static int flagSourceSel = -1; public static int flagSourceSel ;
public static int flagDestSel = -1; public static int flagDestSel ;
public static int listDisplayed = -1; public static int listDisplayed = -1;
public static boolean flagPanelVisible = true; public static boolean flagPanelVisible = true;
public static boolean contentChanged = false ;
public static boolean nearByBusClick = false ;
public static boolean callFromNearTripRoute = false;
public static boolean directRouteDisplayed = false;
public static String _sourceStopId = null; public static String _sourceStopId = null ;
public static String _destStopId = null; public static String _destStopId =null ;
public static String sourceStop = "";
public static String destStop = "";
public static String _routeLongName ;
public static String _routeName ;
public static String _tripId ;
public static String _freq ;
public static Double latDouble=0.0; public static Double latDouble=0.0;
public static Double longDouble=0.0; public static Double longDouble=0.0;
@ -104,16 +127,28 @@ public class Find extends ListActivity {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState ); super.onCreate( savedInstanceState );
System.out.println("SDK VERSION ========="+android.os.Build.VERSION.SDK_INT );
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT) if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT)
TransitionEffect.callOverridePendingTransition(this); TransitionEffect.callOverridePendingTransition(this);
//overridePendingTransition(R.anim.fade_in, R.anim.fade_out); this.setContentView( com.best.ui.R.layout.find );
me = this; GTStore_sqlite.init(this);
m_context = this; flagSourceSel=-1;
me.setContentView( com.best.ui.R.layout.find ); flagDestSel=-1;
flagSourceSel=-1; sourceStop = "";
flagDestSel=-1; destStop = "";
init(); init();
}
@Override
public void onContentChanged() {
if(callFromNearTripRoute == true)
{
init();
callFromNearTripRoute = false;
}
Best.log("CONTENT CHANGED");
} }
@Override @Override
@ -125,23 +160,13 @@ public class Find extends ListActivity {
@Override @Override
protected void onRestoreInstanceState(final Bundle outState) { protected void onRestoreInstanceState(final Bundle outState) {
if(outState.getInt("listDisplay")!=-1)
{
EfficientAdapter adapter = new EfficientAdapter( m_context,resultTemp);
me.setListAdapter( adapter );
( (TextView) me.findViewById(com.best.ui.R.id.txthead) ).setVisibility( WIDGET_VISIBLE );
//((ImageButton) me.findViewById(com.best.ui.R.id.expandable)).setVisibility( WIDGET_VISIBLE );
}
flagSourceSel=outState.getInt("src"); flagSourceSel=outState.getInt("src");
flagDestSel=outState.getInt("dest"); flagDestSel=outState.getInt("dest");
} }
@Override @Override
public void onConfigurationChanged(Configuration newConfig) { public void onConfigurationChanged(Configuration newConfig) {
// do something or nothing when configuration change.
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
init();
} }
@Override @Override
@ -151,8 +176,18 @@ public class Find extends ListActivity {
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
return true;
}
@Override
public boolean onPrepareOptionsMenu (Menu menu){
MenuInflater inflater = getMenuInflater(); MenuInflater inflater = getMenuInflater();
inflater.inflate(com.best.ui.R.menu.menustart, menu); menu.clear();
if(nearByBusClick == true)
inflater.inflate(com.best.ui.R.menu.onlymap, menu);
else
inflater.inflate(com.best.ui.R.menu.menustart, menu);
return true; return true;
} }
@ -163,6 +198,20 @@ public class Find extends ListActivity {
case com.best.ui.R.id.mnuexitmain: case com.best.ui.R.id.mnuexitmain:
Best.exit( me ); Best.exit( me );
return true; return true;
case com.best.ui.R.id.map:
if(NearTripRoute._stopLat != null && NearTripRoute._stopLon != null)
{
Bundle bundle1 = new Bundle();
bundle1.putBoolean( "showSingle", false );
bundle1.putSerializable("StopsGeoX",NearTripRoute._stopLat);
bundle1.putSerializable("StopsGeoY",NearTripRoute._stopLon);
Intent intent = new Intent(m_context, Map.class);
intent.putExtras( bundle1 );
me.startActivityForResult(intent,5);
}
return true;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -171,14 +220,45 @@ public class Find extends ListActivity {
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
// cancelUpdatePosition(); //cancelUpdatePosition();
} }
@Override public boolean onKeyDown(int keyCode, KeyEvent event)
public void onBackPressed() { {//If back was pressed
Best.exit( me ); if (keyCode==KeyEvent.KEYCODE_BACK)
//return; {
back();
return true;
}
return super.onKeyDown(keyCode, event);
} }
public void back()
{
if(contentChanged == true )
{
this.setContentView( com.best.ui.R.layout.find );
contentChanged = false;
init();
nearByBusClick = false;
}
else if(!contentChanged)
Best.exit( this );
}
// @Override
// public void onBackPressed() {
// if(contentChanged == true )
// {
// this.setContentView( com.best.ui.R.layout.find );
// contentChanged = false;
// init();
// nearByBusClick = false;
// }
// else if(!contentChanged)
// Best.exit( this );
// }
public void handleFromSearch(String fromTxt) public void handleFromSearch(String fromTxt)
{ {
@ -187,7 +267,10 @@ public class Find extends ListActivity {
if( fromTxt.length() > 2 ) if( fromTxt.length() > 2 )
findBusStops( false, fromTxt, M_FROM_LIST_CAPTION ); findBusStops( false, fromTxt, M_FROM_LIST_CAPTION );
else else
{
Best.showError( m_context, com.best.ui.R.string.errMsgMoreChar ); Best.showError( m_context, com.best.ui.R.string.errMsgMoreChar );
Best.log("ERROR MESSAGE IN MARATHI: "+com.best.ui.R.string.errMsgMoreChar);
}
} }
else else
Best.showError( m_context, com.best.ui.R.string.errMsgEnterSrcLoc ); Best.showError( m_context, com.best.ui.R.string.errMsgEnterSrcLoc );
@ -219,28 +302,63 @@ public class Find extends ListActivity {
public void init() public void init()
{ {
final TextView txthead = (TextView) me.findViewById(com.best.ui.R.id.txthead); me = this;
//final LinearLayout expLayout = (LinearLayout) me.findViewById(com.best.ui.R.id.explinearlayout); m_context = this;
callSwitchLang();
tripIdList = new ArrayList<String>();
routeNamesList = new ArrayList<String>();
busHeadList = new ArrayList<String>();
busFreqList = new ArrayList<String>();
totalDistList = new ArrayList<String>();
no_StopsList = new ArrayList<String>();
// final ImageButton btnexpand = (ImageButton) me.findViewById(com.best.ui.R.id.expandable); if(prevSearchList != null && prevSearchList.size() > 0)
// btnexpand.setOnClickListener(new View.OnClickListener() { {
// public void onClick(View v) { ((LinearLayout) me.findViewById(com.best.ui.R.id.linearlayout5)).setVisibility(LinearLayout.VISIBLE);
// if(flagPanelVisible == true) EfficientAdapter adapter = new EfficientAdapter( m_context, prevSearchList.toArray( new String[ prevSearchList.size() ][] ) );
// { ( ( ListView ) me.findViewById(android.R.id.list) ).setAdapter( adapter );
// expLayout.setVisibility(LinearLayout.GONE); }
// flagPanelVisible = false;
// btnexpand.setImageResource(R.drawable.ic_plus_trans);
// }
// else
// {
// expLayout.setVisibility(LinearLayout.VISIBLE);
// flagPanelVisible = true;
// btnexpand.setImageResource(R.drawable.ic_minus_trans);
// }
// }
// });
final EditText txtFrm = (EditText) me.findViewById(com.best.ui.R.id.fromtxt); final EditText txtFrm = (EditText) me.findViewById(com.best.ui.R.id.fromtxt);
final EditText txtTo = (EditText) me.findViewById(com.best.ui.R.id.totxt);
if(sourceStop != null && sourceStop.length() > 0)
txtFrm.setText(sourceStop);
if(destStop != null && destStop.length() > 0)
txtTo.setText(destStop);
if(prevSearchList == null || prevSearchList.size() == 0)
((LinearLayout) me.findViewById(com.best.ui.R.id.linearlayout5)).setVisibility(LinearLayout.GONE);
final LinearLayout expLayout = (LinearLayout) me.findViewById(com.best.ui.R.id.explinearlayout);
///////
if( Best.m_latitude.length() > 0 && Best.m_longitude.length() > 0 )
{
latDouble = Double.valueOf( Best.m_latitude );//Double.valueOf( "40.45939" ); 18.930075
longDouble = Double.valueOf( Best.m_longitude );//Double.valueOf( "-3.78429" );72.833308
}
Best.showProcessing( m_context, "Loading","Please wait..." );
NearByTripsSearchThread nearByTripsSearch = new NearByTripsSearchThread( nearByTripsSearchHandler );
nearByTripsSearch.start();
final Button btnexpand = (Button) me.findViewById(com.best.ui.R.id.expandable);
btnexpand.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(flagPanelVisible == true)
{
expLayout.setVisibility(LinearLayout.GONE);
flagPanelVisible = false;
// btnexpand.setImageResource(R.drawable.ic_plus_trans);
}
else
{
expLayout.setVisibility(LinearLayout.VISIBLE);
flagPanelVisible = true;
// btnexpand.setImageResource(R.drawable.ic_minus_trans);
}
}
});
txtFrm.setOnKeyListener( new OnKeyListener() { txtFrm.setOnKeyListener( new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) { public boolean onKey(View v, int keyCode, KeyEvent event) {
handleEnter( event, txtFrm, true ); handleEnter( event, txtFrm, true );
@ -252,10 +370,10 @@ public class Find extends ListActivity {
btnsearchfrm.setOnClickListener(new View.OnClickListener() { btnsearchfrm.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { public void onClick(View v) {
handleFromSearch( txtFrm.getText().toString().trim() ); handleFromSearch( txtFrm.getText().toString().trim() );
} }
}); });
final EditText txtTo = (EditText) me.findViewById(com.best.ui.R.id.totxt);
txtTo.setOnKeyListener( new OnKeyListener() { txtTo.setOnKeyListener( new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) { public boolean onKey(View v, int keyCode, KeyEvent event) {
handleEnter( event, txtTo, false ); handleEnter( event, txtTo, false );
@ -270,19 +388,20 @@ public class Find extends ListActivity {
} }
}); });
final Button btnnearfrom = (Button) me.findViewById(com.best.ui.R.id.nearFrom); // final Button btnnearfrom = (Button) me.findViewById(com.best.ui.R.id.nearFrom);
btnnearfrom.setOnClickListener(new View.OnClickListener() { // btnnearfrom.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { // public void onClick(View v) {
findNearByStops( true ); //// Best.showMessage(me,"Registered GPS LocationListener with values: Lat="+latDouble+"--Long="+longDouble,"GPS");
} // findNearByStops( true );
}); // }
// });
final Button btnnearto = (Button) me.findViewById(com.best.ui.R.id.nearTo); // final Button btnnearto = (Button) me.findViewById(com.best.ui.R.id.nearTo);
btnnearto.setOnClickListener(new View.OnClickListener() { // btnnearto.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { // public void onClick(View v) {
findNearByStops( false ); // findNearByStops( false );
} // }
}); // });
final Button btnfindbus = ( Button ) me.findViewById( com.best.ui.R.id.findbus ); final Button btnfindbus = ( Button ) me.findViewById( com.best.ui.R.id.findbus );
btnfindbus.setOnClickListener( new View.OnClickListener() { btnfindbus.setOnClickListener( new View.OnClickListener() {
@ -317,6 +436,67 @@ public class Find extends ListActivity {
}); });
} }
public Handler nearByTripsSearchHandler = new Handler() {
public void handleMessage(Message msg) {
Bundle dataBundle = msg.getData();
Best.dissmissProcessing();
nearByTripsInfo = ( String[][] )dataBundle.getSerializable( "rts" );
if( nearByTripsInfo != null && nearByTripsInfo.length > 0)
{
listOfTrips = new ArrayList<String[]>();
for(int i=0; i< nearByTripsInfo.length; i++)
{
System.out.println("======nearByTripsInfo=="+nearByTripsInfo[i][0]+"=="+nearByTripsInfo[i][1]+"==="+nearByTripsInfo[i][2]+"==="+nearByTripsInfo[i][3]);
listOfTrips.add(nearByTripsInfo[i]);
if(!(i >= (nearByTripsInfo.length - 2)))
{
if(nearByTripsInfo[i][3].equals(nearByTripsInfo[i+1][3]))
{ i++;}
}
}
if(listOfTrips.size() > 0 )
{
Best.log("listOfTrips NOT NULL");
EfficientAdapterForNear adapter = new EfficientAdapterForNear( m_context, listOfTrips.toArray( new String[ listOfTrips.size() ][] ) );
((TextView) me.findViewById(com.best.ui.R.id.txtnearby)).setVisibility( WIDGET_VISIBLE );
( ( ListView )me.findViewById( com.best.ui.R.id.list ) ).setVisibility( WIDGET_VISIBLE );
( ( ListView )me.findViewById( com.best.ui.R.id.list ) ).setAdapter( adapter );
}
}
else
{
System.out.println("======No near by buses=====");
( ( ListView )me.findViewById( com.best.ui.R.id.list ) ).setVisibility( WIDGET_INVISIBLE );
((TextView) me.findViewById(com.best.ui.R.id.txtnearby)).setVisibility( WIDGET_INVISIBLE );
}
}
};
private class NearByTripsSearchThread extends Thread
{
Handler _handler;
NearByTripsSearchThread(Handler handler )
{
_handler = handler;
}
public void run()
{
//code to get all routes
Bundle dataBundle = new Bundle();
dataBundle.putSerializable( "rts", GTStore_sqlite.getNearByTripInfo(latDouble, longDouble));
Message msg = _handler.obtainMessage();
msg.setData( dataBundle );
_handler.sendMessage( msg );
}
}
public Handler searchRoutesHandler = new Handler() { public Handler searchRoutesHandler = new Handler() {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
Bundle dataBundle = msg.getData(); Bundle dataBundle = msg.getData();
@ -325,25 +505,62 @@ public class Find extends ListActivity {
String[][] routesResult = ( String[][] )dataBundle.getSerializable( "rts" ); String[][] routesResult = ( String[][] )dataBundle.getSerializable( "rts" );
EfficientAdapter adapter = new EfficientAdapter( m_context, routesResult ); if(routesResult != null && routesResult.length > 0 )
me.setListAdapter( adapter );
ListView listview = ( ListView )me.findViewById( android.R.id.list );
listview.requestLayout();
if( routesResult != null && routesResult.length >0 )
{ {
( (TextView) me.findViewById(com.best.ui.R.id.txthead) ).setVisibility( WIDGET_VISIBLE ); String currentTime = Funcs.getCurrentTime(true);
( ( ListView )me.findViewById( android.R.id.list ) ).setVisibility( WIDGET_VISIBLE );
//((ImageButton) me.findViewById(com.best.ui.R.id.expandable)).setVisibility( WIDGET_VISIBLE );
listDisplayed = 1;
}
else
{ ( (TextView) me.findViewById(com.best.ui.R.id.txthead) ).setVisibility( WIDGET_INVISIBLE );
( ( ListView )me.findViewById( android.R.id.list ) ).setVisibility( WIDGET_INVISIBLE );
//((ImageButton) me.findViewById(com.best.ui.R.id.expandable)).setVisibility( WIDGET_INVISIBLE );
Best.showMessage( m_context, "There are no routes to show.", "Processing" );
}
sourceStop =((EditText) me.findViewById(com.best.ui.R.id.fromtxt)).getText().toString().trim();
destStop = ((EditText) me.findViewById(com.best.ui.R.id.totxt)).getText().toString().trim();
String[] searchInfo = {_sourceStopId, sourceStop, _destStopId, destStop ,currentTime};
if(prevSearchList.size() == 4)
prevSearchList.remove(3);
if(prevSearchList.size() > 0)
{
int addItem = 0;
for(int i =0 ;i < prevSearchList.size(); i++)
{
String[] temp = prevSearchList.get(i);
if(temp[0].equals(searchInfo[0]))
{
if(temp[2].equals(searchInfo[2]))
{
prevSearchList.remove(i);
break;
}
}
}
prevSearchList.add(0,searchInfo);
}
else
prevSearchList.add(0,searchInfo);
//GTStore.insertIntoPreviousSearch(_sourceStopId,_destStopId);
//( prevSearchList.toArray( new String[ prevSearchList.size() ][] ) )
( ( ListView )me.findViewById( android.R.id.list ) ).setVisibility( WIDGET_VISIBLE );
listDisplayed = 1;
for(int i = 0; i< routesResult.length; i++)
{
tripIdList.add(routesResult[i][0]);
routeNamesList.add(routesResult[i][1]);
busHeadList.add(routesResult[i][2]);
busFreqList.add(routesResult[i][5]);
totalDistList.add(routesResult[i][4]);
no_StopsList.add(routesResult[i][3]);
if(!(i >= (routesResult.length - 2)))
{
if((routesResult[i][1]).equals(routesResult[i+1][1]))
i++;
}
}
me.setContentView( com.best.ui.R.layout.routing );
contentChanged = true;
Routing.init(m_context);
}
else
Best.showMessage( m_context, "There are no routes to show.", "Processing" );
} }
}; };
@ -361,18 +578,22 @@ public class Find extends ListActivity {
//code to get all routes //code to get all routes
Bundle dataBundle = new Bundle(); Bundle dataBundle = new Bundle();
String currTime = Funcs.getCurrentTime( true ); String currTime = Funcs.getCurrentTime( true );
// dataBundle.putSerializable( "rts", GTStore.getRoutes( _sourceStopId, _destStopId, Funcs.getCurrentDay(), currTime, Funcs.addTime( currTime, "00:25:00" ) ) );
// dataBundle.putSerializable( "rts", GTStore.getRoutes( _sourceStopId, _destStopId, Funcs.getCurrentDay(), currTime, Funcs.addTime( currTime, "00:25:00" ) ) );
//dataBundle.putSerializable( "rts", GTStore.findRoutes( 40.44938, -3.6912, 40.41876, -3.69263, Funcs.getCurrentDay() ) ); //dataBundle.putSerializable( "rts", GTStore.findRoutes( 40.44938, -3.6912, 40.41876, -3.69263, Funcs.getCurrentDay() ) );
dataBundle.putSerializable( "rts", GTStore.getDirectRoutes( _sourceStopId, _destStopId ) ); try
{
String [][] _res = GTStore_sqlite.getDirectRoutes( _sourceStopId, _destStopId );
// String [][] _res = GTStore.getDirectRoutes( _sourceStopId, _destStopId );
//dataBundle.putSerializable( "rts", GTStore.getDirectRoutes( "714", "736" ) ); dataBundle.putSerializable( "rts", _res );
//dataBundle.putSerializable( "rts", GTStore.getDirectRoutes( "46", "73" ) ); Message msg = _handler.obtainMessage();
msg.setData( dataBundle );
_handler.sendMessage( msg );
Message msg = _handler.obtainMessage(); }
msg.setData( dataBundle ); catch(Exception e){Best.dissmissProcessing(); e.printStackTrace();}
_handler.sendMessage( msg );
} }
} }
@ -387,7 +608,7 @@ public class Find extends ListActivity {
} }
} }
public static Handler searchStopsHandler = new Handler() { public Handler searchStopsHandler = new Handler() {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
Bundle dataBundle = msg.getData(); Bundle dataBundle = msg.getData();
@ -446,14 +667,15 @@ public class Find extends ListActivity {
{ {
//near by stops //near by stops
try{ try{
resultSet = GTStore.getNearByStops( latDouble, longDouble );
resultSet = GTStore_sqlite.getNearByStops( latDouble, longDouble );
}catch(Exception e){System.out.println("Excp2: " + e.toString() );allOK = false;} }catch(Exception e){System.out.println("Excp2: " + e.toString() );allOK = false;}
} }
else else
{ {
//search by inputtext //search by inputtext
try{ try{
resultSet = GTStore.getAllStopsByText( _txtSearch, latDouble, longDouble ); resultSet = GTStore_sqlite.getAllStopsByText( _txtSearch, latDouble, longDouble );
}catch(Exception e){allOK = false; e.printStackTrace();} }catch(Exception e){allOK = false; e.printStackTrace();}
} }
@ -480,41 +702,45 @@ public class Find extends ListActivity {
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
try{
Bundle bundle = data.getExtras();
int editBoxNo=bundle.getInt( "EditText" );
selPosition=bundle.getInt( "position" );
if( editBoxNo == 1 || editBoxNo == 3 ) Best.log("ON ACTIVITY RESULT");
{ try{
String FrmLoc=bundle.getString( "frmLoc" ); Bundle bundle = data.getExtras();
EditText txtfrm1 = ( EditText ) findViewById(com.best.ui.R.id.fromtxt); int editBoxNo=bundle.getInt( "EditText" );
txtfrm1.setText(FrmLoc); selPosition=bundle.getInt( "position" );
flagSourceSel = selPosition; Best.log("EDIT BOX NUMBER :" + editBoxNo);
_sourceStopId = bundle.getString( "stopId" ); if( editBoxNo == 1 || editBoxNo == 3 )
{
String FrmLoc=bundle.getString( "frmLoc" );
EditText txtfrm1 = ( EditText ) findViewById(com.best.ui.R.id.fromtxt);
txtfrm1.setText(FrmLoc);
flagSourceSel = selPosition;
_sourceStopId = bundle.getString( "stopId" );
}
else if(editBoxNo==2||editBoxNo==4)
{
String ToLoc=bundle.getString("frmLoc");
EditText txtTo1 = (EditText) findViewById(com.best.ui.R.id.totxt);
txtTo1.setText(ToLoc);
flagDestSel = selPosition;
_destStopId = bundle.getString( "stopId" );
}
} }
else if(editBoxNo==2||editBoxNo==4) catch(Exception e)
{ {
String ToLoc=bundle.getString("frmLoc"); Best.log("Exception-"+e.toString());
EditText txtTo1 = (EditText) findViewById(com.best.ui.R.id.totxt);
txtTo1.setText(ToLoc);
flagDestSel = selPosition;
_destStopId = bundle.getString( "stopId" );
} }
}
catch(Exception e)
{
System.out.println("Exception-"+e.toString());
}
} }
public static void displayList(String[][] resultSet,int editBoxNo) public void displayList(String[][] resultSet,int editBoxNo)
{ {
try{ try{
String[] stopsId, stopName, distance; String[] stopsId, stopName, stopRoad, stopArea;
stopsId = new String[resultSet.length ]; stopsId = new String[resultSet.length ];
stopName = new String[resultSet.length ]; stopName = new String[resultSet.length ];
distance = new String[resultSet.length ]; stopRoad = new String[resultSet.length ];
stopArea = new String[resultSet.length ];
for(int index=0; index<resultSet.length; index++) for(int index=0; index<resultSet.length; index++)
{ {
@ -523,8 +749,9 @@ public class Find extends ListActivity {
String[] stopDesc = (String[])(resultSet[ index ]); String[] stopDesc = (String[])(resultSet[ index ]);
stopsId[ index ] = stopDesc[0]; stopsId[ index ] = stopDesc[0];
stopName[ index ] = stopDesc[1]; stopName[ index ] = stopDesc[1];
distance[ index ] = stopDesc[2]; stopRoad[ index ] = stopDesc[2];
Best.log( "ID : "+stopsId[ index ].toString()+" -- "+stopName[ index ].toString()+" --- "+distance[ index ].toString() ); stopArea[ index ] = stopDesc[3];
Best.log( "ID : "+stopsId[ index ].toString()+" -- "+stopName[ index ].toString()+" --- "+stopRoad[ index ].toString() );
} }
} }
@ -532,19 +759,120 @@ public class Find extends ListActivity {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putStringArray( "StopID", stopsId ); bundle.putStringArray( "StopID", stopsId );
bundle.putStringArray( "Stops", stopName ); bundle.putStringArray( "Stops", stopName );
bundle.putStringArray( "Distance", distance ); bundle.putStringArray( "stopRoad", stopRoad );
bundle.putStringArray( "stopArea", stopArea );
bundle.putInt( "EditText", editBoxNo ); bundle.putInt( "EditText", editBoxNo );
//edit.putExtras( bundle );
intent.putExtras( bundle ); intent.putExtras( bundle );
//parentActivity.startChildActivity("EditActivity", edit);
me.startActivityForResult( intent, 5 ); me.startActivityForResult( intent, 5 );
} }
catch(Exception e){} catch(Exception e){}
} }
private void callSwitchLang() {
Locale[] locales = Locale.getAvailableLocales();
for(int i = 0; i<locales.length; i++)
System.out.println("LOCALE: "+locales[i]);
// Locale locale = new Locale("mr");
// Locale.setDefault(locale);
// Configuration config = new Configuration();
// config.locale = locale;
// getBaseContext().getResources().updateConfiguration(config,getBaseContext().getResources().getDisplayMetrics());
//onCreate(null);
}
public class EfficientAdapter extends BaseAdapter implements Filterable { public class EfficientAdapter extends BaseAdapter implements Filterable {
public String[][] result; public String[][] result;
public int resultSetLength;
public EfficientAdapter(Context context, String[][] resultSet) public EfficientAdapter(Context context, String[][] resultSet)
{
mInflater = LayoutInflater.from( context );
result = new String[resultSet.length][];
result=resultSet;
resultSetLength = resultSet.length;
}
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null)
{
convertView = mInflater.inflate(com.best.ui.R.layout.listthreetext, null);
holder = new ViewHolder();
holder.stop_name = (TextView) convertView.findViewById(com.best.ui.R.id.stopname);
holder.dep_time = (TextView) convertView.findViewById(com.best.ui.R.id.dep);
convertView.setTag(holder);
}
else
holder = (ViewHolder) convertView.getTag();
holder.stop_name.setText(Html.fromHtml("<font color = 'DarkSlateBlue'>"+result[position][1]+"</font>"+"<font color = 'black'>" +" TO "+ "</font>"+"<font color = 'DarkSlateBlue'>"+result[position][3]+"</font>"));
//_startStopID = result[position][1];
holder.stop_name.setTextSize(15);
holder.dep_time.setTextSize(12);
String timeDiff = Funcs.subtractTime(result[position][4], Funcs.getCurrentTime(true));
System.out.println("==Current Time = "+Funcs.getCurrentTime(true)+"---Search Time= "+result[position][4]);
String[] timeDiffSplit = timeDiff.split( ":" );
if( (Integer.parseInt( timeDiffSplit[ 0 ] )) > 0)
holder.dep_time.setText("("+timeDiffSplit[ 0 ]+" hr)");
else if( (Integer.parseInt( timeDiffSplit[ 1 ] )) > 0)
holder.dep_time.setText("("+timeDiffSplit[ 1 ]+" min)");
else
holder.dep_time.setText("");
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
((EditText) me.findViewById(com.best.ui.R.id.fromtxt)).setText(result[position][1]);
_sourceStopId = result[position][0];
flagSourceSel = 1;
((EditText) me.findViewById(com.best.ui.R.id.totxt)).setText(result[position][3]);
_destStopId = result[position][2];
flagDestSel = 1;
}
});
return convertView;
}
public class ViewHolder {
TextView stop_name;
TextView dep_time;
}
@Override
public Filter getFilter() {
return null;
}
@Override
public int getCount() {
return result.length;
}
@Override
public Object getItem(int position) {
return result[position];
}
@Override
public long getItemId(int position) {
return 0;
}
}
public class EfficientAdapterForNear extends BaseAdapter implements Filterable {
public String[][] result;
public EfficientAdapterForNear(Context context, String[][] resultSet)
{ {
if(resultSet!= null) if(resultSet!= null)
{ {
@ -553,89 +881,56 @@ public class Find extends ListActivity {
result=resultSet; result=resultSet;
} }
} }
@Override
public View getView(final int position, View convertView, ViewGroup parent) { public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder; ViewHolder holder;
if(result!= null)
{
if (convertView == null) if (convertView == null)
{ {
convertView = mInflater.inflate(com.best.ui.R.layout.list_button, null); convertView = mInflater.inflate(com.best.ui.R.layout.list_route, null);
holder = new ViewHolder(); holder = new ViewHolder();
holder.routename= (TextView) convertView.findViewById(com.best.ui.R.id.routename);
holder.head = (TextView) convertView.findViewById(com.best.ui.R.id.bushead); holder.head = (TextView) convertView.findViewById(com.best.ui.R.id.bushead);
holder.total_dist = (TextView) convertView.findViewById(com.best.ui.R.id.totaldist);
holder.no_of_stops = (TextView) convertView.findViewById(com.best.ui.R.id.stopsno);
holder.blue_bus = (ImageView) convertView.findViewById(com.best.ui.R.id.busBlue); holder.blue_bus = (ImageView) convertView.findViewById(com.best.ui.R.id.busBlue);
convertView.setOnClickListener(new OnClickListener() { holder.routeName = (TextView) convertView.findViewById(com.best.ui.R.id.routename);
@Override
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putString( "tripID" , result[position][0] );
bundle.putString( "sourceID" ,_sourceStopId);
bundle.putString( "destID" ,_destStopId);
bundle.putBoolean( "showFullRoute" ,false);
Intent intent = new Intent(m_context, Routes.class);
intent.putExtras( bundle );
me.startActivityForResult(intent,6);
}
});
convertView.setTag(holder); convertView.setTag(holder);
} }
else else
holder = (ViewHolder) convertView.getTag(); holder = (ViewHolder) convertView.getTag();
String _routeName = result[position][1]; holder.head.setText( result[position][2] );
String _headerName = result[position][2]; holder.routeName.setText( result[position][3] );
String _betweenStopsNum = result[position][3]; // convertView.setBackgroundColor(Color.parseColor(colors[position % colors.length]));
int _distance = 0; convertView.setOnClickListener(new OnClickListener() {
try{ _distance = Integer.parseInt( result[position][4] ); }catch(Exception e){}
holder.routename.setText( _routeName ); @Override
holder.head.setText( _headerName ); public void onClick(View v) {
if( _distance > 1000)
{ Best.log("CLICKED POSITION :"+ position);
if( _distance == 0 ) Best.log("PASSED TRIP ID :"+result[position][1]+" PASSED Long NAME :"+result[position][2]+"PASSED ROUTE NAME :"+result[position][3]);
{
holder.total_dist.setText( "NA"); me.setContentView( com.best.ui.R.layout.routes );
} contentChanged = true;
else nearByBusClick = true;
{ _routeLongName = result[position][2];
String dist = Double.toString(Funcs.roundDouble((Double.parseDouble(_distance+"")/1000), 1)); _routeName = result[position][3];
holder.total_dist.setText( dist +" km"); _tripId = result[position][1];
} _freq = result[position][4];
} //NearTripRoute object = new NearTripRoute();
else NearTripRoute.init(m_context,result[position][1],result[position][3],result[position][2],result[position][4],true);
holder.total_dist.setText( _distance +" m");
if( _betweenStopsNum == null )
{
holder.no_of_stops.setText( "NA" );
}
else
{
if(Integer.parseInt(_betweenStopsNum) == 1)
holder.no_of_stops.setText( _betweenStopsNum + " Bus stop" );
else
holder.no_of_stops.setText( _betweenStopsNum + " Bus stops" );
} }
});
return convertView; return convertView;
}
return (null);
} }
public class ViewHolder { public class ViewHolder {
TextView routename;
TextView head; TextView head;
TextView routeName;
ImageView blue_bus; ImageView blue_bus;
TextView total_dist;
TextView no_of_stops;
} }
@Override @Override

View File

@ -30,7 +30,7 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import com.best.data.GTStore; import com.best.data.GTStore_sqlite;
import com.best.util.TransitionEffect; import com.best.util.TransitionEffect;
import java.math.RoundingMode; import java.math.RoundingMode;
@ -44,8 +44,9 @@ public class ListLocation extends ListActivity
public EfficientAdapter adapter; public EfficientAdapter adapter;
public static LayoutInflater mInflater; public static LayoutInflater mInflater;
public int EditTextNo; public int EditTextNo;
public static String[] locations; public static String[] stopNames;
public static String[] distance; public static String[] stopsRoad;
public static String[] stopsArea;
public static String[] stopID; public static String[] stopID;
/** Called when the activity is first created. */ /** Called when the activity is first created. */
@ -62,8 +63,9 @@ public class ListLocation extends ListActivity
Bundle b = getIntent().getExtras(); Bundle b = getIntent().getExtras();
stopID = b.getStringArray( "StopID" ); stopID = b.getStringArray( "StopID" );
locations = b.getStringArray( "Stops" ); stopNames = b.getStringArray( "Stops" );
distance = b.getStringArray( "Distance" ); stopsRoad = b.getStringArray( "stopRoad" );
stopsArea = b.getStringArray( "stopArea" );
EditTextNo = b.getInt( "EditText" ); EditTextNo = b.getInt( "EditText" );
if( EditTextNo == Find.M_FROM_LIST_CAPTION ) if( EditTextNo == Find.M_FROM_LIST_CAPTION )
@ -74,9 +76,9 @@ public class ListLocation extends ListActivity
setTitle(com.best.ui.R.string.nearByListTitle); setTitle(com.best.ui.R.string.nearByListTitle);
try{ try{
if(locations.length>0) if(stopNames.length>0)
{ {
adapter = new EfficientAdapter(m_context,locations); adapter = new EfficientAdapter(m_context,stopNames);
me.setListAdapter(adapter); me.setListAdapter(adapter);
} }
}catch(Exception e){} }catch(Exception e){}
@ -86,7 +88,7 @@ public class ListLocation extends ListActivity
private Context context; private Context context;
public EfficientAdapter(Context context , String[] locations) public EfficientAdapter(Context context , String[] stopNames)
{ {
mInflater = LayoutInflater.from(context); mInflater = LayoutInflater.from(context);
this.context = context; this.context = context;
@ -101,7 +103,8 @@ public class ListLocation extends ListActivity
holder = new ViewHolder(); holder = new ViewHolder();
holder.stopName = (TextView) convertView.findViewById(com.best.ui.R.id.stopname); holder.stopName = (TextView) convertView.findViewById(com.best.ui.R.id.stopname);
holder.stopDistance = (TextView) convertView.findViewById(com.best.ui.R.id.dist); holder.stopRoad = (TextView) convertView.findViewById(com.best.ui.R.id.stopRoad);
holder.stopArea = (TextView) convertView.findViewById(com.best.ui.R.id.stopArea);
holder.btnMap = (Button) convertView.findViewById(com.best.ui.R.id.map); holder.btnMap = (Button) convertView.findViewById(com.best.ui.R.id.map);
holder.btnMap.setOnClickListener(new OnClickListener() { holder.btnMap.setOnClickListener(new OnClickListener() {
@ -109,20 +112,26 @@ public class ListLocation extends ListActivity
@Override @Override
public void onClick(View v) { public void onClick(View v) {
String[][] resultset = GTStore.getLatitudeLongitude( stopID[ position ] ); String[][] resultset = null;
String latitude = resultset[0][1]; resultset = GTStore_sqlite.getLatitudeLongitude( stopID[ position ] );
String longitude = resultset[0][2]; if(resultset != null)
{
String latitude = resultset[0][1];
String longitude = resultset[0][2];
Intent intent = new Intent(m_context, Map.class); Intent intent = new Intent(m_context, Map.class);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putBoolean( "showSingle", true ); bundle.putBoolean( "showSingle", true );
bundle.putBoolean( "showMyPlace", ( EditTextNo == Find.M_FROM_NEAR_BY_LIST_CAPTION || EditTextNo == Find.M_TO_NEAR_BY_LIST_CAPTION ) ); bundle.putBoolean( "showMyPlace", ( EditTextNo == Find.M_FROM_NEAR_BY_LIST_CAPTION || EditTextNo == Find.M_TO_NEAR_BY_LIST_CAPTION ) );
bundle.putString( "lat", latitude ); bundle.putString( "lat", latitude );
bundle.putString( "long", longitude ); bundle.putString( "long", longitude );
intent.putExtras( bundle ); intent.putExtras( bundle );
me.startActivityForResult( intent, 5 ); me.startActivityForResult( intent, 5 );
}
else
System.out.println("CANNOT DISPLAY MAP");
} }
}); });
@ -130,20 +139,22 @@ public class ListLocation extends ListActivity
} }
else else
holder = (ViewHolder) convertView.getTag(); holder = (ViewHolder) convertView.getTag();
String strDistance = ""; // String strDistance = "";
Double d = new Double( distance[ position ] ); // Double d = new Double( distance[ position ] );
if(d < 500) // if(d < 500)
{ // {
strDistance = ( new BigDecimal( d.doubleValue() ).round(new MathContext( 2, RoundingMode.HALF_UP ) ).toString() )+" km"; // strDistance = ( new BigDecimal( d.doubleValue() ).round(new MathContext( 2, RoundingMode.HALF_UP ) ).toString() )+" km";
if( d < 1 ) // if( d < 1 )
{ // {
d = d * 1000; // d = d * 1000;
strDistance = ( new BigDecimal( d.doubleValue() ).intValue() )+" m"; // strDistance = ( new BigDecimal( d.doubleValue() ).intValue() )+" m";
} // }
} // }
holder.stopName.setText( locations[position] ); holder.stopName.setText( stopNames[position] );
holder.stopDistance.setText( strDistance ); holder.stopRoad.setText( stopsRoad[position] );
holder.stopArea.setText( stopsArea[position] );
//holder.stopDistance.setText( strDistance );
holder.btnMap.setText( "Map" ); holder.btnMap.setText( "Map" );
convertView.setOnClickListener( new OnClickListener() { convertView.setOnClickListener( new OnClickListener() {
@ -151,17 +162,18 @@ public class ListLocation extends ListActivity
public void onClick(View view) public void onClick(View view)
{ {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString( "frmLoc" , locations[ position ] ); bundle.putString( "frmLoc" , stopNames[ position ] );
bundle.putInt( "position" , position ); bundle.putInt( "position" , position );
bundle.putInt( "EditText" , EditTextNo ); bundle.putInt( "EditText" , EditTextNo );
bundle.putString( "stopId" , stopID[ position ] ); bundle.putString( "stopId" , stopID[ position ] );
Intent mIntent = new Intent(); Intent mIntent = new Intent();
mIntent.putExtras( bundle ); mIntent.putExtras( bundle );
int res = 0; int res = 0;
res = ( ( EditTextNo == Find.M_FROM_LIST_CAPTION || EditTextNo == Find.M_FROM_NEAR_BY_LIST_CAPTION )?( 1 ):( 2 ) ); res = ( ( EditTextNo == Find.M_FROM_LIST_CAPTION || EditTextNo == Find.M_FROM_NEAR_BY_LIST_CAPTION )?( 1 ):( 2 ) );
Best.log("RES VALUE :"+res);
setResult( res, mIntent ); setResult( res, mIntent );
finish(); finish();
} }
@ -171,7 +183,8 @@ public class ListLocation extends ListActivity
public class ViewHolder { public class ViewHolder {
TextView stopName; TextView stopName;
TextView stopDistance; TextView stopRoad;
TextView stopArea;
Button btnMap; Button btnMap;
} }
@ -182,12 +195,12 @@ public class ListLocation extends ListActivity
@Override @Override
public int getCount() { public int getCount() {
return locations.length; return stopNames.length;
} }
@Override @Override
public Object getItem(int position) { public Object getItem(int position) {
return locations[position]; return stopNames[position];
} }
@Override @Override

View File

@ -43,6 +43,7 @@ import android.graphics.Path;
import org.osmdroid.util.BoundingBoxE6; import org.osmdroid.util.BoundingBoxE6;
import android.content.Intent; import android.content.Intent;
import android.content.Context; import android.content.Context;
import android.view.KeyEvent;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
@ -53,6 +54,7 @@ public class Map extends Activity implements MapViewConstants {
private MapController mapController; private MapController mapController;
public static GeoPoint geoPoint1 = null; public static GeoPoint geoPoint1 = null;
public static GeoPoint geoPoint2 = null; public static GeoPoint geoPoint2 = null;
public static GeoPoint centerGPoint = null;
public static GeoPoint averagePoint = null; public static GeoPoint averagePoint = null;
public static boolean m_srcIsNew = true; public static boolean m_srcIsNew = true;
@ -71,6 +73,14 @@ public class Map extends Activity implements MapViewConstants {
public int minLongitude= 0; public int minLongitude= 0;
public int maxLongitude = 0; public int maxLongitude = 0;
public int minimumLat = 99999999;
public int maxxLat = 0;
public int minimumLong= 99999999;
public int maxxLong = 0;
public static int bbLatSpan = 0;
public static int bbLonSpan = 0;
@Override @Override
public void onCreate(final Bundle savedInstanceState) { public void onCreate(final Bundle savedInstanceState) {
super.onCreate( savedInstanceState ); super.onCreate( savedInstanceState );
@ -104,6 +114,21 @@ public class Map extends Activity implements MapViewConstants {
{ {
stopsGeoX = (String[])bundle.getSerializable("StopsGeoX"); stopsGeoX = (String[])bundle.getSerializable("StopsGeoX");
stopsGeoY = (String[])bundle.getSerializable("StopsGeoY"); stopsGeoY = (String[])bundle.getSerializable("StopsGeoY");
centerGPoint = new GeoPoint( Double.parseDouble(stopsGeoX[stopsGeoX.length - 1]), Double.parseDouble(stopsGeoY[stopsGeoY.length - 1]) );
//ArrayList<GeoPoint> geoPointsList = new ArrayList<GeoPoint>();
for(int i = 0;i < stopsGeoX.length; i++)
{
GeoPoint geoPoint = new GeoPoint( Double.parseDouble(stopsGeoX[i]), Double.parseDouble(stopsGeoY[i]) );
int latitude = geoPoint.getLatitudeE6();
int longitude = geoPoint.getLongitudeE6();
minimumLat = ( latitude > minimumLat ) ? minimumLat : latitude;
maxxLat = ( latitude < maxxLat ) ? maxxLat : latitude;
minimumLong = ( longitude > minimumLong ) ? minimumLong : longitude;
maxxLong = ( longitude < maxxLong ) ? maxxLong : longitude;
}
geoPoint1 = new GeoPoint( Double.parseDouble(stopsGeoX[0]), Double.parseDouble(stopsGeoY[0]) ); geoPoint1 = new GeoPoint( Double.parseDouble(stopsGeoX[0]), Double.parseDouble(stopsGeoY[0]) );
geoPoint2 = new GeoPoint( Double.parseDouble(stopsGeoX[stopsGeoX.length - 1]), Double.parseDouble(stopsGeoY[stopsGeoY.length - 1]) ); geoPoint2 = new GeoPoint( Double.parseDouble(stopsGeoX[stopsGeoX.length - 1]), Double.parseDouble(stopsGeoY[stopsGeoY.length - 1]) );
} }
@ -122,24 +147,15 @@ public class Map extends Activity implements MapViewConstants {
minLongitude = ( geoPointLon1 > geoPointLon2 ) ? geoPointLon2 : geoPointLon1; minLongitude = ( geoPointLon1 > geoPointLon2 ) ? geoPointLon2 : geoPointLon1;
maxLongitude = ( geoPointLon1 < geoPointLon2 ) ? geoPointLon2 : geoPointLon1; maxLongitude = ( geoPointLon1 < geoPointLon2 ) ? geoPointLon2 : geoPointLon1;
System.out.println("==minLatitude="+minLatitude+"==maxLatitude="+maxLatitude+"==minLongitude="+minLongitude+"==maxLongitude="+maxLongitude);
System.out.println("==minimumLat="+minimumLat+"==maxLatitude="+maxxLat+"==minLongitude="+minimumLong+"==maxLongitude="+maxxLong);
System.out.println("=== maxLatitude - minLatitude ="+ (maxLatitude - minLatitude)+"==maxLongitude - minLongitude ="+(maxLongitude - minLongitude ) );
int avgLat = ( maxLatitude + minLatitude )/2; int avgLat = ( maxLatitude + minLatitude )/2;
int avgLong = ( maxLongitude + minLongitude )/2 ; int avgLong = ( maxLongitude + minLongitude )/2 ;
averagePoint = GeoPoint.fromCenterBetween( geoPoint1, geoPoint2 );//= new GeoPoint( avgLat, avgLong ); averagePoint = GeoPoint.fromCenterBetween( geoPoint1, geoPoint2 );//= new GeoPoint( avgLat, avgLong );
// if( mapView.getBoundingBox().getDiagonalLengthInMeters() == 0 )
// {
// int latSpan = maxLatitude - minLatitude;
// int longSpan = maxLongitude - minLongitude;
// Integer maxSpan = Math.max( latSpan, longSpan );
// Double ln = Math.log( maxSpan.doubleValue() );
// zoomLevel = 20-ln.intValue();
// if ( zoomLevel < 5 )
// zoomLevel += 2;
// else if ( zoomLevel > 18 )
// zoomLevel = 18;
// }
// else
// mapController.zoomToSpan( ( maxLatitude - minLatitude ),( maxLongitude - minLongitude ) );
} }
else else
{ {
@ -168,6 +184,25 @@ public class Map extends Activity implements MapViewConstants {
super.onResume(); super.onResume();
} }
public boolean onKeyDown(int keyCode, KeyEvent event)
{//If back was pressed
if (keyCode==KeyEvent.KEYCODE_BACK)
{
back();
return true;
}
return super.onKeyDown(keyCode, event);
}
public void back()
{
finish();
}
// @Override
// public void onBackPressed() {
// finish();
// }
class MapOverlay extends org.osmdroid.views.overlay.MyLocationOverlay class MapOverlay extends org.osmdroid.views.overlay.MyLocationOverlay
{ {
@ -234,12 +269,22 @@ public class Map extends Activity implements MapViewConstants {
} }
public void setZoomAndCentre() public void setZoomAndCentre()
{ {
mapController.zoomToSpan( ( maxLatitude - minLatitude ),( maxLongitude - minLongitude )) ; mapController.zoomToSpan(( maxxLat - minimumLat ),( maxxLong - minimumLong )) ;
mapController.setCenter( averagePoint ); //mapController.zoomToSpan(( maxLatitude - minLatitude ),( maxLongitude - minLongitude )) ;
mapController.animateTo( averagePoint ); System.out.println("=== maxxLat - minimumLat ="+ (maxxLat - minimumLat)+"==maxxLong - minimumLong ="+(maxxLong - minimumLong ) );
// BoundingBoxE6 bbox = mapView.getBoundingBox(); System.out.println("===mapView.getZoomLevel()==="+mapView.getZoomLevel());
// System.out.println("==========Bounding box latitudeSpan = "+bbox.getLatitudeSpanE6() ); if(m_showSingle == false && bbLatSpan != 0 && bbLonSpan != 0)
// System.out.println("==========Bounding box diameter = "+bbox.getDiagonalLengthInMeters() ); {
//mapController.zoomToSpan(bbLatSpan , bbLonSpan) ;
mapController.setCenter( centerGPoint );
mapController.animateTo( centerGPoint );
}
else
{
mapController.setCenter( averagePoint );
mapController.animateTo( averagePoint );
}
} }
} }
} }

View File

@ -40,27 +40,32 @@ import android.view.MenuItem;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import com.best.data.GTStore; import com.best.data.GTStore_sqlite;
import com.best.util.TransitionEffect; import com.best.util.TransitionEffect;
import com.best.util.Funcs;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import android.view.KeyEvent;
import android.graphics.Color; import android.graphics.Color;
import android.text.Html; import android.text.Html;
public class Routes extends ListActivity { public class Routes extends Activity {
public static ListActivity me; public static Activity me;
public static Context m_context; public static Context m_context;
public static LayoutInflater mInflater; public static LayoutInflater mInflater;
public static String sourceId=""; public static String sourceId="";
public static String destId=""; public static String destId="";
public static String _tripID; public static String _tripID;
public static String _routeLongName;
public static String _routeName;
public static String _freq;
public static String _startStopID = ""; public static String _startStopID = "";
public static String _endStopID = ""; public static String _endStopID = "";
public static String[] stopGeoPoints; public static String[] stopGeoPoints;
public static String[][]routeResult = null; public static String[][]routeResult = null;
public static String[] colors = {"#ffffff" , "#efefef"};
ArrayList<String> listStopsGeoX = new ArrayList<String>(); ArrayList<String> listStopsGeoX = new ArrayList<String>();
ArrayList<String> listStopsGeoY = new ArrayList<String>(); ArrayList<String> listStopsGeoY = new ArrayList<String>();
@ -81,10 +86,25 @@ public class Routes extends ListActivity {
Bundle bundle = getIntent().getExtras(); Bundle bundle = getIntent().getExtras();
_tripID = bundle.getString( "tripID" ); _tripID = bundle.getString( "tripID" );
_routeLongName = bundle.getString("routeLongName");
_routeName = bundle.getString("routeName");
_freq = bundle.getString("freq");
sourceId = bundle.getString("sourceID"); sourceId = bundle.getString("sourceID");
destId = bundle.getString("destID"); destId = bundle.getString("destID");
showFullRoute = bundle.getBoolean("showFullRoute"); showFullRoute = bundle.getBoolean("showFullRoute");
(( TextView ) me.findViewById( com.best.ui.R.id._routename )).setText(_routeName);
(( TextView ) me.findViewById( com.best.ui.R.id._routelongname )).setText(_routeLongName);
int freq = Integer.parseInt(_freq);
int hr = freq / 60;
(( TextView ) me.findViewById( com.best.ui.R.id._freq )).setText(Funcs.secondsToMinHr(freq));
// if(hr > 0)
// (( TextView ) me.findViewById( com.best.ui.R.id._freq )).setText(hr +"hr "+freq % 60 + " min");
// else
// (( TextView ) me.findViewById( com.best.ui.R.id._freq )).setText(freq + " min");
//(( TextView ) me.findViewById( com.best.ui.R.id._freq )).setText(_freq + " min");
init( _tripID ); init( _tripID );
} }
@Override @Override
@ -107,6 +127,7 @@ public class Routes extends ListActivity {
return true; return true;
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection // Handle item selection
@ -126,6 +147,9 @@ public class Routes extends ListActivity {
Intent intent1 = new Intent(m_context, Routes.class); Intent intent1 = new Intent(m_context, Routes.class);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString( "tripID",_tripID ); bundle.putString( "tripID",_tripID );
bundle.putString("routeLongName",_routeLongName);
bundle.putString("routeName", _routeName);
bundle.putString("freq", _freq);
bundle.putString("sourceID", sourceId); bundle.putString("sourceID", sourceId);
bundle.putString("destID", destId); bundle.putString("destID", destId);
bundle.putBoolean("showFullRoute", true); bundle.putBoolean("showFullRoute", true);
@ -139,8 +163,31 @@ public class Routes extends ListActivity {
} }
} }
public boolean onKeyDown(int keyCode, KeyEvent event)
{//If back was pressed
if (keyCode==KeyEvent.KEYCODE_BACK)
{
back();
return true;
}
return super.onKeyDown(keyCode, event);
}
public void back()
{
finish();
}
// @Override
// public void onBackPressed() {
// finish();
// me.setContentView( com.best.ui.R.layout.routing );
// contentChanged = true;
// Routing.init(m_context);
// return;
//}
public void init(String tripID) public void init(String tripID)
{ {
Find.directRouteDisplayed = true;
if(showFullRoute == false) if(showFullRoute == false)
{ {
@ -156,7 +203,8 @@ public class Routes extends ListActivity {
listStopsGeoY.add( routeResult[index][4] ); listStopsGeoY.add( routeResult[index][4] );
} }
EfficientAdapter adapter = new EfficientAdapter( m_context,routeResult); EfficientAdapter adapter = new EfficientAdapter( m_context,routeResult);
me.setListAdapter( adapter ); //me.setListAdapter( adapter );
( ( ListView ) me.findViewById( com.best.ui.R.id.routeslist ) ).setAdapter( adapter );
} }
else else
Best.showMessage( m_context, "Sorry something went wrong.", "Processing" ); Best.showMessage( m_context, "Sorry something went wrong.", "Processing" );
@ -198,7 +246,8 @@ public class Routes extends ListActivity {
if(listspecificRoute.toArray( new String[ listspecificRoute.size() ][] ) == null) if(listspecificRoute.toArray( new String[ listspecificRoute.size() ][] ) == null)
Best.showMessage( m_context, "Sorry something went wrong.", "Processing" ); Best.showMessage( m_context, "Sorry something went wrong.", "Processing" );
EfficientAdapter adapter = new EfficientAdapter( m_context,listspecificRoute.toArray( new String[ listspecificRoute.size() ][] ) ); EfficientAdapter adapter = new EfficientAdapter( m_context,listspecificRoute.toArray( new String[ listspecificRoute.size() ][] ) );
me.setListAdapter( adapter ); ( ( ListView ) me.findViewById( com.best.ui.R.id.routeslist ) ).setAdapter( adapter );
//me.setListAdapter( adapter );
} }
} }
@ -217,7 +266,7 @@ public class Routes extends ListActivity {
{ {
//code to get all routes //code to get all routes
Bundle dataBundle = new Bundle(); Bundle dataBundle = new Bundle();
dataBundle.putSerializable( "rts", GTStore.getTripInfo(_tripID)); dataBundle.putSerializable( "rts", GTStore_sqlite.getTripInfo(_tripID));
Message msg = _handler.obtainMessage(); Message msg = _handler.obtainMessage();
msg.setData( dataBundle ); msg.setData( dataBundle );
_handler.sendMessage( msg ); _handler.sendMessage( msg );
@ -245,42 +294,57 @@ public class Routes extends ListActivity {
ViewHolder holder; ViewHolder holder;
if (convertView == null) if (convertView == null)
{ {
convertView = mInflater.inflate(com.best.ui.R.layout.listthreetext, null); convertView = mInflater.inflate(com.best.ui.R.layout.list_double_line, null);
holder = new ViewHolder(); holder = new ViewHolder();
holder.stop_name = (TextView) convertView.findViewById(com.best.ui.R.id.stopname); holder.stop_name = (TextView) convertView.findViewById(com.best.ui.R.id.stopname);
holder.dep_time = (TextView) convertView.findViewById(com.best.ui.R.id.dep); holder.dep_time = (TextView) convertView.findViewById(com.best.ui.R.id.dep);
holder.stop_area = (TextView) convertView.findViewById(com.best.ui.R.id.stoparea);
convertView.setTag(holder); convertView.setTag(holder);
} }
else else
holder = (ViewHolder) convertView.getTag(); holder = (ViewHolder) convertView.getTag();
holder.stop_area.setText(result[position][5]);
if(position==0 && showFullRoute == true) if(position==0 && showFullRoute == true)
{ {
holder.stop_name.setText(Html.fromHtml("<font color = 'black'>"+"Bus starts at: "+"</font>"+"<font color = 'DarkSlateBlue'>"+result[position][0]+"</font>")); //holder.stop_name.setText(Html.fromHtml("<font color = 'black'>"+"Bus starts at: "+"</font>"+"<font color = 'DarkSlateBlue'>"+result[position][0]+"</font>"));
holder.stop_name.setText(result[position][0]);
holder.dep_time.setText(Html.fromHtml("<font color = 'Green'>"+"Starting point"+"</font>"));
_startStopID = result[position][1]; _startStopID = result[position][1];
} }
else if(position==(resultSetLength - 1) && showFullRoute == true ) else if(position==(resultSetLength - 1) && showFullRoute == true )
{ {
holder.stop_name.setText(Html.fromHtml("<font color = 'black'>"+"Bus stops at: "+"</font>"+"<font color = 'DarkSlateBlue'>"+result[position][0]+"</font>")); //holder.stop_name.setText(Html.fromHtml("<font color = 'black'>"+"Bus stops at: "+"</font>"+"<font color = 'DarkSlateBlue'>"+result[position][0]+"</font>"));
holder.stop_name.setText(result[position][0]);
holder.dep_time.setText(Html.fromHtml("<font color = 'Blue'>"+"End Station"+"</font>"));
_endStopID = result[position][1]; _endStopID = result[position][1];
} }
else else
{
holder.stop_name.setText(result[position][0]); holder.stop_name.setText(result[position][0]);
holder.dep_time.setText("");
}
//String[] depParts = result[position][2].split('+'); //String[] depParts = result[position][2].split('+');
//holder.dep_time.setText(result[position][2]); //holder.dep_time.setText(result[position][2]);
stopGeoPoints[position] = result[position][3]; stopGeoPoints[position] = result[position][3];
if((result[position][1]).equals(sourceId) || (result[position][1]).equals(destId)) if((result[position][1]).equals(sourceId) || (result[position][1]).equals(destId))
convertView.setBackgroundColor(Color.parseColor("#d4b6d4")); //0xffcccccc convertView.setBackgroundColor(Color.parseColor("#d4b6d4")); //0xffcccccc
else if(position == 0 )
convertView.setBackgroundColor(Color.parseColor("#e6ffe6"));
else if(position == (resultSetLength - 1) )
convertView.setBackgroundColor(Color.parseColor("#e1e1ff"));
else else
convertView.setBackgroundColor(0xffffffff); convertView.setBackgroundColor(Color.parseColor(colors[position % colors.length]));
//convertView.setBackgroundColor(0xffffffff);
return convertView; return convertView;
} }
public class ViewHolder { public class ViewHolder {
TextView stop_name; TextView stop_name;
TextView dep_time; TextView dep_time;
TextView stop_area;
} }
@Override @Override