use of com.bourke.glimmr.tasks.LoadFlickrActivityTask in project glimmr by brk3.
the class ActivityNotificationHandler method startTask.
@Override
public void startTask(OAuth oauth) {
mOAuth = oauth;
new LoadFlickrActivityTask(this).execute(oauth);
}
use of com.bourke.glimmr.tasks.LoadFlickrActivityTask in project glimmr by brk3.
the class MainActivity method updateMenuListItems.
public void updateMenuListItems(boolean forceRefresh) {
if (BuildConfig.DEBUG)
Log.d(TAG, "updateMenuListItems");
final List<Object> menuItems = new ArrayList<Object>();
/* Add the standard page related items */
for (PageItem page : mContent) {
menuItems.add(new MenuDrawerItem(page.mTitle, page.mIconDrawable));
}
menuItems.add(new MenuDrawerCategory(getString(R.string.activity)));
/* If the activity list file exists, add the contents to the menu
* drawer area. Otherwise start a task to fetch one. */
File f = getFileStreamPath(ActivityNotificationHandler.ACTIVITY_ITEMLIST_FILE);
if (f.exists() && !forceRefresh) {
/* There is some duplicated code here. Could move it into another
* function but the task is fragmented enough as is */
List<Item> items = ActivityNotificationHandler.loadItemList(this);
menuItems.addAll(buildActivityStream(items));
mActivityListVersion = mPrefs.getLong(ActivityNotificationHandler.KEY_TIME_ACTIVITY_ITEMS_LAST_UPDATED, -1);
mMenuAdapter.setItems(menuItems);
mMenuAdapter.notifyDataSetChanged();
} else {
setProgressBarIndeterminateVisibility(Boolean.TRUE);
new LoadFlickrActivityTask(new IActivityItemsReadyListener() {
@Override
public void onItemListReady(List<Item> items, Exception e) {
setProgressBarIndeterminateVisibility(Boolean.FALSE);
if (items != null) {
ActivityNotificationHandler.storeItemList(MainActivity.this, items);
menuItems.addAll(buildActivityStream(items));
mActivityListVersion = mPrefs.getLong(ActivityNotificationHandler.KEY_TIME_ACTIVITY_ITEMS_LAST_UPDATED, -1);
} else {
Log.e(TAG, "onItemListReady: Item list is null");
}
mMenuAdapter.setItems(menuItems);
mMenuAdapter.notifyDataSetChanged();
}
}).execute(mOAuth);
}
}
Aggregations