app / sg.edu.ntu.scse.cz2006.gymbuddies / BuddySearchResultActivity

BuddySearchResultActivity

open class BuddySearchResultActivity : AppCompatActivity, AppConstants, OnRecyclerViewInteractedListener<ViewHolder!>

This is the display buddy search result it gets searching condition from Search buddies fragment, and perform query to Firestore After getting response, it display other users on Recycler view. User can then interact and add them as buddy

Author
Chia Yu

Since
2019-09-28

Constructors

<init>

This is the display buddy search result it gets searching condition from Search buddies fragment, and perform query to Firestore After getting response, it display other users on Recycler view. User can then interact and add them as buddy

BuddySearchResultActivity()

Properties

adapter

adapter to bind #listUsers onto #rvResult

var adapter: BuddyResultAdapter!

favBuddiesRef

document reference used to query user's favoured buddies record, response of query will be converted to #favRecord

var favBuddiesRef: DocumentReference!

favRecord

actual object that keeps records of user's favoured buddies record

var favRecord: FavBuddyRecord!

favRecordChangeListener

observer to listen to changes on user's favoured record changes

var favRecordChangeListener: ListenerRegistration!

firestore

Firestore instance to query data

var firestore: FirebaseFirestore!

listFavUserIds

list of favoured users' uid, used to identify buddies

var listFavUserIds: ArrayList<String!>!

listUsers

list of users that matched searching condition

var listUsers: ArrayList<User!>!

querySearchUser

query to search user based on search condition

var querySearchUser: Query!

rvResult

view reference to recycler view that display list of user that matching search conditions

var rvResult: RecyclerView!

TAG

TAG is unique identifier to for logging purpose

val TAG: String!

tvEmptyMessage

view reference to empty view, when there is no user matched the condition, this view will be displayed

var tvEmptyMessage: TextView!

Functions

buildSearchQuery

Craft search user query to firestore, query is based on search parameters are:

  • preferred workout days
  • preferred location
  • preferred time
  • preferred gender

open fun buildSearchQuery(): Query!

commitFavRecord

query to FirebaseFirestore to update

open fun commitFavRecord(): Unit

doAddFavBuddy

Add another user as buddies, uid will be added to favourite list and update to firestore

open fun doAddFavBuddy(otherUser: User!): Unit

doRemoveFavBuddy

Remove buddy, Uid will be removed from favourite list and update to firestore

open fun doRemoveFavBuddy(otherUser: User!): Unit

goChatActivity

Redirect user to chat activity

open fun goChatActivity(other: User!): Unit

listenFavRecordChanges

Register as an observer to listen changes of searched user result

open fun listenFavRecordChanges(): Unit

notifyAndUpdateView

notify recycler view about data is being modified. if nothing to display, it display empty view

open fun notifyAndUpdateView(): Unit

onCreate

Android framework lifecycle

open fun onCreate(savedInstanceState: Bundle?): Unit

onOptionsItemSelected

Handle option menu action

open fun onOptionsItemSelected(item: MenuItem!): Boolean

onPause

Android framework lifecycle

open fun onPause(): Unit

onResume

Android framework lifecycle

open fun onResume(): Unit

onViewInteracted

Listen to user interaction events from BuddyResultAdapter, and perform necessary actions

open fun onViewInteracted(view: View!, holder: ViewHolder!, action: Int): Unit

queryBuddy

perform query to Firestore, and update data based on response

open fun queryBuddy(): Unit

queryFavUserRecord

perform query to retrieve current user's fav

open fun queryFavUserRecord(): Unit

readFavRecordDoc

After query to firestore by #queryFavUserRecord(), this method reads response and update data to be display

open fun readFavRecordDoc(documentSnapshot: DocumentSnapshot!): Unit

stopListenFavRecordChanges

Unregister itself to stop listening changes of searched user result

open fun stopListenFavRecordChanges(): Unit