com.wangjie.rapidfloatingactionbutton.contentimpl.labellist.RFACLabelItem Java Examples

The following examples show how to use com.wangjie.rapidfloatingactionbutton.contentimpl.labellist.RFACLabelItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From samples-android with Apache License 2.0 6 votes vote down vote up
private void initFabBtn() {
    RapidFloatingActionButton fab = findViewById(R.id.fab);
    RapidFloatingActionLayout fabLayout = findViewById(R.id.fab_layout);

    RapidFloatingActionContentLabelList rfaContent = new RapidFloatingActionContentLabelList(this);
    rfaContent.setOnRapidFloatingActionContentLabelListListener(this);
    List<RFACLabelItem> items = new ArrayList<>();
    items.add(new RFACLabelItem<Integer>()
            .setLabel(getString(R.string.scan_qr_code))
    );
    items.add(new RFACLabelItem<Integer>()
            .setLabel(getString(R.string.input_manually))
    );

    rfaContent.setItems(items);
    fabHelper = new RapidFloatingActionHelper(
            this,
            fabLayout,
            fab,
            rfaContent
    ).build();
}
 
Example #2
Source File: MainActivity.java    From samples-android with Apache License 2.0 5 votes vote down vote up
private void handleFabItemClick(RFACLabelItem item) {
    if (item.getLabel().equalsIgnoreCase(getString(R.string.scan_qr_code))) {
        navigateToScanQrCode();
    } else if (item.getLabel().equalsIgnoreCase(getString(R.string.input_manually))) {
        navigateToEnterManually();
    }
}
 
Example #3
Source File: MyRapidFloatingActionContentLabelList.java    From nono-android with GNU General Public License v3.0 5 votes vote down vote up
public MyRapidFloatingActionContentLabelList setItems(List<RFACLabelItem> items) {
    if(!ABTextUtil.isEmpty(items)) {
        this.items = items;
    }

    return this;
}
 
Example #4
Source File: MyRapidFloatingActionContentLabelList.java    From nono-android with GNU General Public License v3.0 5 votes vote down vote up
public void onClick(View v) {
    Integer position;
    if(null != this.onRapidFloatingActionContentLabelListListener && null != (position = (Integer)v.getTag(com.wangjie.rapidfloatingactionbutton.R.id.rfab__id_content_label_list_item_position))) {
        int i = v.getId();
        if(i == com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_label_tv) {
            this.onRapidFloatingActionContentLabelListListener.onRFACItemLabelClick(position.intValue(), (RFACLabelItem)this.items.get(position.intValue()));
        } else if(i == com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_icon_iv) {
            this.onRapidFloatingActionContentLabelListListener.onRFACItemIconClick(position.intValue(), (RFACLabelItem)this.items.get(position.intValue()));
        } else if(i == com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_root_view) {
            this.onRapidFloatingActionListener.collapseContent();
        }

    }
}
 
Example #5
Source File: MainActivity.java    From samples-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onRFACItemLabelClick(int position, RFACLabelItem item) {
    handleFabItemClick(item);
    fabHelper.toggleContent();
}
 
Example #6
Source File: FragmentC.java    From RapidFloatingActionButton with Apache License 2.0 4 votes vote down vote up
private void initRFAB() {
    if (null == rfaButton) {
        return;
    }

    /*
    // 可通过代码设置属性
    rfaLayout.setFrameColor(Color.RED);
    rfaLayout.setFrameAlpha(0.4f);

    rfaBtn.setNormalColor(0xff37474f);
    rfaBtn.setPressedColor(0xff263238);
    rfaBtn.getRfabProperties().setShadowDx(ABTextUtil.dip2px(context, 3));
    rfaBtn.getRfabProperties().setShadowDy(ABTextUtil.dip2px(context, 3));
    rfaBtn.getRfabProperties().setShadowRadius(ABTextUtil.dip2px(context, 5));
    rfaBtn.getRfabProperties().setShadowColor(0xffcccccc);
    rfaBtn.getRfabProperties().setStandardSize(RFABSize.MINI);
    rfaBtn.build();
    */

    Context context = getActivity();

    RapidFloatingActionContentLabelList rfaContent = new RapidFloatingActionContentLabelList(context);
    rfaContent.setOnRapidFloatingActionContentLabelListListener(this);
    List<RFACLabelItem> items = new ArrayList<>();
    items.add(new RFACLabelItem<Integer>()
                    .setLabel("Github: wangjiegulu")
                    .setResId(R.mipmap.ico_test_d)
                    .setIconNormalColor(0xff6a1b9a)
                    .setIconPressedColor(0xff4a148c)
                    .setWrapper(0)
    );
    items.add(new RFACLabelItem<Integer>()
                    .setLabel("[email protected]")
                    .setResId(R.mipmap.ico_test_c)
                    .setIconNormalColor(0xff4e342e)
                    .setIconPressedColor(0xff3e2723)
                    .setLabelColor(Color.WHITE)
                    .setLabelSizeSp(14)
                    .setLabelBackgroundDrawable(RFABShape.generateCornerShapeDrawable(0xaa000000, RFABTextUtil.dip2px(context, 4)))
                    .setWrapper(1)
    );
    items.add(new RFACLabelItem<Integer>()
                    .setLabel("WangJie")
                    .setResId(R.mipmap.ico_test_b)
                    .setIconNormalColor(0xff056f00)
                    .setIconPressedColor(0xff0d5302)
                    .setLabelColor(0xff056f00)
                    .setWrapper(2)
    );
    items.add(new RFACLabelItem<Integer>()
                    .setLabel("Compose")
                    .setResId(R.mipmap.ico_test_a)
                    .setIconNormalColor(0xff283593)
                    .setIconPressedColor(0xff1a237e)
                    .setLabelColor(0xff283593)
                    .setWrapper(3)
    );
    rfaContent
            .setItems(items)
            .setIconShadowRadius(RFABTextUtil.dip2px(context, 5))
            .setIconShadowColor(0xff888888)
            .setIconShadowDy(RFABTextUtil.dip2px(context, 5))
    ;

    rfabHelper = new RapidFloatingActionHelper(
            context,
            rfaLayout,
            rfaButton,
            rfaContent
    ).build();
}
 
Example #7
Source File: FragmentC.java    From RapidFloatingActionButton with Apache License 2.0 4 votes vote down vote up
@Override
public void onRFACItemIconClick(int position, RFACLabelItem item) {
    Toast.makeText(getActivity(), "clicked icon: " + position, Toast.LENGTH_SHORT).show();
    rfabHelper.toggleContent();
}
 
Example #8
Source File: FragmentC.java    From RapidFloatingActionButton with Apache License 2.0 4 votes vote down vote up
@Override
public void onRFACItemLabelClick(int position, RFACLabelItem item) {
    Toast.makeText(getActivity(), "clicked label: " + position, Toast.LENGTH_SHORT).show();
    rfabHelper.toggleContent();
}
 
Example #9
Source File: FragmentA.java    From RapidFloatingActionButton with Apache License 2.0 4 votes vote down vote up
private void initRFAB() {
    if (null == rfaButton) {
        return;
    }

    /*
    // 可通过代码设置属性
    rfaLayout.setFrameColor(Color.RED);
    rfaLayout.setFrameAlpha(0.4f);

    rfaBtn.setNormalColor(0xff37474f);
    rfaBtn.setPressedColor(0xff263238);
    rfaBtn.getRfabProperties().setShadowDx(ABTextUtil.dip2px(context, 3));
    rfaBtn.getRfabProperties().setShadowDy(ABTextUtil.dip2px(context, 3));
    rfaBtn.getRfabProperties().setShadowRadius(ABTextUtil.dip2px(context, 5));
    rfaBtn.getRfabProperties().setShadowColor(0xffcccccc);
    rfaBtn.getRfabProperties().setStandardSize(RFABSize.MINI);
    rfaBtn.build();
    */
    Context context = getActivity();

    RapidFloatingActionContentLabelList rfaContent = new RapidFloatingActionContentLabelList(context);
    rfaContent.setOnRapidFloatingActionContentLabelListListener(this);
    List<RFACLabelItem> items = new ArrayList<>();
    items.add(new RFACLabelItem<Integer>()
                    .setLabel("Github: wangjiegulu")
                    .setResId(R.mipmap.ico_test_d)
                    .setIconNormalColor(0xff6a1b9a)
                    .setIconPressedColor(0xff4a148c)
                    .setWrapper(0)
    );
    items.add(new RFACLabelItem<Integer>()
                    .setLabel("[email protected]")
                    .setResId(R.mipmap.ico_test_c)
                    .setIconNormalColor(0xff4e342e)
                    .setIconPressedColor(0xff3e2723)
                    .setLabelColor(Color.WHITE)
                    .setLabelSizeSp(14)
                    .setLabelBackgroundDrawable(RFABShape.generateCornerShapeDrawable(0xaa000000, RFABTextUtil.dip2px(context, 4)))
                    .setWrapper(1)
    );
    items.add(new RFACLabelItem<Integer>()
                    .setLabel("WangJie")
                    .setResId(R.mipmap.ico_test_b)
                    .setIconNormalColor(0xff056f00)
                    .setIconPressedColor(0xff0d5302)
                    .setLabelColor(0xff056f00)
                    .setWrapper(2)
    );
    items.add(new RFACLabelItem<Integer>()
                    .setLabel("Compose")
                    .setResId(R.mipmap.ico_test_a)
                    .setIconNormalColor(0xff283593)
                    .setIconPressedColor(0xff1a237e)
                    .setLabelColor(0xff283593)
                    .setWrapper(3)
    );
    rfaContent
            .setItems(items)
            .setIconShadowRadius(RFABTextUtil.dip2px(context, 5))
            .setIconShadowColor(0xff888888)
            .setIconShadowDy(RFABTextUtil.dip2px(context, 5))
    ;

    rfabHelper = new RapidFloatingActionHelper(
            context,
            rfaLayout,
            rfaButton,
            rfaContent
    ).build();
}
 
Example #10
Source File: FragmentA.java    From RapidFloatingActionButton with Apache License 2.0 4 votes vote down vote up
@Override
public void onRFACItemIconClick(int position, RFACLabelItem item) {
    Toast.makeText(getActivity(), "clicked icon: " + position, Toast.LENGTH_SHORT).show();
    rfabHelper.toggleContent();
}
 
Example #11
Source File: FragmentA.java    From RapidFloatingActionButton with Apache License 2.0 4 votes vote down vote up
@Override
public void onRFACItemLabelClick(int position, RFACLabelItem item) {
    Toast.makeText(getActivity(), "clicked label: " + position, Toast.LENGTH_SHORT).show();
    rfabHelper.toggleContent();
}
 
Example #12
Source File: LabelListSampleActivity.java    From RapidFloatingActionButton with Apache License 2.0 4 votes vote down vote up
@Override
public void onRFACItemIconClick(int position, RFACLabelItem item) {
    Toast.makeText(this, "clicked icon: " + position, Toast.LENGTH_SHORT).show();
    rfabHelper.toggleContent();
}
 
Example #13
Source File: LabelListSampleActivity.java    From RapidFloatingActionButton with Apache License 2.0 4 votes vote down vote up
@Override
public void onRFACItemLabelClick(int position, RFACLabelItem item) {
    Toast.makeText(this, "clicked label: " + position, Toast.LENGTH_SHORT).show();
    rfabHelper.toggleContent();
}
 
Example #14
Source File: LabelListSampleActivity.java    From RapidFloatingActionButton with Apache License 2.0 4 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.label_list_sample);
        rfaLayout = (RapidFloatingActionLayout) findViewById(R.id.label_list_sample_rfal);
        rfaButton = (RapidFloatingActionButton) findViewById(R.id.label_list_sample_rfab);
        /*
        // 可通过代码设置属性
        rfaLayout.setFrameColor(Color.RED);
        rfaLayout.setFrameAlpha(0.4f);

        rfaButton.setNormalColor(0xff37474f);
        rfaButton.setPressedColor(0xff263238);
        rfaButton.getRfabProperties().setShadowDx(ABTextUtil.dip2px(this, 3));
        rfaButton.getRfabProperties().setShadowDy(ABTextUtil.dip2px(this, 3));
        rfaButton.getRfabProperties().setShadowRadius(ABTextUtil.dip2px(this, 5));
        rfaButton.getRfabProperties().setShadowColor(0xffcccccc);
        rfaButton.getRfabProperties().setStandardSize(RFABSize.MINI);
        rfaButton.build();
        */

        RapidFloatingActionContentLabelList rfaContent = new RapidFloatingActionContentLabelList(this);
        rfaContent.setOnRapidFloatingActionContentLabelListListener(this);
        List<RFACLabelItem> items = new ArrayList<>();
        items.add(new RFACLabelItem<Integer>()
                        .setLabel("Github: wangjiegulu")
                        .setResId(R.mipmap.ico_test_d)
                        .setIconNormalColor(0xffd84315)
                        .setIconPressedColor(0xffbf360c)
                        .setWrapper(0)
        );
        items.add(new RFACLabelItem<Integer>()
                        .setLabel("[email protected]")
//                        .setResId(R.mipmap.ico_test_c)
                        .setDrawable(getResources().getDrawable(R.mipmap.ico_test_c))
                        .setIconNormalColor(0xff4e342e)
                        .setIconPressedColor(0xff3e2723)
                        .setLabelColor(Color.WHITE)
                        .setLabelSizeSp(14)
                        .setLabelBackgroundDrawable(RFABShape.generateCornerShapeDrawable(0xaa000000, RFABTextUtil.dip2px(this, 4)))
                        .setWrapper(1)
        );
        items.add(new RFACLabelItem<Integer>()
                        .setLabel("WangJie")
                        .setResId(R.mipmap.ico_test_b)
                        .setIconNormalColor(0xff056f00)
                        .setIconPressedColor(0xff0d5302)
                        .setLabelColor(0xff056f00)
                        .setWrapper(2)
        );
        items.add(new RFACLabelItem<Integer>()
                        .setLabel("Compose")
                        .setResId(R.mipmap.ico_test_a)
                        .setIconNormalColor(0xff283593)
                        .setIconPressedColor(0xff1a237e)
                        .setLabelColor(0xff283593)
                        .setWrapper(3)
        );
        rfaContent
                .setItems(items)
                .setIconShadowRadius(RFABTextUtil.dip2px(this, 5))
                .setIconShadowColor(0xff888888)
                .setIconShadowDy(RFABTextUtil.dip2px(this, 5))
        ;

        rfabHelper = new RapidFloatingActionHelper(
                this,
                rfaLayout,
                rfaButton,
                rfaContent
        ).build();

    }
 
Example #15
Source File: MyRapidFloatingActionContentLabelList.java    From nono-android with GNU General Public License v3.0 4 votes vote down vote up
private void refreshItems() {
    if(ABTextUtil.isEmpty(this.items)) {
        throw new RuntimeException(this.getClass().getSimpleName() + "[items] can not be empty!");
    } else {
        this.contentView.removeAllViews();
        int i = 0;

        for(int size = this.items.size(); i < size; ++i) {
            RFACLabelItem item = (RFACLabelItem)this.items.get(i);
            View itemView = LayoutInflater.from(this.getContext()).inflate(com.wangjie.rapidfloatingactionbutton.R.layout.rfab__content_label_list_item, (ViewGroup)null);
            View rootView = (ABViewUtil.obtainView(itemView, com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_root_view));
            TextView labelTv = (TextView)ABViewUtil.obtainView(itemView, com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_label_tv);
            ImageView iconIv = (ImageView)ABViewUtil.obtainView(itemView, com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_icon_iv);
            rootView.setOnClickListener(this);
            labelTv.setOnClickListener(this);
            iconIv.setOnClickListener(this);
            rootView.setTag(com.wangjie.rapidfloatingactionbutton.R.id.rfab__id_content_label_list_item_position, Integer.valueOf(i));
            labelTv.setTag(com.wangjie.rapidfloatingactionbutton.R.id.rfab__id_content_label_list_item_position, Integer.valueOf(i));
            iconIv.setTag(com.wangjie.rapidfloatingactionbutton.R.id.rfab__id_content_label_list_item_position, Integer.valueOf(i));
            CircleButtonProperties circleButtonProperties = (new CircleButtonProperties()).setStandardSize(RFABSize.MINI).setShadowColor(this.iconShadowColor).setShadowRadius(this.iconShadowRadius).setShadowDx(this.iconShadowDx).setShadowDy(this.iconShadowDy);
            int shadowOffsetHalf = circleButtonProperties.getShadowOffsetHalf();
            int minPadding = ABTextUtil.dip2px(this.getContext(), 8.0F);
            int realItemSize;
            if(shadowOffsetHalf < minPadding) {
                realItemSize = minPadding - shadowOffsetHalf;
                rootView.setPadding(0, realItemSize, 0, realItemSize);
            }

            realItemSize = circleButtonProperties.getRealSizePx(this.getContext());
            android.widget.LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams)iconIv.getLayoutParams();
            if(null == lp) {
                lp = new android.widget.LinearLayout.LayoutParams(-2, -2);
            }

            int rfabRealSize = this.onRapidFloatingActionListener.obtainRFAButton().getRfabProperties().getRealSizePx(this.getContext());
            lp.rightMargin = (rfabRealSize - realItemSize) / 2;
            lp.width = realItemSize;
            lp.height = realItemSize;
            iconIv.setLayoutParams(lp);
            Integer normalColor = item.getIconNormalColor();
            Integer pressedColor = item.getIconPressedColor();
            CircleButtonDrawable rfacNormalDrawable = new CircleButtonDrawable(this.getContext(), circleButtonProperties, null == normalColor?this.getResources().getColor(com.wangjie.rapidfloatingactionbutton.R.color.rfab__color_background_normal):normalColor.intValue());
            CircleButtonDrawable rfacPressedDrawable = new CircleButtonDrawable(this.getContext(), circleButtonProperties, null == pressedColor?this.getResources().getColor(com.wangjie.rapidfloatingactionbutton.R.color.rfab__color_background_pressed):pressedColor.intValue());
            if(Build.VERSION.SDK_INT > 11) {
                iconIv.setLayerType(1, rfacNormalDrawable.getPaint());
            }

            ABViewUtil.setBackgroundDrawable(iconIv, ABShape.selectorClickSimple(rfacNormalDrawable, rfacPressedDrawable));
            int padding = ABTextUtil.dip2px(this.getContext(), 8.0F) + shadowOffsetHalf;
            iconIv.setPadding(padding, padding, padding, padding);
            String label = item.getLabel();
            if(ABTextUtil.isEmpty(label)) {
                labelTv.setVisibility(GONE);
            } else {
                if(item.isLabelTextBold()) {
                    labelTv.getPaint().setFakeBoldText(true);
                }

                labelTv.setVisibility(VISIBLE);
                labelTv.setText(label);
                Drawable resId = item.getLabelBackgroundDrawable();
                if(null != resId) {
                    ABViewUtil.setBackgroundDrawable(labelTv, resId);
                }

                Integer drawable = item.getLabelColor();
                if(null != drawable) {
                    labelTv.setTextColor(drawable.intValue());
                }

                Integer labelSize = item.getLabelSizeSp();
                if(null != labelSize) {
                    labelTv.setTextSize(2, (float)labelSize.intValue());
                }
            }

            Drawable var23 = item.getDrawable();
            if(null != var23) {
                iconIv.setVisibility(VISIBLE);
                var23.setBounds(0, 0, this.rfacItemDrawableSizePx, this.rfacItemDrawableSizePx);
                iconIv.setImageDrawable(var23);
            } else {
                int var24;
                if((var24 = item.getResId()) > 0) {
                    iconIv.setVisibility(VISIBLE);
                    iconIv.setImageDrawable(ABImageProcess.getResourceDrawableBounded(this.getContext(), var24, this.rfacItemDrawableSizePx));
                } else {
                    iconIv.setVisibility(GONE);
                }
            }

            this.contentView.addView(itemView);
        }

    }
}
 
Example #16
Source File: MyRapidFloatingActionContentLabelList.java    From nono-android with GNU General Public License v3.0 4 votes vote down vote up
public List<RFACLabelItem> getItems() {
    return this.items;
}
 
Example #17
Source File: MainActivity.java    From samples-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onRFACItemIconClick(int position, RFACLabelItem item) {
    handleFabItemClick(item);
    fabHelper.toggleContent();
}
 
Example #18
Source File: MyRapidFloatingActionContentLabelList.java    From nono-android with GNU General Public License v3.0 votes vote down vote up
void onRFACItemIconClick(int var1, RFACLabelItem<T> var2); 
Example #19
Source File: MyRapidFloatingActionContentLabelList.java    From nono-android with GNU General Public License v3.0 votes vote down vote up
void onRFACItemLabelClick(int var1, RFACLabelItem<T> var2);