Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior implementation #7

Open
AlvaroEstrada opened this issue Jan 24, 2019 · 3 comments
Open

Behavior implementation #7

AlvaroEstrada opened this issue Jan 24, 2019 · 3 comments

Comments

@AlvaroEstrada
Copy link

AlvaroEstrada commented Jan 24, 2019

Hi Choota!

I keep using your library that I love!

I need to do a behavior implementation and recover the Layout of the snackbar for its use.

Specifically, I need to do this:
http://alisonhuang-blog.logdown.com/posts/290009-design-support-library-coordinator-layout-and-behavior

I have a button to activate a GPS in the lower area of ​​the screen and when I click on it, I launch a Snackbar that indicates to the user that it is starting. The problem is that said Snackbar hides the button and I can not turn off the gps (the snackbar is undefined).

I would need to be able to use SnackBar.SnackBarLayout with your library.

Would it be possible?

Thank you!

@ChathuraHettiarachchi
Copy link
Owner

Hi,

Normally behavior implementation going to be added on a layout, it's like the main container, not the snackbar I think. Following data will help you only if you are using a FAB.

You can add a coordinator layout, add a floating button to work with location enable disable, then pass the FAB to Snackbar.

@AlvaroEstrada
Copy link
Author

AlvaroEstrada commented Jan 28, 2019

Hi!
I am testing with FAB Although I have no problem with Android 6. I will try to implement it anyway.
I am receiving an error now when I send my view to the .contentView.
I show you the code:

ERROR:
E/AndroidRuntime: FATAL EXCEPTION: main Process: es.indra.isl.es.indra.isl.igea.android.android, PID: 11420 java.lang.ClassCastException: android.support.design.widget.CoordinatorLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams at com.chootdev.csnackbar.Snackbar.contentView(Snackbar.java:94) at es.xxxxx.xxx.xxxx.android.utils.SnackbarFactory.snackBarCustomUpload(SnackbarFactory.java:119)

SnackBarFactory:

public static void snackBarCustomUpload (Context context, String message){
View view = LayoutInflater.from(context).inflate(R.layout.custom_upload_snackbar, isCoordinatorLayout(context));
TextView tv = (TextView) view.findViewById(R.id.snackbar_text);

    tv.setText(message);

    Snackbar snackbar = new Snackbar();
    snackbar.with(context,isFloatingButtonEnabled(context))
            .type(Type.CUSTOM, 0xff323232)
            .fillParent(true)
            .contentView(view, 48) // <-- Line 119
            .duration(Duration.INFINITE)
            .show();
}
public static FloatingActionButton isFloatingButtonEnabled(Context context){
    if (context instanceof MainActivity){
        return ((MainActivity) MainActivity.getActivity()).getmPositionButton();
    }else{
        return null;
    }
}
public static CoordinatorLayout isCoordinatorLayout(Context context){
    if (context instanceof MainActivity){
        return ((MainActivity) MainActivity.getActivity()).getmMainLayout();
    }else{
        return null;
    }
}

This only happens to me if I use a snackbar with a personalized view. If I use .type (Type.SUCCESS) or .type (Type.ERROR) it works perfectly.

@AlvaroEstrada
Copy link
Author

@ChathuraHettiarachchi
Can you think of a solution to move the FAB?
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants