This commit is contained in:
macgregor 2012-10-29 14:30:08 +05:30
parent bbcf7e021d
commit bf58edd52a
45 changed files with 3935 additions and 10 deletions

View File

@ -0,0 +1,85 @@
CREATE TABLE stops_on_trip (
_tripID varchar(30) not null,
_stopID varchar(7) not null,
_stopSeq integer NOT NULL,
_stopDept DATETIME NOT NULL,
_stopDeptOnNextDay boolean not NULL,
_stopArri DATETIME NOT NULL,
_stopArriOnNextDay boolean not NULL,
PRIMARY KEY(_tripID, _stopID, _stopSeq)
);
CREATE TABLE trips (
_tripID varchar(30) NOT NULL,
_routeID varchar(4) not null,
_serviceID varchar(15) NOT NULL,
_tripHeadSign varchar(17) not null,
PRIMARY KEY(_tripID)
);
CREATE TABLE trips_freq (
_tripID varchar(30) NOT NULL,
_start DATETIME NOT NULL,
_end DATETIME NOT NULL,
_end_next_day boolean not null,
_headways integer not null,
_freq integer default null
);
CREATE TABLE routes (
_routeID varchar(4) not null,
_agencyID varchar(3) not null,
_routeName varchar(5) NOT NULL,
_routeLongName varchar(80) NOT NULL,
_routeType varchar(6) not NULL,
PRIMARY KEY(_routeID)
);
CREATE TABLE schedule_rules (
_serviceID varchar(15) NOT NULL,
_serviceDay varchar(3) not null,
_startPeriodDate DATE not null,
_endPeriodDate DATE not null,
PRIMARY KEY(_serviceID, _serviceDay)
);
CREATE TABLE stop_names (
_stopID varchar(7) PRIMARY KEY not null,
_stopName varchar(50) not null,
_stopNameMarathi varchar(80) ,
_stopRoad varchar(50) ,
_stopArea varchar(50)
);
CREATE TABLE stop_geo (
_stopID varchar(7) PRIMARY KEY not null,
_stopLat number NOT NULL,
_stopLon number NOT NULL
);
CREATE TABLE bus_max_freq(
_tripID varchar( 45 ) PRIMARY KEY,
_freq int( 5 )
);
CREATE INDEX ix_stop_names_stopName ON stop_names ( _stopName );
CREATE INDEX ix_stops_on_trip_tripID ON stops_on_trip (_tripID);
CREATE INDEX ix_stops_on_trip_stopID ON stops_on_trip (_stopID);
CREATE INDEX ix_stops_on_trip_stopSeq ON stops_on_trip (_stopSeq);
CREATE INDEX ix_stops_on_trip_stopDept ON stops_on_trip (_stopDept);
CREATE INDEX ix_stops_on_trip_stopArri ON stops_on_trip (_stopArri);
CREATE INDEX ix_stops_on_trip_stopDeptOnNextDay ON stops_on_trip (_stopDeptOnNextDay);
CREATE INDEX ix_stops_on_trip_stopArriOnNextDay ON stops_on_trip (_stopArriOnNextDay);
CREATE INDEX ix_stops_on_trip_stopDeptEx ON stops_on_trip (_stopDept,_stopDeptOnNextDay);
CREATE INDEX ix_stops_on_trip_stopArriEx ON stops_on_trip (_stopArri,_stopArriOnNextDay);
CREATE INDEX ix_trips_routeID ON trips (_routeID);
CREATE INDEX ix_trips_serviceID ON trips (_serviceID);
CREATE INDEX ix_trips_tripHeadSign ON trips (_tripHeadSign);
CREATE INDEX ix_trips_freq_tripID ON trips_freq (_tripID);
CREATE INDEX ix_routes_agencyID ON routes (_agencyID);
CREATE INDEX ix_routes_routeName ON routes (_routeName);
CREATE INDEX ix_routes_routeType ON routes (_routeType);
CREATE INDEX ix_schedule_rules_serviceID ON schedule_rules (_serviceID);
CREATE INDEX ix_schedule_rules_serviceDay ON schedule_rules (_serviceDay);
CREATE INDEX ix_schedule_rules_startPeriodDate ON schedule_rules (_startPeriodDate);
CREATE INDEX ix_schedule_rules_endPeriodDate ON schedule_rules (_endPeriodDate);

94
android/mobile/gen/R.java.d Executable file
View File

@ -0,0 +1,94 @@
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\gen\com\best\ui\R.java \
: D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\anim\accelerate_interpolator.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\anim\decelerate_interpolator.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\anim\dialog_enter.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\anim\dialog_exit.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\anim\fade_in_center.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\anim\fade_out_center.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\area.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\area_red.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\bestheadbar.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\bestlogo.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\blue_button.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\bus.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\bus_blue_small.PNG \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\bus_red.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\bus_small1.gif \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\edittext.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\focused_application_background_static.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\freq.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\handle.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\icon.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\ic_minus_trans.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\ic_plus_trans.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\ic_tab_new.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\ic_tab_newsel.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\ic_tab_sel.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\ic_tab_unsel.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\image_btn_pressd.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\listbackgrnd.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\magglass.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\magglass_tot_trans.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\myroute_view.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\road.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\road_red.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\search_btn.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\stop.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\stop_red.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\tab_area.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\tab_background.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\tab_bus.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\tab_road.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\tab_stops.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\drawable\user.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\find.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\in_progress.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\listbackgrnd.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\listlocation.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\listthreetext.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\listtwotextnbtn.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\list_button.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\list_double_line.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\list_item.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\list_route.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\maintab.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\mapstops.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\myroute_view.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\popup.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\routes.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\routing.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\search.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\simple_list_item_1.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\splash.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\layout\stops.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\menu\mapfullroute.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\menu\menustart.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\menu\onlymap.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\menu\search.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\raw\chalobest.zip \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\values\strings.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\res\values\style.xml \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\area.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\area_red.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\bestheadbar.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\bestlogo.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\bus.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\bus_blue_small.PNG \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\bus_red.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\focused_application_background_static.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\freq.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\handle.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\icon.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\ic_minus_trans.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\ic_plus_trans.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\ic_tab_newsel.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\ic_tab_sel.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\ic_tab_unsel.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\magglass.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\magglass_tot_trans.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\road.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\road_red.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\stop.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\stop_red.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\res\drawable\user.png \
D:\dev\new_dev\BEST_Transportation\BESTMobile\android\mobile\bin\AndroidManifest.xml \

View File

@ -0,0 +1,6 @@
/** Automatically generated file. DO NOT MODIFY */
package com.best.ui;
public final class BuildConfig {
public final static boolean DEBUG = true;
}

View File

@ -0,0 +1,307 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.best.ui;
public final class R {
public static final class anim {
public static final int accelerate_interpolator=0x7f040000;
public static final int decelerate_interpolator=0x7f040001;
public static final int dialog_enter=0x7f040002;
public static final int dialog_exit=0x7f040003;
public static final int fade_in_center=0x7f040004;
public static final int fade_out_center=0x7f040005;
}
public static final class attr {
/** <p>Must be an integer value, such as "<code>100</code>".
<p>This may also be a reference to a resource (in the form
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
theme attribute (in the form
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
containing a value of this type.
*/
public static final int animationDuration=0x7f010003;
/** <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
<p>This may also be a reference to a resource (in the form
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
theme attribute (in the form
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
containing a value of this type.
*/
public static final int collapsedHeight=0x7f010002;
/** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
*/
public static final int content=0x7f010001;
/** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
*/
public static final int handle=0x7f010000;
}
public static final class drawable {
public static final int area=0x7f020000;
public static final int area_red=0x7f020001;
public static final int bestheadbar=0x7f020002;
public static final int bestlogo=0x7f020003;
public static final int blue_button=0x7f020004;
public static final int bus=0x7f020005;
public static final int bus_blue_small=0x7f020006;
public static final int bus_red=0x7f020007;
public static final int bus_small1=0x7f020008;
public static final int edittext=0x7f020009;
public static final int focused_application_background_static=0x7f02000a;
public static final int freq=0x7f02000b;
public static final int handle=0x7f02000c;
public static final int ic_minus_trans=0x7f02000d;
public static final int ic_plus_trans=0x7f02000e;
public static final int ic_tab_new=0x7f02000f;
public static final int ic_tab_newsel=0x7f020010;
public static final int ic_tab_sel=0x7f020011;
public static final int ic_tab_unsel=0x7f020012;
public static final int icon=0x7f020013;
public static final int image_btn_pressd=0x7f020014;
public static final int listbackgrnd=0x7f020015;
public static final int magglass=0x7f020016;
public static final int magglass_tot_trans=0x7f020017;
public static final int myroute_view=0x7f020018;
public static final int road=0x7f020019;
public static final int road_red=0x7f02001a;
public static final int search_btn=0x7f02001b;
public static final int stop=0x7f02001c;
public static final int stop_red=0x7f02001d;
public static final int tab_area=0x7f02001e;
public static final int tab_background=0x7f02001f;
public static final int tab_bus=0x7f020020;
public static final int tab_road=0x7f020021;
public static final int tab_stops=0x7f020022;
public static final int user=0x7f020023;
}
public static final class id {
public static final int ScrollView01=0x7f09000e;
public static final int SearchScreen=0x7f09003f;
public static final int SplashImageView=0x7f090043;
public static final int TheSplashLayout=0x7f090042;
public static final int _freq=0x7f09003b;
public static final int _routelongname=0x7f090039;
public static final int _routename=0x7f090038;
public static final int as_dest=0x7f090034;
public static final int as_source=0x7f090019;
public static final int busBlue=0x7f09001b;
public static final int bus_freq=0x7f090021;
public static final int bushead=0x7f09001d;
public static final int dep=0x7f090025;
public static final int expandable=0x7f09000d;
public static final int explinearlayout=0x7f090001;
public static final int findbus=0x7f09000a;
public static final int findfrom=0x7f090004;
public static final int findto=0x7f090007;
public static final int fromtxt=0x7f090003;
public static final int fullRoute=0x7f090047;
public static final int innerlinearlayout=0x7f090020;
public static final int innerlinearlayout1=0x7f09002c;
public static final int innerlinearlayoutlist1=0x7f09001a;
public static final int innerlinearlayoutlist2=0x7f09001e;
public static final int linearlayout=0x7f090046;
public static final int linearlayout1=0x7f090002;
public static final int linearlayout2=0x7f090005;
public static final int linearlayout3=0x7f090009;
public static final int linearlayout4=0x7f09000c;
public static final int linearlayout5=0x7f090010;
public static final int linearlayout6=0x7f090012;
public static final int linearlayout7=0x7f090013;
public static final int linearlayout8=0x7f090015;
public static final int linearlayoutlist=0x7f090017;
public static final int linearlayoutlist1=0x7f090023;
public static final int linearlayoutlist2=0x7f090026;
public static final int linearlayoutparent=0x7f090008;
public static final int list=0x7f090016;
public static final int list_text=0x7f090029;
public static final int listheader=0x7f090036;
public static final int listheader1=0x7f090037;
public static final int listheader2=0x7f09003a;
public static final int listlinearlayout1=0x7f090018;
public static final int listlinearlayout2=0x7f090032;
public static final int listlinearlayout3=0x7f090033;
public static final int locationdropdown=0x7f09002b;
public static final int mainlinearlayout=0x7f09000f;
public static final int map=0x7f09002f;
public static final int mapview=0x7f090030;
public static final int mnuexitmain=0x7f090048;
public static final int mnusearch=0x7f090049;
public static final int msgtxt=0x7f090044;
public static final int newentrylayout=0x7f09002a;
public static final int rellayoutmain=0x7f090000;
public static final int routename=0x7f09001c;
public static final int routeslayout=0x7f090035;
public static final int routeslist=0x7f09003c;
public static final int routinglist=0x7f09003e;
public static final int search=0x7f090041;
public static final int search_for=0x7f09003d;
public static final int searchtxt=0x7f090040;
public static final int stopArea=0x7f09002e;
public static final int stopRoad=0x7f09002d;
public static final int stoparea=0x7f090028;
public static final int stopname=0x7f090024;
public static final int stoproad=0x7f090027;
public static final int stopslist=0x7f090045;
public static final int stopsno=0x7f090022;
public static final int totaldist=0x7f09001f;
public static final int totxt=0x7f090006;
public static final int txtmyroute=0x7f090031;
public static final int txtnearby=0x7f090014;
public static final int txtpr=0x7f09000b;
public static final int txtprevious=0x7f090011;
}
public static final class layout {
public static final int find=0x7f030000;
public static final int in_progress=0x7f030001;
public static final int list_button=0x7f030002;
public static final int list_double_line=0x7f030003;
public static final int list_item=0x7f030004;
public static final int list_route=0x7f030005;
public static final int listbackgrnd=0x7f030006;
public static final int listlocation=0x7f030007;
public static final int listthreetext=0x7f030008;
public static final int listtwotextnbtn=0x7f030009;
public static final int maintab=0x7f03000a;
public static final int mapstops=0x7f03000b;
public static final int myroute_view=0x7f03000c;
public static final int popup=0x7f03000d;
public static final int routes=0x7f03000e;
public static final int routing=0x7f03000f;
public static final int search=0x7f030010;
public static final int simple_list_item_1=0x7f030011;
public static final int splash=0x7f030012;
public static final int stops=0x7f030013;
}
public static final class menu {
public static final int mapfullroute=0x7f080000;
public static final int menustart=0x7f080001;
public static final int onlymap=0x7f080002;
public static final int search=0x7f080003;
}
public static final class raw {
public static final int chalobest=0x7f050000;
}
public static final class string {
public static final int M_FIND_TAB_ID=0x7f060001;
public static final int M_ROUT_TAB_ID=0x7f060002;
public static final int StopNameHeading=0x7f06001e;
public static final int app_name=0x7f060000;
public static final int busListHead=0x7f06000b;
public static final int buses=0x7f060017;
public static final int destinationHint=0x7f060007;
public static final int errMsgEnterDestLoc=0x7f06000f;
public static final int errMsgEnterSrcLoc=0x7f06000e;
public static final int errMsgEnterValidDest=0x7f060010;
public static final int errMsgEnterValidSrc=0x7f060011;
public static final int errMsgMoreChar=0x7f06000d;
public static final int errMsgNoBusMatch=0x7f060013;
public static final int errMsgNoNearbyStop=0x7f060014;
public static final int errMsgNoStopsMatch=0x7f060012;
public static final int errNoMap=0x7f060016;
public static final int findBtnText=0x7f060008;
public static final int findBusText=0x7f06000a;
public static final int fromListTitle=0x7f060003;
public static final int inittext=0x7f06000c;
public static final int myroute=0x7f06001a;
public static final int nearByListTitle=0x7f060005;
public static final int nearbyBtnText=0x7f060009;
public static final int nearbytext=0x7f06001c;
public static final int noLocation=0x7f060015;
public static final int previoussearch=0x7f06001b;
public static final int search=0x7f060019;
public static final int sourceHint=0x7f060006;
public static final int stops=0x7f060018;
public static final int toListTitle=0x7f060004;
public static final int txtMap=0x7f060021;
public static final int txtSearchFor=0x7f06001d;
public static final int txtSelectDest=0x7f060023;
public static final int txtSelectSource=0x7f060022;
public static final int txtSmthingWentWrong=0x7f060024;
public static final int txtWorkInProgress=0x7f060020;
public static final int txtsearch=0x7f06001f;
}
public static final class style {
public static final int Animations=0x7f070001;
public static final int Animations_SplashScreen=0x7f070002;
public static final int Theme_Transparent=0x7f070000;
}
public static final class styleable {
/** Attributes that can be used with a ExpandablePanel.
<p>Includes the following attributes:</p>
<table>
<colgroup align="left" />
<colgroup align="left" />
<tr><th>Attribute</th><th>Description</th></tr>
<tr><td><code>{@link #ExpandablePanel_animationDuration com.best.ui:animationDuration}</code></td><td></td></tr>
<tr><td><code>{@link #ExpandablePanel_collapsedHeight com.best.ui:collapsedHeight}</code></td><td></td></tr>
<tr><td><code>{@link #ExpandablePanel_content com.best.ui:content}</code></td><td></td></tr>
<tr><td><code>{@link #ExpandablePanel_handle com.best.ui:handle}</code></td><td></td></tr>
</table>
@see #ExpandablePanel_animationDuration
@see #ExpandablePanel_collapsedHeight
@see #ExpandablePanel_content
@see #ExpandablePanel_handle
*/
public static final int[] ExpandablePanel = {
0x7f010000, 0x7f010001, 0x7f010002, 0x7f010003
};
/**
<p>This symbol is the offset where the {@link com.best.ui.R.attr#animationDuration}
attribute's value can be found in the {@link #ExpandablePanel} array.
<p>Must be an integer value, such as "<code>100</code>".
<p>This may also be a reference to a resource (in the form
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
theme attribute (in the form
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
containing a value of this type.
@attr name android:animationDuration
*/
public static final int ExpandablePanel_animationDuration = 3;
/**
<p>This symbol is the offset where the {@link com.best.ui.R.attr#collapsedHeight}
attribute's value can be found in the {@link #ExpandablePanel} array.
<p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
<p>This may also be a reference to a resource (in the form
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
theme attribute (in the form
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
containing a value of this type.
@attr name android:collapsedHeight
*/
public static final int ExpandablePanel_collapsedHeight = 2;
/**
<p>This symbol is the offset where the {@link com.best.ui.R.attr#content}
attribute's value can be found in the {@link #ExpandablePanel} array.
<p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
@attr name android:content
*/
public static final int ExpandablePanel_content = 1;
/**
<p>This symbol is the offset where the {@link com.best.ui.R.attr#handle}
attribute's value can be found in the {@link #ExpandablePanel} array.
<p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
@attr name android:handle
*/
public static final int ExpandablePanel_handle = 0;
};
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use grey -->
<item android:drawable="@drawable/ic_tab_sel"
android:state_selected="true" />
<!-- When not selected, use white-->
<item android:drawable="@drawable/ic_tab_unsel" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,19 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@id/linearlayout1">
<TextView
android:id="@+id/txtmyroute"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity = "center"
android:text="My Route"
android:textStyle="bold"
android:textSize="18sp"
android:textColor="#fb0300"/>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 694 B

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use red -->
<item android:drawable="@drawable/area_red"
android:state_selected="true" />
<!-- When not selected, use gray-->
<item android:drawable="@drawable/area"/>
</selector>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" >
<style>
<item android:textColor = "#fb0300" />
</style>
</item>
</selector>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use red -->
<item android:drawable="@drawable/bus_red"
android:state_selected="true" />
<!-- When not selected, use gray-->
<item android:drawable="@drawable/bus" />
</selector>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use red -->
<item android:drawable="@drawable/road_red"
android:state_selected="true" />
<!-- When not selected, use gray-->
<item android:drawable="@drawable/road" />
</selector>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use red -->
<item android:drawable="@drawable/stop_red"
android:state_selected="true" />
<!-- When not selected, use gray-->
<item android:drawable="@drawable/stop" />
</selector>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/linearlayoutlist"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/listlinearlayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="@drawable/listbackgrnd"
android:orientation="horizontal">
<TextView
android:id="@+id/as_source"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:textSize="20sp"
android:gravity="center_vertical"
android:paddingLeft="0dp"
android:text = "@string/txtWorkInProgress"
android:textColor="#5a5858"/>
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/linearlayoutlist"
android:label="Somelabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="0dp"
android:background="@drawable/listbackgrnd"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/linearlayoutlist1"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:padding="10dp"
android:layout_height="wrap_content">
<TextView
android:id="@+id/stopname"
android:layout_width="0dp"
android:layout_weight="0.75"
android:layout_height="wrap_content"
android:textSize="16sp"
android:gravity = "left"
android:textColor="#4a81af">
</TextView>
<TextView
android:id="@+id/dep"
android:layout_width="0dp"
android:layout_weight="0.25"
android:text = ""
android:gravity = "right"
android:layout_height="wrap_content"
android:textColor="#5a5858">
</TextView>
</LinearLayout>
<LinearLayout
android:id="@+id/linearlayoutlist2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/linearlayoutlist1">
<TextView
android:id="@+id/stoproad"
android:layout_width="0dp"
android:layout_weight="0.7"
android:paddingLeft="10dp"
android:gravity = "left"
android:layout_height="wrap_content"
android:textColor="#5a5858">
</TextView>
<TextView
android:id="@+id/stoparea"
android:layout_width="0dp"
android:layout_weight="0.3"
android:paddingRight="10dp"
android:gravity = "right"
android:layout_height="wrap_content"
android:textColor="#5a5858">
</TextView>
</LinearLayout>
</LinearLayout>
<!-- android:padding="10dp"-->

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/linearlayoutlist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/listbackgrnd"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/innerlinearlayoutlist1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
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="15sp"
android:paddingLeft="0dp"
android:textColor="#5a5858"/>
<TextView
android:id="@+id/bushead"
android:layout_width="0dp"
android:layout_weight="0.75"
android:layout_height="wrap_content"
android:gravity="left"
android:textSize="15sp"
android:paddingLeft="10dp"
android:textColor="#4a81af"/>
</LinearLayout>
</LinearLayout>
<!-- android:background="@drawable/listbackgrnd"-->

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:background="#ffffff"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:background="#535252"
android:tabStripEnabled="true"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="5dp" />
</LinearLayout>
</TabHost>
<!--android:id="@android:id/tabhost"
android:background="#efefef"
android:id="@android:id/tabs"-->

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/txtmyroute"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:gravity = "center"
android:singleLine = "true"
android:text="@+string/myroute"
android:textStyle="bold"
android:textSize="20sp"
android:background = "#999999"
android:textColor="#fb0300"/>

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/linearlayoutlist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/listlinearlayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/listbackgrnd"
android:orientation="horizontal">
<TextView
android:id="@+id/as_source"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:textSize="18sp"
android:gravity="center_vertical"
android:paddingLeft="0dp"
android:text = "@string/txtSelectSource"
android:textColor="#5a5858"/>
</LinearLayout>
<LinearLayout
android:id="@+id/listlinearlayout2"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#d2d2d2"
android:orientation="horizontal"
android:layout_below="@+id/listlinearlayout1">
</LinearLayout>
<LinearLayout
android:id="@+id/listlinearlayout3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/listbackgrnd"
android:paddingTop="10dp"
android:layout_below="@+id/listlinearlayout2">
<TextView
android:id="@+id/as_dest"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:textSize="18sp"
android:gravity="center_vertical"
android:paddingLeft="0dp"
android:text = "@string/txtSelectDest"
android:textColor="#5a5858"/>
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/routeslayout"
android:layout_width="fill_parent"
android:background="#ffffff"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/linearlayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp">
<TextView
android:id="@+id/search_for"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:textSize="18sp"
android:text="@+string/busListHead"
android:background="#d2d2d2"
android:textColor="#070707"/>
</LinearLayout>
<LinearLayout
android:id="@+id/linearlayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingTop = "5dp"
android:layout_below="@id/linearlayout1">
<ListView
android:id="@+id/routinglist"
android:label="Buses"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollY="0dp"
android:background="#ffffff"
android:dividerHeight="0dp"
android:scrollbarSize="0dp"
android:fastScrollEnabled="false"
android:scrollbars="none"
/>
</LinearLayout>
</RelativeLayout>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:layout_height="100dp"
android:orientation="vertical"
android:gravity="center"
android:id="@+id/SearchScreen"
>
<EditText
android:id="@+id/searchtxt"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:paddingLeft="10dp"
android:background="@drawable/edittext"
android:singleLine="true"/>
<Button
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:textSize="14sp"
android:layout_marginTop="10dp"
android:background="@drawable/blue_button"
android:text="@+string/txtsearch"
android:layout_below="@id/searchtxt"/>
</LinearLayout>

View File

@ -0,0 +1,28 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/routeslayout"
android:layout_width="fill_parent"
android:background="#ffffff"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/linearlayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_below="@id/linearlayout1">
<ListView
android:id="@+id/stopslist"
android:label="Buses"
android:background="#efefef"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollY="0dp"
android:dividerHeight="0dp"
android:scrollbarSize="0dp"
android:fastScrollEnabled="false"
android:scrollbars="none"
/>
</LinearLayout>
</RelativeLayout>

View File

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

Binary file not shown.

View File

@ -0,0 +1,30 @@
package com.best.data;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class BEST_DB extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "chalobest_5"; // get stored in /data/data/com.efb.ui/databases/efb.db
private static final int DATABASE_VERSION = 2;
// Database creation sql statement
public BEST_DB(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase database) {
System.out.println("BEST_DB: onCreate Called");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
System.out.println("BEST_DB: onUpgrade Called");
onCreate(db);
}
}

