Skip to content

Commit

Permalink
updated method of getting instance of firebase
Browse files Browse the repository at this point in the history
  • Loading branch information
shahrazeahmad07 committed Jul 7, 2023
1 parent 1394fed commit 61dbab7
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ dependencies {
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

// Firebase
implementation platform('com.google.firebase:firebase-bom:30.2.0')
implementation(platform("com.google.firebase:firebase-bom:32.1.1"))
implementation("com.google.firebase:firebase-database-ktx")
implementation 'com.google.firebase:firebase-analytics-ktx'

// Firebase Auth
implementation 'com.google.firebase:firebase-auth-ktx:21.0.6'


// Google play services for Google maps
implementation 'com.google.android.gms:play-services-maps:18.0.2'
implementation 'com.google.firebase:firebase-database-ktx:20.0.5'

// Getting current location
implementation 'com.karumi:dexter:6.0.1'
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/example/bustracking/Admin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import com.example.bustracking.databinding.ActivityAdminBinding
import com.example.bustracking.modals.RVBusDriverModal
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.*
import com.google.firebase.database.ktx.database
import com.google.firebase.ktx.Firebase

class Admin : AppCompatActivity(), RecyclerAdapter.RecyclerAdapterInterface{
private lateinit var binding: ActivityAdminBinding
Expand All @@ -34,7 +36,7 @@ class Admin : AppCompatActivity(), RecyclerAdapter.RecyclerAdapterInterface{

//! firebase initializations.
mAuth = FirebaseAuth.getInstance()
firebaseDatabase = FirebaseDatabase.getInstance()
firebaseDatabase = Firebase.database
databaseReference = firebaseDatabase.getReference("Locations")

//! recycler View for bus drivers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import com.example.bustracking.databinding.ActivityComplaintBoxBinding
import com.example.bustracking.modals.ComplainModal
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.*
import com.google.firebase.database.ktx.database
import com.google.firebase.ktx.Firebase

class AdminComplaintBox : AppCompatActivity() {

Expand All @@ -30,7 +32,7 @@ class AdminComplaintBox : AppCompatActivity() {
complainModalArrayList = ArrayList()

//! firebase
firebaseDatabase = FirebaseDatabase.getInstance()
firebaseDatabase = Firebase.database
databaseReference = firebaseDatabase.getReference("Complains")

//! Recycler View
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/example/bustracking/ComplaintBox.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import com.example.bustracking.databinding.ActivityComplaintBoxBinding
import com.example.bustracking.modals.ComplainModal
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.*
import com.google.firebase.database.ktx.database
import com.google.firebase.ktx.Firebase

class ComplaintBox : AppCompatActivity() {
private lateinit var binding: ActivityComplaintBoxBinding
Expand Down Expand Up @@ -45,7 +47,7 @@ class ComplaintBox : AppCompatActivity() {
firebaseAuth = FirebaseAuth.getInstance()
email = firebaseAuth.currentUser?.email.toString()
username = email.split("@")[0]
firebaseDatabase = FirebaseDatabase.getInstance()
firebaseDatabase = Firebase.database
databaseReference = firebaseDatabase.getReference("Complains")

//! recyclerView
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/example/bustracking/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import com.example.bustracking.modals.RVBusDriverModal
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.ktx.database
import com.google.firebase.ktx.Firebase
import com.karumi.dexter.Dexter
import com.karumi.dexter.MultiplePermissionsReport
import com.karumi.dexter.PermissionToken
Expand Down Expand Up @@ -50,7 +52,7 @@ class Home : AppCompatActivity() {
setContentView(binding.root)
supportActionBar?.title = "Driver Home"
mAuth = FirebaseAuth.getInstance()
databaseReference = FirebaseDatabase.getInstance().getReference("Locations")
databaseReference = Firebase.database.getReference("Locations")

sharingLocation = false
checkLocationSharing()
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/example/bustracking/MapsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.MarkerOptions
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.*
import com.google.firebase.database.ktx.database
import com.google.firebase.ktx.Firebase

class MapsActivity : AppCompatActivity(), OnMapReadyCallback {

Expand Down Expand Up @@ -38,7 +40,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback {
mapFragment.getMapAsync(this)

mAuth = FirebaseAuth.getInstance()
databaseReference = FirebaseDatabase.getInstance().getReference("Locations")
databaseReference = Firebase.database.getReference("Locations")

}

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/example/bustracking/RouteSchedule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.example.bustracking.databinding.ActivityRouteScheduleBinding
import com.google.firebase.database.*
import com.google.firebase.database.ktx.database
import com.google.firebase.ktx.Firebase

class RouteSchedule : AppCompatActivity() {
private lateinit var binding: ActivityRouteScheduleBinding
Expand All @@ -17,7 +19,7 @@ class RouteSchedule : AppCompatActivity() {
setContentView(binding.root)
supportActionBar?.title = "Route Schedule"

databaseReference = FirebaseDatabase.getInstance().getReference("RouteSchedule")
databaseReference = Firebase.database.getReference("RouteSchedule")
databaseReference.addValueEventListener( object: ValueEventListener {
override fun onDataChange(snapshot: DataSnapshot) {

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/example/bustracking/StudentHome.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import com.example.bustracking.databinding.ActivityStudentHomeBinding
import com.example.bustracking.modals.RVBusDriverModal
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.*
import com.google.firebase.database.ktx.database
import com.google.firebase.ktx.Firebase

class StudentHome : AppCompatActivity(), RecyclerAdapter.RecyclerAdapterInterface {
private lateinit var binding: ActivityStudentHomeBinding
Expand All @@ -35,7 +37,7 @@ class StudentHome : AppCompatActivity(), RecyclerAdapter.RecyclerAdapterInterfac

//! firebase Initializations
mAuth = FirebaseAuth.getInstance()
firebaseDatabase = FirebaseDatabase.getInstance()
firebaseDatabase = Firebase.database
databaseReference = firebaseDatabase.getReference("Locations")

//! recycler View
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/com/example/bustracking/UpdateSchedule.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.example.bustracking

import android.os.Bundle
import android.util.Log
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.example.bustracking.databinding.ActivityUpdateScheduleBinding
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.ktx.database
import com.google.firebase.database.ktx.snapshots
import com.google.firebase.database.ktx.values
import com.google.firebase.ktx.Firebase

class UpdateSchedule : AppCompatActivity() {
private lateinit var binding: ActivityUpdateScheduleBinding
Expand All @@ -19,7 +24,11 @@ class UpdateSchedule : AppCompatActivity() {
setContentView(binding.root)


databaseReference = FirebaseDatabase.getInstance().getReference("RouteSchedule")
databaseReference = Firebase.database.getReference("RouteSchedule")
databaseReference.get().addOnSuccessListener {
dataSnapshot ->
binding.etRouteSchedule.setText(dataSnapshot.value.toString())
}

binding.btnUpdate.setOnClickListener {
if (binding.etRouteSchedule.text.toString().isEmpty()) {
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/example/bustracking/WriteComplain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import com.example.bustracking.modals.ComplainModal
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.ktx.database
import com.google.firebase.ktx.Firebase

class WriteComplain : AppCompatActivity() {
private lateinit var binding: ActivityWriteComplainBinding
Expand All @@ -25,7 +27,7 @@ class WriteComplain : AppCompatActivity() {
supportActionBar?.title = "Write Complain"

firebaseAuth = FirebaseAuth.getInstance()
firebaseDatabase = FirebaseDatabase.getInstance()
firebaseDatabase = Firebase.database
databaseReference = firebaseDatabase.getReference("Complains")


Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_route_schedule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
android:id="@+id/tvRouteSchedule"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/route_schedule"
android:background="@drawable/et_background"
android:layout_margin="40dp"
android:textSize="16sp"
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/layout/activity_update_schedule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
android:id="@+id/etRouteSchedule"
android:layout_width="match_parent"
android:layout_height="500dp"
android:text="@string/route_schedule"
android:background="@drawable/et_background"
android:layout_margin="30dp"
android:textSize="16sp"
android:padding="15dp"
android:hint="@string/add_schedule"
android:gravity="top"
android:textColor="@color/black"/>
android:textColor="@color/black"
android:autofillHints="none"
android:inputType="textImeMultiLine|textMultiLine" />

<Button
android:id="@+id/btnUpdate"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<string name="share_location">Share Location</string>
<string name="positive_location_status">Location is Sharing</string>
<string name="stop_sharing">Stop Sharing</string>
<string name="route_schedule">05–07–22 Tuesday \n🇷‌🇴‌🇺‌🇹‌🇪‌ 🇹‌🇮‌🇲‌ 🇪‌ \nShuttle Route 12:15pm\n🇷‌🇦‌🇼‌🇦‌🇱‌🇵‌🇮‌🇳‌🇩‌🇮‌\nRij 11\nHashim 0312 3103583\nNoman 0313 8978836 \n🇮‌🇸‌🇱‌🇦‌🇲‌🇦‌🇧‌🇦‌🇩‌\nRpT 4473\nJavid 0312 5259567\nMumtaz 0311 5330337\n🇼‌🇦‌🇭‌🇨‌🇦‌🇳‌🇹‌🇹‌\nRpT 2371\nDost Muhammad 0306 5006255\n *2nd full Route 3:30pm\nSaddar to University 7pm\nRij 12\nSaifullah 0313 5093599\nJangeer 0345 5861776</string>
<string name="submit">Submit</string>
<string name="write_complain">Write Complain…</string>
<string name="title_activity_maps">MapsActivity</string>
Expand All @@ -25,4 +24,5 @@
<string name="update">Update</string>
<string name="bus">Bus:</string>
<string name="location_of_buses">Location of Buses:</string>
<string name="add_schedule">Add Schedule</string>
</resources>

0 comments on commit 61dbab7

Please sign in to comment.