Skip to content

Instantly share code, notes, and snippets.

@fauzisho
Created October 11, 2017 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fauzisho/4fd7e7cbaa34fa7cfeb21289e2b63974 to your computer and use it in GitHub Desktop.
Save fauzisho/4fd7e7cbaa34fa7cfeb21289e2b63974 to your computer and use it in GitHub Desktop.
@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