Skip to content

Commit

Permalink
Merge pull request #33 from tndatacommons/dev
Browse files Browse the repository at this point in the history
Bug Fixes/Minor changes
  • Loading branch information
bradmontgomery committed Jun 26, 2015
2 parents 8978465 + d41502e commit 5abea06
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -72,6 +72,10 @@ public class MainActivity extends ActionBarActivity implements
private boolean mDrawerIsOpen = false;
private boolean backButtonSelectsDefaultTab = false;
private static final int DEFAULT_TAB = 0;
private boolean fetchedCategories = false; // Have we fetched the user's categories, already?
// ^ this is used to prevent the app from hitting the api continuously after the app crashes;
// when that happens, the CompassApplication lose's it's local values, then this activity
// keeps calling showCategories in a loop, which hits the api without a proper auth token.

@Override
public void onBackPressed() {
Expand Down Expand Up @@ -176,11 +180,11 @@ public void chooseCategories() {
public void showCategories() {
ArrayList<Category> categories = ((CompassApplication) getApplication()).getCategories();

if (categories == null || categories.isEmpty()) {
if (!fetchedCategories && (categories == null || categories.isEmpty())) {
new GetUserCategoriesTask(this).executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR,
((CompassApplication) getApplication()).getToken());
} else {
} else if(categories != null) {
for (Category cat : ((CompassApplication) getApplication())
.getCategories()) {
Log.d("Category", cat.getTitle());
Expand Down Expand Up @@ -334,6 +338,7 @@ public void onConfigurationChanged(Configuration newConfig) {
public void categoriesLoaded(ArrayList<Category> categories) {
((CompassApplication) getApplication()).setCategories(categories);
showCategories();
fetchedCategories = true;
}

@Override
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/tndata/android/compass/model/Goal.java
Expand Up @@ -153,12 +153,18 @@ public int compareTo(Goal another) {
*/
public void loadIconIntoView(Context context, ImageView imageView) {
String iconUrl = getIconUrl();
if(iconUrl != null && !iconUrl.isEmpty()) {
ImageCache.instance(context).loadBitmap(imageView, iconUrl, false);
}
/*
// TODO: only show goal icons (above) until we figure out what to do here.
if(getBehaviors().isEmpty()) {
if(iconUrl != null && !iconUrl.isEmpty()) {
ImageCache.instance(context).loadBitmap(imageView, iconUrl, false);
}
} else {
imageView.setImageResource(getProgressIcon());
}
*/
}
}

0 comments on commit 5abea06

Please sign in to comment.