-
Notifications
You must be signed in to change notification settings - Fork 551
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: add hashtags to event cards #1595
Conversation
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.
@nikit19 any suggestions ?
app/src/main/java/org/fossasia/openevent/general/event/EventService.kt
Outdated
Show resolved
Hide resolved
I tried using resolve = true but it isn't Saving the object |
a9914f2
to
3999c03
Compare
@iamareebjamal @nikit19 updated please review |
Use the outline style in chip |
90a2afb
to
bdaa97f
Compare
@iamareebjamal updated |
Peer Review |
@liveHarshit please review |
UI is not looking good. You can decrease the size to make UI effective. |
okay anything related to code @liveHarshit ? |
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.
Please revert unnecessary changes
@@ -27,6 +27,7 @@ import kotlinx.android.synthetic.main.content_event.similarEventsContainer | |||
import kotlinx.android.synthetic.main.content_event.view.eventDateDetailsFirst | |||
import kotlinx.android.synthetic.main.content_event.view.eventDateDetailsSecond | |||
import kotlinx.android.synthetic.main.content_event.view.eventDescription | |||
import kotlinx.android.synthetic.main.content_event.view.eventImage |
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.
Unrelated changes
import kotlinx.android.synthetic.main.content_event.view.nestedContentEventScroll | ||
import kotlinx.android.synthetic.main.content_event.view.organizerContainer | ||
import kotlinx.android.synthetic.main.content_event.view.organizerLogoIcon |
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.
same
import kotlinx.android.synthetic.main.fragment_event.view.container | ||
import kotlinx.android.synthetic.main.content_fetching_event_error.view.retry |
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.
same
app/src/main/java/org/fossasia/openevent/general/event/EventDetailsFragment.kt
Outdated
Show resolved
Hide resolved
@liveHarshit which one you're referring to outline or purple colored ones? |
The overall size of the chips. |
@liveHarshit updated |
8b51d36
to
4d84231
Compare
The error is unrelated to GSON, and we are not even using GSON |
app/src/main/java/org/fossasia/openevent/general/event/subtopic/EventSubTopicIdConverter.kt
Outdated
Show resolved
Hide resolved
If we are using it, then please remove it as we already have Jackson |
@iamareebjamal here gson is used to |
@iamareebjamal i'm extremely sorry it was my mistake i forgot to push the build.gradle file in which i added a library |
@iamareebjamal @liveHarshit updated it should work now |
app/build.gradle
Outdated
@@ -118,6 +118,7 @@ dependencies { | |||
testImplementation "androidx.room:room-testing:${roomVersion}" | |||
implementation 'androidx.preference:preference:1.1.0-alpha01' | |||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | |||
implementation "com.google.code.gson:gson:2.8.5" |
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.
Remove
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.
type converter can't work without them
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.
What is GSON?
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.
And why do you need it when the project is using Jackson
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.
GSON
A Java serialization/deserialization library to convert Java Objects into JSON and back
Refrences
https://medium.com/@amit.bhandari/storing-java-objects-other-than-primitive-types-in-room-database-11e45f4f6d22
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.
class EventTypeConverter {
@TypeConverter
fun toEventSubTopic(json: String): EventType? {
val type = object : TypeToken<EventType>() {}.type
return Gson().fromJson(json, type)
}
@TypeConverter
fun toJson(eventSubTopic: EventType?) = Gson().toJson(eventSubTopic) }
here the implementation can't be achieved using jackson
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.
Why can't it be done using Jackson?
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.
i couldn't find any methods for such thing
https://stackoverflow.com/questions/49064618/typetoken-getparameterized-in-jackson-json
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.
I don't think I have a job of pointing to the documentation of a JSON serializing library
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 i'm sorry and intiallly thought you weren't getting the point of gson/jackson for the converter
app/build.gradle
Outdated
@@ -118,6 +118,7 @@ dependencies { | |||
testImplementation "androidx.room:room-testing:${roomVersion}" | |||
implementation 'androidx.preference:preference:1.1.0-alpha01' | |||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | |||
implementation "com.google.code.gson:gson:2.8.5" |
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.
i need it to convert event topic,subtopic and type model into event model by converting into gson and then converting it back to respective models
app/src/main/java/org/fossasia/openevent/general/event/subtopic/EventSubTopicConverter.kt
Show resolved
Hide resolved
@iamareebjamal updated.Thank you |
@@ -42,5 +50,9 @@ abstract class OpenEventDatabase : RoomDatabase() { | |||
|
|||
abstract fun eventTopicsDao(): EventTopicsDao | |||
|
|||
abstract fun eventTypesDao(): EventTypesDao | |||
|
|||
abstract fun eventSubTopicDao(): EventSubTopicDao |
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.
Since these are now stored with the event, this is unneeded
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.
but we can use these dao in future for chips or filtering i suggest we should keep them
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.
We can't use them unless there is a table for them
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.
i'm saving them as well in a seperate table i could remove that part though but we may need them in future
@@ -76,6 +94,8 @@ class EventService( | |||
return eventApi.searchEvents("name", locationName).flatMap { apiList -> | |||
val eventIds = apiList.map { it.id }.toList() | |||
eventTopicsDao.insertEventTopics(getEventTopicList(apiList)) | |||
eventTypesDao.insertEventTypes(getEventTypeList(apiList)) |
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 i'm saving them individually as well so there is a table for them as well
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.
Why are you converting in JSON then? Just save them as JSON. No need to add tables
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.
okay i'll remove them
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.
updated
Since new columns have been added to the table, there must be changes in schema JSON |
474e435
to
6acc55c
Compare
@iamareebjamal updated JSON schema |
Resolved Conflicts |
class EventSubTopicConverter { | ||
@TypeConverter | ||
fun toEventSubTopic(json: String): EventSubTopic? { | ||
return jacksonObjectMapper().readerFor(EventSubTopic::class.java).readValue<EventSubTopic>(json) |
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.
There's already an object mapper in dependency graph, use that
class EventSubTopicConverter { | ||
@TypeConverter | ||
fun toEventSubTopic(json: String): EventSubTopic? { | ||
val objectMapper = ObjectMapper() |
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 updated
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.
No, this is still instantiating ObjectMapper yourself
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
val mapType = object : TypeReference() {}
return ObjectMapper().readValue(json, mapType)
like this ?
instead of
val objectMapper = ObjectMapper()
val mapType = object : TypeReference() {}
return ObjectMapper().readValue(json, mapType)
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.
No, you need to use the ObjectMapper from DI. Who said anything about TypeReference or that your implementation was wrong
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 how i can pass that in type converter because type converter can only have empty constructors
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.
and also ListAttendeeIdConverter uses the same pattern because we can't pass anything to type converter
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 anything else?
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.
You can manually inject the dependency. See field injection
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.
but for field injection, we need a context or something type converter don't even have that
i tired using StandAloneContext.getKoin().koinContext and val objectMapper: ObjectMapper by inject()
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. Create an issue to convert all object mappers from the one in DI
@iamareebjamal please review |
@TypeConverter | ||
fun toEventType(json: String): EventType? { | ||
val mapType = object : TypeReference<EventType>() {} | ||
return ObjectMapper().readValue(json, mapType) } |
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.
Revert to how it was before
@iamareebjamal updated |
addchips(it.name) | ||
} | ||
event.eventSubTopic.let { | ||
if (it != null) |
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.
any particular reason for explicit null checks?
Using ?.let
would work?
Fixes #1592
Changes: Added Event Types, SubTopics to the database to show hashtags in event cards
Screenshots for the change: