app / sg.edu.ntu.scse.cz2006.gymbuddies.ui.home / HomeFragment

HomeFragment

open class HomeFragment : Fragment, OnMapReadyCallback, ISwipeCallback

Fragment being used to display the Home activity of the application. Including nearby gyms, gym details, favourited gyms etc

Author
Kenneth Soh, Chia Yu

Since
2019-09-06

Constructors

<init>

Fragment being used to display the Home activity of the application. Including nearby gyms, gym details, favourited gyms etc

HomeFragment()

Properties

autoExpandFlag

A flag to check if we should auto expand the gym details bottom sheet after it has settled

var autoExpandFlag: Boolean

backStack

Custom backstack handler

var backStack: OnBackPressedCallback!

carpark

View Gym's Nearby Carparks button

var carpark: LinearLayout!

coordinates

The coordinates of the currently displayed gym

var coordinates: LatLng!

coordinatorLayout

The coordinator layout handling the fragment

var coordinatorLayout: CoordinatorLayout!

currentUserFavList

A hashmap containing the realtime favourites list of the logged in user

var currentUserFavList: HashMap<String!, Int!>!

favAdapter

An adapter to store the favourites list for the RecyclerView

var favAdapter: FavGymAdapter!

favBottomSheet

The favourites list bottom sheet

var favBottomSheet: View!

favBottomSheetBehavior

Handles the behavior of the favourites list bottom sheet

var favBottomSheetBehavior: BottomSheetBehavior<View!>!

favCount

Gym Favourites Count TextView

var favCount: TextView!

favListener

Firebase Firestore Favourites List Real-time listener

var favListener: ListenerRegistration!

favListRegistered

A flag to check if we have finished populating the favourites list

var favListRegistered: Boolean

favouritesList

The favourites list recyclerview

var favouritesList: RecyclerView!

firstMarkerLoad

Flag to determine if this is the first time we are initializing the Google map markers for the gym

var firstMarkerLoad: Boolean

flagReviewing

If the user is currently reviewing a gym

var flagReviewing: Boolean

gymBottomSheet

The gym details bottom sheet

var gymBottomSheet: View!

gymBottomSheetBehavior

Handles the behavior of the gym details bottom sheet

var gymBottomSheetBehavior: BottomSheetBehavior<View!>!

gymDesc

Gym Description TextView

var gymDesc: TextView!

gymDetailFavListener

The Firebase Firestore listener for favourites in the gym details bottom sheet This is used to handle real time updates to the favourites count of the gym

var gymDetailFavListener: ListenerRegistration!

gymLocation

Gym Location TextView

var gymLocation: TextView!

gymTitle

Gym Title TextView

var gymTitle: TextView!

hasLocationPermission

If the application has ACCESS_FINE_LOCATION permission flag

var hasLocationPermission: Boolean

heartIcon

Gym Favourites Icon

var heartIcon: FavButtonView!

homeViewModel

The View Model

var homeViewModel: HomeViewModel!

lastLocation

Last known location of the user

var lastLocation: LatLng!

locationClient

The user current location provider client

var locationClient: FusedLocationProviderClient!

mapView

Google Maps View

var mapView: MapView!

markerList

A map of the markers and their corresponding gym objects

var markerList: HashMap<MarkerOptions!, GymShell!>!

mMap

Google Maps Instance

var mMap: GoogleMap!

RC_LOC

The Request Code for Location Permission requests

static val RC_LOC: Int

reviews

Gym Reviews recyclerview

var reviews: RecyclerView!

selectedGymUid

The Gym Unique ID

var selectedGymUid: String!

sp

The application preference file

var sp: SharedPreferences!

TAG

Used for logging purposes for this activity

static val TAG: String

Functions

delete

When a gym in the favourites list has been swiped to unfavourite

open fun delete(position: Int?): Boolean

emptyFavourites

Internal function to call when the user has no favourited gyms

open fun emptyFavourites(): Unit

hasGps

Internal function to start the check for if the app has the ACCESS_FINE_LOCATION permission granted

open fun hasGps(startCheck: Boolean): Boolean

hasGpsPermission

Checks if the application has ACCESS_FINE_LOCATION permission

open fun hasGpsPermission(): Boolean

onCreateOptionsMenu

Internal Android function to create the application options menu on the ActionBar

open fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater): Unit

onCreateView

Creates the fragment view

open fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View?

onMapReady

Internal method called when the Google Map instance has finished loading and is ready for interation

open fun onMapReady(googleMap: GoogleMap!): Unit

onOptionsItemSelected

open fun onOptionsItemSelected(item: MenuItem): Boolean

onPause

Lifecycle event called when the activity is paused

open fun onPause(): Unit

onRequestPermissionsResult

Internal function to handle permission request results

open fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String!>, grantResults: IntArray): Unit

onResume

Method called when the activity is resumed from the lifecycle

open fun onResume(): Unit

onViewCreated

Method called when the view is created in the lifecycle

open fun onViewCreated(view: View, savedInstanceState: Bundle?): Unit

processFavListUpdates

Process real-time updates from Firebase Firestore

open fun processFavListUpdates(querySnapshot: QuerySnapshot!): Unit

registerFavList

Registers the favourites list real time listener with Firebase Firestore

open fun registerFavList(): Unit

setGymStatus

Internal function to set the logged in user's gym review status This will determine if the user has a review for that particular gym or not. If there is, the view review layout is used, otherwise the create new review layout is used

open fun setGymStatus(hasReview: Boolean, message: String?, rating: Float): Unit

setupGymDetailsControls

Initialize method for setting up the gym details bottom sheet

open fun setupGymDetailsControls(): Unit

showGymDetails

Internal function called to hide the favourites list bottom sheet and display the gym details bottom sheet

open fun showGymDetails(): Unit

submitReview

Internal function to submit review for the selected gym

open fun submitReview(bar: MaterialRatingBar!, reviewMessage: TextInputEditText!): Unit

unselectGymDetails

Internal function called to hide the gym details bottom sheet and redisplay the favourites list bottom sheet

open fun unselectGymDetails(): Unit

updateGymDetails

Updates the data in the gym details bottom sheet

open fun updateGymDetails(gym: GymShell?): Unit

updateGymRatings

Internal function to update gym ratings for a selected gym

open fun updateGymRatings(): Unit

updateNearbyMarkers

Internal function to update the markers near to the user's location. The number of markers is configurable in the app settings

open fun updateNearbyMarkers(results: ArrayList<MarkerOptions!>!): Unit

zoomToMyLocation

Internal method to zoom the map to the user's current location

open fun zoomToMyLocation(): Unit