Skip to content

Conversation

@dreadpool2
Copy link

Fixes #123
videotogif_2018 06 25_02 31 29

@@ -0,0 +1,11 @@
package org.fossasia.openevent.general.similar
Copy link
Member

Choose a reason for hiding this comment

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

What similar?

fun getEventTopicOfEvent(eventId: Long): Flowable<EventTopic>
*/
@Query("UPDATE Event SET favorite = :favorite WHERE id = :eventId")
fun setFavorite(eventId: Long, favorite: Boolean)
Copy link
Member

Choose a reason for hiding this comment

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

Ummm This is EventDao

val similarEvents = MutableLiveData<List<Event>>()
val error = MutableLiveData<String>()

fun getSimilarEvents(id: Long) {
Copy link
Member

Choose a reason for hiding this comment

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

A void getter!!!

Copy link
Author

Choose a reason for hiding this comment

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

Will change the function name 😄

Copy link
Author

Choose a reason for hiding this comment

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

Updated PR 👍

val view = LayoutInflater.from(parent.context).inflate(R.layout.item_card_events, parent, false)
return EventViewHolder(view)
val eventView: View
if (eventLayout.equals("similarEvents")) {
Copy link
Member

@simarsingh24 simarsingh24 Jun 25, 2018

Choose a reason for hiding this comment

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

Keep similarEvents and events in some constant string and use reference here

@GET("event-topics/{id}")
fun getEventTopic(@Path("id") id: Long): Single<EventTopic>

*/
Copy link
Member

Choose a reason for hiding this comment

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

why are you keeping commented code?

.map {
eventTopicsDao.insertSimilarEvents(it)
}
.toFlowable()
Copy link
Member

Choose a reason for hiding this comment

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

take this to the line above

eventTopicsDao.insertEventTopic(it)
it
}
.toFlowable()
Copy link
Member

Choose a reason for hiding this comment

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

same here

/*
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertEventTopic(eventTopic: EventTopic)
*/
Copy link
Member

Choose a reason for hiding this comment

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

commented code?

/*
@Query("DELETE FROM EventTopic")
fun deleteAllEventTopics()
*/
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Author

Choose a reason for hiding this comment

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

I thought I might probably require these methods in future, will probably remove them for now 👍

Copy link
Member

Choose a reason for hiding this comment

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

yes please remove this dont keep commented code in final version

}

similarEventsRecyclerAdapter.setListener(recyclerViewClickListener)

Copy link
Member

Choose a reason for hiding this comment

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

extra line feed

super.onCleared()
compositeDisposable.clear()
}

Copy link
Member

Choose a reason for hiding this comment

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

extra line

@simarsingh24
Copy link
Member

good work btw 👍

val error = MutableLiveData<String>()

fun loadSimilarEvents(id: Long) {
if(id.toString() == "-1"){
Copy link
Member

Choose a reason for hiding this comment

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

why a conversion to string ? You can compare that directly

Copy link
Author

@dreadpool2 dreadpool2 Jun 25, 2018

Choose a reason for hiding this comment

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

It's not working if I use id.equals(-1).

Copy link
Member

Choose a reason for hiding this comment

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

why dont you do id == -1

Copy link
Author

Choose a reason for hiding this comment

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

id is of type long actually, so an error is cropping up

Copy link
Member

Choose a reason for hiding this comment

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

Use id == -1

@dreadpool2
Copy link
Author

@iamareebjamal Could you please review this as I want to work on #207 after this

val favorite: Boolean = false,
@ColumnInfo(index = true)
@Relationship("event-topic")
var eventTopic: EventTopicId? = null
Copy link
Member

Choose a reason for hiding this comment

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

Why not load the entire event topic in one go?

Copy link
Member

Choose a reason for hiding this comment

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

This way you can even show the event topic's name

Copy link
Author

Choose a reason for hiding this comment

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

Great! I will do that 👍

rootView.endsOn.text = EventUtils.getFormattedDate(endsAt)

//Set event topic id
if(event.eventTopic != null){
Copy link
Member

Choose a reason for hiding this comment

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

Space around symbols


//Set event topic id
if(event.eventTopic != null){
eventTopicId = (event.eventTopic)?.id
Copy link
Member

Choose a reason for hiding this comment

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

No need for parenthesis

bundle.putLong(EVENT_ID, eventId)
eventTopicId?.let { bundle.putLong(EVENT_TOPIC_ID, it) }
similarEventsFragment.arguments = bundle
val transaction = childFragmentManager.beginTransaction()
Copy link
Member

Choose a reason for hiding this comment

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

No need of storing transaction in a variable

class EventTopicIdConverter {

@TypeConverter
fun fromEventTopicId(eventTopicId: EventTopicId?): Long?{
Copy link
Member

Choose a reason for hiding this comment

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

Space before {

import org.fossasia.openevent.general.event.Event
import org.fossasia.openevent.general.event.EventDao

class EventTopicService(private val eventApi: EventTopicApi, private val eventTopicsDao: EventTopicsDao, private val eventDao: EventDao) {
Copy link
Member

Choose a reason for hiding this comment

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

Property per line

eventApi.getEventsUnderTopicId(id)
.toFlowable()
.map {
eventTopicsDao.insertSimilarEvents(it)
Copy link
Member

Choose a reason for hiding this comment

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

How is this different from event service's method?

}
}

fun setFavorite(eventId: Long, favourite: Boolean): Completable {
Copy link
Member

Choose a reason for hiding this comment

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

Why create unnecessary duplicate methods?

fun deleteAllEvents()

@Query("SELECT * from Event WHERE eventTopic = :topicId")
fun getAllSimilarEvents(topicId: Long): Flowable<List<Event>>
Copy link
Member

Choose a reason for hiding this comment

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

Add this in EventDao, you are selecting from the same table, so should remain in the same DAO

By this logic, we should have FavoriteDao as well

@dreadpool2
Copy link
Author

PR Updated 👍

interface EventTopicApi {

@GET("event-topics/{id}/events")
@GET("event-topics/{id}/events?include=event-topic&fields[event-topic]=id&page[size]=0")
Copy link
Member

Choose a reason for hiding this comment

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

No need to restrict the event topic field now

@Query("DELETE FROM Event")
fun deleteAllEvents()

} No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

No need of this file

Copy link
Member

Choose a reason for hiding this comment

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

No need of this file

Copy link
Author

Choose a reason for hiding this comment

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

Won't we require this in future to show users a list of event topics ?

@Id(LongIdHandler::class)
val id: Long? = null,
val name: String? = null,
val slug: String? = null
Copy link
Member

Choose a reason for hiding this comment

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

Add a foreign key to event

Copy link
Author

@dreadpool2 dreadpool2 Jun 27, 2018

Choose a reason for hiding this comment

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

Actually EventTopic is not being inserted into the database, so I thought that foriegn key is not needed. Is it wrong ?

Copy link
Author

Choose a reason for hiding this comment

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

Okay! Got it wrong 👍

Copy link
Member

Choose a reason for hiding this comment

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

You have to insert it into database as well

Copy link
Author

Choose a reason for hiding this comment

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

Updated PR 👍

@PrimaryKey
val id: Long?,
val name: String?,
val slug: String?
Copy link
Member

Choose a reason for hiding this comment

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

There's no eventId to make foreign key of

@dreadpool2
Copy link
Author

@iamareebjamal Did all the changes requested 👍

@Query("DELETE FROM Event")
fun deleteAllEvents()

} No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

No need of this file

@dreadpool2
Copy link
Author

Removed EventTopicsDao for while 👍


@Type("event-topic")
@JsonNaming(PropertyNamingStrategy.KebabCaseStrategy::class)
data class EventTopic(
Copy link
Member

Choose a reason for hiding this comment

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

Why did you remove this?

Copy link
Author

Choose a reason for hiding this comment

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

I had removed EventTopic as it was not needed that time. I added it again now 👍

@@ -0,0 +1,25 @@
package org.fossasia.openevent.general.similarEvents
Copy link
Member

Choose a reason for hiding this comment

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

Package name doesn't have camel case

Copy link
Author

Choose a reason for hiding this comment

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

Changed it to similar_events

object EventUtils {

val SIMILAR_EVENTS: String = "similarEvents"
val EVENTS: String = "events"
Copy link
Member

Choose a reason for hiding this comment

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

Where are these needed?

Copy link
Author

Choose a reason for hiding this comment

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

These are needed in EventsFragment and SimilarEventsFragment respectively. I have used the same adapter and ViewHolder for both the recycler views.


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
eventsRecyclerAdapter.setEventLayout(EventUtils.EVENTS)
Copy link
Author

Choose a reason for hiding this comment

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

@iamareebjamal Here is one case

Copy link
Member

Choose a reason for hiding this comment

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

Use them locally then, no need for these in EventUtils

Copy link
Author

Choose a reason for hiding this comment

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

Okay 👍

Copy link
Author

Choose a reason for hiding this comment

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

Did the changes 👍


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
similarEventsRecyclerAdapter.setEventLayout(EventUtils.SIMILAR_EVENTS)
Copy link
Author

Choose a reason for hiding this comment

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

Here is another case

Copy link
Member

Choose a reason for hiding this comment

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

Underscore is also not allowed, move the package in event package and rename to topic

Copy link
Author

Choose a reason for hiding this comment

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

Changed package name 👍


class EventDetailsFragment : Fragment() {
val EVENT_ID = "EVENT_ID"
val EVENT_TOPIC_ID = "EVENT_TOPIC_ID"
Copy link
Member

Choose a reason for hiding this comment

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

private const val and above as well

private var clickListener: RecyclerViewClickListener? = null
private var favoriteFabListener: FavoriteFabListener? = null
private var eventLayout: String? = null
val SIMILAR_EVENTS: String = "similarEvents"
Copy link
Member

Choose a reason for hiding this comment

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

private const val

private val similarEventsViewModel by viewModel<SimilarEventsViewModel>()
private lateinit var rootView: View
private var EVENT_TOPIC_ID: String = "EVENT_TOPIC_ID"
val SIMILAR_EVENTS: String = "similarEvents"
Copy link
Member

Choose a reason for hiding this comment

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

Use once

iamareebjamal
iamareebjamal previously approved these changes Jun 27, 2018
Copy link
Member

@iamareebjamal iamareebjamal left a comment

Choose a reason for hiding this comment

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

Follow up PR to save the loaded event topic in DB

@fossasia fossasia deleted a comment Jun 27, 2018
@fossasia fossasia deleted a comment Jun 27, 2018
@iamareebjamal
Copy link
Member

@dreadpool2 Squash your commits

@dreadpool2
Copy link
Author

@iamareebjamal Thanks! I will do that 👍

@fossasia fossasia deleted a comment Jun 27, 2018
@fossasia fossasia deleted a comment Jun 27, 2018
@fossasia fossasia deleted a comment Jun 27, 2018
@dreadpool2
Copy link
Author

@iamareebjamal Rebased my commits 👍

@iamareebjamal iamareebjamal merged commit e3c0ad5 into fossasia:development Jun 27, 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