Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Override
protected int getItemViewTypeCustomMessage(QiscusComment qiscusComment, int position) {
try {
JSONObject payload = new JSONObject(qiscusComment.getExtraPayload());
if (payload.optString("type").equals("survey")) {
return qiscusComment.getSenderEmail().equals(qiscusAccount.getEmail()) ? TYPE_SURVEY : TYPE_SURVEY_OTHERS;
}
} catch (JSONException ignored) {
}
return super.getItemViewTypeCustomMessage(qiscusComment, position);
}
@Override
protected int getItemResourceLayout(int viewType) {
switch (viewType) {
case TYPE_SURVEY:
return R.layout.item_message_survey;
case TYPE_SURVEY_OTHERS:
return R.layout.item_message_survey;
default:
return super.getItemResourceLayout(viewType);
}
}
@Override
public QiscusBaseMessageViewHolder<QiscusComment> onCreateViewHolder(ViewGroup parent, int viewType) {
switch (viewType) {
case TYPE_SURVEY:
case TYPE_SURVEY_OTHERS:
return new BubbleMessageViewHolder(getView(parent, viewType), itemClickListener, longItemClickListener,context);
default:
return super.onCreateViewHolder(parent, viewType);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment