use of com.se491.chef_ly.model.RecipeList in project chefly_android by chef-ly.
the class RecipeListActivity method onLoadFinished.
// LoaderManager callback method
@Override
public void onLoadFinished(Loader<RecipeList> loader, RecipeList data) {
int id = loader.getId();
if (id == FAVORTIESID) {
favoriteRecipes = data;
for (RecipeInformation r : favoriteRecipes) {
//favorites.add(r.getId());
r.setFavorite(true);
}
favs.updateListAdapter(favoriteRecipes);
} else if (id == queryString.hashCode()) {
Log.d(TAG, " Recipe Search -> " + data.size());
if (data.size() > 0) {
// Collect all recipes so list can be redisplayed when search is closed
server.setList(data, true);
} else {
Log.d(TAG, "Error - No recipes loaded from server");
Toast.makeText(this, "Sorry we couldn't find any recipes", Toast.LENGTH_SHORT).show();
//TODO handle case where no recipes are retrieved from server
}
}
Log.d(TAG, "OnLoadFinished " + loader.getId());
}
use of com.se491.chef_ly.model.RecipeList in project chefly_android by chef-ly.
the class ListViewFragment method updateListAdapter.
public void updateListAdapter(RecipeList newList) {
if (list == null) {
list = new RecipeList();
}
for (RecipeInformation r : newList) {
list.add(r);
}
if (listView != null) {
((BaseAdapter) listView.getAdapter()).notifyDataSetChanged();
Log.d(TAG + "/" + title, "ListView updated " + title + " " + listView.getAdapter().getCount() + " list " + list.size());
//listView.setVisibility(View.VISIBLE);
}
}
use of com.se491.chef_ly.model.RecipeList in project chefly_android by chef-ly.
the class ListViewFragment method onSaveInstanceState.
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
RecipeList r = ((RecipeAdapter) listView.getAdapter()).getRecipes();
outState.putString("title", title);
outState.putString("pageNum", pageNum);
outState.putParcelable(title, r);
}
use of com.se491.chef_ly.model.RecipeList in project chefly_android by chef-ly.
the class ListViewFragment method setList.
public void setList(RecipeList newList, boolean goToTop) {
list.clear();
for (RecipeInformation r : newList) {
list.add(r);
}
((BaseAdapter) listView.getAdapter()).notifyDataSetChanged();
if (goToTop) {
listView.setSelectionAfterHeaderView();
}
}
use of com.se491.chef_ly.model.RecipeList in project chefly_android by chef-ly.
the class RecipeListActivity method onStart.
@Override
protected void onStart() {
super.onStart();
Intent intent = getIntent();
Bundle extras = intent.getExtras();
String user = extras.getString("name");
RecipeList list = extras.getParcelable("recipeList");
boolean isSearch = extras.getBoolean("isSearch");
if (isSearch) {
String search = extras.getString("search");
queryString = search;
server.updateSearch(search);
server.updateListAdapter(list);
} else if (list != null) {
serverRecipes = list;
server.updateListAdapter(serverRecipes);
} else {
Log.d(TAG, "Error - No recipes loaded from server");
Toast.makeText(this, "Error", Toast.LENGTH_SHORT).show();
//TODO handle case where no recipes are retrieved from server
}
}
Aggregations