Skip to content

Instantly share code, notes, and snippets.

@veb
Created June 29, 2014 05:29
Show Gist options
  • Save veb/655f11a74f6ad8675f0c to your computer and use it in GitHub Desktop.
Save veb/655f11a74f6ad8675f0c to your computer and use it in GitHub Desktop.
public void doPost() {
// get hashtags and return into tokens
Pattern tagMatcher = Pattern.compile("[#]+[A-Za-z0-9-_]+\\b");
Matcher m = tagMatcher.matcher(statusText.getText().toString());
List<String> tokens = new ArrayList<String>();
while(m.find()) {
String token = m.group();
tokens.add(token);
}
JournalEntry journalEntry = new JournalEntry();
journalEntry.setMood(statusPager.getCurrentItem());
journalEntry.setContent(statusText.getText().toString());
journalEntry.setIntensity(statusSeekBar.getProgress());
journalEntry.setArchived(false);
journalEntry.save();
for (int i = 0; i < tokens.size(); i++) {
HashTagEntry hashtagEntry = new HashTagEntry(journalEntry, tokens.get(i));
}
finish();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment