-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Order feedback by date #2261
Changes from 1 commit
278d169
488e7c8
e0a63db
13416e7
f9f623f
7b12dd2
8c7497e
c20af0c
5c0a5bc
c8b162d
5973d84
5b17ba1
3f38282
b0d5754
81db93a
50a91f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,31 +54,29 @@ class FeedbackAdapter( | |
arrangedFeedbackList.clear() | ||
feedbackResponse.feedbackList.forEach { item -> | ||
if (item.email == PrefManager.getStringSet(Constant.SAVED_EMAIL)?.iterator()?.next()) { | ||
var feedback = Feedback() | ||
feedback.email = item.email | ||
feedback.userName = item.userName | ||
feedback.avatar = item.avatar | ||
feedback.timestamp = item.timestamp | ||
feedback.feedback = item.feedback | ||
arrangedFeedbackList.add(feedback) | ||
addFeedback(item) | ||
} | ||
} | ||
|
||
var reverseResponse = feedbackResponse.feedbackList.asReversed() | ||
reverseResponse.forEach { item -> | ||
if (item.email != PrefManager.getStringSet(Constant.SAVED_EMAIL)?.iterator()?.next()) { | ||
var feedback = Feedback() | ||
feedback.email = item.email | ||
feedback.userName = item.userName | ||
feedback.avatar = item.avatar | ||
feedback.timestamp = item.timestamp | ||
feedback.feedback = item.feedback | ||
arrangedFeedbackList.add(feedback) | ||
addFeedback(item) | ||
} | ||
} | ||
Timber.d("Arranged the feedback") | ||
} | ||
|
||
private fun addFeedback(item: Feedback) { | ||
var feedback = Feedback() | ||
feedback.email = item.email | ||
feedback.userName = item.userName | ||
feedback.avatar = item.avatar | ||
feedback.timestamp = item.timestamp | ||
feedback.feedback = item.feedback | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you copying it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently what we have is that we get a response of the feedback in the order of newest at the top. But what we want is that, if the user logged in has given any feedback, then it should come at the top irrespective of the time he gave that feedback. After user feedback is shown, we need to show the rest of the feedbacks in the order with the newest at the top. So, to arrange the list in such an order, I am keeping a separate list of those items and showing these data, with actually affecting the server response directly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you creating a new feedback object and copying the same data in it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The actual feedback response has many different kinds of data, we don't need those data to display or even to iterate any operation. So, I made a feedback object, which can copy the response that we need, instead of copying all the data. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you don't create a new object, will there be any problem? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, what I can do is that I can create the object only once and reuse it every time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you even want to create an object? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need. I understood what u wanted to say. Updating the pr accordingly. |
||
arrangedFeedbackList.add(feedback) | ||
} | ||
|
||
@NonNull | ||
override fun onBindViewHolder(holder: FeedbackViewHolder, position: Int) { | ||
if (arrangedFeedbackList.isNotEmpty()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PrefManager.getStringSet(Constant.SAVED_EMAIL)?.iterator()?.next()
what?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method has been used throughout the app while extracting email from the PrefManager. So, I used it else I would have simply used
PrefManager.getString(Constant.SAVED_EMAIL,"")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use yours
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamareebjamal the app is crashing if I use the getString method in prefmanger to extract the email, but it is working if I use getStringSet. Probably that's the reason getStringSet has been used throughout the app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, revert but it is very stupid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already reverted in the latest update.