1
+ package com.codeforgvl.trolleytrackerclient
2
+
3
+ import android.content.Context
4
+ import android.support.v4.content.ContextCompat
5
+
6
+ class Constants {
7
+ companion object {
8
+ const val LOG_TAG = " TROLLEYTRACKER"
9
+ const val ROUTE_UPDATE_INTERVAL = 15
10
+ const val SLEEP_INTERVAL = 5000
11
+ const val LOCATION_PERMISSION_REQUEST_ID = 1
12
+
13
+ val HOST =
14
+ if (BuildConfig .DEBUG ) " yeahthattrolley.azurewebsites.net" else " api.yeahthattrolley.com"
15
+ val API_PATH = " /api/v1/"
16
+ // var ALL_TROLLEYS_ENDPOINT =
17
+ // var RUNNING_TROLLEYS_ENDPOINT =
18
+ // var ACTIVE_ROUTES_ENDPOINT =
19
+ // var ROUTE_SCHEDULE_ENDPOINT =
20
+
21
+ private val ROUTE_DETAILS_ENDPOINT = " http://" + HOST + API_PATH + " Routes/"
22
+
23
+ fun getRouteDetailsEndpoint (routeId : Int ): String {
24
+ return ROUTE_DETAILS_ENDPOINT + routeId
25
+ }
26
+
27
+ fun getAllTrolleysEndpoint (): String {
28
+ return """ http://$HOST${API_PATH } Trolleys""" // Complete trolley record - all trolleys
29
+ }
30
+
31
+ fun getRunningTrolleysEndpoint (): String {
32
+ return """ http://$HOST${API_PATH } Trolleys/Running"""
33
+ }
34
+
35
+ fun getActiveRoutesEndpoint (): String {
36
+ return """ http://$HOST${API_PATH } Routes/Active"""
37
+ }
38
+
39
+ fun getRouteScheduleEndpoint (): String {
40
+ return """ http://$HOST${API_PATH } RouteSchedules"""
41
+ }
42
+
43
+ fun getRouteColorForRouteNumber (context : Context , ndx : Int ): Int {
44
+
45
+ val routeNo = ndx % 5 + 1
46
+ return when (routeNo) {
47
+ 1 -> ContextCompat .getColor(context, R .color.route1)
48
+ 2 -> ContextCompat .getColor(context, R .color.route2)
49
+ 3 -> ContextCompat .getColor(context, R .color.route3)
50
+ 4 -> ContextCompat .getColor(context, R .color.route4)
51
+ else -> ContextCompat .getColor(context, R .color.route5)
52
+ }
53
+ }
54
+
55
+ fun getStopColorForRouteNumber (context : Context , ndx : Int ): Int {
56
+ val routeNo = ndx % 5 + 1
57
+ return when (routeNo) {
58
+ 1 -> ContextCompat .getColor(context, R .color.stop1)
59
+ 2 -> ContextCompat .getColor(context, R .color.stop2)
60
+ 3 -> ContextCompat .getColor(context, R .color.stop3)
61
+ 4 -> ContextCompat .getColor(context, R .color.stop4)
62
+ else -> ContextCompat .getColor(context, R .color.stop5)
63
+ }
64
+ }
65
+ }
66
+
67
+ enum class DayOfWeek {
68
+ Monday ,
69
+ Tuesday ,
70
+ Wednesday ,
71
+ Thursday ,
72
+ Friday ,
73
+ Saturday ,
74
+ Sunday
75
+ }
76
+ }
0 commit comments