Commit d5d40a76 authored by Bhavesh Yadav's avatar Bhavesh Yadav

Filled slots now return from firebase

parent 4d7cb155
......@@ -26,8 +26,11 @@ public class currentParks extends Activity {
ll=findViewById(R.id.ll);
sqlite_ops so=new sqlite_ops(this);
al=so.getAllFilledSlotDetails();
so.getAllFilledSlotDetails(this);
}
public void showCurrentParkings(final ArrayList al) {
curparks=findViewById(R.id.curparks);
if(al.size()>0){
SimpleAdapter sa=new SimpleAdapter(this,al,R.layout.current_park_listview,keys,ids);
......
......@@ -191,6 +191,7 @@ public class sqlite_ops extends SQLiteOpenHelper{
parkingRecord.put("slot",cd.getSlot());
parkingRecord.put("vehicle",cd.getVehicle_no());
parkingRecord.put("checkInTimeDate",timeStamp.toString());
parkingRecord.put("status",1);
fdb = FirebaseFirestore.getInstance();
fdb.collection("records")
.add(parkingRecord)
......@@ -412,26 +413,52 @@ public class sqlite_ops extends SQLiteOpenHelper{
return true;
}
public ArrayList getAllFilledSlotDetails(){
ArrayList slots=new ArrayList();
SQLiteDatabase db= this.getWritableDatabase();
Cursor cursor = db.query("records",new String[]{"name","mobile","vehicle","slot"},"isempty=?",
new String[]{"0"}, null, null, null, null);
if(cursor!=null){
cursor.moveToFirst();
if(cursor.getCount()!=0){
do{
HashMap hm=new HashMap();
hm.put("slot", cursor.getString(cursor.getColumnIndex("slot")));
hm.put("vehicle",cursor.getString(cursor.getColumnIndex("vehicle")));
hm.put("name",cursor.getString(cursor.getColumnIndex("name")));
hm.put("mobile",cursor.getString(cursor.getColumnIndex("mobile")));
public void getAllFilledSlotDetails(final currentParks cp){
// ArrayList slots=new ArrayList();
// SQLiteDatabase db= this.getWritableDatabase();
// Cursor cursor = db.query("records",new String[]{"name","mobile","vehicle","slot"},"isempty=?",
// new String[]{"0"}, null, null, null, null);
// if(cursor!=null){
// cursor.moveToFirst();
// if(cursor.getCount()!=0){
// do{
// HashMap hm=new HashMap();
// hm.put("slot", cursor.getString(cursor.getColumnIndex("slot")));
// hm.put("vehicle",cursor.getString(cursor.getColumnIndex("vehicle")));
// hm.put("name",cursor.getString(cursor.getColumnIndex("name")));
// hm.put("mobile",cursor.getString(cursor.getColumnIndex("mobile")));
// slots.add(hm);
// }while(cursor.moveToNext());
// }
//
// }
fdb = FirebaseFirestore.getInstance();
fdb.collection("records").whereEqualTo("uname",userInfo.getInstance().getName())
.whereEqualTo("status",1).get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if(task.isSuccessful()) {
ArrayList slots = new ArrayList();
for (QueryDocumentSnapshot document : task.getResult()) {
// slots.add(document);
HashMap hm = new HashMap();
hm.put("name",document.getData().get("name").toString());
hm.put("uname",document.getData().get("uname").toString());
hm.put("slot",document.getData().get("slot").toString());
hm.put("vehicle",document.getData().get("vehicle").toString());
hm.put("mobile",document.getData().get("mobile").toString());
Log.d("Ticket","getting record"+document.getData().toString());
slots.add(hm);
}while(cursor.moveToNext());
}
cp.showCurrentParkings(slots);
}
db.close();
return slots;
else {
Log.d("Checkin","slot update failed");
}
}
});
// db.close();
return;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment