public RedditInboxItemView(final Context context, final int headerCol, final int bodyCol) {

    super(context);
    this.bodyCol = bodyCol;

    setOrientation(HORIZONTAL);

    final LinearLayout main = new LinearLayout(context);
    main.setOrientation(VERTICAL);

    header = new TextView(context);
    header.setTextSize(11.0f);
    header.setTextColor(headerCol);
    main.addView(header);

    bodyHolder = new FrameLayout(context);
    bodyHolder.setPadding(0, General.dpToPixels(context, 2), 0, 0);
    main.addView(bodyHolder);

    final int paddingPixels = General.dpToPixels(context, 8.0f);
    setPadding(paddingPixels + paddingPixels, paddingPixels, paddingPixels, paddingPixels);

    setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);

    addView(main);
  }
 @Override
 public void onStart() {
   super.onStart();
   TextView message = (TextView) getDialog().findViewById(R.id.message);
   message.setTextAppearance(getActivity(), R.style.Holo_TextAppearance_Small_Light);
   message.setGravity(Gravity.CENTER);
   Linkify.addLinks(message, Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES);
   message.setMovementMethod(LinkMovementMethod.getInstance());
 }
  @Override
  public void setShortcut(boolean showShortcut, char shortcutKey) {
    final int newVisibility =
        showShortcut && mItemData.shouldShowShortcut() ? View.VISIBLE : View.GONE;

    if (newVisibility == View.VISIBLE) {
      mShortcutView.setText(mItemData.getShortcutLabel());
    }

    if (mShortcutView.getVisibility() != newVisibility) {
      mShortcutView.setVisibility(newVisibility);
    }
  }
 /** {@inheritDoc} */
 @Override
 public void onLoadFinished(final Loader<Cursor> loader, final Cursor data) {
   if (data == null || data.isClosed() || data.getCount() <= 0) {
     // Set the empty text
     final TextView empty = (TextView) findViewById(R.id.empty);
     empty.setText(getString(R.string.empty_search));
     mGridView.setEmptyView(empty);
     return;
   }
   // Swap the new cursor in. (The framework will take care of closing the
   // old cursor once we return.)
   mAdapter.swapCursor(data);
 }
  @Override
  public void setTitle(CharSequence title) {
    if (title != null) {
      mTitleView.setText(title);

      if (mTitleView.getVisibility() != View.VISIBLE) {
        mTitleView.setVisibility(View.VISIBLE);
      }
    } else {
      if (mTitleView.getVisibility() != View.GONE) {
        mTitleView.setVisibility(View.GONE);
      }
    }
  }
 @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;
   }
 }
  public void reset(
      final Context context,
      final RedditPreparedInboxItem item,
      final ActiveTextView.OnLinkClickedListener listener) {

    header.setText(item.getHeader());

    bodyHolder.removeAllViews();
    bodyHolder.addView(item.getBody(context, 13.0f, bodyCol, listener));
  }
 @SuppressWarnings("deprecation")
 @Override
 protected void onFinishInflate() {
   super.onFinishInflate();
   setBackgroundDrawable(mBackground);
   mTitleView = (TextView) findViewById(R.id.title);
   if (mTextAppearance != -1) {
     mTitleView.setTextAppearance(mTextAppearanceContext, mTextAppearance);
   }
   mShortcutView = (TextView) findViewById(R.id.shortcut);
 }
  private void setProgressMessage(
      boolean indeterminate, final int max, final int current, final String message) {
    if (progressBar == null || progressMessageTextView == null) return;

    if (indeterminate) {
      progressBar.setIndeterminate(true);
    } else {
      progressBar.setIndeterminate(false);
      progressBar.setMax(max);
      progressBar.setProgress(current);
    }
    progressMessageTextView.setText(message);
  }
  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);
        }
      }
    }
  }
 public void setHeader(String header) {
   mHeader = header;
   mTopicName.setText(mHeader);
 }
Example #12
0
 @SuppressWarnings("deprecation")
 public View bindView(
     SliderItem item,
     View view,
     boolean selected,
     int defaultTextAppearance,
     int defaultTextAppearanceInverse) {
   TextView labelView = (TextView) view.findViewById(android.R.id.text1);
   if (labelView != null) {
     labelView.setText(item.mLabel);
   }
   final int textAppereance =
       item.mTextAppereance != 0 ? item.mTextAppereance : defaultTextAppearance;
   final int textAppereanceInverse =
       item.mTextAppereanceInverse != 0
           ? item.mTextAppereanceInverse
           : defaultTextAppearanceInverse;
   setTextAppearance(
       labelView,
       mInverseTextColorWhenSelected
           ? selected ? textAppereanceInverse : textAppereance
           : textAppereance);
   if (mSelectionBehavior == null) {
     return view;
   }
   View selectionHandlerView = view.findViewById(R.id.selectionHandler);
   switch (mSelectionBehavior) {
     case Default:
       if (selected) {
         view.setBackgroundColor(item.mBackgroundColor);
         if (selectionHandlerView != null) {
           selectionHandlerView.setBackgroundColor(item.mSelectionHandlerColor);
         }
       } else {
         view.setBackgroundDrawable(null);
         if (selectionHandlerView != null) {
           selectionHandlerView.setBackgroundDrawable(null);
         }
       }
       break;
     case BackgroundWhenSelected:
       if (selectionHandlerView != null) {
         selectionHandlerView.setBackgroundColor(item.mSelectionHandlerColor);
       }
       if (selected) {
         view.setBackgroundColor(item.mBackgroundColor);
       } else {
         view.setBackgroundDrawable(null);
       }
       break;
     case OnlyBackground:
       if (selected) {
         view.setBackgroundColor(item.mBackgroundColor);
       } else {
         view.setBackgroundDrawable(null);
       }
       break;
     case OnlyHandler:
       if (selectionHandlerView != null) {
         if (selected) {
           selectionHandlerView.setBackgroundColor(item.mSelectionHandlerColor);
         } else {
           selectionHandlerView.setBackgroundDrawable(null);
         }
       }
       break;
   }
   return view;
 }
Example #13
0
 private static void setTextAppearance(TextView textView, int resid) {
   if (resid != 0) {
     textView.setTextAppearance(textView.getContext(), resid);
   }
 }