@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { logger.v( "onCreateView", "inflater=%s, container=%s, savedInstanceState=%s", inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.fragment_recipe, container, false); if (getArguments() == null) { logger.e("onCreateView", "no Arguments"); return view; } mRecipeId = getArguments().getLong(ARG_RECIPE_ID); mRecipe = mDbOpenHelper.getDaoSession().getRecipeDao().load(mRecipeId); logger.v("onCreateView", "mRecipe=%s", mRecipe); AsyncImageView imageView = (AsyncImageView) view.findViewById(R.id.fragment_test_image_id); imageView.setUrl("http://dummyimage.com/380x380"); Loader loader = getActivity().getLoaderManager().initLoader(0, null, imageView); loader.forceLoad(); return view; }
/** * Use this factory method to create a new instance of this fragment using the provided * parameters. * * @param recipeId * @return */ public static RecipeFragment newInstance(Long recipeId) { logger.v("newInstance", "recipeId=%s", recipeId); RecipeFragment fragment = new RecipeFragment(); Bundle args = new Bundle(); args.putLong(ARG_RECIPE_ID, recipeId); fragment.setArguments(args); return fragment; }
@Override public void onAttach(Activity activity) { logger.v("onAttach", "mRecipeId=%s, activity=%s", mRecipeId, activity); super.onAttach(activity); try { mListener = (OnFragmentInteractionListener) activity; } catch (ClassCastException e) { throw new ClassCastException( activity.toString() + " must implement OnFragmentInteractionListener"); } }
@Override public void onDetach() { logger.v("onDetach", "mRecipeId=%s", mRecipeId); super.onDetach(); mListener = null; }
@Override public void onCreate(Bundle savedInstanceState) { logger.v("onCreate", "savedInstanceState=%s", savedInstanceState); super.onCreate(savedInstanceState); mDbOpenHelper = new DbOpenHelper(getContext(), null); }
public RecipeFragment() { logger.v("RecipeFragment", null); }