Exemplo n.º 1
0
  public SliderDrawView(Context context, AttributeSet attrs) {
    super(context, attrs);

    measurePaint.setAntiAlias(true);
    measurePaint.setColor(Color.DKGRAY);
    measurePaint.setStrokeWidth(3f);
    measurePaint.setStyle(Paint.Style.STROKE);

    infoRectPaintFill.setAntiAlias(true);
    infoRectPaintFill.setColor(Color.BLUE);
    infoRectPaintFill.setAlpha(80);
    infoRectPaintFill.setStyle(Paint.Style.FILL);
    infoRectPaintStroke.setAntiAlias(true);
    infoRectPaintStroke.setStrokeWidth(1.5f);
    infoRectPaintStroke.setColor(Color.BLUE);
    infoRectPaintStroke.setStyle(Paint.Style.STROKE);

    measureTextPaint.setAntiAlias(true);
    int pixel =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics());
    measureTextPaint.setTextSize(pixel);
    measureTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));

    distanceString =
        context.getString(
            R.string.distance); // context.getResources().getString(R.string.distance);
  }
  private void init() {
    setOrientation(LinearLayout.VERTICAL);

    textView = new TextView(getContext());
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
    textView.setTextColor(0xff3b84c0);
    addView(textView);
    LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
    layoutParams.width = LayoutParams.WRAP_CONTENT;
    layoutParams.height = LayoutParams.WRAP_CONTENT;
    layoutParams.leftMargin = AndroidUtilities.dp(8);
    layoutParams.rightMargin = AndroidUtilities.dp(8);
    layoutParams.topMargin = AndroidUtilities.dp(6);
    layoutParams.bottomMargin = AndroidUtilities.dp(4);
    if (LocaleController.isRTL) {
      textView.setGravity(Gravity.RIGHT);
      layoutParams.gravity = Gravity.RIGHT;
    }
    textView.setLayoutParams(layoutParams);

    View view = new View(getContext());
    view.setBackgroundColor(0xff6caae4);
    addView(view);
    layoutParams = (LayoutParams) view.getLayoutParams();
    layoutParams.weight = LayoutParams.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(1);
    view.setLayoutParams(layoutParams);
  }
 /**
  * This method will be called to instantiate a MyParcelableMessage when a Parcel is
  * received. All data fields which where written during the writeToParcel method should be
  * read in the correct sequence during this method.
  */
 @Override
 public MyParcelableMessage createFromParcel(Parcel in) {
   String message = in.readString();
   int fontSize = in.readInt();
   int textColor = in.readInt();
   Typeface typeface = Typeface.defaultFromStyle(in.readInt());
   return new MyParcelableMessage(message, fontSize, textColor, typeface);
 }
Exemplo n.º 4
0
  private void showHelp(int id) {
    final TextView board = this.board;
    final Resources res = this.res;

    final int padding = res.getDimensionPixelSize(R.dimen.pnl_margin);

    board.setPadding(padding, padding, padding, padding);
    board.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
    board.setTextSize(res.getDimension(R.dimen.text_small));
    board.setTextColor(res.getColor(R.color.text_default));
    board.setGravity(Gravity.NO_GRAVITY);
    board.setTag(ContentType.MSG);
    board.setText(Html.fromHtml(res.getString(id), this, this));
  }
Exemplo n.º 5
0
  private void showHint() {
    final TextView board = this.board;
    final Resources res = this.res;
    final String hint;

    if (nfcAdapter == null) hint = res.getString(R.string.msg_nonfc);
    else if (nfcAdapter.isEnabled()) hint = res.getString(R.string.msg_nocard);
    else hint = res.getString(R.string.msg_nfcdisabled);

    final int padding = res.getDimensionPixelSize(R.dimen.text_middle);

    board.setPadding(padding, padding, padding, padding);
    board.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD_ITALIC));
    board.setTextSize(res.getDimension(R.dimen.text_middle));
    board.setTextColor(res.getColor(R.color.text_tip));
    board.setGravity(Gravity.CENTER_VERTICAL);
    board.setTag(ContentType.HINT);
    board.setText(Html.fromHtml(hint));
  }
Exemplo n.º 6
0
  private void showData(String data) {
    if (data == null || data.length() == 0) {
      showHint();
      return;
    }

    final TextView board = this.board;
    final Resources res = this.res;

    final int padding = res.getDimensionPixelSize(R.dimen.pnl_margin);

    board.setPadding(padding, padding, padding, padding);
    board.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
    board.setTextSize(11);
    board.setTextColor(res.getColor(R.color.text_default));
    board.setGravity(Gravity.NO_GRAVITY);
    board.setTag(ContentType.DATA);
    board.setText(Html.fromHtml(data));
  }
Exemplo n.º 7
0
  public void setSwitchTypeface(Typeface tf, int style) {
    if (style > 0) {
      if (tf == null) {
        tf = Typeface.defaultFromStyle(style);
      } else {
        tf = Typeface.create(tf, style);
      }

      setSwitchTypeface(tf);
      // now compute what (if any) algorithmic styling is needed
      int typefaceStyle = tf != null ? tf.getStyle() : 0;
      int need = style & ~typefaceStyle;
      mTextPaint.setFakeBoldText((need & Typeface.BOLD) != 0);
      mTextPaint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0);
    } else {
      mTextPaint.setFakeBoldText(false);
      mTextPaint.setTextSkewX(0);
      setSwitchTypeface(tf);
    }
  }
  private void initViews() {
    isRunning = true;
    innerPaint = new Paint();
    outerPaint = new Paint();
    textPaint = new Paint();

    innerPaint.setDither(true);
    innerPaint.setAntiAlias(true);
    innerPaint.setStyle(Paint.Style.FILL);
    outerPaint.setAntiAlias(true);
    outerPaint.setStyle(Paint.Style.FILL);
    // innerPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
    textPaint.setColor(0x99ffffff);
    textPaint.setTextSize(35);
    textPaint.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC));
    textPaint.setAntiAlias(true);

    outerRect =
        new RectF(
            progressLeft, progressTop, progressLeft + progressWidth, progressTop + progressHeight);
    innerRect =
        new RectF(
            progressLeft, progressTop, progressLeft + innerRectWidth, progressTop + progressHeight);
  }
Exemplo n.º 9
0
    public View getView(int position, View convertView, ViewGroup parent) {
      View view;
      ViewHolder holder;
      if (convertView == null) {
        view = inflater.inflate(R.layout.legislator_voter, null);

        holder = new ViewHolder();
        holder.name = (TextView) view.findViewById(R.id.name);
        holder.position = (TextView) view.findViewById(R.id.position);
        holder.vote = (TextView) view.findViewById(R.id.vote);
        holder.photo = (ImageView) view.findViewById(R.id.photo);
        holder.star = (ImageView) view.findViewById(R.id.star);

        view.setTag(holder);
      } else {
        view = convertView;
        holder = (ViewHolder) view.getTag();
      }

      Roll.Vote vote = getItem(position);
      Legislator legislator = vote.voter;

      // used as the hook to get the legislator image in place when it's loaded
      // and to link to the legislator's activity
      holder.bioguide_id = vote.voter_id;

      holder.name.setText(nameFor(legislator));
      holder.position.setText(positionFor(legislator));

      holder.star.setVisibility(starred ? View.VISIBLE : View.GONE);

      TextView voteView = holder.vote;
      String value = vote.vote;
      if (value.equals(Roll.YEA)) {
        voteView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        voteView.setTextColor(resources.getColor(R.color.yea));
      } else if (value.equals(Roll.NAY)) {
        voteView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        voteView.setTextColor(resources.getColor(R.color.nay));
      } else if (value.equals(Roll.PRESENT)) {
        voteView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
        voteView.setTextColor(resources.getColor(R.color.present));
      } else if (value.equals(Roll.NOT_VOTING)) {
        voteView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
        voteView.setTextColor(resources.getColor(R.color.not_voting));
      } else {
        voteView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        voteView.setTextColor(resources.getColor(android.R.color.white));
      }

      voteView.setText(vote.vote);

      BitmapDrawable photo =
          LegislatorImage.quickGetImage(
              LegislatorImage.PIC_MEDIUM, legislator.bioguide_id, context);
      if (photo != null) holder.photo.setImageDrawable(photo);
      else {
        holder.photo.setImageResource(R.drawable.loading_photo);
        context.loadPhoto(legislator.bioguide_id);
      }

      return view;
    }
Exemplo n.º 10
0
  /**
   * 介绍TypedArray使用方法 获取 attr中formate 十种类型属性值
   * float,integer,boolean,fraction,string,dimension,color,reference,enum,flag
   *
   * <p>
   *
   * @param context 上下文环境
   * @param attrs 属性集合
   */
  private void printAttributes(Context context, AttributeSet attrs) {
    TypedArray typedArray =
        context.obtainStyledAttributes(attrs, R.styleable.CustomTextViewStyle, 0, 0);
    System.out.println(
        "typedArray.getChangingConfigurations() = "
            + Integer.toHexString(typedArray.getChangingConfigurations()));
    float float_value = typedArray.getFloat(R.styleable.CustomTextViewStyle_float_value, 0f);
    int integer_value = typedArray.getInteger(R.styleable.CustomTextViewStyle_integer_value, 0);
    boolean boolean_value =
        typedArray.getBoolean(R.styleable.CustomTextViewStyle_boolean_value, false);

    // public float getFraction (int index, int base, int pbase, float defValue)
    // 如果值为10% 则 fraction_value=10%*base
    // 如果值格式为10%p,则fraction_value=10%*pbase
    float fraction_value =
        typedArray.getFraction(R.styleable.CustomTextViewStyle_fraction_value, 1, 1, 0);
    String string_value = typedArray.getString(R.styleable.CustomTextViewStyle_string_value);

    // 获取像素值,浮点数  eg:27.5625
    float dimension_value_float =
        typedArray.getDimension(R.styleable.CustomTextViewStyle_dimension_value, 0f);
    // 将取得浮点像素值四舍五入 eg:28
    int dimension_value =
        typedArray.getDimensionPixelSize(R.styleable.CustomTextViewStyle_dimension_value, 0);
    // 将取得浮点像素值直接截取整数部分 eg:27
    int dimension_value_offset_ =
        typedArray.getDimensionPixelOffset(R.styleable.CustomTextViewStyle_dimension_value, 0);

    int color_value = typedArray.getColor(R.styleable.CustomTextViewStyle_color_value, 0);
    int reference_drawable_value =
        typedArray.getResourceId(R.styleable.CustomTextViewStyle_reference_drawable_value, 0);
    int reference_array_value =
        typedArray.getResourceId(R.styleable.CustomTextViewStyle_reference_array_value, 0);
    int enum_value = typedArray.getInt(R.styleable.CustomTextViewStyle_enum_value, -1);
    int flag_value = typedArray.getInt(R.styleable.CustomTextViewStyle_flag_value, -1);

    System.out.println(
        "float_value = ["
            + float_value
            + "], integer_value = ["
            + integer_value
            + "], "
            + "boolean_value = ["
            + boolean_value
            + "], fraction_value = ["
            + fraction_value
            + "], string_value = ["
            + string_value
            + "], dimension_value = ["
            + dimension_value
            + "], color_value = ["
            + color_value
            + "], "
            + "reference_drawable_value ="
            + " [0x"
            + Integer.toHexString(reference_drawable_value)
            + "], enum_value = ["
            + enum_value
            + "], "
            + "flag_value1 = ["
            + flag_value
            + "]");

    // 后期数据处理,设置左边图片
    Drawable drawable;
    drawable = typedArray.getDrawable(R.styleable.CustomTextViewStyle_reference_drawable_value);
    // or
    drawable = context.getDrawable(reference_drawable_value);
    drawable.setBounds(new Rect(0, 0, 50, 50));
    setCompoundDrawables(drawable, null, null, null);
    // 设置文字是否大写,斜体
    if (flag_value >= 0) {
      Typeface typeface = getTypeface();
      setTypeface(Typeface.defaultFromStyle(flag_value));
    }

    // 其他方法getTextArray
    CharSequence[] arrays;
    arrays = typedArray.getTextArray(R.styleable.CustomTextViewStyle_reference_array_value);
    // or
    arrays = context.getResources().getTextArray(reference_array_value);
    for (int i = 0; i < arrays.length; i++) {
      System.out.println("arrays[" + i + "] = " + arrays[i]);
    }

    // 遍历TypedArray
    for (int i = 0, m = typedArray.getIndexCount(); i < m; i++) {
      System.out.println(
          "typedArray"
              + i
              + " type= "
              + typedArray.getType(i)
              + " value="
              + typedArray.getString(i));
    }

    int textsize = typedArray.getDimensionPixelSize(R.styleable.CustomTextViewStyle_text_size, 10);
    int textcolor = typedArray.getColor(R.styleable.CustomTextViewStyle_text_color, Color.BLACK);
    String text = typedArray.getString(R.styleable.CustomTextViewStyle_text_content);
    int padding = typedArray.getDimensionPixelSize(R.styleable.CustomTextViewStyle_padding, 0);

    setTextColor(textcolor);
    setTextSize(textsize);
    setText(text);
    setPadding(padding, padding, padding, padding);

    typedArray.recycle();
  }
