Skip to content

Instantly share code, notes, and snippets.

@CanOrhan
Created September 21, 2015 09:06
Show Gist options
  • Save CanOrhan/ea37e9d30b6b59937dab to your computer and use it in GitHub Desktop.
Save CanOrhan/ea37e9d30b6b59937dab to your computer and use it in GitHub Desktop.
Slack Question
//My Activity
@Override
protected void onStart() {
super.onStart();
commentInput.addTextChangedListener(new OnCommentTextChangeListener(fragment));
}
//My Adapter
@Override
public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
String currentAdapterName = fragment.getCurrentAdapterName();
boolean showUsers = true;
List<ExpressionLocation> hashtagLocations = hashtagDetector.getExpressionLocations(charSequence.toString());
for (ExpressionLocation expressionLocation : hashtagLocations) {
if (expressionLocation.getEnd() >= (start + count)) {
if (!currentAdapterName.equals(hashtagAdapterName)) {
fragment.setAdapter(hashtagAdapter, hashtagAdapterName);
}
showUsers = false;
}
}
if(showUsers && !currentAdapterName.equals(commentsAdapterName)) {
fragment.setAdapter(commentsAdapter, commentsAdapterName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment