Created
November 19, 2012 20:30
-
-
Save michiakig/4113683 to your computer and use it in GitHub Desktop.
CheckThread blog post HackerNewsActivityV2Buggy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Thread() { | |
@ThreadConfined("other") | |
public void run() | |
{ | |
try | |
{ | |
// doing IO off the UI thread -- ok | |
String feed = IO.getHttp(kHackerNewsRssUrl); | |
List<String> titles = HackerNewsRSSParser.parseTitles(feed); | |
for (String t : titles) | |
{ | |
// updating the UI from off the UI thread -- this MAY blow up, so you shouldn't do it | |
TextView textView = new TextView(HackerNewsActivityV2Buggy.this); | |
textView.setText(t); | |
linearLayout.addView(textView); | |
} | |
} | |
catch (IOException e) | |
{ | |
e.printStackTrace(); | |
} | |
} | |
}.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment