Scalified / fab

Floating Action Button Library for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

move() method smearing on KitKat with snackbar.

marcochin opened this issue · comments

The FAB seems to be smearing (leaving a image trail behind) under certain conditions in KitKat when move is called.

I'm using your FAB in conjunction with nispok's Snackbar library https://github.com/nispok/snackbar,
and when the snackbar slides up, I move my FAB up by the snackbar height. However, when I SWIPE AWAY the snackbar (very important detail), the FAB comes back down, but it leaves a trail of itself.

I made my own translation animation and the smearing is gone, so it's a good chance that it's a bug in your library. I thought it should be something you should look at.

Note: I've only tested this on the emulator. ICS and Lollipop work fine.
Edit: Jellybean works fine, did not test ICS.

fab smearing

Hi marcochin,

Sure, I'll have a look at this
Please, provide the ActionButton configuration (xml or code) and the method calls to Snackbar and ActionBar libraries

Have you tried also to move ActionButton on KitKat without Snackbar library?

This only happens when you SWIPE AWAY the snackbar. If you dismiss the snackbar by clicking the snackbar action button, the animation will work properly. And no I haven't tried it without the snackbar library, dunno if I can reproduce it without swiping away the snackbar.

ActionButton in xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent" android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:scrollbars="vertical"/>

    <com.software.shell.fab.ActionButton
        android:id="@+id/floating_action_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        fab:button_color="@color/fab_normal_state"
        fab:button_colorPressed="@color/fab_pressed_state"
        fab:image="@drawable/ic_add"
        fab:image_size="30dp"
        />
</RelativeLayout>

Snackbar configuration in java:

 SnackbarManager.show(
                Snackbar.with(getActivity())
                        .text(R.string.snack_bar_text_item_removed)
                        .actionLabel(R.string.snack_bar_action_undo)
                        .actionListener(new ActionClickListener() {
                            @Override
                            public void onActionClicked(Snackbar snackbar) {
                               /* some code */
                            }
                        })
                        .colorResource(R.color.snackbar_bg_color)
                        .textColorResource(R.color.snackbar_text_color)
                        .actionColorResource(R.color.snackbar_action_color)
                        .duration(5000)
                        .type(SnackbarType.SINGLE_LINE)
                        .swipeToDismiss(true)
                        .eventListener(new EventListener() {
                            @Override
                            public void onShow(Snackbar snackbar) {
                                float snackbarHeight = DpPxConversionUtil.convertPixelsToDp(snackbar.getHeight(), getActivity());
                                mFloatingActionButton.moveUp(snackbarHeight);
                            }

                            @Override
                            public void onShowByReplace(Snackbar snackbar) {

                            }

                            @Override
                            public void onShown(Snackbar snackbar) {

                            }

                            @Override
                            public void onDismiss(Snackbar snackbar) {
                                float snackbarHeight = DpPxConversionUtil.convertPixelsToDp(snackbar.getHeight(), getActivity());
                                mFloatingActionButton.moveDown(snackbarHeight);
                            }

                            @Override
                            public void onDismissByReplace(Snackbar snackbar) {

                            }

                            @Override
                            public void onDismissed(Snackbar snackbar) {

                            }
                        })
        );

DpPxConversionUtil Class if you're interested:

public class DpPxConversionUtil {

    public static float convertDpToPixel(float dp, Context context){
        return dp * context.getResources().getDisplayMetrics().density;
    }

    public static float convertPixelsToDp(float px, Context context){
        return px / context.getResources().getDisplayMetrics().density;
    }
}

So, I found a possible place to fix within a library, which ActionButton depends on.

However, KitKat emulator is a sort of hard way to test the fix, because of the rendering (actually I can't get even smooth animation on it).

Will you have a possibility to check the fix on your side if I build the sample application and send you the .apk file?

Yea, but I can also only test it on an emulator. I had a real KitKat device, but I recently updated it to lollipop..

Fixed in version 1.1.2
Please check && confirm

I've ran it on my emulator and seems to be fixed