Skip to content

Commit

Permalink
feat: add hashtags to event cards
Browse files Browse the repository at this point in the history
  • Loading branch information
aggarwalpulkit596 committed Apr 18, 2019
1 parent 32d3792 commit 6acc55c
Show file tree
Hide file tree
Showing 15 changed files with 305 additions and 49 deletions.
154 changes: 144 additions & 10 deletions app/schemas/org.fossasia.openevent.general.OpenEventDatabase/2.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"formatVersion": 1,
"database": {
"version": 2,
"identityHash": "2eccdc20f2068430bba84bf884a2ec02",
"version": 3,
"identityHash": "c1683d44666fdeb803f1ecc0b344ca4f",
"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, `refundPolicy` TEXT, `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, `favorite` INTEGER NOT NULL, `eventTopic` INTEGER, PRIMARY KEY(`id`))",
"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, `refundPolicy` TEXT, `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, `favorite` INTEGER NOT NULL, `eventTopic` TEXT, `eventType` TEXT, `eventSubTopic` TEXT, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
Expand Down Expand Up @@ -305,7 +305,19 @@
{
"fieldPath": "eventTopic",
"columnName": "eventTopic",
"affinity": "INTEGER",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "eventType",
"columnName": "eventType",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "eventSubTopic",
"columnName": "eventSubTopic",
"affinity": "TEXT",
"notNull": false
}
],
Expand All @@ -323,6 +335,22 @@
"eventTopic"
],
"createSql": "CREATE INDEX `index_Event_eventTopic` ON `${TABLE_NAME}` (`eventTopic`)"
},
{
"name": "index_Event_eventType",
"unique": false,
"columnNames": [
"eventType"
],
"createSql": "CREATE INDEX `index_Event_eventType` ON `${TABLE_NAME}` (`eventType`)"
},
{
"name": "index_Event_eventSubTopic",
"unique": false,
"columnNames": [
"eventSubTopic"
],
"createSql": "CREATE INDEX `index_Event_eventSubTopic` ON `${TABLE_NAME}` (`eventSubTopic`)"
}
],
"foreignKeys": []
Expand Down Expand Up @@ -777,25 +805,25 @@
},
{
"tableName": "EventTopic",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER, `name` TEXT, `slug` TEXT, `event` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`event`) REFERENCES `Event`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `name` TEXT NOT NULL, `slug` TEXT NOT NULL, `event` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`event`) REFERENCES `Event`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": false
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
"notNull": true
},
{
"fieldPath": "slug",
"columnName": "slug",
"affinity": "TEXT",
"notNull": false
"notNull": true
},
{
"fieldPath": "event",
Expand Down Expand Up @@ -834,6 +862,112 @@
}
]
},
{
"tableName": "EventSubTopic",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `name` TEXT NOT NULL, `slug` TEXT NOT NULL, `event` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`event`) REFERENCES `Event`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "slug",
"columnName": "slug",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "event",
"columnName": "event",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [
{
"name": "index_EventSubTopic_event",
"unique": false,
"columnNames": [
"event"
],
"createSql": "CREATE INDEX `index_EventSubTopic_event` ON `${TABLE_NAME}` (`event`)"
}
],
"foreignKeys": [
{
"table": "Event",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"event"
],
"referencedColumns": [
"id"
]
}
]
},
{
"tableName": "EventType",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `name` TEXT NOT NULL, `slug` TEXT NOT NULL, `event` INTEGER, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "slug",
"columnName": "slug",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "event",
"columnName": "event",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [
{
"name": "index_EventType_event",
"unique": false,
"columnNames": [
"event"
],
"createSql": "CREATE INDEX `index_EventType_event` ON `${TABLE_NAME}` (`event`)"
}
],
"foreignKeys": []
},
{
"tableName": "Order",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `paymentMode` TEXT, `country` TEXT, `status` TEXT, `amount` REAL, `identifier` TEXT, `orderNotes` TEXT, `completedAt` TEXT, `city` TEXT, `address` TEXT, `createdAt` TEXT, `zipcode` TEXT, `paidVia` TEXT, `discountCodeId` TEXT, `ticketsPdfUrl` TEXT, `transactionId` TEXT, `event` INTEGER, `attendees` TEXT NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`event`) REFERENCES `Event`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`attendees`) REFERENCES `Attendee`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
Expand Down Expand Up @@ -1072,7 +1206,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"2eccdc20f2068430bba84bf884a2ec02\")"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"c1683d44666fdeb803f1ecc0b344ca4f\")"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ import org.fossasia.openevent.general.auth.UserDao
import org.fossasia.openevent.general.event.Event
import org.fossasia.openevent.general.event.EventDao
import org.fossasia.openevent.general.event.EventIdConverter
import org.fossasia.openevent.general.event.subtopic.EventSubTopic
import org.fossasia.openevent.general.event.subtopic.EventSubTopicConverter
import org.fossasia.openevent.general.event.topic.EventTopic
import org.fossasia.openevent.general.event.topic.EventTopicIdConverter
import org.fossasia.openevent.general.event.topic.EventTopicConverter
import org.fossasia.openevent.general.event.topic.EventTopicsDao
import org.fossasia.openevent.general.event.types.EventType
import org.fossasia.openevent.general.event.types.EventTypeConverter
import org.fossasia.openevent.general.order.Order
import org.fossasia.openevent.general.order.OrderDao
import org.fossasia.openevent.general.social.SocialLink
Expand All @@ -25,8 +29,10 @@ import org.fossasia.openevent.general.ticket.TicketDao
import org.fossasia.openevent.general.ticket.TicketIdConverter

