Skip to content

Commit

Permalink
Enable payloads for custom content types
Browse files Browse the repository at this point in the history
  • Loading branch information
mweathers committed Aug 20, 2018
1 parent f6e3ee3 commit 5b58ff4
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,37 @@ MessageHolders registerContentType(
return this;
}

/**
* Registers custom content type (e.g. multimedia, events etc.)
*
* @param type unique id for content type
* @param incomingHolder holder class for incoming message
* @param outcomingHolder holder class for outcoming message
* @param incomingPayload payload for incoming message
* @param outcomingPayload payload for outcoming message
* @param incomingLayout layout resource for incoming message
* @param outcomingLayout layout resource for outcoming message
* @param contentChecker {@link MessageHolders.ContentChecker} for registered type
* @return {@link MessageHolders} for subsequent configuration.
*/
public <TYPE extends MessageContentType>
MessageHolders registerContentType(
byte type,
@NonNull Class<? extends MessageHolders.BaseMessageViewHolder<TYPE>> incomingHolder, Object incomingPayload, @LayoutRes int incomingLayout,
@NonNull Class<? extends MessageHolders.BaseMessageViewHolder<TYPE>> outcomingHolder, Object outcomingPayload, @LayoutRes int outcomingLayout,
@NonNull MessageHolders.ContentChecker contentChecker) {

if (type == 0)
throw new IllegalArgumentException("content type must be greater or less than '0'!");

customContentTypes.add(
new MessageHolders.ContentTypeConfig<>(type,
new MessageHolders.HolderConfig<>(incomingHolder, incomingLayout, incomingPayload),
new MessageHolders.HolderConfig<>(outcomingHolder, outcomingLayout, outcomingPayload)));
this.contentChecker = contentChecker;
return this;
}

/*
* INTERFACES
* */
Expand Down

0 comments on commit 5b58ff4

Please sign in to comment.