コード例 #1
0
  public void a(FoodItem fooditem) {
    fooditem = fooditem.d();
    UsedNutritionalValue ausednutritionalvalue[] = UsedNutritionalValue.values();
    int i1 = ausednutritionalvalue.length;
    int i = 0;
    while (i < i1) {
      UsedNutritionalValue usednutritionalvalue = ausednutritionalvalue[i];
      Object obj = a.inflate(0x7f0401dd, null);
      View view = ((View) (obj)).findViewById(0x7f1104bf);
      TextView textview1 = (TextView) ((View) (obj)).findViewById(0x7f11011f);
      TextView textview = (TextView) ((View) (obj)).findViewById(0x7f1104bc);
      int l;
      if (usednutritionalvalue.e() && usednutritionalvalue.d()) {
        l = 1;
      } else {
        l = 0;
      }
      textview1.setTypeface(textview1.getTypeface(), l);
      textview.setTypeface(textview.getTypeface(), l);
      if (usednutritionalvalue.d()) {
        view.setPadding(0, 0, 0, 0);
      }
      if (usednutritionalvalue.e()) {
        b.addView(((View) (obj)));
      } else {
        c.addView(((View) (obj)));
      }
      textview1.setText(bv.a(getContext().getString(usednutritionalvalue.a())));
      obj = (Double) fooditem.get(usednutritionalvalue.b());
      if (obj == null
          || ((Double) (obj)).isNaN()
          || an.a(((Double) (obj)).doubleValue(), 0) == 0.0D) {
        textview.setText("-");
      } else {
        textview.setText(e.a(getContext(), ((Double) (obj)), usednutritionalvalue.c()));
      }
      i++;
    }
    for (int j = 0; j < b.getChildCount(); j++) {
      if (j % 2 != 0) {
        b.getChildAt(j).setBackgroundColor(getResources().getColor(0x7f0f0098));
      }
    }

    for (int k = 0; k < c.getChildCount(); k++) {
      if (k % 2 != 0) {
        c.getChildAt(k).setBackgroundColor(getResources().getColor(0x7f0f0098));
      }
    }
  }
コード例 #2
0
ファイル: FontHelper.java プロジェクト: hash13/qabel-android
  public void setCustomeFonts(TextView view) {

    if (view != null && !view.isInEditMode()) {
      if (fonts == null) {
        loadCustomeFonts(view.getContext());
      }
      int style = Typeface.NORMAL;
      if (view.getTypeface() != null) {
        style = view.getTypeface().getStyle();
      }
      if (style >= 0 && style < fonts.length) {
        view.setTypeface(fonts[style], style);
      }
    }
  }
コード例 #3
0
 public TitleBuilder setTitle(String title) {
   if (null != title) {
     title_tv.setText(title);
     title_tv.setTypeface(title_tv.getTypeface(), Typeface.BOLD);
   }
   return this;
 }
コード例 #4
0
 public TitleBuilder setLeft(String left) {
   if (null != left) {
     left_tv.setText(left);
     left_tv.setTypeface(left_tv.getTypeface(), Typeface.BOLD);
   }
   return this;
 }
コード例 #5
0
  private void prepare() {
    // Remember current state
    final float diff1 = mText1Difference;

    // Measure
    mPaint.setTextSize(mTextField1.getTextSize());
    mPaint.setTypeface(mTextField1.getTypeface());
    mText1TextWidth = mPaint.measureText(mTextField1.getText().toString());

    // See how much functions are needed at all
    mIsText1MarqueeNeeded = mText1TextWidth > mWidth;

    mText1Difference = Math.abs((mText1TextWidth - mWidth)) + 5;

    if (DEBUG) {
      Log.d(TAG, "mText1TextWidth: " + mText1TextWidth);
      Log.d(TAG, "getMeasuredWidth: " + mWidth);

      Log.d(TAG, "mIsText1MarqueeNeeded: " + mIsText1MarqueeNeeded);

      Log.d(TAG, "mText1Difference: " + mText1Difference);
    }

    if (diff1 != mText1Difference) {
      setupText1Marquee();
    }
  }
コード例 #6
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   View v = super.getView(position, convertView, parent);
   try {
     // TODO create a theme for the whole app so we don't have to do this
     TextView tv = (TextView) v;
     tv.setTypeface(tv.getTypeface(), Typeface.ITALIC);
     if (size == 0.0f) size = tv.getTextSize() * SCALE_FACTOR;
     tv.setTextSize(size);
     v = tv;
   } catch (Exception e) {
     Util.e(null, TAG, "Can't set italic type: " + e);
   }
   if (pics[position] != null) {
     BitmapDrawable pic = new BitmapDrawable(v.getContext().getResources(), pics[position]);
     if (!unscaledBackground) {
       v.setBackgroundDrawable(pic);
     } else {
       TextView tv;
       try {
         tv = (TextView) v;
       } catch (Exception e) {
         Util.w(null, TAG, "Returned view does not " + "support unscaled background images");
         unscaledBackground = true;
         v.setBackgroundDrawable(pic);
         return v;
       }
       tv.setCompoundDrawablesWithIntrinsicBounds(pic, null, null, null);
       return tv;
     }
   }
   return v;
 }
コード例 #7
0
ファイル: SLiveLabel.java プロジェクト: rogersb11/Synapse
  @Override
  public View getView() throws ElementFailureException {
    if (elementView != null) return elementView;

    LinearLayout v =
        (LinearLayout)
            LayoutInflater.from(Utils.mainActivity)
                .inflate(R.layout.template_livelabel, this.layout, false);

    assert v != null;
    elementView = v;

    /** Nesting another element's view in our own for title and description. */
    LinearLayout descriptionFrame = (LinearLayout) v.findViewById(R.id.SLiveLabel_descriptionFrame);

    if (titleObj != null) {
      TextView titleView = (TextView) titleObj.getView();
      titleView.setBackground(null);
      descriptionFrame.addView(titleView);
    }

    if (descriptionObj != null) descriptionFrame.addView(descriptionObj.getView());

    liveLabel = (TextView) v.findViewById(R.id.SLiveLabel_textView);

    if (style != null) {
      if (style.contains("bold") && style.contains("italic")) {
        liveLabel.setTypeface(liveLabel.getTypeface(), Typeface.BOLD_ITALIC);
        return v;
      }

      if (style.contains("bold")) liveLabel.setTypeface(liveLabel.getTypeface(), Typeface.BOLD);

      if (style.contains("italic")) liveLabel.setTypeface(liveLabel.getTypeface(), Typeface.ITALIC);
    }

    try {
      liveLabel.setText(Utils.runCommand(command).replace("@n", "\n"));
    } catch (Exception e) {
      throw new ElementFailureException(this, e);
    }

    return v;
  }
コード例 #8
0
  private void updateGradeViews() {
    getSupportActionBar().setTitle(mGrade.disc != null ? mGrade.disc : "");

    getSupportActionBar()
        .setSubtitle(
            String.format(
                getResources().getQuantityString(R.plurals.avaliacoes, mGrade.nr_avaliations),
                mGrade.nr_avaliations));

    if (mGrade.disc != null) {
      TextView tvGradeName = (TextView) findViewById(R.id.tv_grade_name);
      tvGradeName.setText(
          mGrade.disc + " - " + "(" + mGrade.T + "-" + mGrade.P + "-" + mGrade.I + ")");
    }

    TextView tvGradeRecomendation = (TextView) findViewById(R.id.tv_grade_recomendation);
    tvGradeRecomendation.setText(mGrade.recommendation != null ? mGrade.recommendation : "");

    TextView tvGradeMenu = (TextView) findViewById(R.id.tv_grade_menu);
    tvGradeMenu.setText(mGrade.menu != null ? mGrade.menu : "");

    RatingBar ratingBarGradeExtraWork =
        (RatingBar) findViewById(R.id.rb_grade_amount_of_extra_work);
    ratingBarGradeExtraWork.setRating(mGrade.nr_works);

    TextView tvWorkAverage = (TextView) findViewById(R.id.tv_grade_amount_of_extra_work_average);
    tvWorkAverage.setText(getString(R.string.media_) + String.format("%.2f", mGrade.nr_works));

    TextView tvWorkAmount = (TextView) findViewById(R.id.tv_grade_amount_of_extra_work_amount);
    tvWorkAmount.setText(getWorkAmount(mGrade.nr_works));

    RatingBar ratingBarGradeDedication =
        (RatingBar) findViewById(R.id.rb_grade_required_dedication);
    ratingBarGradeDedication.setRating(mGrade.nr_dedication);

    TextView tvDedicationAverage =
        (TextView) findViewById(R.id.tv_grade_required_dedication_average);
    tvDedicationAverage.setText(
        getString(R.string.media_) + String.format("%.2f", mGrade.nr_dedication));

    TextView tvDedicationNeeded = (TextView) findViewById(R.id.tv_grade_required_dedication_needed);
    tvDedicationNeeded.setText(getDedicationNeeded(mGrade.nr_dedication));

    RatingBar ratingBarGradePrerequesites = (RatingBar) findViewById(R.id.rb_grade_prerequesites);
    ratingBarGradePrerequesites.setRating(mGrade.nr_requirements);

    TextView tvPrerequesitesAverage = (TextView) findViewById(R.id.tv_grade_prerequesites_average);
    tvPrerequesitesAverage.setText(
        getString(R.string.media_) + String.format("%.2f", mGrade.nr_requirements));

    TextView tvPrerequesitesAmount = (TextView) findViewById(R.id.tv_grade_prerequesites_amount);
    tvPrerequesitesAmount.setText(getRequisitesAmount(mGrade.nr_requirements));
    Typeface typeface = tvPrerequesitesAmount.getTypeface();

    setupChart(typeface);
  }
コード例 #9
0
    public CardboardOverlayEyeView(Context context, AttributeSet attrs) {
      super(context, attrs);
      imageView = new ImageView(context, attrs);
      imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
      imageView.setAdjustViewBounds(true); // Preserve aspect ratio.
      //            imageView.setImageResource(R.drawable.crosshair);
      addView(imageView);

      textView = new TextView(context, attrs);
      textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14.0f);
      textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
      textView.setGravity(Gravity.CENTER);
      textView.setShadowLayer(3.0f, 0.0f, 0.0f, Color.DKGRAY);
      addView(textView);
    }
コード例 #10
0
  public ContactListPinnedHeaderView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mContext = context;

    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ContactListItemView);

    mHeaderTextIndent =
        a.getDimensionPixelOffset(R.styleable.ContactListItemView_list_item_header_text_indent, 0);
    mHeaderTextColor =
        a.getColor(R.styleable.ContactListItemView_list_item_header_text_color, Color.BLACK);
    mHeaderTextSize =
        a.getDimensionPixelSize(R.styleable.ContactListItemView_list_item_header_text_size, 12);
    mHeaderUnderlineHeight =
        a.getDimensionPixelSize(
            R.styleable.ContactListItemView_list_item_header_underline_height, 1);
    mHeaderUnderlineColor =
        a.getColor(R.styleable.ContactListItemView_list_item_header_underline_color, 0);
    mHeaderBackgroundHeight =
        a.getDimensionPixelSize(R.styleable.ContactListItemView_list_item_header_height, 30);
    mPaddingLeft =
        a.getDimensionPixelOffset(R.styleable.ContactListItemView_list_item_padding_left, 0);
    mPaddingRight =
        a.getDimensionPixelOffset(R.styleable.ContactListItemView_list_item_padding_right, 0);
    mContactsCountTextColor =
        a.getColor(
            R.styleable.ContactListItemView_list_item_contacts_count_text_color, Color.BLACK);
    mCountViewTextSize =
        (int)
            a.getDimensionPixelSize(
                R.styleable.ContactListItemView_list_item_contacts_count_text_size, 12);

    a.recycle();

    mHeaderTextView = new TextView(mContext);
    mHeaderTextView.setTextColor(mHeaderTextColor);
    mHeaderTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mHeaderTextSize);
    mHeaderTextView.setTypeface(mHeaderTextView.getTypeface(), Typeface.BOLD);
    mHeaderTextView.setGravity(Gravity.CENTER_VERTICAL);

    mHeaderTextView.setAllCaps(true);
    addView(mHeaderTextView);
    mHeaderDivider = new View(mContext);
    mHeaderDivider.setBackgroundColor(mHeaderUnderlineColor);
    addView(mHeaderDivider);
  }
コード例 #11
0
  @Override
  public View getHeaderView(final int columnIndex, final ViewGroup parentView) {
    final TextView textView = new TextView(getContext());

    if (columnIndex < headers.length) {
      textView.setText(headers[columnIndex]);
    }

    textView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
    textView.setTypeface(textView.getTypeface(), typeface);
    textView.setTextSize(textSize);
    textView.setTextColor(textColor);
    textView.setGravity(Gravity.CENTER);
    //        textView.setSingleLine();
    //        textView.setEllipsize(TextUtils.TruncateAt.END);

    return textView;
  }
コード例 #12
0
  private TextView createTextView(String string, boolean bold, boolean weight) {
    TextView view = new TextView(activity);
    view.setText(string);
    int top = (int) (2 * scale);
    int left = (int) (2 * scale);
    view.setPadding(left, top, left, top);
    view.setTextColor(Color.parseColor("#555555"));
    if (weight) {
      view.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, .2f));
    } else {
      view.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    }
    view.setGravity(Gravity.RIGHT);
    if (bold) {
      view.setTypeface(view.getTypeface(), Typeface.BOLD);
    }

    return view;
  }
コード例 #13
0
ファイル: UIUtils.java プロジェクト: hothanhhung/Android
  public static void showAlertGetMoreApps(final Activity activity) {
    alert = new AlertDialog.Builder(activity);
    TextView textView = new TextView(activity);
    textView.setText("Loading...");
    textView.setPadding(10, 10, 10, 10);
    textView.setTextSize(15);
    textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
    alert.setView(textView);
    alert.setNegativeButton(
        "Close",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
            alertDialog = null;
          }
        });
    // alert.setIcon(android.R.drawable.box_new)
    alertDialog = alert.show();

    (new Thread(
            new Runnable() {
              @Override
              public void run() {
                linearLayout = BuildGetMoreApps(activity);
                activity.runOnUiThread(
                    new Runnable() {
                      @Override
                      public void run() {
                        if (alertDialog != null && alertDialog.isShowing()) {
                          alert.setView(linearLayout);
                          alertDialog.dismiss();
                          alertDialog = alert.show();
                        }
                      }
                    });
              }
            }))
        .start();
  }
コード例 #14
0
 public static void run(final TextView tv, float origWidth) {
   String s = tv.getText().toString();
   p.setTypeface(tv.getTypeface());
   String[] splits = s.split(SYSTEM_NEWLINE);
   float width = origWidth - 5;
   for (int x = 0; x < splits.length; x++)
     if (p.measureText(splits[x]) > width) {
       splits[x] = wrap(splits[x], width, p);
       String[] microSplits = splits[x].split(SYSTEM_NEWLINE);
       for (int y = 0; y < microSplits.length - 1; y++)
         microSplits[y] = justify(removeLast(microSplits[y], " "), width, p);
       StringBuilder smb_internal = new StringBuilder();
       for (int z = 0; z < microSplits.length; z++)
         smb_internal.append(
             microSplits[z] + ((z + 1 < microSplits.length) ? SYSTEM_NEWLINE : ""));
       splits[x] = smb_internal.toString();
     }
   final StringBuilder smb = new StringBuilder();
   for (String cleaned : splits) smb.append(cleaned + SYSTEM_NEWLINE);
   tv.setGravity(Gravity.LEFT);
   tv.setText(smb);
 }
コード例 #15
0
ファイル: FontLoader.java プロジェクト: chsj1/android-utils
 public static <T extends View> T applyDefaultStyles(T view) {
   if (view == null || view.getContext() == null || view.getContext().isRestricted()) {
     return view;
   }
   if (view instanceof TextView) {
     TextView text = (TextView) view;
     Typeface typeface = text.getTypeface();
     if (typeface == null) {
       text.setTypeface(FontLoader.loadTypeface(view.getContext(), HoloFont.ROBOTO_REGULAR.font));
       return view;
     }
     HoloFont font;
     boolean isBold = typeface.isBold(), isItalic = typeface.isItalic();
     if (isBold && isItalic) {
       font = HoloFont.ROBOTO_BOLD_ITALIC;
     } else if (isBold && !isItalic) {
       font = HoloFont.ROBOTO_BOLD;
     } else if (!isBold && isItalic) {
       font = HoloFont.ROBOTO_ITALIC;
     } else {
       font = HoloFont.ROBOTO_REGULAR;
     }
     if (!font.ignore) {
       typeface = FontLoader.loadTypeface(view.getContext(), font.font);
       if (typeface != null) {
         text.setTypeface(typeface);
       }
     }
   }
   if (view instanceof ViewGroup) {
     ViewGroup group = (ViewGroup) view;
     for (int i = 0; i < group.getChildCount(); i++) {
       FontLoader.applyDefaultStyles(group.getChildAt(i));
     }
   }
   return view;
 }
コード例 #16
0
  // Please use run(...) instead
  public static void justify(TextView textView) {
    Paint paint = new Paint();

    String[] blocks;
    float spaceOffset = 0;
    float textWrapWidth = 0;

    int spacesToSpread;
    float wrappedEdgeSpace;
    String block;
    String[] lineAsWords;
    String wrappedLine;
    String smb = "";
    Object[] wrappedObj;

    // Pull widget properties
    paint.setColor(textView.getCurrentTextColor());
    paint.setTypeface(textView.getTypeface());
    paint.setTextSize(textView.getTextSize());

    textWrapWidth = textView.getWidth();
    spaceOffset = paint.measureText(" ");
    blocks = textView.getText().toString().split("((?<=\n)|(?=\n))");

    if (textWrapWidth < 20) {
      return;
    }

    for (int i = 0; i < blocks.length; i++) {
      block = blocks[i];

      if (block.length() == 0) {
        continue;
      } else if (block.equals("\n")) {
        smb += block;
        continue;
      }

      block = block.trim();

      if (block.length() == 0) continue;

      wrappedObj = TextJustifyUtils.createWrappedLine(block, paint, spaceOffset, textWrapWidth);
      wrappedLine = ((String) wrappedObj[0]);
      wrappedEdgeSpace = (Float) wrappedObj[1];
      lineAsWords = wrappedLine.split(" ");
      spacesToSpread =
          (int) (wrappedEdgeSpace != Float.MIN_VALUE ? wrappedEdgeSpace / spaceOffset : 0);

      for (String word : lineAsWords) {
        smb += word + " ";

        if (--spacesToSpread > 0) {
          smb += " ";
        }
      }

      smb = smb.trim();

      if (blocks[i].length() > 0) {
        blocks[i] = blocks[i].substring(wrappedLine.length());

        if (blocks[i].length() > 0) {
          smb += "\n";
        }

        i--;
      }
    }

    textView.setGravity(Gravity.LEFT);
    textView.setText(smb);
  }
コード例 #17
0
  /**
   * Sets the message typeface of the SuperCardToast. <br>
   *
   * @param typeface Use a Typeface constants
   */
  public void setTypeface(int typeface) {

    mTypeface = typeface;

    mMessageTextView.setTypeface(mMessageTextView.getTypeface(), typeface);
  }
コード例 #18
0
 public TitleBuilder setLeft(int left) {
   left_tv.setText(left);
   left_tv.setTypeface(left_tv.getTypeface(), Typeface.BOLD);
   return this;
 }
コード例 #19
0
 public TitleBuilder setTitle(int title) {
   title_tv.setText(title);
   title_tv.setTypeface(title_tv.getTypeface(), Typeface.BOLD);
   return this;
 }
コード例 #20
0
ファイル: MarqueeView.java プロジェクト: jeozey/Wisp
  private void prepareAnimation() {
    // Measure
    mPaint.setTextSize(mTextField.getTextSize());
    mPaint.setTypeface(mTextField.getTypeface());
    float mTextWidth = mPaint.measureText(mTextField.getText().toString());

    // See how much functions are needed at all
    mMarqueeNeeded = mTextWidth > getMeasuredWidth();

    mTextDifference = Math.abs((mTextWidth - getMeasuredWidth())) + 5;

    if (BuildConfig.DEBUG) {
      Log.d(TAG, "mTextWidth       : " + mTextWidth);
      Log.d(TAG, "measuredWidth    : " + getMeasuredWidth());
      Log.d(TAG, "mMarqueeNeeded   : " + mMarqueeNeeded);
      Log.d(TAG, "mTextDifference  : " + mTextDifference);
    }

    final int duration = (int) (mTextDifference * mSpeed);

    mMoveTextOut = new TranslateAnimation(0, -mTextDifference, 0, 0);
    mMoveTextOut.setDuration(duration);
    mMoveTextOut.setInterpolator(mInterpolator);
    mMoveTextOut.setFillAfter(true);

    mMoveTextIn = new TranslateAnimation(-mTextDifference, 0, 0, 0);
    mMoveTextIn.setDuration(duration);
    mMoveTextIn.setStartOffset(mAnimationPause);
    mMoveTextIn.setInterpolator(mInterpolator);
    mMoveTextIn.setFillAfter(true);

    mMoveTextOut.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationStart(Animation animation) {
            expandTextView();
          }

          public void onAnimationEnd(Animation animation) {
            if (mCancelled) {
              return;
            }

            mTextField.startAnimation(mMoveTextIn);
          }

          public void onAnimationRepeat(Animation animation) {}
        });

    mMoveTextIn.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationStart(Animation animation) {}

          public void onAnimationEnd(Animation animation) {

            cutTextView();

            if (mCancelled) {
              return;
            }
            startTextFieldAnimation();
          }

          public void onAnimationRepeat(Animation animation) {}
        });
  }