public RelatedRecipeListWidget(Recipe recipe, Activity context) { this.recipe = recipe; this.context = context; this.listWidget = getLayoutInflater().inflate(R.layout.list_widget, null); this.recipes = (ViewGroup) listWidget.findViewById(R.id.category_list); this.editing = false; this.util = UtilityImpl.singleton; TextView title = (TextView) listWidget.findViewById(R.id.category_label); title.setText("Related Recipes"); AppData.getSingleton().useHeadingFont(title); this.addButton = (Button) listWidget.findViewById(R.id.category_button); addButton.setOnClickListener( new OnClickListener() { public void onClick(View v) { Actions.RECIPE_ADD_RELATED.showNotifications(); RelatedRecipeListWidget.this.context.showDialog(ADD_RELATED_RECIPE_DIALOG); } }); }
protected View createRecipeEntry(Suggestion s) { final Recipe suggested = s.getSuggestedRecipe(); final long id = suggested.getId(); View v = getLayoutInflater().inflate(R.layout.list_widget_item, null); TextView ctv = (TextView) v.findViewById(R.id.name_box); AppData.getSingleton().useTextFont(ctv); ctv.setText(suggested.getName()); TextView idBox = (TextView) v.findViewById(R.id.edit_button); idBox.setText(id + ""); idBox.setVisibility(View.GONE); v.setOnClickListener( new OnClickListener() { public void onClick(View v) { Intent i = new Intent(context, RecipeTabs.class); i.putExtra("id", id); context.startActivity(i); } }); View deleteButton = v.findViewById(R.id.delete_button); deleteButton.setVisibility(View.VISIBLE); deleteButton.setOnClickListener( new OnClickListener() { public void onClick(View v) { Bundle bundle = new Bundle(); bundle.putLong("id", id); context.showDialog(REMOVE_RELATED_RECIPE_DIALOG, bundle); } }); return v; }