View File

@ -0,0 +1,64 @@
package com.best.data;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
public class DBHandle_sqlite {
// Database fields
private static SQLiteDatabase database;
private static BEST_DB dbHelper;
public DBHandle_sqlite(Context context) {
dbHelper = new BEST_DB(context);
}
// public void open() throws SQLException {
// database = dbHelper.getWritableDatabase();
// }
private static void openForRead() throws SQLException {
close();
database = dbHelper.getReadableDatabase();
}
public static void close() {
if( database != null && database.isOpen() )
database.close();
}
public String[][] execSelectQuery(String query, int columns) {
Cursor cursor = null;
List<String[]> result = new ArrayList<String[]>();
try{
openForRead();
//database.open();
System.out.println("DBHANDLE QUERY: " +query);
cursor = database.rawQuery( query, null );
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
String[] _row = new String[columns];
for(int i = 0; i < columns; i++)
{
_row[i] = cursor.getString(i);
}
result.add(_row);
cursor.moveToNext();
}
}catch( Exception e ){ System.out.println("DBHANDLE EXCEP: " );e.printStackTrace();}
finally{ if( cursor != null )cursor.close(); close(); }
return (result.toArray( new String[ result.size() ][])) ;
}
}

View File

@ -0,0 +1,914 @@
////////////////////////////////////////////////
//
// A ChaloBEST (http://chalobest.in/) initiative
// Author: Vivek (Macgregor Techknowlogy)
// License: GPLv3
//
//
package com.best.data;
import java.util.Vector;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Vector;
import java.util.Date;
import java.util.Calendar;
import java.util.Hashtable;
import org.osmdroid.util.GeoPoint;
import java.util.ArrayList;
import android.content.Context;
import com.best.ui.Best;
import com.best.util.Funcs;
import com.best.data.DBHandle_sqlite;
public class GTStore_sqlite{
public static DBHandle_sqlite dbhandle = null;
public static int M_MAX_STOP_SEARCH_ROW_BY_TEXT = 30;
public static int M_MAX_RANGE = 500;
public static int M_STOP_NEAR_POINT_DISTANCE_INDEX = 0;
public static int M_STOP_NEAR_POINT_LAT_INDEX = 1;
public static int M_STOP_NEAR_POINT_LON_INDEX = 2;
public static int M_STOP_INFO_ID_INDEX = 0;
public static int M_STOP_INFO_LAT_INDEX = 1;
public static int M_STOP_INFO_LON_INDEX = 2;
public static int M_STOP_INFO_SEQ_INDEX = 3;
public static int M_STOP_INFO_ARR_TIME_INDEX = 4;
public static int M_STOP_INFO_ARR_DISTANCE_INDEX = 5;
public static double M_WALING_DISTANCE_KM = 0.3;
public static double GEO_DELTA = 0.003;
public static void init(Context context)
{
dbhandle = new DBHandle_sqlite(context);
}
//has _stopLoc
public static String[][] getAllStopsByText(String matchString, Double lat, Double lon)
{
try{
//String query = "select g._stopID, _stopName, Distance( _stopLoc ,ST_GeomFromText('POINT("+ lat +" "+ lon +" )'))*111 distance from stop_names n, stop_geo g where n._stopID = g._stopID and ( _stopName like '"+matchString+"%' or _stopName like '% "+matchString+"%' ) limit "+M_MAX_STOP_SEARCH_ROW_BY_TEXT+";";
//String query = "select g._stopID, _stopName, Distance( _stopLoc ,ST_GeomFromText('POINT("+ lat +" "+ lon +" )'))*111 distance from stop_names n, stop_geo g where n._stopID = g._stopID and ( _stopName like '"+matchString+"%' or _stopName like '% "+matchString+"%' ) UNION select g._stopID, _stopName, Distance( _stopLoc ,ST_GeomFromText('POINT("+ lat +" "+ lon +" )'))*111 distance from stop_names n, stop_geo g where n._stopID = g._stopID and ( _stopRoad like '"+matchString+"%' or _stopRoad like '% "+matchString+"%' ) UNION select g._stopID, _stopName, Distance( _stopLoc ,ST_GeomFromText('POINT("+ lat +" "+ lon +" )'))*111 distance from stop_names n, stop_geo g where n._stopID = g._stopID and ( _stopArea like '"+matchString+"%' or _stopArea like '% "+matchString+"%' ) order by distance limit "+M_MAX_STOP_SEARCH_ROW_BY_TEXT+";";
String query = "select g._stopID, _stopName,_stopRoad, _stopArea from stop_names n, stop_geo g where n._stopID = g._stopID and ( _stopName like '"+matchString+"%' or _stopName like '% "+matchString+"%' ) UNION select g._stopID, _stopName, _stopRoad, _stopArea from stop_names n, stop_geo g where n._stopID = g._stopID and ( _stopRoad like '"+matchString+"%' or _stopRoad like '% "+matchString+"%' ) UNION select g._stopID, _stopName, _stopRoad, _stopArea from stop_names n, stop_geo g where n._stopID = g._stopID and ( _stopArea like '"+matchString+"%' or _stopArea like '% "+matchString+"%' ) limit 100;";
String query1 = "select g._stopID, _stopName,_stopRoad, _stopArea from stop_names n, stop_geo g where n._stopID = g._stopID and ( _stopName like '"+matchString+"%' or _stopName like '% "+matchString+"%' ) limit 30;";
String query2 = "select g._stopID, _stopName, _stopRoad, _stopArea from stop_names n, stop_geo g where n._stopID = g._stopID and ( _stopRoad like '"+matchString+"%' or _stopRoad like '% "+matchString+"%' ) limit 30;";
String query3 = "select g._stopID, _stopName, _stopRoad, _stopArea from stop_names n, stop_geo g where n._stopID = g._stopID and ( _stopArea like '"+matchString+"%' or _stopArea like '% "+matchString+"%' ) limit 30;";
Hashtable singleUniqueStop = new Hashtable();
ArrayList<String[]> listOfStops = new ArrayList<String[]>();
String[][] resultSet1 = dbhandle.execSelectQuery( query1, 4 );
if(resultSet1 != null && resultSet1.length > 0)
{
for(int i = 0 ;i < resultSet1.length; i++)
{
singleUniqueStop.put(resultSet1[i][0],resultSet1[i][0]);
listOfStops.add(resultSet1[i]);
}
}
String[][] resultSet2 = dbhandle.execSelectQuery( query2, 4 );
if(resultSet2 != null && resultSet2.length > 0)
{
for(int i = 0 ;i < resultSet2.length; i++)
{
if(!singleUniqueStop.containsKey(resultSet2[i][0]))
{
singleUniqueStop.put(resultSet2[i][0],resultSet2[i][0]);
listOfStops.add(resultSet2[i]);
}
}
}
String[][] resultSet3 = dbhandle.execSelectQuery( query3, 4 );
if(resultSet3 != null && resultSet3.length > 0)
{
for(int i = 0 ;i < resultSet3.length; i++)
{
if(!singleUniqueStop.containsKey(resultSet3[i][0]))
{
singleUniqueStop.put(resultSet3[i][0],resultSet3[i][0]);
listOfStops.add(resultSet3[i]);
}
}
}
return( listOfStops.toArray( new String[ listOfStops.size() ][] ) );
}catch(Exception e){ System.out.println("===EXEC ERR=="+e.getMessage() ); }
System.out.println("RETURNING NULL");
return( null );
}
//has _stopLoc
public static String[][] getNearByStops(Double lat, Double lon)
{
//String nearByStopQuery = "select distinct g._stopID,_stopName, Distance( ST_GeomFromText('POINT(_stopLat _stopLon)'), ST_GeomFromText('POINT(" + lat + " " + lon + ")') )*111 distance from stop_geo g, stop_names n where g._stopID = n._stopID and Distance( ST_GeomFromText('POINT(_stopLat _stopLon)'), ST_GeomFromText('POINT(" + lat + " " + lon + ")') )*111 <= 0.5 order by distance asc limit 30 ;";
Double maxLatitude = lat + 0.005000 ;
Double minLatitude = lat - 0.005000 ;
Double maxLongitude = lon + 0.005000 ;
Double minLongitude = lon - 0.005000 ;
String nearByStopQuery = "select g._stopID,_stopName, _stopLat, _stopLon from stop_geo g, stop_names n where g._stopID = n._stopID and _stopLat between '"+minLatitude+"' and '"+maxLatitude+"' and _stopLon between '"+minLongitude+"' and '"+maxLongitude+"' limit 30 ;";
//"select g._stopID,_stopName, Distance( _stopLoc, ST_GeomFromText('POINT(" + lat + " " + lon + ")') )*111 distance from stop_geo g, stop_names n where g._stopID = n._stopID and PtDistWithin( _stopLoc, ST_GeomFromText('POINT(" + lat + " " + lon + ")', 4326),"+M_MAX_RANGE+") order by distance asc limit 30;";
Best.log("nearByStopQuery=="+nearByStopQuery);
String[][] resultSet = dbhandle.execSelectQuery(nearByStopQuery,3);
return(resultSet);
}
public static String[][] getLatitudeLongitude(String stopID)
{
String query = "select _stopID,_stopLat,_stopLon from stop_geo where stop_geo._stopID = '"+stopID+"';";
System.out.println("QUERY :"+query);
String[][] resultSet = dbhandle.execSelectQuery( query , 3 );
if(resultSet != null && resultSet.length > 0)
System.out.println("RESULT SET LENGTH ="+resultSet.length);
return(resultSet);
}
public static void insertIntoPreviousSearch(String sourceID, String destID)
{
String currentDateTime = Funcs.getCurrentDateTime();
String delete_query = "delete from previous_search where _sourceStopID = '"+sourceID+"' and _destStopID = '"+destID+"';";
Best.log(delete_query);
//DBHandle.execInsDelQuery( delete_query );
String insert_query = "insert into previous_search (_sourceStopID,_destStopID,_searchDate) values ('"+sourceID+"','"+destID+"','"+currentDateTime+"');";
Best.log(insert_query);
DBHandle.execInsertQuery( insert_query );
String[][] res = DBHandle.execQuery("select * from previous_search;");
//System.out.println("RESULT SIZE = "+res.length+" NUMBER OF ENTERIES = "+res[0][0]);
if(res != null && res.length > 0)
{
for(int i =0 ;i < res.length; i++)
{
for(int j = 0 ; j < res[i].length ;j++)
{System.out.println("RESULT = "+res[i][j]);}
}
}
}
public static String[][] getPreviousSearches()
{
String query = "select _searchID, _sourceStopID,(select _stopName from stop_names where _stopID = _sourceStopID), _destStopID,(select _stopName from stop_names where _stopID = _destStopID), _searchDate from previous_search;";
return null ;
}
/*public static String[][] getRoutes(String fromStopID, String toStopID, String day, String timeStart,String timeEnd)
{
try{
// String _qryForAllRouteForFromStop = "select stops_on_trip._tripid , stops_on_trip._stopid, stops_on_trip._stopseq, stops_on_trip._stopdept,stops_on_trip._stopDeptOnNextDay from stops_on_trip, trips, schedule_rules where stops_on_trip._tripid = trips._tripid and trips._serviceid = schedule_rules._serviceid and stops_on_trip._stopid='"+fromStopID+"' and schedule_rules._serviceday='"+day+"' and schedule_rules._startperioddate<=date('now') and date('now')<=schedule_rules._endperioddate and stops_on_trip._stopDept > strftime('%H:%M:%S', '"+timeStart+"') and strftime('%H:%M:%S', '"+timeEnd+"') >(stops_on_trip._stopDept) and stops_on_trip._stopDeptOnNextDay=0";
// String _qryForAllRouteForFromStop = "select stops_on_trip._tripid , stops_on_trip._stopid, stops_on_trip._stopseq, stops_on_trip._stopdept,stops_on_trip._stopDeptOnNextDay from stops_on_trip, trips, schedule_rules where stops_on_trip._tripid = trips._tripid and trips._serviceid = schedule_rules._serviceid and stops_on_trip._stopid='714' and schedule_rules._serviceday='Thu'and strftime('%Y%m%d',schedule_rules._startperioddate) <=strftime('%Y%m%d','20120117') and strftime('%Y%m%d','20120117') <= strftime('%Y%m%d',schedule_rules._endperioddate) and stops_on_trip._stopDept > strftime('%H:%M:%S', '09:00:00') and strftime('%H:%M:%S', '09:25:00') >(stops_on_trip._stopDept) and stops_on_trip._stopDeptOnNextDay=0;";
String _qryForAllRouteForFromStop = "select stops_on_trip_frequency._uniqtripID,stops_on_trip_frequency._stopid, stops_on_trip_frequency._stopseq, trips_sum._tripid, trips_sum._start, trips_sum._start_next_day, trips_sum._freq, st_distance( stop_geo._stopLoc , st_pointFromText( 'POINT( lat lon )' ) )*111 as distd from stop_geo, stops_on_trip_frequency, schedule_rules, trips_sum where trips_sum._uniqtripID = stops_on_trip_frequency._uniqtripID and trips_sum._serviceid = schedule_rules._serviceid and stops_on_trip_frequency._stopid=stop_geo._stopid and schedule_rules._serviceday='Thu' and schedule_rules._startperioddate <='2012-01-17' and '2012-01-17' <= schedule_rules._endperioddateand stops_on_trip_frequency._stopid in ('714') order by distd;";
String[][] resultSet = DBHandle.execQuery( _qryForAllRouteForFromStop, M_MAX_STOP_SEARCH_ROW_BY_TEXT );
Hashtable _allEmergingRoutes = null;
if( resultSet != null )
{
String _tripIdSet = "";
_allEmergingRoutes = new Hashtable( resultSet.length );
for( int cnt=0; cnt < resultSet.length; cnt++ )
{
Vector _tripInfo = new Vector( 2 );
String _tripId = resultSet[ cnt ][ 0 ];
_tripInfo.add( resultSet[ cnt ][ 2 ] ); //StopSequence
_tripInfo.add( resultSet[ cnt ][ 3 ] ); //deprtrTime
_allEmergingRoutes.put( _tripId, _tripInfo );//trip id is key
_tripIdSet += ( ( cnt > 0 )?( "," ):( "" ) ) + "'"+_tripId+"'";
}
if( _tripIdSet.length() > 0 )
{
// String _qryForAllRouteForToStop = "select stops_on_trip._tripid, trips._tripHeadSign, routes._routeName, stops_on_trip._stopid , stops_on_trip._stopseq, stops_on_trip._stopArri, stops_on_trip._stopArriOnNextDay from stops_on_trip, stop_geo, trips, routes, schedule_rules where routes._routeID=trips._routeID and stops_on_trip._stopid=stop_geo._stopid and stops_on_trip._tripid=trips._tripid and trips._serviceid=schedule_rules._serviceid and schedule_rules._serviceday='"+ day +"' and schedule_rules._startperioddate<=date('now') and date('now')<=schedule_rules._endperioddate and trips._tripid in ("+ _tripIdSet +") and stops_on_trip._Stopid='"+toStopID+"';";
String _qryForAllRouteForToStop = "select stops_on_trip._tripid, trips._tripHeadSign, routes._routeName, stops_on_trip._stopid , stops_on_trip._stopseq, stops_on_trip._stopArri, stops_on_trip._stopArriOnNextDay from stops_on_trip, stop_geo, trips, routes, schedule_rules where routes._routeID=trips._routeID and stops_on_trip._stopid=stop_geo._stopid and stops_on_trip._tripid=trips._tripid and trips._serviceid=schedule_rules._serviceid and schedule_rules._serviceday='Thu' and strftime('%Y%m%d',schedule_rules._startperioddate)<=strftime('%Y%m%d','20120117') and strftime('%Y%m%d','20120117')<=strftime('%Y%m%d',schedule_rules._endperioddate ) and trips._tripid in ( 'LA0010052','LA0010053','LA0010081','LA0010082' ) and stops_on_trip._Stopid='1750';";
resultSet = DBHandle.execQuery( _qryForAllRouteForToStop, M_MAX_STOP_SEARCH_ROW_BY_TEXT );
if( resultSet != null && resultSet.length > 0 )
{
String[][] _returnArr = new String[ resultSet.length ][ 6 ];
for( int cnt=0; cnt < resultSet.length; cnt++ )
{
String _tripId = resultSet[ cnt ][ 0 ];
if( _allEmergingRoutes.containsKey( _tripId ) )
{
Vector v = ( Vector )_allEmergingRoutes.get( _tripId );
int _fromStopSeq = Integer.parseInt( ( String ) v.elementAt( 0 ) );
String _deptTime = ( String ) v.elementAt( 1 );
String _tripHeadSign = resultSet[ cnt ][ 1 ];
String _routeName = resultSet[ cnt ][ 2 ];
int _toStopSeq = Integer.parseInt( resultSet[ cnt ][ 4 ] );
String _arrivalTime = resultSet[ cnt ][ 5 ];
Best.log( _routeName+" -- "+_tripHeadSign+" -- "+(_toStopSeq - _fromStopSeq)+" -- "+_deptTime+" -- "+_arrivalTime );
if( _toStopSeq > _fromStopSeq )
{
_returnArr[ cnt ][ 0 ] = _tripId;
_returnArr[ cnt ][ 1 ] = _routeName;
_returnArr[ cnt ][ 2 ] = _tripHeadSign;
_returnArr[ cnt ][ 3 ] = (_toStopSeq - _fromStopSeq)+"";
_returnArr[ cnt ][ 4 ] = _deptTime;
_returnArr[ cnt ][ 5 ] = _arrivalTime;
}
}
//else shud never happen
}
return( _returnArr );
}
}
}
}catch(Exception e){}
return( null );
} */
////has _stopLoc
public static String[][] getTripInfo(String tripID)
{
String q = "select distinct _stopName, stop_names._stopID _stopID, _stopSeq ,_stopLat, _stopLon, _stopArea,_stopRoad from trips, stops_on_trip, stop_names, stop_geo where trips._tripID = '"+tripID+"' and trips._tripID = stops_on_trip._tripID and stops_on_trip._stopID = stop_names._stopID and stop_geo._stopID = stop_names._stopID order by _stopSeq asc;";
System.out.println("==Query:getTripInfo=="+q);
return ( dbhandle.execSelectQuery( q ,7) );
}
/* public static Vector searchRoutes(int rec_level,String fromStopId,String lat_from,String lon_from,String lat_to,String lon_to,Calendar dept_date,Calendar dept_time)
{
double waling_distance_km = 0.3;
rec_level++;
Hashtable singleUniqueTrips = new Hashtable();
Hashtable tripTimes = new Hashtable();
Hashtable doneTrips = new Hashtable();
Vector workingTrips = null;
String dept_day = Funcs.getCurrentDay();
String q = "select stops_on_trip_frequency._uniqtripID,stops_on_trip_frequency._stopid, stops_on_trip_frequency._stopseq, trips_sum._tripid, trips_sum._start, trips_sum._start_next_day, trips_sum._freq, st_distance( stop_geo._stopLoc , st_pointFromText( 'POINT( "+lat_from+" "+lon_from+")' ) )*111 as distd from stop_geo, stops_on_trip_frequency, schedule_rules, trips_sum where trips_sum._uniqtripID = stops_on_trip_frequency._uniqtripID and trips_sum._serviceid = schedule_rules._serviceid and stops_on_trip_frequency._stopid=stop_geo._stopid and schedule_rules._serviceday='"+dept_day+"' and schedule_rules._startperioddate<=date( 'now' ) and date( 'now' )<=schedule_rules._endperioddate and stops_on_trip_frequency._stopid = '"+fromStopId+"' order by distd ;";
String[][] resultSet = DBHandle.execQuery( q );
if( resultSet != null )
{
for( int cnt = 0; cnt <= resultSet.length; cnt++ )
{
String utripID = resultSet[ cnt ][ 0 ];
String tripID = resultSet[ cnt ][ 3 ];
if( ! singleUniqueTrips.containsKey( utripID ) )
{
String stopID = resultSet[ cnt ][ 1 ];
int stopSeq = Integer.parseInt( resultSet[ cnt ][ 2 ] );
boolean start_time_tom = ( resultSet[ cnt ][5].equals( "t" ) );
String _dept_time = resultSet[ cnt ][ 4 ];
//TODO: needs to reworked
Calendar start_time = Funcs.addTime( dept_date, _dept_time );
if( !start_time_tom )
start_time = Funcs.getNextDay( start_time );
int stop_freq = Integer.parseInt( resultSet[ cnt ][ 6 ] );
long stop_time = ( start_time.getTimeInMillis() + ( stopSeq * stop_freq) );
/////////////////
if( ( ( stop_time - 1500 ) < dept_time.getTimeInMillis() ) && ( ( stop_time + 1500 ) > dept_time.getTimeInMillis() ) )
{
Vector v = new Vector();
v.add( start_time );
v.add( stop_freq );
tripTimes.put( tripID, v );
Vector vTripInfo = init_dec( stopID, lat_from, lon_from, stopSeq+"", stop_time+"", "" );
singleUniqueTrips.put( utripID, vTripInfo );
}
}
}
allKeys = tripTimes.keys();
String trip_list = "";
while( allKeys.hasMoreElements() )
trip_list = ( ( trip_list.length() > 0 )?( "," ):( "" ) )+"'"+( String )allKeys.nextElement()+"'";
if( singleUniqueTrips.size() > 0 )
{
q = "select stops_on_trip_frequency._uniqtripID, trips_sum._tripID, trips_sum._tripHeadSign, routes._routeName, stops_on_trip_frequency._stopid , stops_on_trip_frequency._stopseq, st_distance( stop_geo._stopLoc , st_pointFromText( 'POINT( "+lat_to+" "+lon_to+")' ) )*111 as distd, ST_X( stop_geo._stopLoc ) as xlat, ST_Y( stop_geo._stopLoc ) as ylon from stops_on_trip_frequency, stop_geo, trips_sum, routes where stops_on_trip_frequency._uniqtripID=trips_sum._uniqtripID and routes._routeID=trips_sum._routeID and stops_on_trip_frequency._stopid=stop_geo._stopid and trips_sum._tripID in ("+trip_list+") order by trips_sum._tripID, distd ;";
resultSet = DBHandle.execQuery( q );
if( resultSet != null )
{
int max_check = 0;
for( int cnt = 0; cnt <= resultSet.length; cnt++ )
{
String utripID = resultSet[ cnt ][ 0 ];
String tripID = resultSet[ cnt ][ 1 ];
String tripSign = resultSet[ cnt ][ 2 ];
String routeName = resultSet[ cnt ][ 3 ];
String stopID = resultSet[ cnt ][ 4 ];
int stopSeq = Integer.parseInt( resultSet[ cnt ][ 5 ] );
double stopDistanceFromDestination = Double.parseDouble( resultSet[ cnt ][ 6 ] );
String stopLat = resultSet[ cnt ][ 7 ];
String stopLon = resultSet[ cnt ][ 8 ];
if( !doneTrips.containsKey( utripID ) )
{
Vector start_stop_dec = ( Vector ) singleUniqueTrips.get( utripID );
if( start_stop_dec.size() == 6 )
{
int stored_stopSeq = Integer.parseInt( (String)start_stop_dec.elementAt( 3 ) );
if( stored_stopSeq < stopSeq )
{
if( stopDistanceFromDestination <= waling_distance_km )
{
Vector tripVector = ( Vector )tripTimes.get( tripID );
long stop_arr_time = Long.parseLong( ( String )tripVector.elementAt( 0 ) ) + ( Long.parseLong(( ( String )tripVector.elementAt( 1 ) ) ) * stopSeq );
doneTrips.put( utripID, true );
workingTrips = insertWorkingTrips( workingTrips, calc_createWorkingRoute( tripID, utripID, tripSign, routeName, start_stop_dec, init_dec( stopID, stopLat, stopLon, stopSeq+"", stop_arr_time+"", stopDistanceFromDestination+"" ), new Vector() ) );
}
}
}
}
}
}
}
}
return( workingTrips );
} */
public static Vector findRoutes(double lat_from,double lon_from,double lat_to,double lon_to,String srcDay)
{
Vector workingTrips = new Vector();
Hashtable allNearByStops = getAllNearByBustStops( lat_from, lon_from );
String[][] _allPassingRoutes = getAllPassingRoutesFromStops( Funcs.getHashKeys( allNearByStops ), lat_from, lon_from, srcDay );
if( _allPassingRoutes != null )
{
Hashtable tripTimes = new Hashtable();
Hashtable _uniqPassingRoutes = new Hashtable();
Hashtable singleUniqueTrips = new Hashtable();
Best.log( " _allPassingRoutes - size : " + _allPassingRoutes.length );
for( int cnt = 0; cnt < _allPassingRoutes.length; cnt++ )
{
String _uniqRouteId = _allPassingRoutes[ cnt ][ 0 ];
Best.log( " _allPassingRoutes - cnt : " + cnt + " -- " + _uniqRouteId );
if( !_uniqPassingRoutes.containsKey( _uniqRouteId ) )
{
Best.log( " _allPassingRoutes - new" );
String stopID = _allPassingRoutes[ cnt ][ 1 ];
Best.log( " _allPassingRoutes - stopID : " + stopID );
String _currTime = Funcs.getCurrentTime( true );
String _busStartTime = _allPassingRoutes[ cnt ][ 4 ];
int stopSeq = Integer.parseInt( _allPassingRoutes[ cnt ][ 2 ] );
int stop_freq = Integer.parseInt( _allPassingRoutes[ cnt ][ 6 ] );
double stop_time = ( Funcs.timeToSeconds( _busStartTime ) + ( stopSeq * stop_freq ) );
long dept_time = Funcs.timeToSeconds( _currTime );
Best.log( " stop_time: " + stop_time + " -- dept_time "+ dept_time );
if( ( ( stop_time - 1500 ) < dept_time ) && ( ( stop_time + 1500 ) > dept_time ) )
{
String tripID = _allPassingRoutes[ cnt ][ 3 ];
Vector v = new Vector( 2 );
v.add( Long.toString( dept_time ) );
v.add( Integer.toString( stop_freq ) );
tripTimes.put( tripID, v );
Vector _t = ( Vector ) allNearByStops.get( stopID );
Vector vTripInfo = init_dec( stopID, ( String ) _t.elementAt( M_STOP_NEAR_POINT_LAT_INDEX ), ( String ) _t.elementAt( M_STOP_NEAR_POINT_LON_INDEX ) , Integer.toString( stopSeq ), Double.toString( stop_time ), "0" );
singleUniqueTrips.put( _uniqRouteId, vTripInfo );
}
}
}
Best.log( " singleUniqueTrips - size : " + singleUniqueTrips.size() );
if( singleUniqueTrips.size() > 0 )
{
String trip_list = "'" + android.text.TextUtils.join( "','", Funcs.getHashKeys( tripTimes ) ) + "'";
String q = "select stops_on_trip_frequency._uniqtripID, trips_sum._tripID, trips_sum._tripHeadSign, routes._routeName, stops_on_trip_frequency._stopid , stops_on_trip_frequency._stopseq, st_distance( stop_geo._stopLoc , st_pointFromText( 'POINT( "+lat_to+" "+lon_to+")' ) )*111 as distd, ST_X( stop_geo._stopLoc ) as xlat, ST_Y( stop_geo._stopLoc ) as ylon from stops_on_trip_frequency, stop_geo, trips_sum, routes where stops_on_trip_frequency._uniqtripID=trips_sum._uniqtripID and routes._routeID=trips_sum._routeID and stops_on_trip_frequency._stopid=stop_geo._stopid and trips_sum._tripID in ("+trip_list+") order by trips_sum._tripID, distd;";
Best.log( " q2 : " + q );
String[][] allStopsFromTrips = DBHandle.execQuery( q );
if( allStopsFromTrips != null )
{
Best.log( " allStopsFromTrips : size : " + allStopsFromTrips.length );
int max_check = 0;
for( int cnt = 0; cnt < allStopsFromTrips.length; cnt++ )
{
Best.log( " allStopsFromTrips : cnt : " + cnt );
String utripID = allStopsFromTrips[ cnt ][ 0 ];
String tripID = allStopsFromTrips[ cnt ][ 1 ];
String tripSign = allStopsFromTrips[ cnt ][ 2 ];
String routeName = allStopsFromTrips[ cnt ][ 3 ];
String stopID = allStopsFromTrips[ cnt ][ 4 ];
int stopSeq = Integer.parseInt( allStopsFromTrips[ cnt ][ 5 ] );
double stopDistanceFromDestination = Double.parseDouble( allStopsFromTrips[ cnt ][ 6 ] );
String stopLat = allStopsFromTrips[ cnt ][ 7 ];
String stopLon = allStopsFromTrips[ cnt ][ 8 ];
Best.log( " allStopsFromTrips : " + utripID + " -- " + tripID );
Hashtable doneTrips = new Hashtable();
if( !doneTrips.containsKey( utripID ) )
{
if( singleUniqueTrips.containsKey( utripID ) )
{
Best.log( " -- " );
Vector vTripInfo = ( Vector ) singleUniqueTrips.get( utripID );
int _storedStopSeq = Integer.parseInt( ( String ) vTripInfo.elementAt( M_STOP_INFO_SEQ_INDEX ) );
if( _storedStopSeq < stopSeq )
{
if( stopDistanceFromDestination <= M_WALING_DISTANCE_KM )
{
Vector _tmp = ( Vector )tripTimes.get( tripID );
long stored_dept_time = Long.parseLong( (String) _tmp.elementAt( 0 ) );
int stored_freq = Integer.parseInt( (String) _tmp.elementAt( 1 ) );
double stop_arr_time = stored_dept_time + ( stored_freq * stopSeq );
//echo("calc time: ${tripID} start: ".$tripTimes[ $tripID ][ 'start_time' ]." - freq: ".$tripTimes[ $tripID ][ 'stop_freq' ]." - endseq: $stopSeq - startseq: ".$start_stop_dec[$this->_M_I_STOP_SEQ]." = ".$start_stop_dec['stoptime']." | $stop_arr_time \n");
//echo("Adding Trip: ".$singleUniqueTrips[ $utripID ][ 'stop_start' ][$this->_M_I_STOP_ID]." -> ${tripID} -> ${stopID} ( ${stopDistanceFromDestination})\n");
doneTrips.put( utripID, true );
workingTrips = insertWorkingTrips( workingTrips, calc_createWorkingRoute( tripID, utripID, tripSign, routeName, vTripInfo, init_dec( stopID, stopLat, stopLon, Integer.toString( stopSeq ), Double.toString( stop_arr_time ), Double.toString( stopDistanceFromDestination ) ), new Vector() ) );
}
}
}
}
}
}
}
}
return( workingTrips );
}
public static Hashtable getAllNearByBustStops(double latFrom,double lonFrom)
{
double swlat = ( latFrom - GEO_DELTA );
double swlon = ( lonFrom - GEO_DELTA );
double nelat = ( latFrom + GEO_DELTA );
double nelon = ( lonFrom + GEO_DELTA );
String q = "select _stopID,st_distance( stop_geo._stopLoc , st_pointFromText( 'POINT( "+latFrom+" "+lonFrom+" )' ) )*111 as distd, ST_X( stop_geo._stopLoc ) as xlat, ST_Y( stop_geo._stopLoc ) as ylon from stop_geo where ST_Contains( GeomFromText( 'Polygon(("+swlat+" "+swlon+","+nelat+" "+swlon+","+nelat+" "+nelon+","+swlat+" "+nelon+","+swlat+" "+swlon+"))' ), _stopLoc ) order by distd;";
Best.log( " getAllNearByBustStops : query" + q );
String[][] allStops = DBHandle.execQuery( q );
if( allStops != null )
{
Best.log( " getAllNearByBustStops : query_res_length " + allStops.length );
int len = allStops.length;
Hashtable _allStopNearPointHash = new Hashtable( len );
for( int i = 0; i < len; i++ )
{
String _stopID = allStops[ i ][ 0 ];
double _distanceFromPoint = Double.parseDouble( allStops[ i ][ 1 ] );
double _stopLat = Double.parseDouble( allStops[ i ][ 2 ] );
double _stopLon = Double.parseDouble( allStops[ i ][ 3 ] );
Best.log( " getAllNearByBustStops : stop at "+ i +" :: " + _stopID + " -- " + " -- " + _distanceFromPoint + " -- " + _stopLat + " -- " + _stopLon );
Vector _stopNearPointInfo = new Vector( 3 );
_stopNearPointInfo.insertElementAt( Double.toString( _distanceFromPoint ), M_STOP_NEAR_POINT_DISTANCE_INDEX );
_stopNearPointInfo.insertElementAt( Double.toString( _stopLat ), M_STOP_NEAR_POINT_LAT_INDEX );
_stopNearPointInfo.insertElementAt( Double.toString( _stopLon ), M_STOP_NEAR_POINT_LON_INDEX );
_allStopNearPointHash.put( _stopID, _stopNearPointInfo );
}
return( _allStopNearPointHash );
}
return( null );
}
public static String[][] getAllPassingRoutesFromStops(String[] stops,double lat,double lon,String srcDay)
{
if( stops.length > 0 )
{
String stopsList = "'" + android.text.TextUtils.join( "','", stops ) + "'";
String q = "select stops_on_trip_frequency._uniqtripID,stops_on_trip_frequency._stopid, stops_on_trip_frequency._stopseq, trips_sum._tripid, trips_sum._start, trips_sum._start_next_day, trips_sum._freq, st_distance( stop_geo._stopLoc , st_pointFromText( 'POINT( "+lat+" "+lon+")' ) )*111 as distd from stop_geo, stops_on_trip_frequency, schedule_rules, trips_sum where trips_sum._uniqtripID = stops_on_trip_frequency._uniqtripID and trips_sum._serviceid = schedule_rules._serviceid and stops_on_trip_frequency._stopid=stop_geo._stopid and schedule_rules._serviceday='"+srcDay+"' and schedule_rules._startperioddate<=date( 'now' ) and date( 'now' )<=schedule_rules._endperioddate and stops_on_trip_frequency._stopid in ("+stopsList+") order by distd;";
Best.log( " getAllPassingRoutesFromStops : query : " + q );
return( DBHandle.execQuery( q ) );
}
return( null );
}
public static Vector init_dec(String stopID,String stopLat,String stopLon,String stopSeq,String stop_arr_time,String stopDistanceFromDestination )
{
Vector v = new Vector();
v.insertElementAt( stopID, M_STOP_INFO_ID_INDEX );
v.insertElementAt( stopLat, M_STOP_INFO_LAT_INDEX );
v.insertElementAt( stopLon, M_STOP_INFO_LON_INDEX );
v.insertElementAt( stopSeq, M_STOP_INFO_SEQ_INDEX );
v.insertElementAt( stop_arr_time, M_STOP_INFO_ARR_TIME_INDEX );
v.insertElementAt( stopDistanceFromDestination, M_STOP_INFO_ARR_DISTANCE_INDEX );
return( v );
}
public static Vector insertWorkingTrips(Vector wtrips,Vector wt)
{
int wlen = wtrips.size();
Vector ret = new Vector();
if( wlen > 0 )
{
boolean b_done_insert = false;
Vector infoVector = ( Vector )wt.elementAt( 2 );
double suppliedDistance = Double.parseDouble( ( String )infoVector.elementAt( 2 ) );
for( int i=0; i < wlen; i++ )
{
Vector singleTrip = ( Vector )wtrips.elementAt( i );
Vector innerVector = ( Vector )singleTrip.elementAt( 2 );
if( suppliedDistance < Double.parseDouble( ( String )innerVector.elementAt( 2 ) ) )
{ ret.add( wt ); b_done_insert = true; }
ret.add( singleTrip );
}
if(!b_done_insert) { ret.add( wt ); }
}
else
ret.add( wt );
return( ret );
}
public static Vector calc_createWorkingRoute(String tripID,String uniqueTripID,String tripSign,String routeName,Vector start_stop_dec,Vector end_stop_dec,Vector next_trip_hops)
{
double s = Double.parseDouble( (String)start_stop_dec.elementAt( M_STOP_INFO_ARR_TIME_INDEX ) );
double e = Double.parseDouble( (String)end_stop_dec.elementAt( M_STOP_INFO_ARR_TIME_INDEX ) );
int strartBusStopNo = Integer.parseInt( (String)start_stop_dec.elementAt( M_STOP_INFO_SEQ_INDEX ) );
int lastBusStopNo = Integer.parseInt( (String)end_stop_dec.elementAt( M_STOP_INFO_SEQ_INDEX ) );
double trip_time = e - s;
double trip_dist = getTripDistance( uniqueTripID, strartBusStopNo+"", lastBusStopNo+"" );
Vector v = new Vector();
v.add( tripID );
v.add( uniqueTripID );
v.add( init_trip_dec( trip_time+"", "0", trip_dist+"", tripSign, routeName ) );
v.add( start_stop_dec );
v.add( end_stop_dec );
v.add( next_trip_hops );
return( v );
}
public static double getTripDistance(String tripID,String start_seq,String end_seq)
{
try{
String q = "select asText(stop_geo._stoploc) from stops_on_trip_frequency inner join stop_geo on (stop_geo._stopid=stops_on_trip_frequency._stopid) where _uniqtripID='"+tripID+"' and _stopseq>="+start_seq+" and _stopseq<="+end_seq;
String[][] resultSet = DBHandle.execQuery( q );
if( resultSet != null )
{
String lastPoint = "";
String distanceSelectClause = "";
for( int cnt = 0; cnt < resultSet.length; cnt++ )
{
if( cnt > 0 )
{
distanceSelectClause = ( ( distanceSelectClause.length() > 0 )?( "+" ):( "" ) )+"distance( GeomFromText( '"+lastPoint+"' ), GeomFromText( '"+resultSet[ cnt ][ 0 ]+"' ) )";
}
distanceSelectClause += "*111";
lastPoint = resultSet[ cnt ][ 0 ];
}
q = "select "+distanceSelectClause;
resultSet = DBHandle.execQuery( q );
Best.log( " getTripDistance q: " + q );
if( resultSet != null )
{
Best.log( " ANSWER : " + resultSet[ 0 ][ 0 ] );
return( Double.parseDouble( resultSet[ 0 ][ 0 ] ) );
}
}
}catch(Exception e){}
return( 0 );
}
public static Vector init_trip_dec(String tripTime,String tripFare,String tripDist,String tripSign,String routeName)
{
Vector v = new Vector();
v.add( tripTime );v.add( tripFare );v.add( tripDist );v.add( tripSign );v.add( routeName );
return( v );
}
//------------DIRECT ROUTING ---------
public static String[][] getDirectRoutes(String fromStopID, String toStopID)
{
String _currDay = Funcs.getCurrentDay();
System.out.println("-----CurrentDAy----"+_currDay);
String q = "select distinct stops_on_trip._tripID, stops_on_trip._stopSeq, trips_freq._start, trips_freq._end, trips_freq._end_next_day, trips_freq._headways, bus_max_freq._freq, routes._routeLongName , routes._routeName from stops_on_trip, trips_freq, trips, routes, schedule_rules, bus_max_freq where stops_on_trip._stopID='"+fromStopID +"' and stops_on_trip._tripID = trips_freq._tripID and stops_on_trip._tripID = trips._tripID and schedule_rules._serviceID = trips._serviceID and routes._routeID = trips._routeID and schedule_rules._serviceDay='"+ _currDay +"' and trips._tripID = bus_max_freq._tripID order by stops_on_trip._tripID asc, _start asc;" ;
Best.log( q );
String[][] resultSet = dbhandle.execSelectQuery( q ,9);
Best.log("===resultSet.Length=="+resultSet.length);
if(resultSet != null )
{
Hashtable _passingFromStopsTrips = new Hashtable();
String _allTripId = "";
int _passedTrips = 0;
for( int cnt = 0; cnt < resultSet.length; cnt++ )
{
Best.log("====resultSet Count==="+ cnt);
String _tripId = resultSet[ cnt ][ 0 ];
int _seq = Integer.parseInt( resultSet[ cnt ][ 1 ] );
String _startTime = resultSet[ cnt ][ 2 ];
String _endTime = resultSet[ cnt ][ 3 ];
int _freq = Integer.parseInt( resultSet[ cnt ][ 6 ] );
String _routeLongName = resultSet[ cnt ][ 7 ];
String _routeName = resultSet[ cnt ][ 8 ];
String _currTime = Funcs.getCurrentTime( true );
Best.log("===_tripId=="+_tripId+"==_seq=="+_seq+"==_startTime=="+_startTime+"==_freq=="+_freq+"==_routeLongName=="+_routeLongName+"==_routeName=="+_routeName);
long _startTimeInSecs = Funcs.timeToSeconds( _startTime );
long _endTimeInSecs = Funcs.timeToSeconds( _endTime );
long _currTimeInSecs = Funcs.timeToSeconds( _currTime );
Best.log("===_currTime=="+_currTime);
Best.log("===_currTimeInSecs=="+_currTimeInSecs);
int _trip_travel_time = (_freq * _seq);
long _trip_start_esti_beg = (_currTimeInSecs - _trip_travel_time) - 900;
long _trip_start_esti_end = (_currTimeInSecs - _trip_travel_time) + 900;
Best.log("===_startTimeInSecs=="+_startTimeInSecs);
Best.log("_trip_start_esti_beg="+_trip_start_esti_beg);
Best.log("===_endTimeInSecs=="+_endTimeInSecs);
Best.log("_trip_start_esti_end="+_trip_start_esti_end);
if( ( (_startTimeInSecs <= _trip_start_esti_beg) && (_endTimeInSecs <= _trip_start_esti_beg) ) || ( (_startTimeInSecs <= _trip_start_esti_end) && (_endTimeInSecs <= _trip_start_esti_end) ) )
{
double _stopTime = ( _startTimeInSecs + ( _seq * _freq ) );
Best.log("===_stopTime=="+_stopTime);
//if( ( ( _stopTime - 900 ) < 57600 ) && ( ( _stopTime + 900 ) > 57600 ) )
//{
Vector _trip_info = new Vector( 6 );
_trip_info.add( _tripId );
_trip_info.add( Integer.toString( _seq ) );
_trip_info.add( Integer.toString( _freq ) );
_trip_info.add( _startTime );
_trip_info.add( _routeLongName );
_trip_info.add( _routeName );
Best.log( "STORRING : " + _tripId + " -> " + _seq + " -- " + _freq + " -- " + _startTime + " -- " + _tripId );
if(_passingFromStopsTrips.containsKey( _tripId ) )
{
System.out.println("KEY EXIST");
Vector _tripVec = (Vector)_passingFromStopsTrips.get(_tripId);
_tripVec.add(_trip_info);
}
else
{
Vector _tripVec = new Vector();
System.out.println("KEY DOESNT EXIST");
_tripVec.add(_trip_info);
_passingFromStopsTrips.put( _tripId, _tripVec );
}
if(((Vector)(_passingFromStopsTrips.get(_tripId))).size() == 1)
_allTripId += ( ( _allTripId.length() > 0 )?( "," ):( "" ) ) + "'"+_tripId+"'";
}
}
Best.log("=======_passingFromStopsTrips Size===="+_passingFromStopsTrips.size());
Best.log("=======_allTripId===="+_allTripId);
if( _passingFromStopsTrips.size() > 0 && _allTripId.length() > 0 )
{
String q2 = "select distinct _tripID, _stopSeq from stops_on_trip where _tripID in ("+_allTripId+") and _stopID = '"+toStopID+"';";
Best.log( "2nd query======="+q2 );
resultSet = dbhandle.execSelectQuery( q2 ,2 );
if( resultSet != null )
{
String _TripIds = "";
Hashtable _toStopSeqStore = new Hashtable();
for( int c = 0; c < resultSet.length; c++ )
{
String tripId = resultSet[ c ][ 0 ];
int _toStopSeq = Integer.parseInt( resultSet[ c ][ 1 ] );
Best.log( "Q2 : "+tripId+" :: "+_toStopSeq );
if( _passingFromStopsTrips.containsKey( tripId ) )
{
Vector _tripPassingFrom = ( Vector )_passingFromStopsTrips.get( tripId );
int _fromStopSeq = Integer.parseInt((String)( ( Vector )_tripPassingFrom.elementAt( 0 )).elementAt(1) );
Best.log( "SQS : "+ _fromStopSeq + " :: " + _toStopSeq );
if( _fromStopSeq < _toStopSeq )
{
_passedTrips++;
_TripIds += ( ( _TripIds.length() > 0 )?( "," ):( "" ) )+ tripId;
_toStopSeqStore.put( tripId, Integer.toString( _toStopSeq ) );
}
}
else
Best.log( "NOT STORED : "+tripId );
}
Best.log( "_TripIds : "+ _TripIds );
if( _TripIds.length() > 0 )
{
String[] _trips = _TripIds.split( "," );
String _tripIds = "";
int k = 0;
for( k = 0 ;k < _trips.length -1; k++)
{
_tripIds += "'"+_trips[k]+"'"+",";
}
_tripIds += "'"+_trips[k]+"'";
String[][] _ret = null;
if( _passedTrips > 0 )
_ret = new String[ _passedTrips ][ 6 ];
//has _stopLoc
String query = "select _stopLat , _stopLon , _tripID , _stopSeq ,stops_on_trip._stopID from stops_on_trip ,stop_geo where stops_on_trip._stopID = stop_geo._stopID and stops_on_trip._tripID in ("+_tripIds+") order by _tripID , _stopSeq ;";
Best.log("query="+query);
String[][] tripInfoResult = dbhandle.execSelectQuery( query , 5 );
ArrayList<String> distanceList = new ArrayList<String>();
for(int i =0 ; i < tripInfoResult.length; i++)
{
ArrayList<String> stopGeoX = new ArrayList<String>();
ArrayList<String> stopGeoY = new ArrayList<String>();
if(tripInfoResult[i][4].equals(fromStopID))
{
for(int j = 0; j< tripInfoResult.length; j++,i++)
{
stopGeoX.add( tripInfoResult[i][0]);
stopGeoY.add( tripInfoResult[i][1]);
if(tripInfoResult[i][4].equals(toStopID))
break ;
}
int distanceBetweenStops = 0;
for(int index = 0; index <stopGeoX.size() - 1; index++ )
{
GeoPoint gp1 = new GeoPoint(Double.parseDouble(stopGeoX.get(index)) , Double.parseDouble(stopGeoY.get(index)) );
GeoPoint gp2 = new GeoPoint(Double.parseDouble(stopGeoX.get(index + 1)) , Double.parseDouble(stopGeoY.get(index + 1)) );
distanceBetweenStops += gp1.distanceTo( gp2 );
Best.log("distanceBetweenStops ="+ distanceBetweenStops);
}
distanceList.add(Integer.toString(distanceBetweenStops));
}
}
if( _ret != null )
{
for( int c = 0,_passeIndex=0; c < _trips.length; c++ )
{
String _trip_id = _trips[ c ];
Best.log( "_trip_id: "+_trip_id);
if( _passingFromStopsTrips.containsKey( _trip_id ) )
{
Vector _trip_vec = ( Vector ) _passingFromStopsTrips.get( _trip_id );
for(int i =0; i < _trip_vec.size() ; i++)
{
System.out.println("TRIP_VEC_SIZE="+_trip_vec.size());
if( _passeIndex < _passedTrips )
{
Vector _t = (Vector)(_trip_vec.elementAt(i));
_ret[ _passeIndex ][ 0 ] = ( String )_t.elementAt( 0 ); //trip ID
_ret[ _passeIndex ][ 1 ] = ( String )_t.elementAt( 5 ); //routeName
_ret[ _passeIndex ][ 2 ] = ( String )_t.elementAt( 4 ); //head sign
_ret[ _passeIndex ][ 3 ] = Integer.toString( Integer.parseInt( ( String ) _toStopSeqStore.get( _trip_id ) ) - Integer.parseInt( ( String ) _t.elementAt( 1 ) ) ); // number of stops
//_ret[ c ][ 4 ] = ( String )_t.elementAt( 2 ); //departure time
_ret[ _passeIndex ][ 4 ] = distanceList.get(c);
_ret[ _passeIndex ][ 5 ] = ( String )_t.elementAt( 2 ); //freq
//String[][] tripInfoResultSet = getTripInfo( ( String )_t.elementAt( 0 ));
Best.log( "_x RET INFO : " + android.text.TextUtils.join( "','", _ret[ _passeIndex ] ) );
_passeIndex++;
}
}
}
else
Best.log( "_x else : " );
}
}
return( _ret );
}
}
}
}
else
Best.log("getDirectRoutes:=====Resultset null=====");
return( null );
}
public static String[][] getAllStops()
{
String _currDay = Funcs.getCurrentDay();
String allStopsQuery = "select _stopID, _stopName, _stopRoad, _stopArea from stop_names group by _stopName order by _stopName asc limit 100;";
System.out.println("allStops QUERY==:"+allStopsQuery);
String[][] allStops = dbhandle.execSelectQuery( allStopsQuery ,4 );
return (allStops);
}
public static String[][] getAllTrips()
{
String _currDay = Funcs.getCurrentDay();
String allTripsQuery = "select distinct routes._routeID, trips._tripID, _routeLongName ,_routeName , bus_max_freq._freq from routes, trips, schedule_rules, bus_max_freq where trips._routeID = routes._routeID and trips._tripID = bus_max_freq._tripID and trips._serviceID = schedule_rules._serviceID and _serviceDay = '"+_currDay+"' group by routes._routeID order by routes._routeID asc limit 100;";
System.out.println("allTrips QUERY==:"+allTripsQuery);
String[][] allTrips = dbhandle.execSelectQuery( allTripsQuery , 5);
return (allTrips);
}
public static String[][] getAllTripsByText(String matchText)
{
String _currDay = Funcs.getCurrentDay();
String allTripsByTextQuery = "select distinct routes._routeID, trips._tripID, _routeLongName ,_routeName , bus_max_freq._freq from routes, trips, schedule_rules, bus_max_freq where ( _routeLongName like '"+matchText+"%' or _routeLongName like '% "+matchText+"%' or _routeName like '"+matchText+"%' or _routeName like '% "+matchText+"%') and trips._routeID = routes._routeID and trips._tripID = bus_max_freq._tripID and trips._serviceID = schedule_rules._serviceID and _serviceDay = '"+_currDay+"' group by routes._routeID order by routes._routeID asc limit 100;";
System.out.println("allTrips QUERY==:"+allTripsByTextQuery);
String[][] allTrips = dbhandle.execSelectQuery( allTripsByTextQuery , 5);
return (allTrips);
}
public static String[][] getAllTripsPassingByStop(String stopID)
{
String _currDay = Funcs.getCurrentDay();
String query = " select distinct _stopID, routes._routeID, trips._tripID, _routeLongName ,_routeName , bus_max_freq._freq from stops_on_trip, routes, trips, bus_max_freq where trips._tripID = stops_on_trip._tripID and _stopID = '"+stopID+"' and trips._routeID = routes._routeID and trips._tripID = bus_max_freq._tripID group by routes._routeID order by routes._routeID asc limit 30;";
String[][] allPassingByTrips = dbhandle.execSelectQuery( query , 6);
return(allPassingByTrips);
}
//------------------------------------
//has _stopLoc
public static String[][] getNearByTripInfo(Double lat, Double lon)
{
String _currDay = Funcs.getCurrentDay();
String nearByStopQuery = "select g._stopID from stop_geo g, stop_names n where g._stopID = n._stopID and Distance( _stopLoc, ST_GeomFromText('POINT(" + lat + " " + lon + ")') )*111 <= 0.5 limit 30 ";
//String nearByPassingTrips = "select distinct routes._routeID, trips._tripID, _routeLongName ,_routeName ,trips_freq._freq from routes, trips, schedule_rules, trips_freq where trips._routeID = routes._routeID and trips._tripID in (select _tripID from stops_on_trip where _stopID in ( select stop_geo._stopID from stop_geo where Distance( _stopLoc, ST_GeomFromText('POINT("+lat+" "+lon+")') )*111 <= 0.5 limit 30)) and trips_freq._tripID = trips._tripID and trips._serviceID = schedule_rules._serviceID and _serviceDay = '"+_currDay+"' group by routes._routeID order by routes._routeID asc ;";
Double maxLatitude = lat + 0.005000 ;
Double minLatitude = lat - 0.005000 ;
Double maxLongitude = lon + 0.005000 ;
Double minLongitude = lon - 0.005000 ;
String nearByPassingTrips = "select distinct routes._routeID, trips._tripID, _routeLongName ,_routeName ,bus_max_freq._freq from routes, trips, schedule_rules, bus_max_freq where trips._routeID = routes._routeID and trips._tripID in (select _tripID from stops_on_trip where _stopID in ( select stop_geo._stopID from stop_geo where _stopLat between '"+minLatitude+"' and '"+maxLatitude+"' and _stopLon between '"+minLongitude+"' and '"+maxLongitude+"' limit 30)) and bus_max_freq._tripID = trips._tripID and trips._serviceID = schedule_rules._serviceID and _serviceDay = '"+_currDay+"' group by routes._routeID order by routes._routeID asc ;";
System.out.println("QUERY==:"+nearByPassingTrips);
String[][] nearbyTrips_Name = dbhandle.execSelectQuery( nearByPassingTrips , 5 );
return (nearbyTrips_Name);
}
}

View File

@ -0,0 +1,384 @@
package com.best.ui;
import java.util.List;
import java.util.ArrayList;
import android.app.Activity;
import android.app.ListActivity;
import android.os.Bundle;
import android.os.Message;
import android.os.Handler;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.Filterable;
import android.widget.Filter;
import android.widget.AbsListView;
import android.widget.ImageView;
import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.view.View.OnClickListener;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MenuInflater;
import android.content.res.Configuration;
import android.content.Intent;
import android.content.Context;
import android.graphics.Color;
import android.view.KeyEvent;
import com.best.util.Funcs;
import com.best.data.GTStore_sqlite;
import com.best.util.TransitionEffect;
public class Buses extends Activity {
public static Activity me;
public static Context m_context;
public LayoutInflater mInflater;
public static String scrStopId;
public static String destStopId;
public static String searchtext = "";
public static boolean contentChanged = false;
public static boolean RouteDisplayed = false;
public static boolean searchResultDisplayed = false;
//public static String[] colors = {"#fcfcfc" , "#ececec"};
public static String[][] tripsResult, _tripsResult ;
public void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT)
TransitionEffect.callOverridePendingTransition(this);
this.setContentView( com.best.ui.R.layout.routing );
init();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
//Best.dissmissProcessing();
}
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()
{
if(RouteDisplayed == true && searchResultDisplayed == false)
{
me.setContentView(com.best.ui.R.layout.routing );
EfficientAdapter adapter = new EfficientAdapter( m_context , tripsResult);
((LinearLayout) me.findViewById(com.best.ui.R.id.linearlayout1)).setVisibility(LinearLayout.GONE);
( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
RouteDisplayed = false;
}
else if(searchResultDisplayed == true && RouteDisplayed == false )
{
me.setContentView(com.best.ui.R.layout.routing );
EfficientAdapter adapter = new EfficientAdapter( m_context , tripsResult);
((LinearLayout) me.findViewById(com.best.ui.R.id.linearlayout1)).setVisibility(LinearLayout.GONE);
( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
searchResultDisplayed = false;
}
else if(searchResultDisplayed == true && RouteDisplayed == true )
{
me.setContentView(com.best.ui.R.layout.routing );
EfficientAdapter adapter = new EfficientAdapter( m_context , _tripsResult);
( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
RouteDisplayed = false;
( ( TextView ) me.findViewById( com.best.ui.R.id.search_for ) ).setText("Search Result for : " + searchtext);
}
else
Best.exit( me );
}
// @Override
// public void onBackPressed() {
// if(RouteDisplayed == true && searchResultDisplayed == false)
// {
// me.setContentView(com.best.ui.R.layout.routing );
// EfficientAdapter adapter = new EfficientAdapter( m_context , tripsResult);
// ((LinearLayout) me.findViewById(com.best.ui.R.id.linearlayout1)).setVisibility(LinearLayout.GONE);
// ( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
// RouteDisplayed = false;
// }
// else if(searchResultDisplayed == true && RouteDisplayed == false )
// {
// me.setContentView(com.best.ui.R.layout.routing );
// EfficientAdapter adapter = new EfficientAdapter( m_context , tripsResult);
// ((LinearLayout) me.findViewById(com.best.ui.R.id.linearlayout1)).setVisibility(LinearLayout.GONE);
// ( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
// searchResultDisplayed = false;
// }
// else if(searchResultDisplayed == true && RouteDisplayed == true )
// {
// me.setContentView(com.best.ui.R.layout.routing );
// EfficientAdapter adapter = new EfficientAdapter( m_context , _tripsResult);
// ( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
// RouteDisplayed = false;
// ( ( TextView ) me.findViewById( com.best.ui.R.id.search_for ) ).setText("Search Result for : " + searchtext);
// }
// else
// Best.exit( me );
// }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return true;
}
@Override
public boolean onPrepareOptionsMenu (Menu menu){
MenuInflater inflater = getMenuInflater();
menu.clear();
if( searchResultDisplayed == false && RouteDisplayed == false)
{
inflater.inflate(com.best.ui.R.menu.search, menu);
return true;
}
else if( RouteDisplayed == true )
{
inflater.inflate(com.best.ui.R.menu.onlymap, menu);
return true;
}
else
return false;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case com.best.ui.R.id.mnusearch:
Intent intent = new Intent(m_context, Search.class);
intent.putExtra( "callFromStops" , false );
me.startActivityForResult( intent, 5 );
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 intent1 = new Intent(m_context, Map.class);
intent1.putExtras( bundle1 );
me.startActivityForResult(intent1,5);
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void init()
{
me = this;
m_context = this;
((LinearLayout) me.findViewById(com.best.ui.R.id.linearlayout1)).setVisibility(LinearLayout.GONE);
Best.showProcessing(m_context, "Processing","Please wait..." );
TripsSearchThread tripsSearchThread = new TripsSearchThread( searchTripsHandler );
tripsSearchThread.start();
}
public Handler searchTripsHandler = new Handler() {
public void handleMessage(Message msg) {
Bundle dataBundle = msg.getData();
Best.dissmissProcessing();
tripsResult = ( String[][] )dataBundle.getSerializable( "rts" );
if(tripsResult != null && tripsResult.length > 0 )
{
EfficientAdapter adapter = new EfficientAdapter( m_context , tripsResult);
( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
//me.setListAdapter( adapter );
}
else
Best.showMessage( m_context, "There are no routes to show.", "Processing" );
}
};
private class TripsSearchThread extends Thread
{
Handler _handler;
TripsSearchThread(Handler handler )
{
_handler = handler;
}
public void run()
{
//code to get all routes
Bundle dataBundle = new Bundle();
try
{
String [][] _res = GTStore_sqlite.getAllTrips();
dataBundle.putSerializable( "rts", _res );
Message msg = _handler.obtainMessage();
msg.setData( dataBundle );
_handler.sendMessage( msg );
}
catch(Exception e){Best.dissmissProcessing(); e.printStackTrace();
}
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try{
Bundle bundle = data.getExtras();
String[] routeID = bundle.getStringArray( "routeID" );
String[] tripID = bundle.getStringArray( "tripID" );
String[] routeLongName = bundle.getStringArray( "routeLongName" );
String[] routeName = bundle.getStringArray( "routeName" );
String[] tripFreq = bundle.getStringArray( "tripFreq" );
searchtext = bundle.getString( "searchtxt");
_tripsResult = new String[routeID.length][5];
for(int i = 0; i < routeID.length ; i++)
{
_tripsResult[i][0] = routeID[i];
_tripsResult[i][1] = tripID[i];
_tripsResult[i][2] = routeLongName[i];
_tripsResult[i][3] = routeName[i];
_tripsResult[i][4] = tripFreq[i];
}
me.setContentView( com.best.ui.R.layout.routing );
EfficientAdapter adapter = new EfficientAdapter( m_context , _tripsResult);
( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
( ( TextView ) me.findViewById( com.best.ui.R.id.search_for ) ).setText("Search Result for : " + searchtext);
searchResultDisplayed = true ;
}
catch(Exception e)
{
Best.log("Exception-"+e.toString());
}
}
public class EfficientAdapter extends BaseAdapter implements Filterable {
public String[][] result;
public EfficientAdapter(Context context, String[][] resultSet)
{
mInflater = LayoutInflater.from( context );
result = new String[resultSet.length][];
result=resultSet;
if(resultSet == null)
Best.showError(context ,"Sorry.. Something went wrong..");
}
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if(result!= null)
{
if (convertView == null)
{
convertView = mInflater.inflate(com.best.ui.R.layout.list_route, null);
holder = new ViewHolder();
holder.head = (TextView) convertView.findViewById(com.best.ui.R.id.bushead);
holder.blue_bus = (ImageView) convertView.findViewById(com.best.ui.R.id.busBlue);
holder.routeName = (TextView) convertView.findViewById(com.best.ui.R.id.routename);
convertView.setTag(holder);
}
else
holder = (ViewHolder) convertView.getTag();
holder.head.setText( result[position][2] );
holder.routeName.setText( result[position][3] );
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
RouteDisplayed = true;
Bundle bundle = new Bundle();
bundle.putString( "tripID" , result[position][1] );
bundle.putString("routeLongName",result[position][2]);
bundle.putString("routeName",result[position][3]);
Best.log("CLICKED POSITION :"+ position);
me.setContentView( com.best.ui.R.layout.routes );
contentChanged = true;
//NearTripRoute object = new NearTripRoute();
NearTripRoute.init(m_context,result[position][1],result[position][3],result[position][2],result[position][4],false);
}
});
return convertView;
}
return (null);
}
public class ViewHolder {
TextView head;
TextView routeName;
ImageView blue_bus;
}
@Override
public Filter getFilter() {
return null;
}
@Override
public int getCount() {
if(result != null)
return result.length;
else
return 0;
}
@Override
public Object getItem(int position) {
if(result != null)
return result[position];
else
return (null);
}
@Override
public long getItemId(int position) {
return 0;
}
}
}

View File

@ -0,0 +1,56 @@
////////////////////////////////////////////////
//
// A ChaloBEST (http://chalobest.in/) initiative
// Author: Nikita (Macgregor Techknowlogy)
// License: GPLv3
//
//
package com.best.ui;
import android.app.Activity;
import android.content.Intent;
import android.content.Context;
import android.os.Bundle;
import com.best.util.TransitionEffect;
public class EmptyActivity extends Activity {
public static Activity me;
public static Context m_context;
public void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT)
TransitionEffect.callOverridePendingTransition(this);
//overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
me = this;
m_context = this;
me.setContentView( com.best.ui.R.layout.in_progress );
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
}
@Override
public void onBackPressed() {
Best.exit( me );
//return;
}
}

View File

@ -0,0 +1,143 @@
package com.best.ui;
import android.app.Activity;
//import android.app.ActivityGroup;
import android.app.TabActivity;
import android.os.Bundle;
import android.content.res.Resources;
import android.content.Intent;
import android.content.Context;
import java.util.ArrayList;
import android.view.View;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabWidget;
import android.text.Html;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Paint;
import android.graphics.Canvas;
import android.graphics.Paint.Style;
public class MainTab extends TabActivity
{
public static TabHost _mainTab = null;
public static LayoutInflater layoutInflater;
//public static TabHost tabHost = null;
public static Activity me = null;
public TextView tv;
public static Context m_context;
public static String M_FIND_TAB_ID = "find";
public static String M_BUS_TAB_ID = "bus";
public static String M_STOP_TAB_ID = "stop";
public static String M_ROAD_TAB_ID = "road";
public static String M_AREA_TAB_ID = "area";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
me = this;
m_context = this;
setContentView(R.layout.maintab);
Resources res = getResources();
final TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
TabHost.TabSpec spec;
Intent intent;
layoutInflater = (LayoutInflater) m_context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final TextView tab1ViewRed = (TextView)layoutInflater.inflate(com.best.ui.R.layout.myroute_view, null);
// BitmapDrawable bitDrawable = new BitmapDrawable();
// bitDrawable = writeOnDrawable(R.drawable.bus_red2, "BUS" );
intent = new Intent().setClass(this, Find.class);
spec = tabHost.newTabSpec(M_FIND_TAB_ID ).setIndicator( tab1ViewRed ).setContent(intent);
tabHost.addTab( spec );
//spec = tabHost.newTabSpec(M_FIND_TAB_ID ).setIndicator( Html.fromHtml("<font color = 'Red'>"+"My Route"+"</font>")).setContent(intent);
//spec = tabHost.newTabSpec(M_FIND_TAB_ID ).setIndicator( "My Route",res.getDrawable(R.drawable.ic_tab_new) ).setContent(intent);
intent = new Intent().setClass(this, Buses.class);
spec = tabHost.newTabSpec(M_BUS_TAB_ID ).setIndicator( "Buses",res.getDrawable(R.drawable.tab_bus) ).setContent(intent);
//spec = tabHost.newTabSpec(M_BUS_TAB_ID ).setIndicator( "", bitDrawable).setContent(intent);
tabHost.addTab( spec );
intent = new Intent().setClass(this, Stops.class);
spec = tabHost.newTabSpec(M_STOP_TAB_ID ).setIndicator( "Stops",res.getDrawable(R.drawable.tab_stops) ).setContent(intent);
tabHost.addTab( spec );
// intent = new Intent().setClass(this, EmptyActivity.class);
// spec = tabHost.newTabSpec(M_ROAD_TAB_ID ).setIndicator( "",res.getDrawable(R.drawable.tab_road) ).setContent(intent);
// tabHost.addTab( spec );
// intent = new Intent().setClass(this, EmptyActivity.class);
// spec = tabHost.newTabSpec(M_AREA_TAB_ID ).setIndicator( "",res.getDrawable(R.drawable.tab_area) ).setContent(intent);
// tabHost.addTab( spec );
TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);
final int tabChildrenCount = tabWidget.getChildCount();
View currentView;
for (int i = 0; i < tabChildrenCount; i++) {
currentView = tabWidget.getChildAt(i);
LinearLayout.LayoutParams currentLayout =
(LinearLayout.LayoutParams) currentView.getLayoutParams();
currentLayout.setMargins(0, 0, 5, 0);
}
tabWidget.requestLayout();
tabHost.setCurrentTab(0);
//tabHost.getTabWidget().setDividerDrawable(R.drawable.back);
for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
{
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#F2F2F2"));
}
//// //tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#dcdcdc"));//F9F9F9
tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#9f9f9f"));
tabHost.setOnTabChangedListener(new OnTabChangeListener(){
@Override
public void onTabChanged(String tabId) {
tv = (TextView) tabHost.getTabWidget().getChildAt(0).findViewById(com.best.ui.R.id.txtmyroute);
for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
{
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#F2F2F2"));
}
//// //tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#dcdcdc"));
tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#9f9f9f"));
if( M_FIND_TAB_ID.equals( tabId ) ) {
tv.setTextColor(Color.parseColor("#fb0300"));
System.out.println("MY ROUTE SELECTED");
}
else {
tv.setTextColor(Color.parseColor("#666666"));
System.out.println("MY ROUTE UNSELECTED");
}
}
});
}
// public BitmapDrawable writeOnDrawable(int drawableId, String text){
// Bitmap bm = BitmapFactory.decodeResource(getResources(), drawableId).copy(Bitmap.Config.ARGB_8888, true);
// Paint paint = new Paint();
// paint.setStyle(Style.FILL);
// paint.setColor(Color.BLACK);
// paint.setTextSize(18);
// Canvas canvas = new Canvas(bm);
// canvas.drawText(text, bm.getHeight(),bm.getHeight()+bm.getHeight()/2, paint);
// return new BitmapDrawable(bm);
// }
}

View File

@ -0,0 +1,384 @@
////////////////////////////////////////////////
//
// A ChaloBEST (http://chalobest.in/) initiative
// Author: Nikita (Macgregor Techknowlogy)
// License: GPLv3
//
//
package com.best.ui;
import android.app.Activity;
import android.app.ListActivity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Message;
import android.os.Handler;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.EditText;
import android.widget.Button;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Filterable;
import android.widget.Filter;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MenuInflater;
import android.view.ViewGroup.LayoutParams;
import android.widget.PopupWindow;
import android.app.Dialog;
import android.view.View.OnLongClickListener;
import com.best.data.GTStore_sqlite;
import com.best.util.Funcs;
import com.best.util.TransitionEffect;
import java.util.List;
import java.util.ArrayList;
import android.graphics.Color;
import android.text.Html;
import android.widget.ListView;
public class NearTripRoute{
public static ListActivity me;
public static Context m_context;
public static LayoutInflater mInflater,layoutInflater;
public static String _tripID;
public static String _routeLongName;
public static String _routeName;
public static String nearestStopID;
public static int _freq;
public static int nearByPosition = 0;
public static Double nearestDistance = 999999.0;
public static String selectedStopId;
public static String selectedStopName;
public static String[][] routeResult ;
public static String[][] nearByStops = null;
public static Double latDouble=0.0;
public static Double longDouble=0.0;
//public static String[] colors = {"#fcfcfc" , "#ececec"};
public static String[] colors = {"#ffffff" , "#efefef"};
public static String[] _stopLat = null;
public static String[] _stopLon = null;
public static PopupWindow popupWindow;
public static Dialog dialog;
public static boolean _callFromMyroute = false;
public static void init(Context context, String tripID, String routeName, String routeLongName, String frequency,boolean callFromMyroute)
{
try{
m_context = context;
_callFromMyroute = callFromMyroute;
_tripID = tripID;
_routeLongName = routeLongName;
_routeName = routeName;
_freq = Integer.parseInt(frequency);
//nearByPosition = 0;
int min = _freq / 60;
(( TextView ) ((Activity)m_context).findViewById( com.best.ui.R.id._routename )).setText(_routeName);
(( TextView ) ((Activity)m_context).findViewById( com.best.ui.R.id._routelongname )).setText(_routeLongName);
(( TextView ) ((Activity)m_context).findViewById( com.best.ui.R.id._freq)).setText(Funcs.secondsToMinHr(_freq));
// if(min > 0)
// {
// if(_freq % 60 > 0)
// (( TextView ) ((Activity)m_context).findViewById( com.best.ui.R.id._freq)).setText(min +"min "+_freq % 60 + " sec");
// else
// (( TextView ) ((Activity)m_context).findViewById( com.best.ui.R.id._freq)).setText(min +"min ");
// }
// else
// (( TextView ) ((Activity)m_context).findViewById( com.best.ui.R.id._freq)).setText(_freq + " sec");
layoutInflater = (LayoutInflater) m_context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(com.best.ui.R.layout.popup, null);
dialog = new Dialog(m_context);
dialog.setContentView(popupView,new LayoutParams(350 , LayoutParams.WRAP_CONTENT));
dialog.setTitle("Select Stop as:");
dialog.setCancelable(true);
if(callFromMyroute == true)
{
final TextView selectAsSource = ( TextView ) dialog.findViewById( com.best.ui.R.id.as_source );
if(selectAsSource != null)
{
selectAsSource.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putString( "frmLoc" , selectedStopName );
bundle.putInt( "position" , 4 );
bundle.putInt( "EditText" , 1 );
bundle.putString( "stopId" , selectedStopId );
Find.contentChanged = false;
Find.sourceStop = selectedStopName;
Find._sourceStopId = selectedStopId;
Find.flagSourceSel = 1;
Find.callFromNearTripRoute = true;
dialog.dismiss();
((Activity)m_context).setContentView( com.best.ui.R.layout.find );
Find.nearByBusClick = false;
}
});
}
else
{System.out.println("TextView NULL");}
final TextView selectAsDest = ( TextView ) dialog.findViewById( com.best.ui.R.id.as_dest );
selectAsDest.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
Bundle b = new Bundle();
b.putString( "frmLoc" , selectedStopName );
b.putInt( "position" , 5 );
b.putInt( "EditText" , 2 );
b.putString( "stopId" , selectedStopId );
Find.contentChanged = false;
Find.destStop = selectedStopName;
Find._destStopId = selectedStopId;
Find.flagDestSel = 1;
Find.callFromNearTripRoute = true;
dialog.dismiss();
((Activity)m_context).setContentView( com.best.ui.R.layout.find );
Find.nearByBusClick = false;
// Intent intent = new Intent(m_context, MainTab.class);
// ((Activity)m_context).startActivityForResult(intent,6);
// ((Activity)m_context).finish();
// setResult( 6, intent );
// finish();
// me.finish();
}
});
}
if( Best.m_latitude.length() > 0 && Best.m_longitude.length() > 0 )
{
latDouble = Double.valueOf( Best.m_latitude );//Double.valueOf( "40.45939" );
longDouble = Double.valueOf( Best.m_longitude );//Double.valueOf( "-3.78429" );
nearByStops = GTStore_sqlite.getNearByStops( latDouble, longDouble);
// for(int i = 0 ;i < nearByStops.length; i++)
// {
// if(nearestDistance > Double.valueOf(nearByStops[i][2]))
// {
// nearestStopID = nearByStops[i][0];
// nearestDistance = Double.valueOf(nearByStops[i][2]);
// }
// }
}
Best.showProcessing(m_context, "Processing","Please wait..." );
TripInfoThread tripInfoThread = new TripInfoThread( tripInfoHandler );
tripInfoThread.start();
}
catch(Exception e)
{Best.showMessage(m_context,e.toString(),"EXCEPTION");}
}
public static Handler tripInfoHandler = new Handler() {
public void handleMessage(Message msg) {
Bundle dataBundle = msg.getData();
Best.dissmissProcessing();
routeResult = ( String[][] )dataBundle.getSerializable( "rts" );
if( routeResult != null && routeResult.length > 0)
{
_stopLat = new String[routeResult.length];
_stopLon = new String[routeResult.length];
for(int i = 0; i< routeResult.length ; i++)
{
_stopLat[i] = routeResult[i][3];
_stopLon[i] = routeResult[i][4];
}
EfficientAdapter adapter = new EfficientAdapter( m_context,routeResult);
//(((ListActivity)m_context).getListView()).setListAdapter( adapter );
( ( ListView )((Activity)m_context).findViewById( com.best.ui.R.id.routeslist ) ).setAdapter( adapter );
System.out.println("SDK VERSION ========="+android.os.Build.VERSION.SDK_INT );
if(nearByStops != null)
{
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT)
{
System.out.println("SDK VERSION = "+android.os.Build.VERSION.SDK_INT);
// ( ( ListView )((Activity)m_context).findViewById( com.best.ui.R.id.routeslist ) ).smoothScrollToPosition (nearByPosition); //method smoothScrollToPosition is since API level 8.
}
System.out.println("NEAR BU POSITION="+nearByPosition);
}
}
else
Best.showMessage( m_context, com.best.ui.R.string.txtSmthingWentWrong, _tripID );
}
};
private static class TripInfoThread extends Thread
{
Handler _handler;
TripInfoThread(Handler handler )
{
_handler = handler;
}
public void run()
{
//code to get all routes
Bundle dataBundle = new Bundle();
dataBundle.putSerializable( "rts", GTStore_sqlite.getTripInfo(_tripID));
Message msg = _handler.obtainMessage();
msg.setData( dataBundle );
_handler.sendMessage( msg );
}
}
public static class EfficientAdapter extends BaseAdapter implements Filterable {
public String[][] result;
public int resultSetLength;
public EfficientAdapter(Context context, String[][] resultSet)
{
mInflater = LayoutInflater.from( context );
result = new String[resultSet.length][];
result=resultSet;
resultSetLength = resultSet.length;
if(resultSet == null)
Best.showError(context ,com.best.ui.R.string.txtSmthingWentWrong);
}
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null)
{
convertView = mInflater.inflate(com.best.ui.R.layout.list_double_line, 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);
holder.stop_area = (TextView) convertView.findViewById(com.best.ui.R.id.stoparea);
holder.stop_road = (TextView) convertView.findViewById(com.best.ui.R.id.stoproad);
convertView.setTag(holder);
}
else
holder = (ViewHolder) convertView.getTag();
holder.stop_name.setText(result[position][0]);
holder.stop_area.setText(result[position][5]);
holder.stop_road.setText(result[position][6]);
boolean nearby = false;
int i = 0;
if(nearByStops != null)
{
for(i = 0; i < nearByStops.length; i++)
{
if(result[position][1].equals(nearByStops[i][0]))
{
nearby = true;
// if(nearestDistance > Double.valueOf(nearByStops[i][2]))
// {
// nearestStopID = nearByStops[i][0];
// nearestDistance = Double.valueOf(nearByStops[i][2]);
// }
break;
}
}
}
if(position == 0 )
{
holder.dep_time.setText(Html.fromHtml("<font color = 'Green'>"+"Starting point"+"</font>"));
//holder.stop_name.setText(Html.fromHtml("<font color = 'black'>"+"Bus starts at: "+"</font>"+"<font color = 'DarkSlateBlue'>"+result[position][0]+"</font>"));
convertView.setBackgroundColor(Color.parseColor("#e6ffe6"));
}
else if(position == (resultSetLength - 1) )
{
holder.dep_time.setText(Html.fromHtml("<font color = 'Blue'>"+"End Station"+"</font>"));
convertView.setBackgroundColor(Color.parseColor("#e1e1ff"));
}
else if(nearby == true)
{
// if(nearByPosition == 0)
nearByPosition = position;
convertView.setBackgroundColor(Color.parseColor("#d4b6d4")); //0xffcccccc
holder.dep_time.setText(Html.fromHtml("<font color = 'Blue'>"+"Close to you"+"</font>"));
}
else
{
convertView.setBackgroundColor(Color.parseColor(colors[position % colors.length]));
holder.dep_time.setText("");
}
convertView.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
selectedStopId = result[position][1];
selectedStopName = result[position][0];
if(_callFromMyroute)
dialog.show();
//popupWindow.showAsDropDown(v);
//popupMenu.show();
System.out.println("Selected Stop:"+result[position][0]);
return (true);
}
});
return convertView;
}
public class ViewHolder {
TextView stop_name;
TextView dep_time;
TextView stop_area;
TextView stop_road;
}
@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;
}
}
}

View File

@ -0,0 +1,219 @@
package com.best.ui;
import java.util.List;
import java.util.ArrayList;
import android.app.Activity;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.Filterable;
import android.widget.Filter;
import android.widget.AbsListView;
import android.widget.ImageView;
import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.view.View.OnClickListener;
import android.text.Html;
import android.content.Intent;
import android.content.Context;
import com.best.util.Funcs;
import com.best.util.TransitionEffect;
public class Routing {
//public static ListActivity me;
public static Context m_context;
public static LayoutInflater mInflater;
public static String scrStopId , destStopId;
public static String sourceStopName = "";
public static String destStopName = "";
public static String[] routes , routeNames ,busHead, totalDist,no_Stops ,busFreq ,tripId = new String[5];
public static boolean routeDisplayed = false;
public static void init(Context context)
{
m_context = context;
routeDisplayed = false;
tripId = Find.tripIdList.toArray( new String[ Find.tripIdList.size() ] ) ;
routeNames = Find.routeNamesList.toArray( new String[ Find.routeNamesList.size() ] ) ;
busHead = Find.busHeadList.toArray( new String[ Find.busHeadList.size() ] ) ;
busFreq = Find.busFreqList.toArray( new String[ Find.busFreqList.size() ] ) ;
totalDist = Find.totalDistList.toArray( new String[ Find.totalDistList.size() ] ) ;
no_Stops = Find.no_StopsList.toArray( new String[ Find.no_StopsList.size() ]) ;
scrStopId = Find._sourceStopId;
destStopId = Find._destStopId;
sourceStopName = Find.sourceStop;
destStopName = Find.destStop;
((TextView) ((Activity)m_context).findViewById(com.best.ui.R.id.search_for)).setText(Html.fromHtml("<font color = 'Red'>Search Results for : </font><font color = 'Black'>"+sourceStopName+" to "+destStopName+"</font>"));
EfficientAdapter adapter = new EfficientAdapter( m_context );
try{
if(adapter != null && context != null && routeDisplayed == false)
{
( ( ListView )((Activity)m_context).findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
}
else if(context != null)
Best.log("ADAPTER IS NULL");
else
Best.log("CONTEXT IS NULL");
}
catch(Exception e){e.printStackTrace();}
}
public static class EfficientAdapter extends BaseAdapter implements Filterable {
public EfficientAdapter(Context context)
{
if(routeNames!= null && routeNames.length > 0)
{
mInflater = LayoutInflater.from( context );
}
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if(routeNames!= null)
{
if (convertView == null)
{
convertView = mInflater.inflate(com.best.ui.R.layout.list_button, null);
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.total_dist = (TextView) convertView.findViewById(com.best.ui.R.id.totaldist);
holder.bus_freq = (TextView) convertView.findViewById(com.best.ui.R.id.bus_freq);
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);
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putString( "tripID" , tripId[position] );
bundle.putString( "sourceID" , scrStopId);
bundle.putString( "destID" ,destStopId);
bundle.putString("routeLongName",busHead[position]);
bundle.putString("routeName",routeNames[position]);
bundle.putString("freq",busFreq[position]);
bundle.putBoolean( "showFullRoute" ,false);
Intent intent = new Intent(m_context, Routes.class);
routeDisplayed = true;
intent.putExtras( bundle );
((Activity)m_context).startActivityForResult(intent,6);
}
});
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
String _routeName = routeNames[position];
String _headerName = busHead[position];
String _betweenStopsNum = no_Stops[position];
int freq = freq = Integer.parseInt(busFreq[position]);
holder.bus_freq.setText(Funcs.secondsToMinHr(freq));
// int min = freq / 60;
// if(min > 0)
// {
// if(freq % 60 > 0)
// holder.bus_freq.setText(min +"min "+freq % 60 + " sec");
// else
// holder.bus_freq.setText(min +"min ");
// }
// else
// holder.bus_freq.setText(freq + " sec");
int _distance = 0;
try{ _distance = Integer.parseInt( totalDist[position] ); }catch(Exception e){}
holder.routename.setText( _routeName );
holder.head.setText( _headerName );
if( _distance > 1000)
{
if( _distance == 0 )
{
holder.total_dist.setText( "NA");
}
else
{
String dist = Double.toString(Funcs.roundDouble((Double.parseDouble(_distance+"")/1000), 1));
holder.total_dist.setText( dist +" km");
}
}
else
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 (null);
}
public class ViewHolder {
TextView routename;
TextView head;
ImageView blue_bus;
TextView total_dist;
TextView bus_freq ;
TextView no_of_stops;
}
@Override
public Filter getFilter() {
return null;
}
@Override
public int getCount() {
if(routeNames != null)
return routeNames.length;
else
return 0;
}
@Override
public Object getItem(int position) {
if(routeNames != null)
return routeNames[position];
else
return (null);
}
@Override
public long getItemId(int position) {
return 0;
}
}
}

View File

@ -0,0 +1,241 @@
////////////////////////////////////////////////
//
// A ChaloBEST (http://chalobest.in/) initiative
// Author: Nikita (Macgregor Techknowlogy)
// License: GPLv3
//
//
package com.best.ui;
import android.app.Activity;
import android.app.ListActivity;
import android.os.Bundle;
import android.os.Message;
import android.os.Handler;
import android.content.Intent;
import android.content.Context;
import android.widget.Button;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Filterable;
import android.widget.Filter;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import com.best.data.GTStore_sqlite;
import com.best.util.TransitionEffect;
import java.math.RoundingMode;
import java.math.BigDecimal;
import java.math.MathContext;
public class Search extends Activity
{
public static Activity me = null;
public static Context m_context;
public static LayoutInflater mInflater;
public int EditTextNo;
public static boolean _callFromStops = false;
public static String[] stopNames;
public static String[] stopsRoad;
public static String[] stopsArea;
public static String[] stopID;
public static String searchtxt;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate( savedInstanceState );
//overridePendingTransition( R.anim.fade_in, R.anim.fade_out );
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT) {
TransitionEffect.callOverridePendingTransition(this);
}
me = this;
m_context = this;
me.setContentView( com.best.ui.R.layout.search );
setTitle(com.best.ui.R.string.txtSearchFor);
Intent intent = me.getIntent();
_callFromStops = intent.getBooleanExtra("callFromStops" , false);
init();
}
public void init()
{
final Button btnSearch = ( Button ) me.findViewById( com.best.ui.R.id.search );
final EditText txtSearch = (EditText) findViewById(com.best.ui.R.id.searchtxt);
btnSearch.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
searchtxt = txtSearch.getText().toString();
if(searchtxt != null && searchtxt.length() > 0)
{
if(_callFromStops == true)
{
Best.showProcessing( m_context, "Searching","Please wait while searching.." );
StopSearchThread thread = new StopSearchThread( searchStopsHandler, searchtxt);
thread.start();
}
else
{
Best.showProcessing( m_context, "Searching","Please wait while searching.." );
BusSearchThread thread = new BusSearchThread( searchBusHandler, searchtxt);
thread.start();
}
}
}
});
}
public Handler searchStopsHandler = new Handler() {
public void handleMessage(Message msg) {
Bundle dataBundle = msg.getData();
String[][] resultSet = (String[][]) dataBundle.getSerializable( "resultSet" );
Best.dissmissProcessing();
if( resultSet!=null && resultSet.length > 0 )
{
System.out.println("SEARCH RESULT LENGTH = "+resultSet.length );
String[] stopIDs = new String[resultSet.length];
String[] stopNames = new String[resultSet.length];
String[] stopRoad = new String[resultSet.length];
String[] stopArea = new String[resultSet.length];
for(int i = 0; i < resultSet.length;i++)
{
stopIDs[i] = resultSet[i][0];
stopNames[i] = resultSet[i][1];
stopRoad[i] = resultSet[i][2];
stopArea[i] = resultSet[i][3];
}
Intent mIntent = new Intent();
Bundle bundle = new Bundle();
bundle.putStringArray( "StopId" , stopIDs );
bundle.putStringArray( "StopName" , stopNames );
bundle.putStringArray( "StopRoad" , stopRoad );
bundle.putStringArray( "StopArea" , stopArea );
bundle.putString( "searchtxt" , searchtxt);
mIntent.putExtras( bundle );
setResult( 0, mIntent );
finish();
}
else
{
Best.showMessage( m_context, com.best.ui.R.string.errMsgNoStopsMatch, "Message" );
}
}
};
private class StopSearchThread extends Thread
{
Handler _handler;
String _txtSearch = "";
StopSearchThread(Handler handler, String txtSearch)
{
_handler = handler;
_txtSearch = txtSearch;
}
public void run()
{
String[][] resultSet = null;
try{
resultSet = GTStore_sqlite.getAllStopsByText( _txtSearch, 0.0, 0.0 );
}catch(Exception e){System.out.println("Excp2: " + e.toString() );}
Bundle dataBundle = new Bundle();
dataBundle.putSerializable( "resultSet", resultSet );
Message msg = _handler.obtainMessage();
msg.setData( dataBundle );
_handler.sendMessage( msg );
}
}
public Handler searchBusHandler = new Handler() {
public void handleMessage(Message msg) {
Bundle dataBundle = msg.getData();
String[][] resultSet = (String[][]) dataBundle.getSerializable( "resultSet" );
Best.dissmissProcessing();
if( resultSet!=null && resultSet.length > 0 )
{
System.out.println("SEARCH RESULT LENGTH = "+resultSet.length );
String[] routeID = new String[resultSet.length];
String[] tripID = new String[resultSet.length];
String[] routeLongName = new String[resultSet.length];
String[] routeName = new String[resultSet.length];
String[] tripFreq = new String[resultSet.length];
for(int i = 0; i < resultSet.length;i++)
{
routeID[i] = resultSet[i][0];
tripID[i] = resultSet[i][1];
routeLongName[i] = resultSet[i][2];
routeName[i] = resultSet[i][3];
tripFreq[i] = resultSet[i][4];
}
Intent mIntent = new Intent();
Bundle bundle = new Bundle();
bundle.putStringArray( "routeID" , routeID );
bundle.putStringArray( "tripID" , tripID );
bundle.putStringArray( "routeLongName" , routeLongName );
bundle.putStringArray( "routeName" , routeName );
bundle.putStringArray( "tripFreq" , tripFreq );
bundle.putString( "searchtxt" , searchtxt);
mIntent.putExtras( bundle );
setResult( 0, mIntent );
finish();
}
else
{
Best.showMessage( m_context, com.best.ui.R.string.errMsgNoBusMatch, "Message" );
}
}
};
private class BusSearchThread extends Thread
{
Handler _handler;
String _txtSearch = "";
BusSearchThread(Handler handler, String txtSearch)
{
_handler = handler;
_txtSearch = txtSearch;
}
public void run()
{
String[][] resultSet = null;
try{
resultSet = GTStore_sqlite.getAllTripsByText( _txtSearch);
}catch(Exception e){System.out.println("Excp2: " + e.toString() );}
Bundle dataBundle = new Bundle();
dataBundle.putSerializable( "resultSet", resultSet );
Message msg = _handler.obtainMessage();
msg.setData( dataBundle );
_handler.sendMessage( msg );
}
}
}

View File

@ -0,0 +1,567 @@
////////////////////////////////////////////////
//
// A ChaloBEST (http://chalobest.in/) initiative
// Author: Nikita (Macgregor Techknowlogy)
// License: GPLv3
//
//
package com.best.ui;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Message;
import android.os.Handler;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.ImageView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.EditText;
import android.widget.Button;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Filterable;
import android.widget.Filter;
import android.content.res.Configuration;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MenuInflater;
import android.view.View.OnClickListener;
import com.best.data.GTStore_sqlite;
import com.best.util.TransitionEffect;
import java.util.List;
import java.util.ArrayList;
import android.graphics.Color;
import android.text.Html;
import android.view.KeyEvent;
public class Stops extends Activity {
public static Activity me;
public static Context m_context;
public static LayoutInflater mInflater;
public static boolean tripsDisplayed = false;
public static boolean tripsRouteDisplayed = false;
public static boolean searchResultDisplayed = false;
public static String _selectedStopID = null;
public static String _selectedStopName = "";
public static String searchtext = "";
public static String[] colors = {"#fcfcfc" , "#ececec"};
public static String[][] _stopsResult, stopsResult;
public static String[][] tripsResult ;
public static boolean showFullRoute = true;
public void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT)
TransitionEffect.callOverridePendingTransition(this);
//overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
me = this;
m_context = this;
me.setContentView( com.best.ui.R.layout.stops );
mInflater = LayoutInflater.from(m_context);
init( );
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return true;
}
@Override
public boolean onPrepareOptionsMenu (Menu menu){
MenuInflater inflater = getMenuInflater();
menu.clear();
if(tripsDisplayed == false && tripsRouteDisplayed == false && searchResultDisplayed == false)
{
inflater.inflate(com.best.ui.R.menu.search, menu);
return true;
}
else if(tripsDisplayed == true && tripsRouteDisplayed == true)
{
inflater.inflate(com.best.ui.R.menu.onlymap, menu);
return true;
}
return false;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case com.best.ui.R.id.mnusearch:
Intent intent = new Intent(m_context, Search.class);
intent.putExtra( "callFromStops" , true );
me.startActivityForResult( intent, 5 );
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 intent1 = new Intent(m_context, Map.class);
intent1.putExtras( bundle1 );
me.startActivityForResult(intent1,5);
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try{
Bundle bundle = data.getExtras();
String[] stopID = bundle.getStringArray( "StopId" );
String[] stopName = bundle.getStringArray( "StopName" );
String[] stopRoad = bundle.getStringArray( "StopRoad" );
String[] stopArea = bundle.getStringArray( "StopArea" );
searchtext = bundle.getString( "searchtxt");
stopsResult = new String[stopID.length][4];
for(int i = 0; i < stopID.length ; i++)
{
stopsResult[i][0] = stopID[i];
stopsResult[i][1] = stopName[i];
stopsResult[i][2] = stopRoad[i];
stopsResult[i][3] = stopArea[i];
}
me.setContentView( com.best.ui.R.layout.routing );
EfficientAdapter adapter = new EfficientAdapter( m_context , stopsResult);
( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
( ( TextView ) me.findViewById( com.best.ui.R.id.search_for ) ).setText("Search Result for : " + searchtext);
searchResultDisplayed = true ;
}
catch(Exception e)
{
Best.log("Exception-"+e.toString());
}
}
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()
{
System.out.println("STOPS=========ON BACK PRESS====");
if(tripsDisplayed == true && tripsRouteDisplayed == false && searchResultDisplayed == false)
{
me.setContentView(com.best.ui.R.layout.stops );
tripsDisplayed = false;
init();
}
else if(tripsRouteDisplayed == true && tripsDisplayed == true && searchResultDisplayed == false)
{
me.setContentView( com.best.ui.R.layout.routing );
tripsRouteDisplayed = false;
EfficientAdapterTrip adapter = new EfficientAdapterTrip( m_context);
( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
( ( TextView ) me.findViewById( com.best.ui.R.id.search_for ) ).setText("Buses Available from : "+_selectedStopName);
}
else if(searchResultDisplayed == true && tripsDisplayed == true && tripsRouteDisplayed == true)
{
me.setContentView( com.best.ui.R.layout.routing );
tripsRouteDisplayed = false;
EfficientAdapterTrip adapter = new EfficientAdapterTrip( m_context);
( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
( ( TextView ) me.findViewById( com.best.ui.R.id.search_for ) ).setText("Buses Available from : "+_selectedStopName);
}
else if(searchResultDisplayed == true && tripsDisplayed == true && tripsRouteDisplayed == false)
{
me.setContentView( com.best.ui.R.layout.routing );
tripsDisplayed = false;
EfficientAdapter adapter = new EfficientAdapter( m_context , stopsResult);
( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
( ( TextView ) me.findViewById( com.best.ui.R.id.search_for ) ).setText("Search Result for : " + searchtext);
}
else if(searchResultDisplayed == true && tripsDisplayed == false && tripsRouteDisplayed == false)
{
me.setContentView(com.best.ui.R.layout.stops );
searchResultDisplayed = false;
init();
}
else
Best.exit( me );
}
// @Override
// public void onBackPressed() {
// System.out.println("STOPS=========ON BACK PRESS====");
// if(tripsDisplayed == true && tripsRouteDisplayed == false && searchResultDisplayed == false)
// {
// me.setContentView(com.best.ui.R.layout.stops );
// tripsDisplayed = false;
// init();
// }
// else if(tripsRouteDisplayed == true && tripsDisplayed == true && searchResultDisplayed == false)
// {
// me.setContentView( com.best.ui.R.layout.routing );
// tripsRouteDisplayed = false;
// EfficientAdapterTrip adapter = new EfficientAdapterTrip( m_context);
// ( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
// ( ( TextView ) me.findViewById( com.best.ui.R.id.search_for ) ).setText("Buses Available from : "+_selectedStopName);
// }
// else if(searchResultDisplayed == true && tripsDisplayed == true && tripsRouteDisplayed == true)
// {
// me.setContentView( com.best.ui.R.layout.routing );
// tripsRouteDisplayed = false;
// EfficientAdapterTrip adapter = new EfficientAdapterTrip( m_context);
// ( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
// ( ( TextView ) me.findViewById( com.best.ui.R.id.search_for ) ).setText("Buses Available from : "+_selectedStopName);
// }
// else if(searchResultDisplayed == true && tripsDisplayed == true && tripsRouteDisplayed == false)
// {
// me.setContentView( com.best.ui.R.layout.routing );
// tripsDisplayed = false;
// EfficientAdapter adapter = new EfficientAdapter( m_context , stopsResult);
// ( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
// ( ( TextView ) me.findViewById( com.best.ui.R.id.search_for ) ).setText("Search Result for : " + searchtext);
// }
// else if(searchResultDisplayed == true && tripsDisplayed == false && tripsRouteDisplayed == false)
// {
// me.setContentView(com.best.ui.R.layout.stops );
// searchResultDisplayed = false;
// init();
// }
// else
// Best.exit( me );
// }
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
public void init()
{
//( ( TextView ) me.findViewById( com.best.ui.R.id.search_for ) ).setVisibility(LinearLayout.GONE);
Best.showProcessing(m_context, "Processing","Please wait..." );
try{
GetStopsThread getStopsThread = new GetStopsThread( getStopsHandler );
getStopsThread.start();
}
catch(Exception e){
Best.dissmissProcessing();
Best.showMessage( m_context, "Sorry something went wrong.", "Processing" );
}
}
public Handler getStopsHandler = new Handler() {
public void handleMessage(Message msg) {
Bundle dataBundle = msg.getData();
Best.dissmissProcessing();
_stopsResult = ( String[][] )dataBundle.getSerializable( "rts" );
if( _stopsResult != null && _stopsResult.length > 0 )
{
EfficientAdapter adapter = new EfficientAdapter( m_context,_stopsResult );
( ( ListView ) me.findViewById( com.best.ui.R.id.stopslist ) ).setAdapter( adapter );
}
}
};
private class GetStopsThread extends Thread
{
Handler _handler;
GetStopsThread(Handler handler )
{
_handler = handler;
}
public void run()
{
//code to get all routes
Bundle dataBundle = new Bundle();
dataBundle.putSerializable( "rts", GTStore_sqlite.getAllStops());
Message msg = _handler.obtainMessage();
msg.setData( dataBundle );
_handler.sendMessage( msg );
}
}
public void getAllTripsPassingByStop(String StopID)
{
_selectedStopID = StopID;
Best.showProcessing(m_context, "Processing","Please wait..." );
TripsSearchThread tripsSearchThread = new TripsSearchThread( searchTripsHandler );
tripsSearchThread.start();
}
public Handler searchTripsHandler = new Handler() {
public void handleMessage(Message msg) {
Bundle dataBundle = msg.getData();
Best.dissmissProcessing();
tripsResult = ( String[][] )dataBundle.getSerializable( "rts" );
if(tripsResult != null && tripsResult.length > 0 )
{
( ( TextView ) me.findViewById( com.best.ui.R.id.search_for ) ).setText("Buses Available from : "+_selectedStopName);
EfficientAdapterTrip adapter = new EfficientAdapterTrip( m_context);
( ( ListView ) me.findViewById( com.best.ui.R.id.routinglist ) ).setAdapter( adapter );
//me.setListAdapter( adapter );
}
else
{
//Best.showMessage( m_context, "There are no routes to show.", "Processing" );
( ( TextView ) me.findViewById( com.best.ui.R.id.search_for ) ).setText("Sorry...Stop data not available..");
}
}
};
private class TripsSearchThread extends Thread
{
Handler _handler;
TripsSearchThread(Handler handler )
{
_handler = handler;
}
public void run()
{
//code to get all routes
Bundle dataBundle = new Bundle();
try
{
if(_selectedStopID != null)
{
String [][] _res = GTStore_sqlite.getAllTripsPassingByStop(_selectedStopID);
dataBundle.putSerializable( "rts", _res );
Message msg = _handler.obtainMessage();
msg.setData( dataBundle );
_handler.sendMessage( msg );
}
}
catch(Exception e){Best.dissmissProcessing(); e.printStackTrace();
}
}
}
public class EfficientAdapter extends BaseAdapter implements Filterable {
public String[][] result;
public EfficientAdapter(Context context, String[][] resultSet)
{
mInflater = LayoutInflater.from( context );
result = new String[resultSet.length][];
result=resultSet;
if(resultSet == null)
Best.showError(context ,"Sorry.. Something went wrong..");
}
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null)
{
convertView = mInflater.inflate(com.best.ui.R.layout.list_double_line, null);
holder = new ViewHolder();
holder.stop_name = (TextView) convertView.findViewById(com.best.ui.R.id.stopname);
holder.stop_road = (TextView) convertView.findViewById(com.best.ui.R.id.stoproad);
holder.stop_area = (TextView) convertView.findViewById(com.best.ui.R.id.stoparea);
holder.dep_time = (TextView) convertView.findViewById(com.best.ui.R.id.dep);
convertView.setTag(holder);
}
else
holder = (ViewHolder) convertView.getTag();
holder.stop_name.setText(result[position][1]);
holder.stop_area.setText(result[position][3]);
holder.stop_road.setText(result[position][2]);
//convertView.setBackgroundColor(Color.parseColor(colors[position % colors.length]));
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
tripsDisplayed = true;
me.setContentView( com.best.ui.R.layout.routing );
getAllTripsPassingByStop(result[position][0]);
_selectedStopName = result[position][1];
}
});
return convertView;
}
public class ViewHolder {
TextView stop_name;
TextView stop_area;
TextView stop_road;
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 EfficientAdapterTrip extends BaseAdapter implements Filterable {
public EfficientAdapterTrip(Context context)
{
if(tripsResult!= null)
{
mInflater = LayoutInflater.from( context );
}
}
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if(tripsResult!= null)
{
if (convertView == null)
{
convertView = mInflater.inflate(com.best.ui.R.layout.list_route, null);
holder = new ViewHolder();
holder.head = (TextView) convertView.findViewById(com.best.ui.R.id.bushead);
holder.blue_bus = (ImageView) convertView.findViewById(com.best.ui.R.id.busBlue);
holder.routeName = (TextView) convertView.findViewById(com.best.ui.R.id.routename);
convertView.setTag(holder);
}
else
holder = (ViewHolder) convertView.getTag();
holder.head.setText( tripsResult[position][3] );
holder.routeName.setText( tripsResult[position][4] );
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putString( "tripID" , tripsResult[position][2] );
bundle.putString("routeLongName",tripsResult[position][3]);
bundle.putString("routeName",tripsResult[position][4]);
Best.log("CLICKED POSITION :"+ position);
tripsRouteDisplayed = true;
me.setContentView( com.best.ui.R.layout.routes );
//NearTripRoute object = new NearTripRoute();
NearTripRoute.init(m_context,tripsResult[position][2],tripsResult[position][4],tripsResult[position][3],tripsResult[position][5],false);
}
});
return convertView;
}
return (null);
}
public class ViewHolder {
TextView head;
TextView routeName;
ImageView blue_bus;
}
@Override
public Filter getFilter() {
return null;
}
@Override
public int getCount() {
if(tripsResult != null)
return tripsResult.length;
else
return 0;
}
@Override
public Object getItem(int position) {
if(tripsResult != null)
return tripsResult[position];
else
return (null);
}
@Override
public long getItemId(int position) {
return 0;
}
}
}

View File

@ -61,7 +61,7 @@
<file leaf-file-name="CZipCreate.java" pinned="false" current="true" current-in-tab="true"> <file leaf-file-name="CZipCreate.java" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/ZipGen/src/CZipCreate.java"> <entry file="file://$PROJECT_DIR$/ZipGen/src/CZipCreate.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="20" column="71" selection-start="575" selection-end="575" vertical-scroll-proportion="0.37037036"> <state line="20" column="71" selection-start="575" selection-end="575" vertical-scroll-proportion="0.95238096">
<folding> <folding>
<element signature="n#!!doc" expanded="true" /> <element signature="n#!!doc" expanded="true" />
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
@ -88,10 +88,10 @@
<option name="jreName" value="1.6" /> <option name="jreName" value="1.6" />
</component> </component>
<component name="ProjectFrameBounds"> <component name="ProjectFrameBounds">
<option name="x" value="-8" /> <option name="x" value="149" />
<option name="y" value="-8" /> <option name="y" value="124" />
<option name="width" value="1382" /> <option name="width" value="897" />
<option name="height" value="744" /> <option name="height" value="559" />
</component> </component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false"> <component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" /> <OptionsSetting value="true" id="Add" />
@ -340,14 +340,14 @@
<servers /> <servers />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="-8" y="-8" width="1382" height="744" extended-state="6" /> <frame x="149" y="124" width="897" height="559" extended-state="0" />
<editor active="true" /> <editor active="false" />
<layout> <layout>
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="JetGradle" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> <window_info id="JetGradle" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.3989726" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.5839599" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" /> <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
@ -356,7 +356,7 @@
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.15781488" sideWeight="0.60102737" order="0" side_tool="false" content_ui="combo" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24969988" sideWeight="0.4160401" order="0" side_tool="false" content_ui="combo" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32876712" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32876712" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
@ -426,7 +426,7 @@
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/ZipGen/src/CZipCreate.java"> <entry file="file://$PROJECT_DIR$/ZipGen/src/CZipCreate.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="20" column="71" selection-start="575" selection-end="575" vertical-scroll-proportion="0.37037036"> <state line="20" column="71" selection-start="575" selection-end="575" vertical-scroll-proportion="0.95238096">
<folding> <folding>
<element signature="n#!!doc" expanded="true" /> <element signature="n#!!doc" expanded="true" />
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />