Skip to content

Commit

Permalink
feat: Show Ticket Sales in Events List (#1315)
Browse files Browse the repository at this point in the history
  • Loading branch information
Masquerade0097 authored and iamareebjamal committed Aug 14, 2018
1 parent 0f8e339 commit 579b54f
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public final class OrgaDatabase {
public static final String NAME = "orga_database";
private static final String DROP_TABLE = "DROP TABLE IF EXISTS ";
// To be bumped after each schema change and migration addition
public static final int VERSION = 17;
public static final int VERSION = 18;


private OrgaDatabase() {
Expand Down Expand Up @@ -259,6 +259,7 @@ public void migrate(@NonNull DatabaseWrapper databaseWrapper) {
}
}

@Migration(version = 16, database = OrgaDatabase.class)
public static class MigrationTo16 extends BaseMigration {

@Override
Expand Down Expand Up @@ -290,4 +291,23 @@ public void onPreMigrate() {
addColumn(SQLiteType.TEXT, column);
}
}

@Migration(version = 18, database = OrgaDatabase.class)
public static class MigrationTo18 extends AlterTableMigration<Event> {

public MigrationTo18(Class<Event> table) {
super(table);
}

@Override
public void onPreMigrate() {
super.onPreMigrate();

List<String> addedColumns = Arrays.asList("ticketsSold", "ticketsAvailable", "revenue");

for (String column : addedColumns)
addColumn(SQLiteType.TEXT, column);
}
}

}
11 changes: 7 additions & 4 deletions app/src/main/java/com/eventyay/organizer/data/event/Event.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.eventyay.organizer.data.event;

import com.eventyay.organizer.common.model.HeaderProvider;
import com.eventyay.organizer.data.db.configuration.OrgaDatabase;
import com.eventyay.organizer.data.ticket.Ticket;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
Expand All @@ -12,10 +15,6 @@
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;

import com.eventyay.organizer.common.model.HeaderProvider;
import com.eventyay.organizer.data.db.configuration.OrgaDatabase;
import com.eventyay.organizer.data.ticket.Ticket;

import java.util.List;

import lombok.AllArgsConstructor;
Expand Down Expand Up @@ -96,6 +95,10 @@ public class Event implements Comparable<Event>, HeaderProvider {
public boolean isTaxEnabled;
public boolean isMapShown;

public Long ticketsSold;
public Long ticketsAvailable;
public Long revenue;

@ColumnIgnore
@Relationship("tickets")
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
Expand Down
85 changes: 77 additions & 8 deletions app/src/main/res/layout/event_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

<import type="android.view.View" />

<import type="com.eventyay.organizer.data.event.Event" />

<import type="com.eventyay.organizer.utils.DateUtils" />

<import type="com.eventyay.organizer.utils.Utils" />

<variable
name="event"
type="com.eventyay.organizer.data.event.Event" />

<variable
name="selectedEventId"
type="Long" />
Expand Down Expand Up @@ -38,12 +44,27 @@
android:paddingStart="@dimen/spacing_small"
android:paddingTop="@dimen/spacing_small">

<ImageView
android:layout_width="@dimen/image_small"
android:layout_height="@dimen/image_small"
android:contentDescription="@string/event_thumbnail"
app:circleImageUrl="@{ event.thumbnailImageUrl }"
app:placeholder="@{ @drawable/ic_photo_shutter }" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start">

<com.mikhaellopez.circularprogressbar.CircularProgressBar
android:layout_width="@dimen/ticket_progress_smaller_size"
android:layout_height="@dimen/ticket_progress_smaller_size"
app:circular_progress_color='@{"light_blue"}'
app:cpb_background_progressbar_width="5dp"
app:cpb_progressbar_width="10dp"
app:progress_with_animation="@{event.ticketsAvailable == 0 ? 0 : (int) ((event.ticketsSold*100)/event.ticketsAvailable)}" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text='@{(event.ticketsAvailable == 0 ? 0 : (int) ((event.ticketsSold*100)/event.ticketsAvailable)) + "%"}'
android:textSize="@dimen/text_size_normal" />

</FrameLayout>

<LinearLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -99,9 +120,57 @@
android:layout_marginLeft="@dimen/spacing_medium"
android:layout_marginStart="@dimen/spacing_medium"
android:text="@{ DateUtils.formatDateWithDefault(DateUtils.FORMAT_DAY_DATE_TIME, event.getStartsAt()) }"
android:textAllCaps="true"
android:textColor="@color/grey_600"
android:textSize="@dimen/text_size_extra_small"
android:textAllCaps="true"/>
android:textSize="@dimen/text_size_extra_small" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="17">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="10"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/spacing_medium"
android:layout_marginStart="@dimen/spacing_medium"
android:text="@{event.ticketsSold}"
android:textSize="@dimen/text_size_normal"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{"/" + event.ticketsAvailable}'
android:textSize="@dimen/text_size_small" />

</LinearLayout>

<FrameLayout
android:id="@+id/currency_frame"
android:layout_width="0dp"
android:layout_height="match_parent"
android:visibility="@{ Utils.isEmpty(event.paymentCurrency) ? View.GONE : View.VISIBLE }"
android:layout_weight="7">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:paddingEnd="@dimen/spacing_small"
android:paddingLeft="@dimen/spacing_small"
android:paddingRight="@dimen/spacing_small"
android:paddingStart="@dimen/spacing_small"
android:text='@{ event.revenue + " " + event.paymentCurrency }' />

</FrameLayout>
</LinearLayout>

</LinearLayout>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<dimen name="check_in_button_height">44dp</dimen>
<dimen name="size_sale_box">160dp</dimen>
<dimen name="ticket_progress_size">80dp</dimen>
<dimen name="ticket_progress_smaller_size">60dp</dimen>
<dimen name="nav_header_height">160dp</dimen>
<dimen name="ticket_chart_height">200dp</dimen>
<dimen name="avatar_size">150dp</dimen>
Expand Down

0 comments on commit 579b54f

Please sign in to comment.