コード例 #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;
   }
 }
コード例 #2
0
        public void handleMessage(android.os.Message msg) {
          mLinearLayoutProgress.setVisibility(View.GONE);
          switch (msg.what) {
            case HANDLE_REQUEST_RECIPEDETAIL_SUCCESS:
              mRecipeDetailInfo = (RecipeDetailInfo) msg.obj;
              if (mPullToRefreshScrollView == null) {
                mViewStub.setLayoutResource(R.layout.fragment_recipe_detail_base);
                mPullToRefreshScrollView = (PullToRefreshScrollView) mViewStub.inflate();
                initViewStubComponent(mPullToRefreshScrollView);
                mOptions =
                    new DisplayImageOptions.Builder()
                        .showStubImage(R.drawable.yaoyiyao_pic_background)
                        .showImageForEmptyUri(R.drawable.yaoyiyao_pic_background)
                        .cacheInMemory()
                        .cacheOnDisc()
                        .bitmapConfig(Bitmap.Config.RGB_565)
                        .build();
                mOptions2 =
                    new DisplayImageOptions.Builder()
                        .showStubImage(R.drawable.yaoyiyao_pic_background)
                        .showImageForEmptyUri(R.drawable.yaoyiyao_pic_background)
                        .cacheInMemory()
                        .bitmapConfig(Bitmap.Config.RGB_565)
                        .build();
              }
              mPullToRefreshScrollView.setVisibility(View.VISIBLE);
              mImageViewEmpty.setVisibility(View.GONE);
              fillComponent();
              break;
            case HANDLE_REQUEST_RECIPEDETAIL_FAIL:
              mRecipeDetailInfo = null;
              if (mPullToRefreshScrollView != null) {

                mPullToRefreshScrollView.setVisibility(View.GONE);
              }
              mImageViewEmpty.setVisibility(View.VISIBLE);
              if (msg.obj
                  .toString()
                  .equals(
                      MeishiApplication.getApplication()
                          .getResources()
                          .getString(R.string.login_no_user))) {
                Toaster.showShort(
                    getSupportActivity(), getString(R.string.login_please_first_logon));
                Intent intent = new Intent(getSupportActivity(), LoginActivity.class);
                startActivity(intent);
              } else {

                Toaster.showShort(getSupportActivity(), msg.obj.toString());
              }
              break;
          }
        };
コード例 #3
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);
        }
      }
    }
  }