@Database(entities = [Event::class, User::class, SocialLink::class, Ticket::class, Attendee::class,
EventTopic::class, Order::class, CustomForm::class], version = 2)
@TypeConverters(EventIdConverter::class, EventTopicIdConverter::class, TicketIdConverter::class,
EventTopic::class, EventSubTopic::class, EventType::class,
Order::class, CustomForm::class], version = 3)
@TypeConverters(EventIdConverter::class, EventTopicConverter::class, EventTypeConverter::class,
EventSubTopicConverter::class, TicketIdConverter::class,
AttendeeIdConverter::class, ListAttendeeIdConverter::class)
abstract class OpenEventDatabase : RoomDatabase() {

Expand Down
19 changes: 13 additions & 6 deletions app/src/main/java/org/fossasia/openevent/general/di/Modules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.facebook.stetho.okhttp3.StethoInterceptor
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.github.jasminb.jsonapi.ResourceConverter
import com.github.jasminb.jsonapi.SerializationFeature
import com.github.jasminb.jsonapi.retrofit.JSONAPIConverterFactory
import okhttp3.Interceptor
import okhttp3.OkHttpClient
Expand Down Expand Up @@ -44,6 +46,7 @@ import org.fossasia.openevent.general.event.feedback.Feedback
import org.fossasia.openevent.general.event.feedback.FeedbackApi
import org.fossasia.openevent.general.event.location.EventLocation
import org.fossasia.openevent.general.event.location.EventLocationApi
import org.fossasia.openevent.general.event.subtopic.EventSubTopic
import org.fossasia.openevent.general.event.topic.EventTopic
import org.fossasia.openevent.general.event.topic.EventTopicApi
import org.fossasia.openevent.general.event.types.EventType
Expand Down Expand Up @@ -206,16 +209,20 @@ val networkModule = module {
single {
val baseUrl = BuildConfig.DEFAULT_BASE_URL
val objectMapper: ObjectMapper = get()
val onlineApiResourceConverter = ResourceConverter(
objectMapper, Event::class.java, User::class.java,
SignUp::class.java, Ticket::class.java, SocialLink::class.java, EventId::class.java,
EventTopic::class.java, Attendee::class.java, TicketId::class.java, Order::class.java,
AttendeeId::class.java, Charge::class.java, Paypal::class.java, ConfirmOrder::class.java,
CustomForm::class.java, EventLocation::class.java, EventType::class.java,
EventSubTopic::class.java, Feedback::class.java)

onlineApiResourceConverter.enableSerializationOption(SerializationFeature.INCLUDE_RELATIONSHIP_ATTRIBUTES)

Retrofit.Builder()
.client(get())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(JSONAPIConverterFactory(objectMapper, Event::class.java, User::class.java,
SignUp::class.java, Ticket::class.java, SocialLink::class.java, EventId::class.java,
EventTopic::class.java, Attendee::class.java, TicketId::class.java, Order::class.java,
AttendeeId::class.java, Charge::class.java, Paypal::class.java, ConfirmOrder::class.java,
CustomForm::class.java, EventLocation::class.java, EventType::class.java,
Feedback::class.java))
.addConverterFactory(JSONAPIConverterFactory(onlineApiResourceConverter))
.addConverterFactory(JacksonConverterFactory.create(objectMapper))
.baseUrl(baseUrl)
.build()
Expand Down
13 changes: 11 additions & 2 deletions app/src/main/java/org/fossasia/openevent/general/event/Event.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import com.github.jasminb.jsonapi.LongIdHandler
import com.github.jasminb.jsonapi.annotations.Id
import com.github.jasminb.jsonapi.annotations.Relationship
import com.github.jasminb.jsonapi.annotations.Type
import org.fossasia.openevent.general.event.subtopic.EventSubTopic
import org.fossasia.openevent.general.event.topic.EventTopic
import org.fossasia.openevent.general.event.types.EventType

@Type("event")
@JsonNaming(PropertyNamingStrategy.KebabCaseStrategy::class)
Expand Down Expand Up @@ -68,6 +70,13 @@ data class Event(
val isMapShown: Boolean = false,
var favorite: Boolean = false,
@ColumnInfo(index = true)
@Relationship("event-topic")
var eventTopic: EventTopic? = null
@Relationship("event-topic", resolve = true)
var eventTopic: EventTopic? = null,
@ColumnInfo(index = true)
@Relationship("event-type", resolve = true)
var eventType: EventType? = null,
@ColumnInfo(index = true)
@Relationship("event-sub-topic", resolve = true)
var eventSubTopic: EventSubTopic? = null

)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface EventApi {
@GET("events?include=event-topic")
fun getEvents(): Single<List<Event>>

@GET("events?include=event-topic")
@GET("events?include=event-sub-topic,event-topic,event-type")
fun searchEvents(@Query("sort") sort: String, @Query("filter") eventName: String): Single<List<Event>>

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class EventDetailsFragment : Fragment() {
if (event.eventTopic != null || !event.locationName.isNullOrBlank() ||
!event.searchableLocationName.isNullOrBlank()) {
similarEventsContainer.isVisible = true
eventTopicId = event.eventTopic?.id
eventTopicId = event.eventTopic?.id ?: 0
eventLocation =
if (event.searchableLocationName.isNullOrBlank()) event.locationName
else event.searchableLocationName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package org.fossasia.openevent.general.event

import android.content.res.ColorStateList
import android.view.View
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.chip.Chip
import com.squareup.picasso.Callback
import com.squareup.picasso.Picasso
import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.item_card_events.view.chipTags
import kotlinx.android.synthetic.main.item_card_events.view.date
import kotlinx.android.synthetic.main.item_card_events.view.eventImage
import kotlinx.android.synthetic.main.item_card_events.view.eventName
Expand Down Expand Up @@ -57,6 +61,19 @@ class EventViewHolder(override val containerView: View) : RecyclerView.ViewHolde

setFabBackground(event.favorite)

event.eventType.let {
if (it != null)
addchips(it.name)
}
event.eventTopic.let {
if (it != null)
addchips(it.name)
}
event.eventSubTopic.let {
if (it != null)
addchips(it.name)
}

event.originalImageUrl?.let { url ->
Picasso.get()
.load(url)
Expand Down Expand Up @@ -87,6 +104,18 @@ class EventViewHolder(override val containerView: View) : RecyclerView.ViewHolde
}
}

private fun addchips(name: String) {
val chip = Chip(containerView.context)
chip.text = name
chip.isCheckable = false
chip.chipStartPadding = 0f
chip.chipEndPadding = 0f
chip.chipStrokeWidth = 2f
chip.chipStrokeColor =
ColorStateList.valueOf(ContextCompat.getColor(containerView.context, R.color.colorPrimary))
containerView.chipTags.addView(chip)
}

private fun setFabBackground(isFavorite: Boolean) {
if (isFavorite) {
containerView.favoriteFab.setImageResource(R.drawable.ic_baseline_favorite)
Expand Down
Loading

0 comments on commit 6acc55c

Please sign in to comment.