Exemplo n.º 11
0
  @Override
  protected void init() {
    // 标识位不要动
    SystemConfig.isDeflossPage = false;

    // 报案号和任务类型
    if (bundle != null) {
      registNo = bundle.getString("registNo");
      // 地区
      String arean = registNo.substring(1, 3);
      if ("01".equals(arean)) {
        SystemConfig.AREAN = "北京";
      } else if ("11".equals(arean)) {
        SystemConfig.AREAN = "北京";
      } else if ("02".equals(arean)) {
        SystemConfig.AREAN = "上海";
      } else {
        SystemConfig.AREAN = "";
      }
      checkStatue = bundle.getString("checkStatue");
      SystemConfig.PHOTO_CLAIMNO = registNo;
      checkTask = CheckTaskAccess.findByRegistno(registNo);
    } else {
      registNo = "报案号错误";
      SystemConfig.PHOTO_CLAIMNO = "00000000";
      checkTask = new CheckTask();
    }

    // 加载布局文件
    layout = inflater.inflate(R.layout.survey_basic, null);
    // 填充布局
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    layout.setLayoutParams(params);

    promptManager = new PromptManager();

    // 初始化抽屉
    gDrawer = layout.findViewById(R.id.survey_basic_drawer);
    drawerUtils = new DrawerUtils(gDrawer);

    dbHelper = new FastClaimDbHelper(context);
    // 获取报案号
    commonUtils = new CommonUtils();
    TopManager.getInstance().setHeadTitle(registNo, 16, Typeface.defaultFromStyle(Typeface.BOLD));
    TopManager.getInstance()
        .getBtnSurveyBasicMsg()
        .setBackgroundResource(R.drawable.tasks_infortab_click);
    caseinfoRl = (RelativeLayout) layout.findViewById(R.id.survey_basic_btn_caseinfo);
    taskinfoRl = (RelativeLayout) layout.findViewById(R.id.survey_basic_btn_taskinfo);
    ACaseImv = (ImageView) layout.findViewById(R.id.survey_basic_caseinfo_ll);
    ATaskImg = (ImageView) layout.findViewById(R.id.survey_basic_taskinfo_ll);
    caseListView = (ListView) layout.findViewById(R.id.survey_basic_caseinfo_listview);
    taskListView = (ListView) layout.findViewById(R.id.survey_basic_taskinfo_listview);
    rlBaoDan = (RelativeLayout) layout.findViewById(R.id.survey_basic_btn_baodaninfo);
    rlHistory = (RelativeLayout) layout.findViewById(R.id.survey_basic_btn_history);
    rlOrderTime = (RelativeLayout) layout.findViewById(R.id.survey_basic_btn_predicttime);
    llOrderTime = (LinearLayout) layout.findViewById(R.id.survey_basic_ll_ordertime);
    imvOrderTime = (ImageView) layout.findViewById(R.id.survey_basic_taskinfo_ll_ordertime);
    messagesQuery = (RelativeLayout) layout.findViewById(R.id.survey_basic_btn_messagesQuery);
    messagesEditxiepei =
        (RelativeLayout) layout.findViewById(R.id.survey_basic_btn_messagesEditxiepei);
    edOrderTime =
        (EditText) layout.findViewById(R.id.survrybasic_taskinfo_listview_item_ed_ordertime);
    setDateTimeUsils = new SetDateTimeUsils(context);
    edOrderTime.setText(checkTask.getOrdertime());

    contactRL = (RelativeLayout) layout.findViewById(R.id.survey_basic_btn_contactinfo);
    if (!SystemConfig.UserRightIsAdvanced) {
      contactRL.setVisibility(View.VISIBLE);
      contactImv = (ImageView) layout.findViewById(R.id.survey_basic_contactinfo_ll);
      contactListView = (ListView) layout.findViewById(R.id.survey_basic_contactinfo_listview);
      messagesEditxiepei.setVisibility(View.VISIBLE);
      // 联系人信息
      if (sContactView == null) sContactView = new SContactView(context);
    } else {
      contactRL.setVisibility(View.GONE);
      messagesEditxiepei.setVisibility(View.GONE);
    }

    // 初始化数据
    setData();
    controlEd();
  }
Exemplo n.º 12
0
  public void onToolDraw(Canvas canvas) {
    int cWidth = canvas.getWidth();
    int cHeight = canvas.getHeight();

    int upper = 70;

    if (gpsLogInfo == null) return;

    GpsLogInfo logInfo = gpsLogInfo;
    int color = Color.BLACK;
    try {
      color = Color.parseColor(logInfo.color);
    } catch (Exception e) {
      // ignore
    }
    linePaint.setAntiAlias(true);
    linePaint.setColor(color);
    linePaint.setStrokeWidth(3f);
    linePaint.setStyle(Paint.Style.STROKE);

    colorBoxPaint.setAntiAlias(false);
    colorBoxPaint.setColor(color);
    colorBoxPaint.setStyle(Paint.Style.FILL);

    measureTextPaint.setAntiAlias(true);
    measureTextPaint.setTextSize(pixel);
    measureTextPaint.setColor(color);
    measureTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));

    String name = logInfo.logName;
    String ts = " - ";
    try {
      ts = TimeUtilities.INSTANCE.TIME_FORMATTER_LOCAL.format(new Date(logInfo.timestamp));
    } catch (Exception e) {
      GPLog.error(this, "Error in timestamp: " + logInfo.timestamp, e);
    }
    String time = timeString + ts;
    Coordinate pointXYZ = logInfo.pointXYZ;
    if (pointXYZ == null) pointXYZ = new Coordinate(-999, -999);
    String lon = lonString + coordFormatter.format(pointXYZ.x);
    String lat = latString + coordFormatter.format(pointXYZ.y);
    String altim = altimString + elevFormatter.format(pointXYZ.z);

    String[] texts = {name, time, lon, lat, altim};

    int runningY = upper;
    int textWidth = 0;
    for (String text : texts) {
      measureTextPaint.getTextBounds(text, 0, text.length(), rect);
      int textHeight = rect.height();
      runningY += textHeight + 3;
    }

    canvas.drawRect(0, 0, cWidth, runningY + 10, whiteBoxPaint);
    canvas.drawRect(0, runningY, cWidth, runningY + 10, colorBoxPaint);

    runningY = upper;
    for (String text : texts) {
      measureTextPaint.getTextBounds(text, 0, text.length(), rect);
      textWidth = rect.width();
      int textHeight = rect.height();
      int x = cWidth / 2 - textWidth / 2;
      canvas.drawText(text, x, runningY, measureTextPaint);
      runningY += textHeight + 7;
    }

    GeoPoint geoPoint = new GeoPoint(pointXYZ.y, pointXYZ.x);
    Point point = projection.toPixels(geoPoint, null);
    canvas.drawLine(point.x, point.y, cWidth / 2, runningY, linePaint);
  }