Skip to content

Commit

Permalink
And this should be the last of the silly thread usage
Browse files Browse the repository at this point in the history
Signed-off-by: Eddie Ringle <eddie@eringle.net>
  • Loading branch information
EddieRingle committed Mar 31, 2010
1 parent c8776d0 commit f405b13
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 50 deletions.
53 changes: 19 additions & 34 deletions src/org/idlesoft/android/hubroid/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,32 +82,6 @@ public void run() {
}
}

private Runnable threadProc_itemClick = new Runnable() {
public void run() {
try {
if (m_type.equals(REPO_TYPE)) {
m_intent = new Intent(Search.this, RepositoryInfo.class);
m_intent.putExtra("repo_name", m_repositoriesData
.getJSONObject(m_position).getString("name"));
m_intent.putExtra("username", m_repositoriesData
.getJSONObject(m_position).getString("username"));
} else if (m_type.equals(USER_TYPE)) {
m_intent = new Intent(Search.this, UserInfo.class);
m_intent.putExtra("username", m_usersData.getJSONObject(
m_position).getString("username"));
}
} catch (JSONException e) {
e.printStackTrace();
}

runOnUiThread(new Runnable() {
public void run() {
Search.this.startActivityForResult(m_intent, 5005);
}
});
}
};

protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode == 5005) {
Expand Down Expand Up @@ -188,8 +162,22 @@ public void onClick(View v) {
private OnItemClickListener m_MessageClickedHandler = new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
m_position = position;
Thread thread = new Thread(null, threadProc_itemClick);
thread.start();
try {
if (m_type.equals(REPO_TYPE)) {
m_intent = new Intent(Search.this, RepositoryInfo.class);
m_intent.putExtra("repo_name", m_repositoriesData
.getJSONObject(m_position).getString("name"));
m_intent.putExtra("username", m_repositoriesData
.getJSONObject(m_position).getString("username"));
} else if (m_type.equals(USER_TYPE)) {
m_intent = new Intent(Search.this, UserInfo.class);
m_intent.putExtra("username", m_usersData.getJSONObject(
m_position).getString("username"));
}
} catch (JSONException e) {
e.printStackTrace();
}
Search.this.startActivityForResult(m_intent, 5005);
}
};

Expand Down Expand Up @@ -286,8 +274,7 @@ public void onRestoreInstanceState(Bundle savedInstanceState) {
m_type = savedInstanceState.getString("type");
try {
if (savedInstanceState.containsKey("repositories_json")) {
m_repositoriesData = new JSONArray(savedInstanceState
.getString("repositories_json"));
m_repositoriesData = new JSONArray(savedInstanceState.getString("repositories_json"));
} else {
m_repositoriesData = new JSONArray();
}
Expand All @@ -296,17 +283,15 @@ public void onRestoreInstanceState(Bundle savedInstanceState) {
}
try {
if (savedInstanceState.containsKey("users_json")) {
m_usersData = new JSONArray(savedInstanceState
.getString("users_json"));
m_usersData = new JSONArray(savedInstanceState.getString("users_json"));
} else {
m_usersData = new JSONArray();
}
} catch (JSONException e) {
m_usersData = new JSONArray();
}
if (m_repositoriesData.length() > 0) {
m_repositories_adapter = new RepositoriesListAdapter(
Search.this, m_repositoriesData);
m_repositories_adapter = new RepositoriesListAdapter(Search.this, m_repositoriesData);
} else {
m_repositories_adapter = null;
}
Expand Down
20 changes: 4 additions & 16 deletions src/org/idlesoft/android/hubroid/WatchedRepositories.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,17 @@ public void run() {
}
};

private Runnable threadProc_itemClick = new Runnable() {
public void run() {
private OnItemClickListener m_MessageClickedHandler = new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
m_position = position;
try {
m_intent = new Intent(WatchedRepositories.this, RepositoryInfo.class);
m_intent.putExtra("repo_name", m_jsonData.getJSONArray("repositories").getJSONObject(m_position).getString("name"));
m_intent.putExtra("username", m_jsonData.getJSONArray("repositories").getJSONObject(m_position).getString("owner"));
} catch (JSONException e) {
e.printStackTrace();
}

runOnUiThread(new Runnable() {
public void run() {
WatchedRepositories.this.startActivity(m_intent);
}
});
}
};

private OnItemClickListener m_MessageClickedHandler = new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
m_position = position;
Thread thread = new Thread(null, threadProc_itemClick);
thread.start();
WatchedRepositories.this.startActivity(m_intent);
}
};

Expand Down

0 comments on commit f405b13

Please sign in to comment.