Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
parkingo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
SHAILESH KUMAR
parkingo
Commits
11089ae0
Commit
11089ae0
authored
Nov 27, 2019
by
Bhavesh Yadav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished checkout and charging
parent
9785da74
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
38 deletions
+107
-38
app/src/main/java/com/example/infiniteLoop/parkingo/checkout.java
...main/java/com/example/infiniteLoop/parkingo/checkout.java
+6
-4
app/src/main/java/com/example/infiniteLoop/parkingo/sqlite_ops.java
...in/java/com/example/infiniteLoop/parkingo/sqlite_ops.java
+38
-14
app/src/main/java/com/example/infiniteLoop/parkingo/ticket.java
...c/main/java/com/example/infiniteLoop/parkingo/ticket.java
+20
-12
app/src/main/java/com/example/infiniteLoop/parkingo/userInfo.java
...main/java/com/example/infiniteLoop/parkingo/userInfo.java
+3
-0
app/src/main/res/layout/ticket_layout.xml
app/src/main/res/layout/ticket_layout.xml
+40
-8
No files found.
app/src/main/java/com/example/infiniteLoop/parkingo/checkout.java
View file @
11089ae0
...
@@ -25,6 +25,7 @@ public class checkout extends Activity {
...
@@ -25,6 +25,7 @@ public class checkout extends Activity {
String
slot_number
,
ticket_number
;
String
slot_number
,
ticket_number
;
LinearLayout
innerll
;
LinearLayout
innerll
;
ArrayList
ticketData
;
ArrayList
ticketData
;
long
checkInTimeLong
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
...
@@ -72,19 +73,20 @@ public class checkout extends Activity {
...
@@ -72,19 +73,20 @@ public class checkout extends Activity {
}
}
else
{
else
{
sqlite_ops
so
=
new
sqlite_ops
(
this
);
sqlite_ops
so
=
new
sqlite_ops
(
this
);
so
.
check_out
(
slot_number
,
ticket_number
,
this
);
so
.
check_out
(
slot_number
,
ticket_number
,
checkInTimeLong
,
this
);
}
}
}
}
}
}
public
void
checkoutSuccess
(
Long
checkoutDateTime
)
{
public
void
checkoutSuccess
(
Long
checkoutDateTime
,
int
charges
)
{
Intent
i
=
new
Intent
(
this
,
ticket
.
class
);
Intent
i
=
new
Intent
(
this
,
ticket
.
class
);
long
datetime
=
Long
.
parseLong
(
checkoutDateTime
.
toString
());
long
datetime
=
Long
.
parseLong
(
checkoutDateTime
.
toString
());
Date
date
=
new
Date
(
datetime
*
1000
);
Date
date
=
new
Date
(
datetime
*
1000
);
Format
format
=
new
SimpleDateFormat
(
"dd/MM/yy HH:mm"
);
Format
format
=
new
SimpleDateFormat
(
"dd/MM/yy HH:mm"
);
String
dateString
=
format
.
format
(
date
);
String
dateString
=
format
.
format
(
date
);
ticketData
.
add
(
6
,
dateString
);
ticketData
.
add
(
6
,
dateString
);
ticketData
.
add
(
7
,
charges
);
i
.
putExtra
(
"ticket_data"
,
ticketData
);
i
.
putExtra
(
"ticket_data"
,
ticketData
);
i
.
putExtra
(
"ticket_no"
,
ticket_number
);
i
.
putExtra
(
"ticket_no"
,
ticket_number
);
i
.
putExtra
(
"checkout"
,
true
);
i
.
putExtra
(
"checkout"
,
true
);
...
@@ -164,8 +166,8 @@ public class checkout extends Activity {
...
@@ -164,8 +166,8 @@ public class checkout extends Activity {
public
void
showTicketDetails
(
ArrayList
data
)
{
public
void
showTicketDetails
(
ArrayList
data
)
{
name
.
setText
(
data
.
get
(
4
).
toString
());
name
.
setText
(
data
.
get
(
4
).
toString
());
slot
.
setText
(
data
.
get
(
1
).
toString
());
slot
.
setText
(
data
.
get
(
1
).
toString
());
long
datetime
=
Long
.
parseLong
(
data
.
get
(
3
).
toString
());
checkInTimeLong
=
Long
.
parseLong
(
data
.
get
(
3
).
toString
());
Date
date
=
new
Date
(
datetime
*
1000
);
Date
date
=
new
Date
(
checkInTimeLong
*
1000
);
Format
format
=
new
SimpleDateFormat
(
"dd/MM/yy HH:mm"
);
Format
format
=
new
SimpleDateFormat
(
"dd/MM/yy HH:mm"
);
String
dateString
=
format
.
format
(
date
);
String
dateString
=
format
.
format
(
date
);
data
.
add
(
3
,
dateString
);
data
.
add
(
3
,
dateString
);
...
...
app/src/main/java/com/example/infiniteLoop/parkingo/sqlite_ops.java
View file @
11089ae0
...
@@ -28,6 +28,8 @@ import java.util.HashMap;
...
@@ -28,6 +28,8 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.Map
;
import
static
android
.
content
.
ContentValues
.
TAG
;
import
static
android
.
content
.
ContentValues
.
TAG
;
import
static
com
.
google
.
common
.
primitives
.
UnsignedLongs
.
max
;
import
static
com
.
google
.
common
.
primitives
.
UnsignedLongs
.
min
;
public
class
sqlite_ops
extends
SQLiteOpenHelper
{
public
class
sqlite_ops
extends
SQLiteOpenHelper
{
FirebaseFirestore
fdb
;
FirebaseFirestore
fdb
;
...
@@ -458,13 +460,16 @@ public class sqlite_ops extends SQLiteOpenHelper{
...
@@ -458,13 +460,16 @@ public class sqlite_ops extends SQLiteOpenHelper{
});
});
}
}
public
void
check_out
(
String
slot
,
final
String
tkt
,
final
checkout
co
){
public
void
check_out
(
String
slot
,
final
String
tkt
,
long
checkInDateTime
,
final
checkout
co
){
// SQLiteDatabase db= this.getWritableDatabase();
// SQLiteDatabase db= this.getWritableDatabase();
// db.execSQL("update records set check_out=current_timestamp,isempty=1 where tkt_no="+tkt);
// db.execSQL("update records set check_out=current_timestamp,isempty=1 where tkt_no="+tkt);
// db.execSQL("update slots set status=0 where slot='"+slot+"'");
// db.execSQL("update slots set status=0 where slot='"+slot+"'");
// db.close();
// db.close();
// return true;
// return true;
Log
.
e
(
"Checkout called"
,
tkt
);
final
Long
checkoutTimeStamp
=
System
.
currentTimeMillis
()/
1000
;
final
Long
checkoutTimeStamp
=
System
.
currentTimeMillis
()/
1000
;
final
Long
Difference
=
(
checkoutTimeStamp
-
checkInDateTime
)/
60
*
60
;
fdb
=
FirebaseFirestore
.
getInstance
();
fdb
=
FirebaseFirestore
.
getInstance
();
final
CollectionReference
collection
=
fdb
.
collection
(
"slots"
);
final
CollectionReference
collection
=
fdb
.
collection
(
"slots"
);
fdb
.
collection
(
"slots"
).
whereEqualTo
(
"slot"
,
slot
).
get
()
fdb
.
collection
(
"slots"
).
whereEqualTo
(
"slot"
,
slot
).
get
()
...
@@ -476,24 +481,43 @@ public class sqlite_ops extends SQLiteOpenHelper{
...
@@ -476,24 +481,43 @@ public class sqlite_ops extends SQLiteOpenHelper{
for
(
QueryDocumentSnapshot
document
:
task
.
getResult
())
{
for
(
QueryDocumentSnapshot
document
:
task
.
getResult
())
{
String
id
=
document
.
getId
();
String
id
=
document
.
getId
();
collection
.
document
(
id
).
update
(
"status"
,
0
);
collection
.
document
(
id
).
update
(
"status"
,
0
);
}
}
else
{
Log
.
d
(
"Checkout"
,
"slot update failed"
);
}
}
});
fdb
.
collection
(
"misc"
).
document
(
"rate"
).
get
()
.
addOnCompleteListener
(
new
OnCompleteListener
<
DocumentSnapshot
>()
{
@Override
public
void
onComplete
(
@NonNull
Task
<
DocumentSnapshot
>
task
)
{
int
rate
=
Integer
.
parseInt
(
task
.
getResult
().
get
(
"value"
).
toString
());
long
difference
=
max
(
Difference
,
1
);
Log
.
d
(
"Charges"
,
"Difference"
+
difference
);
final
int
charges
=
Math
.
round
(
difference
*
rate
);
Log
.
d
(
"Charges"
,
"Charge"
+
charges
);
fdb
.
collection
(
"records"
).
document
(
tkt
).
update
(
fdb
.
collection
(
"records"
).
document
(
tkt
).
update
(
"checkOutDateTime"
,
checkoutTimeStamp
,
"checkOutDateTime"
,
checkoutTimeStamp
,
"status"
,
"0"
"status"
,
"0"
,
"charges"
,
charges
).
addOnCompleteListener
(
new
OnCompleteListener
<
Void
>()
{
).
addOnCompleteListener
(
new
OnCompleteListener
<
Void
>()
{
@Override
@Override
public
void
onComplete
(
@NonNull
Task
task
)
{
public
void
onComplete
(
@NonNull
Task
task
)
{
if
(
task
.
isSuccessful
())
{
if
(
task
.
isSuccessful
())
{
co
.
checkoutSuccess
(
checkoutTimeStamp
);
userInfo
uinfo
=
userInfo
.
getInstance
();
uinfo
.
deductCharge
(
charges
);
updateBalance
(
uinfo
.
getUsername
(),
uinfo
.
getBalance
());
co
.
checkoutSuccess
(
checkoutTimeStamp
,
charges
);
}
else
{
}
else
{
co
.
checkoutFailed
();
co
.
checkoutFailed
();
}
}
}
}
});
});
}
}
else
{
Log
.
d
(
"Checkout"
,
"slot update failed"
);
}
}
}
});
});
...
...
app/src/main/java/com/example/infiniteLoop/parkingo/ticket.java
View file @
11089ae0
...
@@ -5,6 +5,7 @@ import android.content.Intent;
...
@@ -5,6 +5,7 @@ import android.content.Intent;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
...
@@ -14,8 +15,10 @@ import java.util.ArrayList;
...
@@ -14,8 +15,10 @@ import java.util.ArrayList;
import
java.util.Date
;
import
java.util.Date
;
public
class
ticket
extends
Activity
{
public
class
ticket
extends
Activity
{
TextView
slot
,
tkt
,
time_tv
,
date_tv
,
vehicle
,
ticket_title
,
checkout_label
,
checkout_time
;
LinearLayout
checkout_parent
,
checkout_date_parent
;
TextView
checkout_date_label
,
checkout_date
;
LinearLayout
charge_parent
;
TextView
slot
,
tkt
,
time_tv
,
date_tv
,
vehicle
,
ticket_title
,
checkout_time
,
charge_value
;
TextView
checkout_date
;
ArrayList
ticketData
;
ArrayList
ticketData
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
@@ -28,10 +31,12 @@ public class ticket extends Activity {
...
@@ -28,10 +31,12 @@ public class ticket extends Activity {
time_tv
=
findViewById
(
R
.
id
.
time_tv
);
time_tv
=
findViewById
(
R
.
id
.
time_tv
);
date_tv
=
findViewById
(
R
.
id
.
date_tv
);
date_tv
=
findViewById
(
R
.
id
.
date_tv
);
ticket_title
=
findViewById
(
R
.
id
.
ticket_title
);
ticket_title
=
findViewById
(
R
.
id
.
ticket_title
);
checkout_label
=
findViewById
(
R
.
id
.
checkout_label
);
checkout_parent
=
findViewById
(
R
.
id
.
checkout_parent
);
charge_parent
=
findViewById
(
R
.
id
.
charge_parent
);
checkout_date_parent
=
findViewById
(
R
.
id
.
checkout_date_parent
);
charge_value
=
findViewById
(
R
.
id
.
charge_value
);
checkout_time
=
findViewById
(
R
.
id
.
checkout_time
);
checkout_time
=
findViewById
(
R
.
id
.
checkout_time
);
checkout_date
=
findViewById
(
R
.
id
.
checkout_date
);
checkout_date
=
findViewById
(
R
.
id
.
checkout_date
);
checkout_date_label
=
findViewById
(
R
.
id
.
checkout_date_label
);
Intent
i
=
getIntent
();
Intent
i
=
getIntent
();
String
ticket_no
;
String
ticket_no
;
if
(
i
.
hasExtra
(
"ticket_data"
)){
if
(
i
.
hasExtra
(
"ticket_data"
)){
...
@@ -53,20 +58,23 @@ public class ticket extends Activity {
...
@@ -53,20 +58,23 @@ public class ticket extends Activity {
// ticketData=so.getTicketDetails(ticket_no);
// ticketData=so.getTicketDetails(ticket_no);
Log
.
d
(
"CHECKOUT"
,
"successfully checkout out"
);
Log
.
d
(
"CHECKOUT"
,
"successfully checkout out"
);
ticket_title
.
setText
(
"Checkout Receipt"
);
ticket_title
.
setText
(
"Checkout Receipt"
);
checkout_label
.
setVisibility
(
View
.
VISIBLE
);
checkout_parent
.
setVisibility
(
View
.
VISIBLE
);
checkout_time
.
setVisibility
(
View
.
VISIBLE
);
//checkout_time.setVisibility(View.VISIBLE);
checkout_date
.
setVisibility
(
View
.
VISIBLE
);
checkout_date_parent
.
setVisibility
(
View
.
VISIBLE
);
checkout_date_label
.
setVisibility
(
View
.
VISIBLE
);
charge_parent
.
setVisibility
(
View
.
VISIBLE
);
//checkout_date_label.setVisibility(View.VISIBLE);
String
checkout_date_data
=
ticketData
.
get
(
6
).
toString
();
String
checkout_date_data
=
ticketData
.
get
(
6
).
toString
();
String
[]
checkoutdateandtime
=
checkout_date_data
.
split
(
" "
);
String
[]
checkoutdateandtime
=
checkout_date_data
.
split
(
" "
);
checkout_date
.
setText
(
checkoutdateandtime
[
0
]);
checkout_date
.
setText
(
checkoutdateandtime
[
0
]);
checkout_time
.
setText
(
checkoutdateandtime
[
1
]);
checkout_time
.
setText
(
checkoutdateandtime
[
1
]);
charge_value
.
setText
(
ticketData
.
get
(
7
).
toString
());
}
else
{
}
else
{
ticket_title
.
setText
(
"Parking Ticket"
);
ticket_title
.
setText
(
"Parking Ticket"
);
checkout_label
.
setVisibility
(
View
.
INVISIBLE
);
checkout_parent
.
setVisibility
(
View
.
GONE
);
checkout_time
.
setVisibility
(
View
.
INVISIBLE
);
//checkout_time.setVisibility(View.INVISIBLE);
checkout_date
.
setVisibility
(
View
.
INVISIBLE
);
//checkout_date.setVisibility(View.INVISIBLE);
checkout_date_label
.
setVisibility
(
View
.
INVISIBLE
);
checkout_date_parent
.
setVisibility
(
View
.
GONE
);
charge_parent
.
setVisibility
(
View
.
GONE
);
}
}
if
(
i
.
hasExtra
(
"ticket_data"
))
{
if
(
i
.
hasExtra
(
"ticket_data"
))
{
...
...
app/src/main/java/com/example/infiniteLoop/parkingo/userInfo.java
View file @
11089ae0
...
@@ -2,6 +2,8 @@ package com.example.infiniteLoop.parkingo;
...
@@ -2,6 +2,8 @@ package com.example.infiniteLoop.parkingo;
import
android.util.Log
;
import
android.util.Log
;
import
static
java
.
lang
.
StrictMath
.
max
;
public
class
userInfo
{
public
class
userInfo
{
public
static
userInfo
u_instance
=
null
;
public
static
userInfo
u_instance
=
null
;
private
String
username
=
null
;
private
String
username
=
null
;
...
@@ -35,4 +37,5 @@ public class userInfo {
...
@@ -35,4 +37,5 @@ public class userInfo {
public
int
getBalance
(){
return
this
.
balance
;}
public
int
getBalance
(){
return
this
.
balance
;}
public
void
setBalance
(
int
newBalance
){
this
.
balance
=
newBalance
;}
public
void
setBalance
(
int
newBalance
){
this
.
balance
=
newBalance
;}
public
void
deductCharge
(
int
charge
)
{
this
.
balance
=
max
(
this
.
balance
-
charge
,
0
);}
}
}
app/src/main/res/layout/ticket_layout.xml
View file @
11089ae0
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
<TextView
<TextView
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Date:"
android:text=
"
Check-in
Date:"
android:textColor=
"#000"
android:textColor=
"#000"
android:gravity=
"left"
android:gravity=
"left"
android:textSize=
"20sp"
/>
android:textSize=
"20sp"
/>
...
@@ -66,7 +66,7 @@
...
@@ -66,7 +66,7 @@
<TextView
<TextView
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Time:"
android:text=
"
Check-in
Time:"
android:textSize=
"20sp"
android:textSize=
"20sp"
android:textColor=
"#000"
android:textColor=
"#000"
...
@@ -130,11 +130,13 @@
...
@@ -130,11 +130,13 @@
android:text=
"parking slot"
/>
android:text=
"parking slot"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
<LinearLayout
android:id=
"@+id/checkout_date_parent"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"25dp"
android:layout_marginTop=
"25dp"
android:gravity=
"left"
android:gravity=
"left"
android:orientation=
"horizontal"
>
android:orientation=
"horizontal"
android:visibility=
"gone"
>
<TextView
<TextView
android:id=
"@+id/checkout_date_label"
android:id=
"@+id/checkout_date_label"
...
@@ -144,7 +146,7 @@
...
@@ -144,7 +146,7 @@
android:textColor=
"#000"
android:textColor=
"#000"
android:gravity=
"left"
android:gravity=
"left"
android:textSize=
"20sp"
android:textSize=
"20sp"
android:visibility=
"
gon
e"
/>
android:visibility=
"
visibl
e"
/>
<TextView
<TextView
android:id=
"@+id/checkout_date"
android:id=
"@+id/checkout_date"
...
@@ -155,14 +157,16 @@
...
@@ -155,14 +157,16 @@
android:textStyle=
"bold"
android:textStyle=
"bold"
android:paddingLeft=
"10dp"
android:paddingLeft=
"10dp"
android:text=
"Date here"
android:text=
"Date here"
android:visibility=
"
gon
e"
/>
android:visibility=
"
visibl
e"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
<LinearLayout
android:id=
"@+id/checkout_parent"
android:layout_marginTop=
"5dp"
android:layout_marginTop=
"5dp"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
android:orientation=
"horizontal"
android:gravity=
"left"
>
android:gravity=
"left"
android:visibility=
"gone"
>
<TextView
<TextView
android:id=
"@+id/checkout_label"
android:id=
"@+id/checkout_label"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
...
@@ -170,7 +174,7 @@
...
@@ -170,7 +174,7 @@
android:text=
"Checkout Time:"
android:text=
"Checkout Time:"
android:textSize=
"20sp"
android:textSize=
"20sp"
android:textColor=
"#000"
android:textColor=
"#000"
android:visibility=
"
gon
e"
android:visibility=
"
visibl
e"
/>
/>
<TextView
<TextView
...
@@ -182,7 +186,35 @@
...
@@ -182,7 +186,35 @@
android:textStyle=
"bold"
android:textStyle=
"bold"
android:paddingLeft=
"10dp"
android:paddingLeft=
"10dp"
android:text=
"time here"
android:text=
"time here"
android:visibility=
"gone"
/>
android:visibility=
"visible"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/charge_parent"
android:layout_marginTop=
"5dp"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
android:gravity=
"left"
android:visibility=
"gone"
>
<TextView
android:id=
"@+id/charge_label"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Charge :"
android:textSize=
"20sp"
android:textColor=
"#000"
android:visibility=
"visible"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:id=
"@+id/charge_value"
android:textSize=
"20sp"
android:textColor=
"#000"
android:textStyle=
"bold"
android:paddingLeft=
"10dp"
android:text=
"0"
android:visibility=
"visible"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
<LinearLayout
android:layout_marginTop=
"25dp"
android:layout_marginTop=
"25dp"
...
...
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