Search in sources :

Example 1 with BGABadgeable

use of cn.bingoogolapple.badgeview.BGABadgeable in project BGABadgeView-Android by bingoogolapple.

the class MainActivity method testRadioButton.

private void testRadioButton() {
    mHomeBrb.showTextBadge("10");
    mMessageBrb.showTextBadge("1");
    mDiscoverBrb.showTextBadge("...");
    mMeBrb.showDrawableBadge(BitmapFactory.decodeResource(getResources(), R.mipmap.avatar_vip));
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            mHomeBrb.showTextBadge("1");
        }
    }, 5000);
    mHomeBrb.setDragDismissDelegage(new BGADragDismissDelegate() {

        @Override
        public void onDismiss(BGABadgeable badgeable) {
            ToastUtil.show("消息单选按钮徽章拖动消失");
        }
    });
    mTabRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            switch(checkedId) {
                case R.id.brb_main_home:
                    ToastUtil.show("首页");
                    break;
                case R.id.brb_main_message:
                    ToastUtil.show("消息");
                    break;
                case R.id.brb_main_discover:
                    ToastUtil.show("发现");
                    break;
                case R.id.brb_main_me:
                    ToastUtil.show("我");
                    break;
            }
        }
    });
}
Also used : BGADragDismissDelegate(cn.bingoogolapple.badgeview.BGADragDismissDelegate) BGABadgeable(cn.bingoogolapple.badgeview.BGABadgeable) RadioGroup(android.widget.RadioGroup) Handler(android.os.Handler)

Example 2 with BGABadgeable

use of cn.bingoogolapple.badgeview.BGABadgeable in project BGABadgeView-Android by bingoogolapple.

the class MainActivity method testBadgeView.

private void testBadgeView() {
    mTestBv.showTextBadge("9");
    mTestBv.getBadgeViewHelper().setBadgeTextSizeSp(15);
    mTestBv.getBadgeViewHelper().setBadgePaddingDp(8);
    mTestBv.getBadgeViewHelper().setBadgeTextColorInt(Color.parseColor("#FF0000"));
    mTestBv.getBadgeViewHelper().setBadgeBgColorInt(Color.parseColor("#00FF00"));
    mTestBv.getBadgeViewHelper().setDragable(true);
    mTestBv.getBadgeViewHelper().setBadgePaddingDp(7);
    mTestBv.getBadgeViewHelper().setBadgeBorderWidthDp(2);
    mTestBv.getBadgeViewHelper().setBadgeBorderColorInt(Color.parseColor("#0000FF"));
    mTestBtv.showCirclePointBadge();
    mNormalBiv.showCirclePointBadge();
    Bitmap avatarBadgeBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.avatar_vip);
    RoundedBitmapDrawable roundedDrawable = RoundedBitmapDrawableFactory.create(getResources(), BitmapFactory.decodeResource(getResources(), R.mipmap.avator));
    roundedDrawable.getPaint().setAntiAlias(true);
    roundedDrawable.setCornerRadius(30);
    mRoundedBiv.setImageDrawable(roundedDrawable);
    mRoundedBiv.showDrawableBadge(avatarBadgeBitmap);
    Bitmap avatarBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.avator);
    RoundedBitmapDrawable circleDrawable = RoundedBitmapDrawableFactory.create(getResources(), avatarBitmap);
    circleDrawable.getPaint().setAntiAlias(true);
    circleDrawable.setCornerRadius(Math.max(avatarBitmap.getWidth(), avatarBitmap.getHeight()) / 2.0f);
    mCircleBiv.setImageDrawable(circleDrawable);
    mCircleBiv.showDrawableBadge(avatarBadgeBitmap);
    mTestBll.showDrawableBadge(avatarBadgeBitmap);
    mTestBrl.showTextBadge("LoveAndroid");
    mTestBfl.showTextBadge("8");
    mChatBfab.showTextBadge("8");
    mChatBfab.setDragDismissDelegage(new BGADragDismissDelegate() {

        @Override
        public void onDismiss(BGABadgeable badgeable) {
            ToastUtil.show("清空聊天消息");
        }
    });
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            mRoundedBiv.hiddenBadge();
        }
    }, 3000);
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            mRoundedBiv.showCirclePointBadge();
        }
    }, 6000);
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            mRoundedBiv.showDrawableBadge(BitmapFactory.decodeResource(getResources(), R.mipmap.avatar_vip));
        }
    }, 9000);
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) Bitmap(android.graphics.Bitmap) BGADragDismissDelegate(cn.bingoogolapple.badgeview.BGADragDismissDelegate) BGABadgeable(cn.bingoogolapple.badgeview.BGABadgeable) Handler(android.os.Handler)

Example 3 with BGABadgeable

use of cn.bingoogolapple.badgeview.BGABadgeable in project BGABadgeView-Android by bingoogolapple.

the class MessageAdapter method fillData.

@Override
protected void fillData(BGAViewHolderHelper holderHelper, final int position, final MessageModel message) {
    holderHelper.setText(R.id.tv_item_message_title, message.title);
    holderHelper.setText(R.id.tv_item_message_detail, message.detail);
    BGABadgeLinearLayout rootView = (BGABadgeLinearLayout) holderHelper.getConvertView();
    if (message.newMsgCount > 0) {
        rootView.showTextBadge("" + message.newMsgCount);
        rootView.setDragDismissDelegage(new BGADragDismissDelegate() {

            @Override
            public void onDismiss(BGABadgeable badgeable) {
                message.newMsgCount = 0;
                ToastUtil.show(message.title + "的徽章消失");
            }
        });
    } else {
        rootView.hiddenBadge();
    }
}
Also used : BGADragDismissDelegate(cn.bingoogolapple.badgeview.BGADragDismissDelegate) BGABadgeable(cn.bingoogolapple.badgeview.BGABadgeable) BGABadgeLinearLayout(cn.bingoogolapple.badgeview.BGABadgeLinearLayout)

Aggregations

BGABadgeable (cn.bingoogolapple.badgeview.BGABadgeable)3 BGADragDismissDelegate (cn.bingoogolapple.badgeview.BGADragDismissDelegate)3 Handler (android.os.Handler)2 Bitmap (android.graphics.Bitmap)1 RoundedBitmapDrawable (android.support.v4.graphics.drawable.RoundedBitmapDrawable)1 RadioGroup (android.widget.RadioGroup)1 BGABadgeLinearLayout (cn.bingoogolapple.badgeview.BGABadgeLinearLayout)1