Exemplo n.º 1
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.emptys:
       if (!"".equals(id)) {
         HttpRequest.getInstance().recipeDetailRequest(getSupportActivity(), mHandler, id);
         mLinearLayoutProgress.setVisibility(View.VISIBLE);
         mImageViewEmpty.setVisibility(View.GONE);
       }
       break;
     case R.id.frament_recipe_detail_item_userCover:
       if (mRecipeDetailInfo != null) {
         Intent intent = new Intent(getSupportActivity(), PersonalActivity.class);
         intent.putExtra("uid", mRecipeDetailInfo.getUId().trim());
         intent.putExtra("name", mTextViewUserName.getText().toString());
         if (MeishiApplication.getApplication().getUserInfo() != null
             && MeishiApplication.getApplication().getUserInfo().getSid() != null
             && MeishiApplication.getApplication()
                 .getUserInfo()
                 .getuId()
                 .trim()
                 .equals(mRecipeDetailInfo.getUId().trim())) {
           intent.putExtra("ismyself", true);
         } else {
           intent.putExtra("ismyself", false);
         }
         startActivity(intent);
       }
       break;
   }
 }
Exemplo n.º 2
0
  private void fillComponent() {
    if (mRecipeDetailInfo != null) {
      mImageLoader.displayImage(
          MeishiApplication.getApplication().isShowPic()
              ? mRecipeDetailInfo.getRecipeCover().trim()
              : null,
          mImageViewTop,
          mOptions);
      mImageLoader.displayImage(
          MeishiApplication.getApplication().isShowPic()
              ? mRecipeDetailInfo.getRecipeAuthorAvator().trim()
              : null,
          mImageViewUser,
          mOptions2);

      mTextViewUserName.setText(mRecipeDetailInfo.getRecipeAuthor().trim());
      mTextViewRecipeName.setText(mRecipeDetailInfo.getRecipeTitle().trim());
      mTextViewDescr.setText(
          mRecipeDetailInfo.getRecipeDescr().replace("<br />", "").replace("&nbsp;", ""));
      mTextViewKouwei.setText(mRecipeDetailInfo.getCuisine().trim());
      mTextViewGongyi.setText(mRecipeDetailInfo.getTechnics().trim());
      mTextViewTime.setText(mRecipeDetailInfo.getDuring().trim());
      mTextViewDifficulty.setText(mRecipeDetailInfo.getLevel().trim());
      mImageViewUser.setOnClickListener(RecipeDetailFragment.this);

      List<IngredientInfo> mIngredientInfos01 = mRecipeDetailInfo.getmIngredientInfos1();
      if (mIngredientInfos01 != null && mIngredientInfos01.size() > 0) {
        RelativeLayout localRelativeLayout =
            (RelativeLayout)
                LayoutInflater.inflate(
                    getSupportActivity(), R.layout.recipe_detail_ingredients_category_name);
        TextView mTextView =
            (TextView) localRelativeLayout.findViewById(R.id.ingredientsCategoryName);
        mTextView.setText(
            MeishiApplication.getApplication().getString(R.string.fragment_recipe_detail_zhuliao));
        mLinearLayoutIngredients.addView(localRelativeLayout);

        for (int i = 0; i < mIngredientInfos01.size(); i = i + 2) {

          View view =
              LayoutInflater.inflate(getSupportActivity(), R.layout.recipe_detail_ingredients_item);

          TextView textView01 = (TextView) view.findViewById(R.id.text11);
          TextView textView02 = (TextView) view.findViewById(R.id.text12);

          textView01.setText(mIngredientInfos01.get(i).getIngredientName().trim());
          textView02.setText(mIngredientInfos01.get(i).getIngredientScale().trim());

          if (i + 1 < mIngredientInfos01.size()) {
            TextView textView03 = (TextView) view.findViewById(R.id.text21);
            TextView textView04 = (TextView) view.findViewById(R.id.text22);

            textView03.setText(mIngredientInfos01.get(i + 1).getIngredientName().trim());
            textView04.setText(mIngredientInfos01.get(i + 1).getIngredientScale().trim());
          }
          this.mLinearLayoutIngredients.addView(view);
        }
      }

      List<IngredientInfo> mIngredientInfos02 = mRecipeDetailInfo.getmIngredientInfos2();
      if (mIngredientInfos02 != null && mIngredientInfos02.size() > 0) {
        RelativeLayout localRelativeLayout =
            (RelativeLayout)
                LayoutInflater.inflate(
                    getSupportActivity(), R.layout.recipe_detail_ingredients_category_name);
        TextView mTextView =
            (TextView) localRelativeLayout.findViewById(R.id.ingredientsCategoryName);
        mTextView.setText(
            MeishiApplication.getApplication().getString(R.string.fragment_recipe_detail_fuliao));
        mLinearLayoutIngredients.addView(localRelativeLayout);

        for (int i = 0; i < mIngredientInfos02.size(); i = i + 2) {

          View view =
              LayoutInflater.inflate(getSupportActivity(), R.layout.recipe_detail_ingredients_item);

          TextView textView01 = (TextView) view.findViewById(R.id.text11);
          TextView textView02 = (TextView) view.findViewById(R.id.text12);

          textView01.setText(mIngredientInfos02.get(i).getIngredientName().trim());
          textView02.setText(mIngredientInfos02.get(i).getIngredientScale().trim());

          if (i + 1 < mIngredientInfos02.size()) {
            TextView textView03 = (TextView) view.findViewById(R.id.text21);
            TextView textView04 = (TextView) view.findViewById(R.id.text22);

            textView03.setText(mIngredientInfos02.get(i + 1).getIngredientName().trim());
            textView04.setText(mIngredientInfos02.get(i + 1).getIngredientScale().trim());
          }
          this.mLinearLayoutIngredients.addView(view);
        }
      }

      List<IngredientInfo> mIngredientInfos03 = mRecipeDetailInfo.getmIngredientInfos3();
      if (mIngredientInfos03 != null && mIngredientInfos03.size() > 0) {
        RelativeLayout localRelativeLayout =
            (RelativeLayout)
                LayoutInflater.inflate(
                    getSupportActivity(), R.layout.recipe_detail_ingredients_category_name);
        TextView mTextView =
            (TextView) localRelativeLayout.findViewById(R.id.ingredientsCategoryName);
        mTextView.setText(
            MeishiApplication.getApplication().getString(R.string.fragment_recipe_detail_peiliao));
        mLinearLayoutIngredients.addView(localRelativeLayout);

        for (int i = 0; i < mIngredientInfos03.size(); i = i + 2) {

          View view =
              LayoutInflater.inflate(getSupportActivity(), R.layout.recipe_detail_ingredients_item);

          TextView textView01 = (TextView) view.findViewById(R.id.text11);
          TextView textView02 = (TextView) view.findViewById(R.id.text12);

          textView01.setText(mIngredientInfos03.get(i).getIngredientName().trim());
          textView02.setText(mIngredientInfos03.get(i).getIngredientScale().trim());

          if (i + 1 < mIngredientInfos03.size()) {
            TextView textView03 = (TextView) view.findViewById(R.id.text21);
            TextView textView04 = (TextView) view.findViewById(R.id.text22);

            textView03.setText(mIngredientInfos03.get(i + 1).getIngredientName().trim());
            textView04.setText(mIngredientInfos03.get(i + 1).getIngredientScale().trim());
          }
          this.mLinearLayoutIngredients.addView(view);
        }
      }
      if ((mIngredientInfos01 == null || mIngredientInfos01.size() == 0)
          && (mIngredientInfos02 == null || mIngredientInfos02.size() == 0)
          && (mIngredientInfos03 == null || mIngredientInfos03.size() == 0)) {
        TextView mTextView =
            (TextView)
                this.mLinearLayoutIngredients.findViewById(
                    R.id.fragment_recipe_detail_main_ingredients_text);
        mTextView.setVisibility(View.VISIBLE);
        mTextView.setText(
            mRecipeDetailInfo.getMainIngredient().replace("<br />", "").replace("&nbsp;", ""));
      }

      if (!"".equals(mRecipeDetailInfo.getRecipeTips().trim())) {

        mTextViewTips.setText(
            mRecipeDetailInfo.getRecipeTips().replace("<br />", "").replace("&nbsp;", ""));
      } else {
        mTextViewTips.setVisibility(View.GONE);
        mTextViewTipsText.setVisibility(View.GONE);
      }

      mStepInfos = mRecipeDetailInfo.getmStepInfos();
      if (mStepInfos != null && mStepInfos.size() > 0) {

        for (int i = 0; i < mStepInfos.size(); i++) {
          View view =
              LayoutInflater.inflate(getSupportActivity(), R.layout.recipe_detail_step_item);
          ImageView mImageView =
              (ImageView) view.findViewById(R.id.fragment_recipe_detail_step_image);
          TextView mTextViewIndex =
              (TextView) view.findViewById(R.id.fragment_recipe_detail_step_index);
          TextView mTextViewDesc =
              (TextView) view.findViewById(R.id.fragment_recipe_detail_step_description);

          String idx = mStepInfos.get(i).getIdx();
          String pic = mStepInfos.get(i).getPic();
          String note = mStepInfos.get(i).getNote();

          if (!"".equals(pic.trim())) {
            mImageLoader.displayImage(
                MeishiApplication.getApplication().isShowPic() ? pic.trim() : null,
                mImageView,
                mOptions);
          }
          SpannableString spannableString = new SpannableString(idx + ".");
          spannableString.setSpan(
              new StyleSpan(Typeface.BOLD_ITALIC),
              0,
              idx.length(),
              Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

          mTextViewIndex.setText(spannableString);

          mTextViewDesc.setText(note.replace("<br />", "").replace("&nbsp;", ""));

          this.mLinearLayoutSteps.addView(view);

          view.setTag(Integer.valueOf(i));
          StepInfoClick stepInfoClick = new StepInfoClick();
          view.setOnClickListener(stepInfoClick);
        }
      }
    }
  }