open class ChatListFragment : Fragment, AppConstants, OnRecyclerViewInteractedListener<ChatViewHolder!>
The fragment display list of buddies (favoured user) of current user it allow user to view profile information, start chat and un-favour of user
Author
Chia Yu
Since
2019-09-06
<init> |
The fragment display list of buddies (favoured user) of current user it allow user to view profile information, start chat and un-favour of user ChatListFragment() |
adapter |
handle binding of data to be display on RecyclerView var adapter: ChatAdapter! |
chatListViewModel |
view model to separate data from activity life cycle var chatListViewModel: ChatListViewModel! |
chats |
list to hold queried chat room data var chats: ArrayList<Chat!>! |
favBuddiesRef |
document reference used to query user's favoured buddies record var favBuddiesRef: DocumentReference! |
favUserIds |
list to hold buddies' user id var favUserIds: ArrayList<String!>! |
firestore |
Firestore instance to query data var firestore: FirebaseFirestore! |
queryChatListener |
Observer to listen to changes on chat room records var queryChatListener: ListenerRegistration! |
queryChats |
query on chat room has current user involved in var queryChats: Query! |
queryFavListener |
Observer to listen to changes on user's favour buddies record var queryFavListener: ListenerRegistration! |
rvChats |
reference to RecyclerView, used to display chat room data on screen var rvChats: RecyclerView! |
srlUpdateChats |
reference to SwipeRefreshLayout, allow user to drag down for refresh data var srlUpdateChats: SwipeRefreshLayout! |
TAG |
TAG is unique identifier to for logging purpose static 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! |
commitFavRecord |
commit changes of removing user from buddies record in firestore open fun commitFavRecord(): Unit |
goChatActivity |
redirect user to chat activity open fun goChatActivity(chat: Chat!): Unit |
listenChatListChanges |
register an observer to chat room records changes open fun listenChatListChanges(): Unit |
listenFavChanges |
register an observer to listen to changes on user's favoured buddies records open fun listenFavChanges(): Unit |
notifyAndUpdateView |
notify recycler view about data is being modified. if nothing to display, it display empty view open fun notifyAndUpdateView(): Unit |
onCreateView |
Android framework lifecycle open fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? |
onPause |
android framework lifecycle open fun onPause(): Unit |
onResume |
android framework lifecycle open fun onResume(): Unit |
onViewInteracted |
interface for observer to handle event when subject notify the view interaction of RecyclerView open fun onViewInteracted(view: View!, holder: ChatViewHolder!, action: Int): Unit |
queryUser |
After chat room data is retrieved from firestore, make another query to retrieve involved member profile for chat rooms open fun queryUser(): Unit |
readQuerySnapshot |
After open fun readQuerySnapshot(snapshots: QuerySnapshot!): Unit |
readUserAndUpdateChats |
After open fun readUserAndUpdateChats(snapshots: QuerySnapshot!): Unit |
stopListenChatListChanges |
unregister an observer to chat room records changes open fun stopListenChatListChanges(): Unit |
stopListenFavChanges |
unregister observer to listen to changes on user's favoured buddies records open fun stopListenFavChanges(): Unit |