Skip to content
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: View social links in event details #105

Merged
merged 19 commits into from
Jun 14, 2018
Merged

feat: View social links in event details #105

merged 19 commits into from
Jun 14, 2018

Conversation

dreadpool2
Copy link

@dreadpool2 dreadpool2 commented Jun 8, 2018

Fixes #95
screenshot_20180609-144208

@dreadpool2
Copy link
Author

dreadpool2 commented Jun 9, 2018

@nikit19 @simarsingh24 @iamareebjamal I made some social links using the API, Should I change the UI or just keep it like this ?

Copy link
Member

@nikit19 nikit19 left a comment

Choose a reason for hiding this comment

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

Have a look at Eventbrite's UI and try to make it like that

@dreadpool2
Copy link
Author

@iamareebjamal We can only have the UI as same to Eventbrite after issue #106 is taken care of. Meanwhile changed the colour to grey
image

@Id(IntegerIdHandler::class)
val id: Int,
val link: String,
val name: String
Copy link
Member

Choose a reason for hiding this comment

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

Add foreign key

fun deleteAll()

@Query("SELECT * from SocialLink ORDER BY startsAt DESC")
fun getAllSocialLinks(id: Long): Flowable<List<SocialLink>>
Copy link
Member

Choose a reason for hiding this comment

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

Wrong logic, should get social links for an event

Copy link
Author

Choose a reason for hiding this comment

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

Yeah Actually I haven't implemented db storage yet, I am doing it 👍

@dreadpool2
Copy link
Author

@iamareebjamal Added type converter and it is compiling correctly, but the fetching and storing is not working

val link: String,
val name: String,
@Relationship("event")
var event: Event?
Copy link
Member

Choose a reason for hiding this comment

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

Why var and nullable?

Copy link
Author

Choose a reason for hiding this comment

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

I was facing an error which gave that parameter specified as non-null is null

Copy link
Member

Choose a reason for hiding this comment

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

This means that response is not receiving event as relationship. Fix that instead of removing this

Copy link
Member

Choose a reason for hiding this comment

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

that is because you havent added include event statement inside the API

Copy link
Author

Choose a reason for hiding this comment

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

Its still returning that error, event is always null

Copy link
Member

Choose a reason for hiding this comment

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

Check the logs for why is that

Copy link
Author

Choose a reason for hiding this comment

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

Yeah I did check, it like the jackson mapping is not done properly

Copy link
Author

Choose a reason for hiding this comment

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

java.lang.RuntimeException: com.fasterxml.jackson.databind.JsonMappingException: Instantiation of [simple type, class org.fossasia.openevent.general.social.SocialLink] value failed (java.lang.IllegalArgumentException): Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter event 06-12 18:08:18.409 32538-32538/org.fossasia.openevent.general E/SocialLinksViewModel$loadSocialLinks:

Copy link
Member

Choose a reason for hiding this comment

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

Create a new type called EventId which only contains id attribute and use it instead of whole Event

Sanyog Ghosh added 2 commits June 12, 2018 17:49
@dreadpool2
Copy link
Author

@iamareebjamal seemingly after doing even that the loading is failing :(

@dreadpool2
Copy link
Author

06-12 19:04:25.801 15162-15162/org.fossasia.openevent.general E/SocialLinksViewModel$loadSocialLinks: java.lang.RuntimeException: com.fasterxml.jackson.databind.JsonMappingException: Instantiation of [simple type, class org.fossasia.openevent.general.social.SocialLink] value failed (java.lang.IllegalArgumentException): Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter eventId

@iamareebjamal
Copy link
Member

Name should be event

@iamareebjamal
Copy link
Member

First resolve conflicts so that PR can be locally inspected

@dreadpool2
Copy link
Author

@iamareebjamal Resolved conflicts

@@ -89,7 +96,7 @@ val networkModule = applicationContext {
Retrofit.Builder()
.client(get())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(JSONAPIConverterFactory(objectMapper, Event::class.java, User::class.java, SignUp::class.java, Ticket::class.java))
.addConverterFactory(JSONAPIConverterFactory(objectMapper, Event::class.java, User::class.java, SignUp::class.java, Ticket::class.java, SocialLink::class.java, EventId::class.java))
Copy link
Member

Choose a reason for hiding this comment

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

@iamareebjamal why is eventid class here would it be needed?

Copy link
Member

Choose a reason for hiding this comment

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

Yes

@dreadpool2
Copy link
Author

The mapping is still not being done correctly though it looks quite correct.
06-12 22:02:21.908 5808-5808/org.fossasia.openevent.general E/SocialLinksViewModel$loadSocialLinks: java.lang.RuntimeException: com.fasterxml.jackson.databind.JsonMappingException: Instantiation of [simple type, class org.fossasia.openevent.general.social.SocialLink] value failed (java.lang.IllegalArgumentException): Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter event

@iamareebjamal
Copy link
Member

I'm looking at it

@iamareebjamal
Copy link
Member

@dreadpool2 Which event has social links

@dreadpool2
Copy link
Author

seminar on functional programming

@dreadpool2
Copy link
Author

@iamareebjamal Did it work after making it nullable ?

@dreadpool2
Copy link
Author

@iamareebjamal Wow! I checked it out it seems to work really fine 👍

data class SocialLink(
@Id(IntegerIdHandler::class)
@PrimaryKey
val id: Int,
val link: String,
val name: String,
@ColumnInfo(index = true)
@ForeignKey(entity = Event::class, parentColumns = ["id"], childColumns = ["event"], onDelete = CASCADE, onUpdate = CASCADE)
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why this foreign key does not work, please revert back to your method of declaring foreign key

Copy link
Author

Choose a reason for hiding this comment

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

Okay will do that 👍 Was the error due to ColumnInfo ?

Copy link
Member

Choose a reason for hiding this comment

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

No, JSONAPI converter can't set relationship at the time of creation of entity

Copy link
Author

Choose a reason for hiding this comment

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

Ohhkay !! I verified that now 👍 So nullable made the difference

import org.fossasia.openevent.general.event.EventId
import timber.log.Timber

class EventConverter {
Copy link
Member

Choose a reason for hiding this comment

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

Move to correct package

@dreadpool2
Copy link
Author

Did the changes 👍

@dreadpool2
Copy link
Author

@iamareebjamal Are any other changes required ?


import android.arch.persistence.room.TypeConverter

class EventConverter {
Copy link
Member

Choose a reason for hiding this comment

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

EventIdConverter


class SocialLinksService(private val socialLinkApi: SocialLinkApi, private val socialLinksDao: SocialLinksDao) {

fun getSocialLinks(id: Long): Single<List<SocialLink>> {
Copy link
Member

Choose a reason for hiding this comment

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

Should return flowable

Copy link
Author

Choose a reason for hiding this comment

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

@iamareebjamal We used Single in all the previous cases, should we still use Flowable ?

Copy link
Author

Choose a reason for hiding this comment

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

@iamareebjamal Should it remain as Single?

Copy link
Member

Choose a reason for hiding this comment

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

We are always using Flowable AFAIK

Copy link
Author

Choose a reason for hiding this comment

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

Actually in the discount codes fetching we use Single, even when dealing with users we are using Single actually.

Copy link
Author

Choose a reason for hiding this comment

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

Okay I think I understood 👍

@iamareebjamal
Copy link
Member

Always remove he wip tag once the PR is finalized

@dreadpool2 dreadpool2 changed the title (wip) feat: view social links in event details feat: View social links in event details Jun 13, 2018
@dreadpool2
Copy link
Author

PR Updated

"entities": [
{
"tableName": "Event",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `name` TEXT NOT NULL, `identifier` TEXT NOT NULL, `startsAt` TEXT NOT NULL, `endsAt` TEXT NOT NULL, `timezone` TEXT NOT NULL, `privacy` TEXT NOT NULL, `paymentCountry` TEXT, `paypalEmail` TEXT, `thumbnailImageUrl` TEXT, `schedulePublishedOn` TEXT, `paymentCurrency` TEXT, `organizerDescription` TEXT, `originalImageUrl` TEXT, `onsiteDetails` TEXT, `organizerName` TEXT, `largeImageUrl` TEXT, `deletedAt` TEXT, `ticketUrl` TEXT, `locationName` TEXT, `codeOfConduct` TEXT, `state` TEXT, `searchableLocationName` TEXT, `description` TEXT, `pentabarfUrl` TEXT, `xcalUrl` TEXT, `logoUrl` TEXT, `externalEventUrl` TEXT, `iconImageUrl` TEXT, `icalUrl` TEXT, `createdAt` TEXT, `bankDetails` TEXT, `chequeDetails` TEXT, `isComplete` INTEGER NOT NULL, `latitude` REAL, `longitude` REAL, `canPayByStripe` INTEGER NOT NULL, `canPayByCheque` INTEGER NOT NULL, `canPayByBank` INTEGER NOT NULL, `canPayByPaypal` INTEGER NOT NULL, `canPayOnsite` INTEGER NOT NULL, `isSponsorsEnabled` INTEGER NOT NULL, `hasOrganizerInfo` INTEGER NOT NULL, `isSessionsSpeakersEnabled` INTEGER NOT NULL, `isTicketingEnabled` INTEGER NOT NULL, `isTaxEnabled` INTEGER NOT NULL, `isMapShown` INTEGER NOT NULL, PRIMARY KEY(`id`))",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABAuLE_NAME}` (`id` INTEGER NOT NULL, `name` TEXT NOT NULL, `identifier` TEXT NOT NULL, `startsAt` TEXT NOT NULL, `endsAt` TEXT NOT NULL, `timezone` TEXT NOT NULL, `privacy` TEXT NOT NULL, `paymentCountry` TEXT, `paypalEmail` TEXT, `thumbnailImageUrl` TEXT, `schedulePublishedOn` TEXT, `paymentCurrency` TEXT, `organizerDescription` TEXT, `originalImageUrl` TEXT, `onsiteDetails` TEXT, `organizerName` TEXT, `largeImageUrl` TEXT, `deletedAt` TEXT, `ticketUrl` TEXT, `locationName` TEXT, `codeOfConduct` TEXT, `state` TEXT, `searchableLocationName` TEXT, `description` TEXT, `pentabarfUrl` TEXT, `xcalUrl` TEXT, `logoUrl` TEXT, `externalEventUrl` TEXT, `iconImageUrl` TEXT, `icalUrl` TEXT, `createdAt` TEXT, `bankDetails` TEXT, `chequeDetails` TEXT, `isComplete` INTEGER NOT NULL, `latitude` REAL, `longitude` REAL, `canPayByStripe` INTEGER NOT NULL, `canPayByCheque` INTEGER NOT NULL, `canPayByBank` INTEGER NOT NULL, `canPayByPaypal` INTEGER NOT NULL, `canPayOnsite` INTEGER NOT NULL, `isSponsorsEnabled` INTEGER NOT NULL, `hasOrganizerInfo` INTEGER NOT NULL, `isSessionsSpeakersEnabled` INTEGER NOT NULL, `isTicketingEnabled` INTEGER NOT NULL, `isTaxEnabled` INTEGER NOT NULL, `isMapShown` INTEGER NOT NULL, PRIMARY KEY(`id`))",
Copy link
Member

Choose a reason for hiding this comment

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

TABAuLE_NAME typo

@dreadpool2
Copy link
Author

PR Updated

.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe({
progress.value = true
}).doOnNext({
Copy link
Member

Choose a reason for hiding this comment

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

doFinally

Copy link
Author

Choose a reason for hiding this comment

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

It's not working with doFinally

Copy link
Author

Choose a reason for hiding this comment

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

Progress is never complete

@iamareebjamal iamareebjamal merged commit a2b093e into fossasia:development Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants