Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
5
5711403296
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paded
5711403296
Commits
c4d7463f
Commit
c4d7463f
authored
Jan 25, 2018
by
Paded
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return bus success
parent
396711c0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
9 deletions
+68
-9
CreateAccountActivity.java
...er/paded/com/ubontransitdriver/CreateAccountActivity.java
+39
-6
MainActivity.java
...ansitdriver/paded/com/ubontransitdriver/MainActivity.java
+0
-0
ProfileSettingActivity.java
...r/paded/com/ubontransitdriver/ProfileSettingActivity.java
+6
-1
TrackerService.java
...sitdriver/paded/com/ubontransitdriver/TrackerService.java
+13
-1
TrackerService3.java
...itdriver/paded/com/ubontransitdriver/TrackerService3.java
+10
-1
No files found.
app/src/main/java/ubontransitdriver/paded/com/ubontransitdriver/CreateAccountActivity.java
View file @
c4d7463f
...
...
@@ -55,6 +55,8 @@ public class CreateAccountActivity extends AppCompatActivity implements ItemAdap
BottomSheetBehavior
behavior
;
ArrayList
<
String
>
items
;
Map
<
String
,
String
>
myLine
;
String
start_busstop_id
;
String
stop_busstop_id
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -269,8 +271,9 @@ public class CreateAccountActivity extends AppCompatActivity implements ItemAdap
}
public
void
insertData
(
String
uid
,
String
name
,
String
select_bus
){
public
void
insertData
(
final
String
uid
,
final
String
name
,
String
select_bus
){
String
busid
=
""
;
if
(
select_bus
.
equalsIgnoreCase
(
"สาย ม."
)){
busid
=
"B00"
;
}
else
if
(
select_bus
.
equalsIgnoreCase
(
"สาย 1"
)){
...
...
@@ -293,11 +296,41 @@ public class CreateAccountActivity extends AppCompatActivity implements ItemAdap
busid
=
"B012"
;
}
FirebaseDatabase
database
=
FirebaseDatabase
.
getInstance
();
DatabaseReference
myRef
=
database
.
getReference
(
"users/"
+
uid
);
myRef
.
child
(
"name"
).
setValue
(
name
);
myRef
.
child
(
"bus_id"
).
setValue
(
busid
);
myRef
.
child
(
"status"
).
setValue
(
"on"
);
DatabaseReference
keyReference
=
FirebaseDatabase
.
getInstance
().
getReference
().
child
(
"allbus/"
+
busid
);
final
String
finalBusid
=
busid
;
keyReference
.
addValueEventListener
(
new
ValueEventListener
()
{
@Override
public
void
onDataChange
(
DataSnapshot
dataSnapshot
)
{
String
x
=
dataSnapshot
.
child
(
"bus_stop"
).
getValue
(
String
.
class
);
// String string = dataSnapshot.getValue(String.class);
String
[]
bus_stop
=
x
.
split
(
","
);
int
bus_stop_size
=
bus_stop
.
length
;
// String start_stop_busstop[] = new String[2];
// start_stop_busstop[0] = bus_stop[0];
// start_stop_busstop[1] = bus_stop[bus_stop_size - 1];
start_busstop_id
=
bus_stop
[
0
];
stop_busstop_id
=
bus_stop
[
bus_stop_size
-
1
];
FirebaseDatabase
database
=
FirebaseDatabase
.
getInstance
();
DatabaseReference
myRef
=
database
.
getReference
(
"users/"
+
uid
);
myRef
.
child
(
"name"
).
setValue
(
name
);
myRef
.
child
(
"bus_id"
).
setValue
(
finalBusid
);
myRef
.
child
(
"status"
).
setValue
(
"off"
);
myRef
.
child
(
"start_busstop"
).
setValue
(
start_busstop_id
);
myRef
.
child
(
"stop_busstop"
).
setValue
(
stop_busstop_id
);
}
@Override
public
void
onCancelled
(
DatabaseError
databaseError
)
{
Log
.
d
(
TAG
,
"Read failed"
);
}
});
Log
.
d
(
TAG
,
"insertData: "
+
start_busstop_id
);
Log
.
d
(
TAG
,
"insertData: "
+
stop_busstop_id
);
}
@Override
...
...
app/src/main/java/ubontransitdriver/paded/com/ubontransitdriver/MainActivity.java
View file @
c4d7463f
This diff is collapsed.
Click to expand it.
app/src/main/java/ubontransitdriver/paded/com/ubontransitdriver/ProfileSettingActivity.java
View file @
c4d7463f
package
ubontransitdriver
.
paded
.
com
.
ubontransitdriver
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.support.annotation.NonNull
;
import
android.support.v7.app.AppCompatActivity
;
...
...
@@ -44,8 +45,12 @@ public class ProfileSettingActivity extends AppCompatActivity {
progressBar
.
setVisibility
(
View
.
GONE
);
// user auth state is changed - user is null
// launch login activity
startActivity
(
new
Intent
(
ProfileSettingActivity
.
this
,
LoginActivity
.
class
));
Intent
returnIntent
=
new
Intent
();
returnIntent
.
putExtra
(
"logout"
,
true
);
setResult
(
Activity
.
RESULT_OK
,
returnIntent
);
finish
();
// startActivity(new Intent(ProfileSettingActivity.this, LoginActivity.class));
// finish();
}
}
};
...
...
app/src/main/java/ubontransitdriver/paded/com/ubontransitdriver/TrackerService.java
View file @
c4d7463f
...
...
@@ -28,6 +28,12 @@ import com.google.android.gms.location.LocationServices;
import
com.google.firebase.database.DatabaseReference
;
import
com.google.firebase.database.FirebaseDatabase
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.TimeZone
;
public
class
TrackerService
extends
Service
{
private
static
final
String
TAG
=
"GPS2"
;
private
boolean
isRunning
=
false
;
...
...
@@ -144,7 +150,13 @@ public class TrackerService extends Service {
Log
.
d
(
TAG
,
"location update "
+
location
);
ref
.
child
(
"latitude"
).
setValue
(
location
.
getLatitude
());
ref
.
child
(
"longitude"
).
setValue
(
location
.
getLongitude
());
ref
.
child
(
"time"
).
setValue
(
location
.
getTime
());
Calendar
c
=
Calendar
.
getInstance
();
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
formattedDate
=
df
.
format
(
c
.
getTime
());
Log
.
d
(
"dddd"
,
"onLocationResult: "
+
formattedDate
);
ref
.
child
(
"time"
).
setValue
(
formattedDate
);
}
}
...
...
app/src/main/java/ubontransitdriver/paded/com/ubontransitdriver/TrackerService3.java
View file @
c4d7463f
...
...
@@ -23,6 +23,7 @@ import com.google.android.gms.location.LocationServices;
import
com.google.firebase.database.DatabaseReference
;
import
com.google.firebase.database.FirebaseDatabase
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
...
...
@@ -44,6 +45,7 @@ public class TrackerService3 extends Service implements
@Override
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
Log
.
d
(
"dddd"
,
"onStartCommand: "
);
user_id
=
intent
.
getStringExtra
(
"user_id"
);
bus_id
=
intent
.
getStringExtra
(
"bus_id"
);
destination
=
intent
.
getStringExtra
(
"destination"
);
...
...
@@ -96,7 +98,14 @@ public class TrackerService3 extends Service implements
DatabaseReference
ref
=
FirebaseDatabase
.
getInstance
().
getReference
(
path
);
ref
.
child
(
"latitude"
).
setValue
(
location
.
getLatitude
());
ref
.
child
(
"longitude"
).
setValue
(
location
.
getLongitude
());
ref
.
child
(
"time"
).
setValue
(
location
.
getTime
());
Calendar
c
=
Calendar
.
getInstance
();
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
formattedDate
=
df
.
format
(
c
.
getTime
());
Log
.
d
(
"dddd"
,
"onLocationResult: "
+
formattedDate
);
ref
.
child
(
"time"
).
setValue
(
formattedDate
);
ref
.
child
(
"destination"
).
setValue
(
destination
);
// Date currentTime = Calendar.getInstance().getTime();
// Log.d(TAG, "Location: " + location.getLatitude() + " " + location.getLongitude()+" "+location.getTime()+" "+currentTime);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment