android.widget.FrameLayout#setWillNotDraw ( )源码实例Demo

下面列出了android.widget.FrameLayout#setWillNotDraw ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PTVGlass   文件: CompassRenderer.java
/**
 * Creates a new instance of the {@code CompassRenderer} with the specified context,
 * orientation manager, and landmark collection.
 */
public CompassRenderer(Context context, OrientationManager orientationManager,
            Landmarks landmarks) {
    LayoutInflater inflater = LayoutInflater.from(context);
    mLayout = (FrameLayout) inflater.inflate(R.layout.compass, null);
    mLayout.setWillNotDraw(false);

    mCompassView = (CompassView) mLayout.findViewById(R.id.compass);
    mTipsContainer = (RelativeLayout) mLayout.findViewById(R.id.tips_container);
    mTipsView = (TextView) mLayout.findViewById(R.id.tips_view);

    mOrientationManager = orientationManager;
    mLandmarks = landmarks;

    mCompassView.setOrientationManager(mOrientationManager);
}
 
源代码2 项目: PTVGlass   文件: CompassRenderer.java
/**
 * Creates a new instance of the {@code CompassRenderer} with the specified context,
 * orientation manager, and landmark collection.
 */
public CompassRenderer(Context context, OrientationManager orientationManager,
            Landmarks landmarks) {
    LayoutInflater inflater = LayoutInflater.from(context);
    mLayout = (FrameLayout) inflater.inflate(R.layout.compass, null);
    mLayout.setWillNotDraw(false);

    mCompassView = (CompassView) mLayout.findViewById(R.id.compass);
    mTipsContainer = (RelativeLayout) mLayout.findViewById(R.id.tips_container);
    mTipsView = (TextView) mLayout.findViewById(R.id.tips_view);

    mOrientationManager = orientationManager;
    mLandmarks = landmarks;

    mCompassView.setOrientationManager(mOrientationManager);
}
 
源代码3 项目: SpeedHud   文件: SpeedHudRenderer.java
/**
 * Creates a new instance of the {@code SpeedHudRenderer} with the specified context
 * and orientation manager.
 */
public SpeedHudRenderer(Context context, OrientationManager orientationManager) {
    LayoutInflater inflater = LayoutInflater.from(context);
    mLayout = (FrameLayout) inflater.inflate(R.layout.speed_hud, null);
    mLayout.setWillNotDraw(false);

    mSpeedHudView = (SpeedHudView) mLayout.findViewById(R.id.speed_hud);
    mTipsContainer = (RelativeLayout) mLayout.findViewById(R.id.tips_container);
    mTipsView = (TextView) mLayout.findViewById(R.id.tips_view);

    mOrientationManager = orientationManager;

    mSpeedHudView.setOrientationManager(mOrientationManager);
}
 
源代码4 项目: Voidstar-AutoHud   文件: HudRenderer.java
/**
 * Creates a new instance of the {@code CompassRenderer} with the specified context,
 * orientation manager, and landmark collection.
 */
public HudRenderer(Context context, ObdManager obd) {
    LayoutInflater inflater = LayoutInflater.from(context);
    mLayout = (FrameLayout) inflater.inflate(R.layout.autohud, null);
    mLayout.setWillNotDraw(false);

    mHudView = (HudView) mLayout.findViewById(R.id.compass);
    //mTipsContainer = (RelativeLayout) mLayout.findViewById(R.id.tips_container);
    //mTipsView = (TextView) mLayout.findViewById(R.id.tips_view);
    
    mObdManager = obd;
}
 
源代码5 项目: TelePlus-Android   文件: UpdateAppAlertDialog.java
public UpdateAppAlertDialog(final Activity activity, TLRPC.TL_help_appUpdate update, int account) {
    super(activity, 0);
    appUpdate = update;
    accountNum = account;
    if (update.document instanceof TLRPC.TL_document) {
        fileName = FileLoader.getAttachFileName(update.document);
    }
    parentActivity = activity;

    setTopImage(R.drawable.update, Theme.getColor(Theme.key_dialogTopBackground));
    setTopHeight(175);
    setMessage(appUpdate.text);
    if (appUpdate.document instanceof TLRPC.TL_document) {
        setSecondTitle(AndroidUtilities.formatFileSize(appUpdate.document.size));
    }
    setDismissDialogByButtons(false);
    setTitle(LocaleController.getString("UpdateTelegram", R.string.UpdateTelegram));
    setPositiveButton(LocaleController.getString("UpdateNow", R.string.UpdateNow), (dialog, which) ->
    {
        if (!BlockingUpdateView.checkApkInstallPermissions(getContext())) {
            return;
        }
        if (appUpdate.document instanceof TLRPC.TL_document) {
            if (!BlockingUpdateView.openApkInstall(parentActivity, appUpdate.document)) {
                FileLoader.getInstance(accountNum).loadFile(appUpdate.document, true, 1);
                showProgress(true);
            }
        } else if (appUpdate.url != null) {
            Browser.openUrl(getContext(), appUpdate.url);
            dialog.dismiss();
        }
    });
    setNeutralButton(LocaleController.getString("Later", R.string.Later), (dialog, which) ->
    {
        if (appUpdate.document instanceof TLRPC.TL_document) {
            FileLoader.getInstance(accountNum).cancelLoadFile(appUpdate.document);
        }
        dialog.dismiss();
    });

    radialProgressView = new FrameLayout(parentActivity) {
        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super.onLayout(changed, left, top, right, bottom);
            int width = right - left;
            int height = bottom - top;
            int w = AndroidUtilities.dp(24);
            int l = (width - w) / 2;
            int t = (height - w) / 2 + AndroidUtilities.dp(2);
            radialProgress.setProgressRect(l, t, l + w, t + w);
        }

        @Override
        protected void onDraw(Canvas canvas) {
            radialProgress.draw(canvas);
        }
    };
    radialProgressView.setWillNotDraw(false);
    radialProgressView.setAlpha(0.0f);
    radialProgressView.setScaleX(0.1f);
    radialProgressView.setScaleY(0.1f);
    radialProgressView.setVisibility(View.INVISIBLE);
    radialProgress = new RadialProgress(radialProgressView);
    radialProgress.setStrokeWidth(AndroidUtilities.dp(2));
    radialProgress.setBackground(null, true, false);
    radialProgress.setProgressColor(Theme.getColor(Theme.key_dialogButton));
}
 
源代码6 项目: TelePlus-Android   文件: UpdateAppAlertDialog.java
public UpdateAppAlertDialog(final Activity activity, TLRPC.TL_help_appUpdate update, int account) {
    super(activity, 0);
    appUpdate = update;
    accountNum = account;
    if (update.document instanceof TLRPC.TL_document) {
        fileName = FileLoader.getAttachFileName(update.document);
    }
    parentActivity = activity;

    setTopImage(R.drawable.update, Theme.getColor(Theme.key_dialogTopBackground));
    setTopHeight(175);
    setMessage(appUpdate.text);
    if (appUpdate.document instanceof TLRPC.TL_document) {
        setSecondTitle(AndroidUtilities.formatFileSize(appUpdate.document.size));
    }
    setDismissDialogByButtons(false);
    setTitle(LocaleController.getString("UpdateTelegram", R.string.UpdateTelegram));
    setPositiveButton(LocaleController.getString("UpdateNow", R.string.UpdateNow), (dialog, which) ->
    {
        if (!BlockingUpdateView.checkApkInstallPermissions(getContext())) {
            return;
        }
        if (appUpdate.document instanceof TLRPC.TL_document) {
            if (!BlockingUpdateView.openApkInstall(parentActivity, appUpdate.document)) {
                FileLoader.getInstance(accountNum).loadFile(appUpdate.document, true, 1);
                showProgress(true);
            }
        } else if (appUpdate.url != null) {
            Browser.openUrl(getContext(), appUpdate.url);
            dialog.dismiss();
        }
    });
    setNeutralButton(LocaleController.getString("Later", R.string.Later), (dialog, which) ->
    {
        if (appUpdate.document instanceof TLRPC.TL_document) {
            FileLoader.getInstance(accountNum).cancelLoadFile(appUpdate.document);
        }
        dialog.dismiss();
    });

    radialProgressView = new FrameLayout(parentActivity) {
        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super.onLayout(changed, left, top, right, bottom);
            int width = right - left;
            int height = bottom - top;
            int w = AndroidUtilities.dp(24);
            int l = (width - w) / 2;
            int t = (height - w) / 2 + AndroidUtilities.dp(2);
            radialProgress.setProgressRect(l, t, l + w, t + w);
        }

        @Override
        protected void onDraw(Canvas canvas) {
            radialProgress.draw(canvas);
        }
    };
    radialProgressView.setWillNotDraw(false);
    radialProgressView.setAlpha(0.0f);
    radialProgressView.setScaleX(0.1f);
    radialProgressView.setScaleY(0.1f);
    radialProgressView.setVisibility(View.INVISIBLE);
    radialProgress = new RadialProgress(radialProgressView);
    radialProgress.setStrokeWidth(AndroidUtilities.dp(2));
    radialProgress.setBackground(null, true, false);
    radialProgress.setProgressColor(Theme.getColor(Theme.key_dialogButton));
}
 
源代码7 项目: Telegram-FOSS   文件: PhotoPickerPhotoCell.java
public PhotoPickerPhotoCell(Context context) {
    super(context);
    setWillNotDraw(false);

    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(4));
    addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    checkFrame = new FrameLayout(context);
    addView(checkFrame, LayoutHelper.createFrame(42, 42, Gravity.RIGHT | Gravity.TOP));

    videoInfoContainer = new FrameLayout(context) {

        private Path path = new Path();
        float[] radii = new float[8];
        private RectF rect = new RectF();
        private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

        @Override
        protected void onDraw(Canvas canvas) {
            rect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
            radii[0] = radii[1] = radii[2] = radii[3] = 0;
            radii[4] = radii[5] = radii[6] = radii[7] = AndroidUtilities.dp(4);
            path.reset();
            path.addRoundRect(rect, radii, Path.Direction.CW);
            path.close();
            paint.setColor(0x7f000000);
            canvas.drawPath(path, paint);
        }
    };
    videoInfoContainer.setWillNotDraw(false);
    videoInfoContainer.setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0);
    addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 16, Gravity.BOTTOM | Gravity.LEFT));

    ImageView imageView1 = new ImageView(context);
    imageView1.setImageResource(R.drawable.ic_video);
    videoInfoContainer.addView(imageView1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL));

    videoTextView = new TextView(context);
    videoTextView.setTextColor(0xffffffff);
    videoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    videoTextView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    videoInfoContainer.addView(videoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 18, -0.7f, 0, 0));

    checkBox = new CheckBox2(context, 24);
    checkBox.setDrawBackgroundAsArc(11);
    checkBox.setColor(Theme.key_chat_attachCheckBoxBackground, Theme.key_chat_attachPhotoBackground, Theme.key_chat_attachCheckBoxCheck);
    addView(checkBox, LayoutHelper.createFrame(26, 26, Gravity.LEFT | Gravity.TOP, 55, 4, 0, 0));
    checkBox.setVisibility(VISIBLE);

    setFocusable(true);
}
 
public TooManyCommunitiesHintCell(Context context) {
    super(context);

    imageView = new ImageView(context);
    imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_nameMessage_threeLines), PorterDuff.Mode.MULTIPLY));

    headerTextView = new TextView(context);
    headerTextView.setTextColor(Theme.getColor(Theme.key_chats_nameMessage_threeLines));
    headerTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    headerTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    headerTextView.setGravity(Gravity.CENTER);
    addView(headerTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 52, 75, 52, 0));

    messageTextView = new TextView(context);
    messageTextView.setTextColor(Theme.getColor(Theme.key_chats_message));
    messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    messageTextView.setGravity(Gravity.CENTER);
    addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 36, 110, 36, 0));

    TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setColor(Color.WHITE);
    textPaint.setTextSize(AndroidUtilities.dp(12));
    textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

    String s = "500";
    imageLayout = new FrameLayout(context) {

        RectF rect = new RectF();


        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            paint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));

            canvas.save();
            canvas.translate(getMeasuredWidth() - textPaint.measureText(s) - AndroidUtilities.dp(8), AndroidUtilities.dpf2(7f));
            rect.set(0, 0, textPaint.measureText(s), textPaint.getTextSize());
            rect.inset(-AndroidUtilities.dp(6), -AndroidUtilities.dp(3));
            float r = (textPaint.getTextSize()) / 2f + AndroidUtilities.dp(3);
            canvas.drawRoundRect(rect, r, r, paint);
            canvas.drawText(s, 0, textPaint.getTextSize() - AndroidUtilities.dpf2(2f), textPaint);
            canvas.restore();
        }
    };
    imageLayout.setWillNotDraw(false);
    imageLayout.addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));
    addView(imageLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 12, 0, 6));
    headerTextView.setText(LocaleController.getString("TooManyCommunities", R.string.TooManyCommunities));
    imageView.setImageResource(R.drawable.groups_limit1);
}
 
源代码9 项目: Telegram-FOSS   文件: SharedPhotoVideoCell.java
public PhotoVideoView(Context context) {
    super(context);

    setWillNotDraw(false);

    container = new FrameLayout(context);
    addView(container, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    imageView = new BackupImageView(context);
    imageView.getImageReceiver().setNeedsQualityThumb(true);
    imageView.getImageReceiver().setShouldGenerateQualityThumb(true);
    container.addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    videoInfoContainer = new FrameLayout(context) {

        private RectF rect = new RectF();

        @Override
        protected void onDraw(Canvas canvas) {
            rect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
            canvas.drawRoundRect(rect, AndroidUtilities.dp(4), AndroidUtilities.dp(4), Theme.chat_timeBackgroundPaint);
        }
    };
    videoInfoContainer.setWillNotDraw(false);
    videoInfoContainer.setPadding(AndroidUtilities.dp(5), 0, AndroidUtilities.dp(5), 0);
    container.addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 17, Gravity.BOTTOM | Gravity.LEFT, 4, 0, 0, 4));

    ImageView imageView1 = new ImageView(context);
    imageView1.setImageResource(R.drawable.play_mini_video);
    videoInfoContainer.addView(imageView1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL));

    videoTextView = new TextView(context);
    videoTextView.setTextColor(0xffffffff);
    videoTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    videoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    videoTextView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    videoInfoContainer.addView(videoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 13, -0.7f, 0, 0));

    selector = new View(context);
    selector.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    addView(selector, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    checkBox = new CheckBox2(context, 21);
    checkBox.setVisibility(INVISIBLE);
    checkBox.setColor(null, Theme.key_sharedMedia_photoPlaceholder, Theme.key_checkboxCheck);
    checkBox.setDrawUnchecked(false);
    checkBox.setDrawBackgroundAsArc(1);
    addView(checkBox, LayoutHelper.createFrame(24, 24, Gravity.RIGHT | Gravity.TOP, 0, 1, 1, 0));
}
 
源代码10 项目: Telegram-FOSS   文件: PhotoAttachPhotoCell.java
public PhotoAttachPhotoCell(Context context) {
    super(context);

    setWillNotDraw(false);

    container = new FrameLayout(context);
    addView(container, LayoutHelper.createFrame(80, 80));

    imageView = new BackupImageView(context);
    container.addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    videoInfoContainer = new FrameLayout(context) {

        private RectF rect = new RectF();

        @Override
        protected void onDraw(Canvas canvas) {
            rect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
            canvas.drawRoundRect(rect, AndroidUtilities.dp(4), AndroidUtilities.dp(4), Theme.chat_timeBackgroundPaint);
        }
    };
    videoInfoContainer.setWillNotDraw(false);
    videoInfoContainer.setPadding(AndroidUtilities.dp(5), 0, AndroidUtilities.dp(5), 0);
    container.addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 17, Gravity.BOTTOM | Gravity.LEFT, 4, 0, 0, 4));

    ImageView imageView1 = new ImageView(context);
    imageView1.setImageResource(R.drawable.play_mini_video);
    videoInfoContainer.addView(imageView1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL));

    videoTextView = new TextView(context);
    videoTextView.setTextColor(0xffffffff);
    videoTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    videoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    videoTextView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    videoInfoContainer.addView(videoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 13, -0.7f, 0, 0));

    checkBox = new CheckBox2(context, 24);
    checkBox.setDrawBackgroundAsArc(7);
    checkBox.setColor(Theme.key_chat_attachCheckBoxBackground, Theme.key_chat_attachPhotoBackground, Theme.key_chat_attachCheckBoxCheck);
    addView(checkBox, LayoutHelper.createFrame(26, 26, Gravity.LEFT | Gravity.TOP, 52, 4, 0, 0));
    checkBox.setVisibility(VISIBLE);
    setFocusable(true);

    checkFrame = new FrameLayout(context);
    addView(checkFrame, LayoutHelper.createFrame(42, 42, Gravity.LEFT | Gravity.TOP, 38, 0, 0, 0));

    itemSize = AndroidUtilities.dp(80);
}
 
源代码11 项目: Telegram-FOSS   文件: UpdateAppAlertDialog.java
public UpdateAppAlertDialog(final Activity activity, TLRPC.TL_help_appUpdate update, int account) {
    super(activity, 0);
    appUpdate = update;
    accountNum = account;
    if (update.document instanceof TLRPC.TL_document) {
        fileName = FileLoader.getAttachFileName(update.document);
    }
    parentActivity = activity;

    setTopImage(R.drawable.update, Theme.getColor(Theme.key_dialogTopBackground));
    setTopHeight(175);
    setMessage(appUpdate.text);
    if (appUpdate.document instanceof TLRPC.TL_document) {
        setSecondTitle(AndroidUtilities.formatFileSize(appUpdate.document.size));
    }
    setDismissDialogByButtons(false);
    setTitle(LocaleController.getString("UpdateTelegram", R.string.UpdateTelegram));
    setPositiveButton(LocaleController.getString("UpdateNow", R.string.UpdateNow), (dialog, which) -> {
        if (!BlockingUpdateView.checkApkInstallPermissions(getContext())) {
            return;
        }
        if (appUpdate.document instanceof TLRPC.TL_document) {
            if (!BlockingUpdateView.openApkInstall(parentActivity, appUpdate.document)) {
                FileLoader.getInstance(accountNum).loadFile(appUpdate.document, "update", 1, 1);
                showProgress(true);
            }
        } else if (appUpdate.url != null) {
            Browser.openUrl(getContext(), appUpdate.url);
            dialog.dismiss();
        }
    });
    setNeutralButton(LocaleController.getString("Later", R.string.Later), (dialog, which) -> {
        if (appUpdate.document instanceof TLRPC.TL_document) {
            FileLoader.getInstance(accountNum).cancelLoadFile(appUpdate.document);
        }
        dialog.dismiss();
    });

    radialProgressView = new FrameLayout(parentActivity) {
        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super.onLayout(changed, left, top, right, bottom);
            int width = right - left;
            int height = bottom - top;
            int w = AndroidUtilities.dp(24);
            int l = (width - w) / 2;
            int t = (height - w) / 2 + AndroidUtilities.dp(2);
            radialProgress.setProgressRect(l, t, l + w, t + w);
        }

        @Override
        protected void onDraw(Canvas canvas) {
            radialProgress.draw(canvas);
        }
    };
    radialProgressView.setWillNotDraw(false);
    radialProgressView.setAlpha(0.0f);
    radialProgressView.setScaleX(0.1f);
    radialProgressView.setScaleY(0.1f);
    radialProgressView.setVisibility(View.INVISIBLE);
    radialProgress = new RadialProgress(radialProgressView);
    radialProgress.setStrokeWidth(AndroidUtilities.dp(2));
    radialProgress.setBackground(null, true, false);
    radialProgress.setProgressColor(Theme.getColor(Theme.key_dialogButton));
}
 
源代码12 项目: Telegram   文件: PhotoPickerPhotoCell.java
public PhotoPickerPhotoCell(Context context) {
    super(context);
    setWillNotDraw(false);

    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(4));
    addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    checkFrame = new FrameLayout(context);
    addView(checkFrame, LayoutHelper.createFrame(42, 42, Gravity.RIGHT | Gravity.TOP));

    videoInfoContainer = new FrameLayout(context) {

        private Path path = new Path();
        float[] radii = new float[8];
        private RectF rect = new RectF();
        private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

        @Override
        protected void onDraw(Canvas canvas) {
            rect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
            radii[0] = radii[1] = radii[2] = radii[3] = 0;
            radii[4] = radii[5] = radii[6] = radii[7] = AndroidUtilities.dp(4);
            path.reset();
            path.addRoundRect(rect, radii, Path.Direction.CW);
            path.close();
            paint.setColor(0x7f000000);
            canvas.drawPath(path, paint);
        }
    };
    videoInfoContainer.setWillNotDraw(false);
    videoInfoContainer.setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0);
    addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 16, Gravity.BOTTOM | Gravity.LEFT));

    ImageView imageView1 = new ImageView(context);
    imageView1.setImageResource(R.drawable.ic_video);
    videoInfoContainer.addView(imageView1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL));

    videoTextView = new TextView(context);
    videoTextView.setTextColor(0xffffffff);
    videoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    videoTextView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    videoInfoContainer.addView(videoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 18, -0.7f, 0, 0));

    checkBox = new CheckBox2(context, 24);
    checkBox.setDrawBackgroundAsArc(11);
    checkBox.setColor(Theme.key_chat_attachCheckBoxBackground, Theme.key_chat_attachPhotoBackground, Theme.key_chat_attachCheckBoxCheck);
    addView(checkBox, LayoutHelper.createFrame(26, 26, Gravity.LEFT | Gravity.TOP, 55, 4, 0, 0));
    checkBox.setVisibility(VISIBLE);

    setFocusable(true);
}
 
源代码13 项目: Telegram   文件: TooManyCommunitiesHintCell.java
public TooManyCommunitiesHintCell(Context context) {
    super(context);

    imageView = new ImageView(context);
    imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_nameMessage_threeLines), PorterDuff.Mode.MULTIPLY));

    headerTextView = new TextView(context);
    headerTextView.setTextColor(Theme.getColor(Theme.key_chats_nameMessage_threeLines));
    headerTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    headerTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    headerTextView.setGravity(Gravity.CENTER);
    addView(headerTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 52, 75, 52, 0));

    messageTextView = new TextView(context);
    messageTextView.setTextColor(Theme.getColor(Theme.key_chats_message));
    messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    messageTextView.setGravity(Gravity.CENTER);
    addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 36, 110, 36, 0));

    TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setColor(Color.WHITE);
    textPaint.setTextSize(AndroidUtilities.dp(12));
    textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

    String s = "500";
    imageLayout = new FrameLayout(context) {

        RectF rect = new RectF();


        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            paint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));

            canvas.save();
            canvas.translate(getMeasuredWidth() - textPaint.measureText(s) - AndroidUtilities.dp(8), AndroidUtilities.dpf2(7f));
            rect.set(0, 0, textPaint.measureText(s), textPaint.getTextSize());
            rect.inset(-AndroidUtilities.dp(6), -AndroidUtilities.dp(3));
            float r = (textPaint.getTextSize()) / 2f + AndroidUtilities.dp(3);
            canvas.drawRoundRect(rect, r, r, paint);
            canvas.drawText(s, 0, textPaint.getTextSize() - AndroidUtilities.dpf2(2f), textPaint);
            canvas.restore();
        }
    };
    imageLayout.setWillNotDraw(false);
    imageLayout.addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));
    addView(imageLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 12, 0, 6));
    headerTextView.setText(LocaleController.getString("TooManyCommunities", R.string.TooManyCommunities));
    imageView.setImageResource(R.drawable.groups_limit1);
}
 
源代码14 项目: Telegram   文件: SharedPhotoVideoCell.java
public PhotoVideoView(Context context) {
    super(context);

    setWillNotDraw(false);

    container = new FrameLayout(context);
    addView(container, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    imageView = new BackupImageView(context);
    imageView.getImageReceiver().setNeedsQualityThumb(true);
    imageView.getImageReceiver().setShouldGenerateQualityThumb(true);
    container.addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    videoInfoContainer = new FrameLayout(context) {

        private RectF rect = new RectF();

        @Override
        protected void onDraw(Canvas canvas) {
            rect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
            canvas.drawRoundRect(rect, AndroidUtilities.dp(4), AndroidUtilities.dp(4), Theme.chat_timeBackgroundPaint);
        }
    };
    videoInfoContainer.setWillNotDraw(false);
    videoInfoContainer.setPadding(AndroidUtilities.dp(5), 0, AndroidUtilities.dp(5), 0);
    container.addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 17, Gravity.BOTTOM | Gravity.LEFT, 4, 0, 0, 4));

    ImageView imageView1 = new ImageView(context);
    imageView1.setImageResource(R.drawable.play_mini_video);
    videoInfoContainer.addView(imageView1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL));

    videoTextView = new TextView(context);
    videoTextView.setTextColor(0xffffffff);
    videoTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    videoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    videoTextView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    videoInfoContainer.addView(videoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 13, -0.7f, 0, 0));

    selector = new View(context);
    selector.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    addView(selector, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    checkBox = new CheckBox2(context, 21);
    checkBox.setVisibility(INVISIBLE);
    checkBox.setColor(null, Theme.key_sharedMedia_photoPlaceholder, Theme.key_checkboxCheck);
    checkBox.setDrawUnchecked(false);
    checkBox.setDrawBackgroundAsArc(1);
    addView(checkBox, LayoutHelper.createFrame(24, 24, Gravity.RIGHT | Gravity.TOP, 0, 1, 1, 0));
}
 
源代码15 项目: Telegram   文件: PhotoAttachPhotoCell.java
public PhotoAttachPhotoCell(Context context) {
    super(context);

    setWillNotDraw(false);

    container = new FrameLayout(context);
    addView(container, LayoutHelper.createFrame(80, 80));

    imageView = new BackupImageView(context);
    container.addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    videoInfoContainer = new FrameLayout(context) {

        private RectF rect = new RectF();

        @Override
        protected void onDraw(Canvas canvas) {
            rect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
            canvas.drawRoundRect(rect, AndroidUtilities.dp(4), AndroidUtilities.dp(4), Theme.chat_timeBackgroundPaint);
        }
    };
    videoInfoContainer.setWillNotDraw(false);
    videoInfoContainer.setPadding(AndroidUtilities.dp(5), 0, AndroidUtilities.dp(5), 0);
    container.addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 17, Gravity.BOTTOM | Gravity.LEFT, 4, 0, 0, 4));

    ImageView imageView1 = new ImageView(context);
    imageView1.setImageResource(R.drawable.play_mini_video);
    videoInfoContainer.addView(imageView1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL));

    videoTextView = new TextView(context);
    videoTextView.setTextColor(0xffffffff);
    videoTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    videoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    videoTextView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    videoInfoContainer.addView(videoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 13, -0.7f, 0, 0));

    checkBox = new CheckBox2(context, 24);
    checkBox.setDrawBackgroundAsArc(7);
    checkBox.setColor(Theme.key_chat_attachCheckBoxBackground, Theme.key_chat_attachPhotoBackground, Theme.key_chat_attachCheckBoxCheck);
    addView(checkBox, LayoutHelper.createFrame(26, 26, Gravity.LEFT | Gravity.TOP, 52, 4, 0, 0));
    checkBox.setVisibility(VISIBLE);
    setFocusable(true);

    checkFrame = new FrameLayout(context);
    addView(checkFrame, LayoutHelper.createFrame(42, 42, Gravity.LEFT | Gravity.TOP, 38, 0, 0, 0));

    itemSize = AndroidUtilities.dp(80);
}
 
源代码16 项目: Telegram   文件: UpdateAppAlertDialog.java
public UpdateAppAlertDialog(final Activity activity, TLRPC.TL_help_appUpdate update, int account) {
    super(activity, 0);
    appUpdate = update;
    accountNum = account;
    if (update.document instanceof TLRPC.TL_document) {
        fileName = FileLoader.getAttachFileName(update.document);
    }
    parentActivity = activity;

    setTopImage(R.drawable.update, Theme.getColor(Theme.key_dialogTopBackground));
    setTopHeight(175);
    setMessage(appUpdate.text);
    if (appUpdate.document instanceof TLRPC.TL_document) {
        setSecondTitle(AndroidUtilities.formatFileSize(appUpdate.document.size));
    }
    setDismissDialogByButtons(false);
    setTitle(LocaleController.getString("UpdateTelegram", R.string.UpdateTelegram));
    setPositiveButton(LocaleController.getString("UpdateNow", R.string.UpdateNow), (dialog, which) -> {
        if (!BlockingUpdateView.checkApkInstallPermissions(getContext())) {
            return;
        }
        if (appUpdate.document instanceof TLRPC.TL_document) {
            if (!BlockingUpdateView.openApkInstall(parentActivity, appUpdate.document)) {
                FileLoader.getInstance(accountNum).loadFile(appUpdate.document, "update", 1, 1);
                showProgress(true);
            }
        } else if (appUpdate.url != null) {
            Browser.openUrl(getContext(), appUpdate.url);
            dialog.dismiss();
        }
    });
    setNeutralButton(LocaleController.getString("Later", R.string.Later), (dialog, which) -> {
        if (appUpdate.document instanceof TLRPC.TL_document) {
            FileLoader.getInstance(accountNum).cancelLoadFile(appUpdate.document);
        }
        dialog.dismiss();
    });

    radialProgressView = new FrameLayout(parentActivity) {
        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super.onLayout(changed, left, top, right, bottom);
            int width = right - left;
            int height = bottom - top;
            int w = AndroidUtilities.dp(24);
            int l = (width - w) / 2;
            int t = (height - w) / 2 + AndroidUtilities.dp(2);
            radialProgress.setProgressRect(l, t, l + w, t + w);
        }

        @Override
        protected void onDraw(Canvas canvas) {
            radialProgress.draw(canvas);
        }
    };
    radialProgressView.setWillNotDraw(false);
    radialProgressView.setAlpha(0.0f);
    radialProgressView.setScaleX(0.1f);
    radialProgressView.setScaleY(0.1f);
    radialProgressView.setVisibility(View.INVISIBLE);
    radialProgress = new RadialProgress(radialProgressView);
    radialProgress.setStrokeWidth(AndroidUtilities.dp(2));
    radialProgress.setBackground(null, true, false);
    radialProgress.setProgressColor(Theme.getColor(Theme.key_dialogButton));
}