Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.

Conversation

@Kormaican
Copy link
Contributor

Currently, it only changes a TextView based on data from Firestore in the activity main in order to test it. To test, click on a tab beside home, then click back on home, and the TextView should change.

…y, it only changes a TextView based on data from Firestore in the activity main in order to test it. To test, click on a tab beside home, then click back on home, and the TextView should change.
@Kormaican Kormaican requested a review from fedorareis March 27, 2020 02:37
Comment on lines +18 to +26
fun setText(textView: TextView) {
db.collection(collectionName).document(testDoc).get()
.addOnSuccessListener {
val tempStr = it.get("description")
if(tempStr is String)
textView.text = tempStr
else println("Value from Firestore is not of type String")
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little fuzzy on what is going on in this function, especially in light of what is in the MainActivity. It appears that this function gets a document from the collection then sets the textView's text to the description from the document. It seems like a lot of what is in this file is just proof of concept that you can get data from the DB. I'm however hesitant to accept it into the repo in that state. The DatabaseManager should just be reading and writing from the DB. We should probably have models for each item type such as Event. Then in the MainActivity you would have something like

R.id.navigation_events -> {
                 textMessage.setText("Events")
                 textMessage.text = event.get("description")
                 return@OnNavigationItemSelectedListener true
}

As a rule of thumb also avoid variable names like tmpStr I'm fine with something being a temp variable, but tell me what it is temporarily storing (e.g. tmpDescription). Descriptive variable naming helps for a better comment/code sturcture. Your code should tell me "what" (in a pretty clear way) and your comments should tell me "why".

Sorry about the length of this comment, I just want to make sure we get the data modeling set up well at the start since it is the core to the whole application.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants