-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
luca
committed
Nov 28, 2019
1 parent
5326e64
commit 6fe180e
Showing
28 changed files
with
140 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 7 additions & 26 deletions
33
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/ArticlesController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,17 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import com.airbnb.epoxy.EpoxyController | ||
import com.kirkbushman.sampleapp.models.article | ||
import com.kirkbushman.sampleapp.models.empty | ||
import com.kirkbushman.zammad.models.TicketArticle | ||
|
||
class ArticlesController(private val callback: OnArticleCallback) : EpoxyController() { | ||
class ArticlesController(callback: OnArticleCallback) : BaseController<TicketArticle>(callback) { | ||
|
||
private val articles = ArrayList<TicketArticle>() | ||
override fun onItem(item: TicketArticle) { | ||
|
||
fun setArticles(articles: Collection<TicketArticle>) { | ||
this.articles.clear() | ||
this.articles.addAll(articles) | ||
requestModelBuild() | ||
} | ||
|
||
override fun buildModels() { | ||
|
||
if (articles.isEmpty()) { | ||
empty { | ||
id("empty_items") | ||
} | ||
} | ||
|
||
articles.forEach { | ||
|
||
article { | ||
id(it.id) | ||
article(it) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
attachmentsClick { _, _, _, position -> callback.onAttachmentsClick(position) } | ||
} | ||
article { | ||
id(item.id) | ||
article(item) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
attachmentsClick { _, _, _, position -> (callback as OnArticleCallback).onAttachmentsClick(position) } | ||
} | ||
} | ||
} |
31 changes: 6 additions & 25 deletions
31
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/AttachmentsController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,16 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import com.airbnb.epoxy.EpoxyController | ||
import com.kirkbushman.sampleapp.models.attachment | ||
import com.kirkbushman.sampleapp.models.empty | ||
import com.kirkbushman.zammad.models.ArticleAttachment | ||
|
||
class AttachmentsController(private val callback: OnClickCallback) : EpoxyController() { | ||
class AttachmentsController(callback: OnClickCallback) : BaseController<ArticleAttachment>(callback) { | ||
|
||
private val attachments = ArrayList<ArticleAttachment>() | ||
override fun onItem(item: ArticleAttachment) { | ||
|
||
fun setAttachments(attachments: Collection<ArticleAttachment>) { | ||
this.attachments.clear() | ||
this.attachments.addAll(attachments) | ||
requestModelBuild() | ||
} | ||
|
||
override fun buildModels() { | ||
|
||
if (attachments.isEmpty()) { | ||
empty { | ||
id("empty_items") | ||
} | ||
} | ||
|
||
attachments.forEach { | ||
|
||
attachment { | ||
id(it.id) | ||
attachment(it) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
} | ||
attachment { | ||
id(item.id) | ||
attachment(item) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/BaseController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import com.airbnb.epoxy.EpoxyController | ||
import com.kirkbushman.sampleapp.models.empty | ||
|
||
abstract class BaseController<T>(protected val callback: OnClickCallback) : EpoxyController() { | ||
|
||
private val items = ArrayList<T>() | ||
|
||
fun setItems(items: Collection<T>) { | ||
this.items.clear() | ||
this.items.addAll(items) | ||
requestModelBuild() | ||
} | ||
|
||
override fun buildModels() { | ||
|
||
if (items.isEmpty()) { | ||
empty { | ||
id("empty_items") | ||
} | ||
} | ||
|
||
items.forEach { onItem(it) } | ||
} | ||
|
||
abstract fun onItem(item: T) | ||
} |
35 changes: 8 additions & 27 deletions
35
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/GroupsController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,18 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import com.airbnb.epoxy.EpoxyController | ||
import com.kirkbushman.sampleapp.models.empty | ||
import com.kirkbushman.sampleapp.models.group | ||
import com.kirkbushman.zammad.models.Group | ||
|
||
class GroupsController(private val callback: OnUpDelCallback) : EpoxyController() { | ||
class GroupsController(callback: OnUpDelCallback) : BaseController<Group>(callback) { | ||
|
||
private val groups = ArrayList<Group>() | ||
override fun onItem(item: Group) { | ||
|
||
fun setGroups(groups: Collection<Group>) { | ||
this.groups.clear() | ||
this.groups.addAll(groups) | ||
requestModelBuild() | ||
} | ||
|
||
override fun buildModels() { | ||
|
||
if (groups.isEmpty()) { | ||
empty { | ||
id("empty_items") | ||
} | ||
} | ||
|
||
groups.forEach { | ||
|
||
group { | ||
id(it.id) | ||
group(it) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
updateListener { _, _, _, position -> callback.onUpdateClick(position) } | ||
deleteListener { _, _, _, position -> callback.onDeleteClick(position) } | ||
} | ||
group { | ||
id(item.id) | ||
group(item) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
updateListener { _, _, _, position -> (callback as OnUpDelCallback).onUpdateClick(position) } | ||
deleteListener { _, _, _, position -> (callback as OnUpDelCallback).onDeleteClick(position) } | ||
} | ||
} | ||
} |
29 changes: 5 additions & 24 deletions
29
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/NotificationsController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,15 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import com.airbnb.epoxy.EpoxyController | ||
import com.kirkbushman.sampleapp.models.empty | ||
import com.kirkbushman.sampleapp.models.notification | ||
import com.kirkbushman.zammad.models.OnlineNotification | ||
|
||
class NotificationsController : EpoxyController() { | ||
class NotificationsController(callback: OnClickCallback) : BaseController<OnlineNotification>(callback) { | ||
|
||
private val notifications = ArrayList<OnlineNotification>() | ||
override fun onItem(item: OnlineNotification) { | ||
|
||
fun setNotifications(notifications: Collection<OnlineNotification>) { | ||
this.notifications.clear() | ||
this.notifications.addAll(notifications) | ||
requestModelBuild() | ||
} | ||
|
||
override fun buildModels() { | ||
|
||
if (notifications.isEmpty()) { | ||
empty { | ||
id("empty_items") | ||
} | ||
} | ||
|
||
notifications.forEach { | ||
|
||
notification { | ||
id(it.id) | ||
notification(it) | ||
} | ||
notification { | ||
id(item.id) | ||
notification(item) | ||
} | ||
} | ||
} |
31 changes: 6 additions & 25 deletions
31
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/ObjectsController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,17 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import com.airbnb.epoxy.EpoxyController | ||
import com.kirkbushman.sampleapp.models.`object` | ||
import com.kirkbushman.sampleapp.models.empty | ||
import com.kirkbushman.zammad.models.Object | ||
|
||
class ObjectsController(private val callback: OnClickCallback) : EpoxyController() { | ||
class ObjectsController(callback: OnClickCallback) : BaseController<Object>(callback) { | ||
|
||
private val objects = ArrayList<Object>() | ||
override fun onItem(item: Object) { | ||
|
||
fun setObjects(items: Collection<Object>) { | ||
this.objects.clear() | ||
this.objects.addAll(items) | ||
requestModelBuild() | ||
} | ||
|
||
override fun buildModels() { | ||
|
||
if (objects.isEmpty()) { | ||
empty { | ||
id("empty_items") | ||
} | ||
} | ||
|
||
objects.forEach { | ||
|
||
`object` { | ||
`object` { | ||
|
||
id(it.id) | ||
`object`(it) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
} | ||
id(item.id) | ||
`object`(item) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
} | ||
} | ||
} |
35 changes: 8 additions & 27 deletions
35
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/OrganizationsController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,18 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import com.airbnb.epoxy.EpoxyController | ||
import com.kirkbushman.sampleapp.models.empty | ||
import com.kirkbushman.sampleapp.models.organization | ||
import com.kirkbushman.zammad.models.Organization | ||
|
||
class OrganizationsController(private val callback: OnUpDelCallback) : EpoxyController() { | ||
class OrganizationsController(callback: OnUpDelCallback) : BaseController<Organization>(callback) { | ||
|
||
private val organizations = ArrayList<Organization>() | ||
override fun onItem(item: Organization) { | ||
|
||
fun setOrganizations(organizations: Collection<Organization>) { | ||
this.organizations.clear() | ||
this.organizations.addAll(organizations) | ||
requestModelBuild() | ||
} | ||
|
||
override fun buildModels() { | ||
|
||
if (organizations.isEmpty()) { | ||
empty { | ||
id("empty_items") | ||
} | ||
} | ||
|
||
organizations.forEach { | ||
|
||
organization { | ||
id(it.id) | ||
organization(it) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
updateListener { _, _, _, position -> callback.onUpdateClick(position) } | ||
deleteListener { _, _, _, position -> callback.onDeleteClick(position) } | ||
} | ||
organization { | ||
id(item.id) | ||
organization(item) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
updateListener { _, _, _, position -> (callback as OnUpDelCallback).onUpdateClick(position) } | ||
deleteListener { _, _, _, position -> (callback as OnUpDelCallback).onDeleteClick(position) } | ||
} | ||
} | ||
} |
31 changes: 6 additions & 25 deletions
31
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/OverviewsController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,16 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import com.airbnb.epoxy.EpoxyController | ||
import com.kirkbushman.sampleapp.models.empty | ||
import com.kirkbushman.sampleapp.models.overview | ||
import com.kirkbushman.zammad.models.Overview | ||
|
||
class OverviewsController(private val callback: OnClickCallback) : EpoxyController() { | ||
class OverviewsController(callback: OnClickCallback) : BaseController<Overview>(callback) { | ||
|
||
private val overviews = ArrayList<Overview>() | ||
override fun onItem(item: Overview) { | ||
|
||
fun setOverviews(overviews: Collection<Overview>) { | ||
this.overviews.clear() | ||
this.overviews.addAll(overviews) | ||
requestModelBuild() | ||
} | ||
|
||
override fun buildModels() { | ||
|
||
if (overviews.isEmpty()) { | ||
empty { | ||
id("empty_items") | ||
} | ||
} | ||
|
||
overviews.forEach { | ||
|
||
overview { | ||
id(it.id) | ||
overview(it) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
} | ||
overview { | ||
id(item.id) | ||
overview(item) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
} | ||
} | ||
} |
35 changes: 8 additions & 27 deletions
35
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/PrioritiesController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,18 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import com.airbnb.epoxy.EpoxyController | ||
import com.kirkbushman.sampleapp.models.empty | ||
import com.kirkbushman.sampleapp.models.priority | ||
import com.kirkbushman.zammad.models.TicketPriority | ||
|
||
class PrioritiesController(private val callback: OnUpDelCallback) : EpoxyController() { | ||
class PrioritiesController(callback: OnUpDelCallback) : BaseController<TicketPriority>(callback) { | ||
|
||
private val priorities = ArrayList<TicketPriority>() | ||
override fun onItem(item: TicketPriority) { | ||
|
||
fun setPriorities(priorities: Collection<TicketPriority>) { | ||
this.priorities.clear() | ||
this.priorities.addAll(priorities) | ||
requestModelBuild() | ||
} | ||
|
||
override fun buildModels() { | ||
|
||
if (priorities.isEmpty()) { | ||
empty { | ||
id("empty_items") | ||
} | ||
} | ||
|
||
priorities.forEach { | ||
|
||
priority { | ||
id(it.id) | ||
priority(it) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
updateListener { _, _, _, position -> callback.onUpdateClick(position) } | ||
deleteListener { _, _, _, position -> callback.onDeleteClick(position) } | ||
} | ||
priority { | ||
id(item.id) | ||
priority(item) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
updateListener { _, _, _, position -> (callback as OnUpDelCallback).onUpdateClick(position) } | ||
deleteListener { _, _, _, position -> (callback as OnUpDelCallback).onDeleteClick(position) } | ||
} | ||
} | ||
} |
31 changes: 6 additions & 25 deletions
31
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/RolesController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,16 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import com.airbnb.epoxy.EpoxyController | ||
import com.kirkbushman.sampleapp.models.empty | ||
import com.kirkbushman.sampleapp.models.role | ||
import com.kirkbushman.zammad.models.Role | ||
|
||
class RolesController(private val callback: OnClickCallback) : EpoxyController() { | ||
class RolesController(callback: OnClickCallback) : BaseController<Role>(callback) { | ||
|
||
private val roles = ArrayList<Role>() | ||
override fun onItem(item: Role) { | ||
|
||
fun setRoles(roles: Collection<Role>) { | ||
this.roles.clear() | ||
this.roles.addAll(roles) | ||
requestModelBuild() | ||
} | ||
|
||
override fun buildModels() { | ||
|
||
if (roles.isEmpty()) { | ||
empty { | ||
id("empty_items") | ||
} | ||
} | ||
|
||
roles.forEach { | ||
|
||
role { | ||
id(it.id) | ||
role(it) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
} | ||
role { | ||
id(item.id) | ||
role(item) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
} | ||
} | ||
} |
35 changes: 8 additions & 27 deletions
35
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/StatesController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,18 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import com.airbnb.epoxy.EpoxyController | ||
import com.kirkbushman.sampleapp.models.empty | ||
import com.kirkbushman.sampleapp.models.state | ||
import com.kirkbushman.zammad.models.TicketState | ||
|
||
class StatesController(private val callback: OnUpDelCallback) : EpoxyController() { | ||
class StatesController(callback: OnUpDelCallback) : BaseController<TicketState>(callback) { | ||
|
||
private val states = ArrayList<TicketState>() | ||
override fun onItem(item: TicketState) { | ||
|
||
fun setStates(states: Collection<TicketState>) { | ||
this.states.clear() | ||
this.states.addAll(states) | ||
requestModelBuild() | ||
} | ||
|
||
override fun buildModels() { | ||
|
||
if (states.isEmpty()) { | ||
empty { | ||
id("empty_items") | ||
} | ||
} | ||
|
||
states.forEach { | ||
|
||
state { | ||
id(it.id) | ||
state(it) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
updateListener { _, _, _, position -> callback.onUpdateClick(position) } | ||
deleteListener { _, _, _, position -> callback.onDeleteClick(position) } | ||
} | ||
state { | ||
id(item.id) | ||
state(item) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
updateListener { _, _, _, position -> (callback as OnUpDelCallback).onUpdateClick(position) } | ||
deleteListener { _, _, _, position -> (callback as OnUpDelCallback).onDeleteClick(position) } | ||
} | ||
} | ||
} |
31 changes: 6 additions & 25 deletions
31
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/TagsController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,16 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import com.airbnb.epoxy.EpoxyController | ||
import com.kirkbushman.sampleapp.models.empty | ||
import com.kirkbushman.sampleapp.models.tag | ||
import com.kirkbushman.zammad.models.Tag | ||
|
||
class TagsController(private val callback: OnClickCallback) : EpoxyController() { | ||
class TagsController(callback: OnClickCallback) : BaseController<Tag>(callback) { | ||
|
||
private val tags = ArrayList<Tag>() | ||
override fun onItem(item: Tag) { | ||
|
||
fun setTags(tags: Collection<Tag>) { | ||
this.tags.clear() | ||
this.tags.addAll(tags) | ||
requestModelBuild() | ||
} | ||
|
||
override fun buildModels() { | ||
|
||
if (tags.isEmpty()) { | ||
empty { | ||
id("empty_items") | ||
} | ||
} | ||
|
||
tags.forEach { | ||
|
||
tag { | ||
id(it.id) | ||
tag(it) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
} | ||
tag { | ||
id(item.id) | ||
tag(item) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
} | ||
} | ||
} |
37 changes: 9 additions & 28 deletions
37
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/TicketsController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,19 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import com.airbnb.epoxy.EpoxyController | ||
import com.kirkbushman.sampleapp.models.empty | ||
import com.kirkbushman.sampleapp.models.ticket | ||
import com.kirkbushman.zammad.models.Ticket | ||
|
||
class TicketsController(private val callback: OnTicketCallback) : EpoxyController() { | ||
class TicketsController(callback: OnTicketCallback) : BaseController<Ticket>(callback) { | ||
|
||
private val tickets = ArrayList<Ticket>() | ||
override fun onItem(item: Ticket) { | ||
|
||
fun setTickets(tickets: Collection<Ticket>) { | ||
this.tickets.clear() | ||
this.tickets.addAll(tickets) | ||
requestModelBuild() | ||
} | ||
|
||
override fun buildModels() { | ||
|
||
if (tickets.isEmpty()) { | ||
empty { | ||
id("empty_items") | ||
} | ||
} | ||
|
||
tickets.forEach { | ||
|
||
ticket { | ||
id(it.id) | ||
ticket(it) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
articleListener { _, _, _, position -> callback.onArticleClick(position) } | ||
updateListener { _, _, _, position -> callback.onUpdateClick(position) } | ||
deleteListener { _, _, _, position -> callback.onDeleteClick(position) } | ||
} | ||
ticket { | ||
id(item.id) | ||
ticket(item) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
articleListener { _, _, _, position -> (callback as OnTicketCallback).onArticleClick(position) } | ||
updateListener { _, _, _, position -> (callback as OnTicketCallback).onUpdateClick(position) } | ||
deleteListener { _, _, _, position -> (callback as OnTicketCallback).onDeleteClick(position) } | ||
} | ||
} | ||
} |
35 changes: 8 additions & 27 deletions
35
sampleapp/src/main/java/com/kirkbushman/sampleapp/controllers/UsersController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,18 @@ | ||
package com.kirkbushman.sampleapp.controllers | ||
|
||
import com.airbnb.epoxy.EpoxyController | ||
import com.kirkbushman.sampleapp.models.empty | ||
import com.kirkbushman.sampleapp.models.user | ||
import com.kirkbushman.zammad.models.User | ||
|
||
class UsersController(private val callback: OnUpDelCallback) : EpoxyController() { | ||
class UsersController(callback: OnUpDelCallback) : BaseController<User>(callback) { | ||
|
||
private val users = ArrayList<User>() | ||
override fun onItem(item: User) { | ||
|
||
fun setUsers(users: Collection<User>) { | ||
this.users.clear() | ||
this.users.addAll(users) | ||
requestModelBuild() | ||
} | ||
|
||
override fun buildModels() { | ||
|
||
if (users.isEmpty()) { | ||
empty { | ||
id("empty_items") | ||
} | ||
} | ||
|
||
users.forEach { | ||
|
||
user { | ||
id(it.id) | ||
user(it) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
updateListener { _, _, _, position -> callback.onUpdateClick(position) } | ||
deleteListener { _, _, _, position -> callback.onDeleteClick(position) } | ||
} | ||
user { | ||
id(item.id) | ||
user(item) | ||
clickListener { _, _, _, position -> callback.onClick(position) } | ||
updateListener { _, _, _, position -> (callback as OnUpDelCallback).onUpdateClick(position) } | ||
deleteListener { _, _, _, position -> (callback as OnUpDelCallback).onDeleteClick(position) } | ||
} | ||
} | ||
} |