コード例 #1
0
  public SharedDocumentCell(Context context) {
    super(context);

    if (paint == null) {
      paint = new Paint();
      paint.setColor(0xffd9d9d9);
      paint.setStrokeWidth(1);
    }

    TAG = MediaController.getInstance().generateObserverTag();

    placeholderImabeView = new ImageView(context);
    addView(
        placeholderImabeView,
        LayoutHelper.createFrame(
            40,
            40,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 0 : 12,
            8,
            LocaleController.isRTL ? 12 : 0,
            0));

    extTextView = new TextView(context);
    extTextView.setTextColor(0xffffffff);
    extTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    extTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    extTextView.setLines(1);
    extTextView.setMaxLines(1);
    extTextView.setSingleLine(true);
    extTextView.setGravity(Gravity.CENTER);
    extTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(
        extTextView,
        LayoutHelper.createFrame(
            32,
            LayoutHelper.WRAP_CONTENT,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 0 : 16,
            22,
            LocaleController.isRTL ? 16 : 0,
            0));

    thumbImageView = new BackupImageView(context);
    addView(
        thumbImageView,
        LayoutHelper.createFrame(
            40,
            40,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 0 : 12,
            8,
            LocaleController.isRTL ? 12 : 0,
            0));
    thumbImageView
        .getImageReceiver()
        .setDelegate(
            new ImageReceiver.ImageReceiverDelegate() {
              @Override
              public void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb) {
                extTextView.setVisibility(set ? INVISIBLE : VISIBLE);
                placeholderImabeView.setVisibility(set ? INVISIBLE : VISIBLE);
              }
            });

    nameTextView = new TextView(context);
    nameTextView.setTextColor(0xff212121);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    nameTextView.setLines(1);
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setGravity(
        (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    addView(
        nameTextView,
        LayoutHelper.createFrame(
            LayoutHelper.MATCH_PARENT,
            LayoutHelper.WRAP_CONTENT,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 8 : 72,
            5,
            LocaleController.isRTL ? 72 : 8,
            0));

    statusImageView = new ImageView(context);
    statusImageView.setVisibility(INVISIBLE);
    addView(
        statusImageView,
        LayoutHelper.createFrame(
            LayoutHelper.WRAP_CONTENT,
            LayoutHelper.WRAP_CONTENT,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 8 : 72,
            35,
            LocaleController.isRTL ? 72 : 8,
            0));

    dateTextView = new TextView(context);
    dateTextView.setTextColor(0xff999999);
    dateTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    dateTextView.setLines(1);
    dateTextView.setMaxLines(1);
    dateTextView.setSingleLine(true);
    dateTextView.setEllipsize(TextUtils.TruncateAt.END);
    dateTextView.setGravity(
        (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    addView(
        dateTextView,
        LayoutHelper.createFrame(
            LayoutHelper.MATCH_PARENT,
            LayoutHelper.WRAP_CONTENT,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 8 : 72,
            30,
            LocaleController.isRTL ? 72 : 8,
            0));

    progressView = new LineProgressView(context);
    addView(
        progressView,
        LayoutHelper.createFrame(
            LayoutHelper.MATCH_PARENT,
            2,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 0 : 72,
            54,
            LocaleController.isRTL ? 72 : 0,
            0));

    checkBox = new CheckBox(context, R.drawable.round_check2);
    checkBox.setVisibility(INVISIBLE);
    addView(
        checkBox,
        LayoutHelper.createFrame(
            22,
            22,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 0 : 34,
            30,
            LocaleController.isRTL ? 34 : 0,
            0));
  }
コード例 #2
0
 public void setChecked(boolean checked, boolean animated) {
   if (checkBox.getVisibility() != VISIBLE) {
     checkBox.setVisibility(VISIBLE);
   }
   checkBox.setChecked(checked, animated);
 }