Krupen / FabulousFilter

Android library to animate Floating Action Button to Bottom Sheet Dialog and vice-versa
Apache License 2.0
2.68k stars 323 forks source link

Can't implement this in fragment #1

Closed sajorahasan closed 7 years ago

sajorahasan commented 7 years ago

Hi, Thanks for this awesome looking library but can you please help me, I'm trying to implement this library in fragment and getSupportFragmentManager is not working even getActivity().getSupportFragmentManager()

Krupen commented 7 years ago

Are you trying to use Fragments inside AAH_FabulousFragment ?

Below code when called from fragment works fine:

 FilterDialogFragment dialogFrag = FilterDialogFragment.newInstance();
                dialogFrag.setParentFab(fab);
                dialogFrag.show(getActivity().getSupportFragmentManager(), dialogFrag.getTag());
sajorahasan commented 7 years ago

capture No i have fragment in which i have floating action button and on the onClickEvent I'm trying to call FilterDialogFragment

` FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.filterbtn); fab.setOnClickListener(v -> { FilterFragment dialogFrag = FilterFragment.newInstance(); dialogFrag.setParentFab(fab);

        dialogFrag.show(getActivity().getSupportFragmentManager(), dialogFrag.getTag());
    });`
Krupen commented 7 years ago

Seems like an issue with the Activity. Does your Activity extend AppCompatActivity ? If not, try using getFragmentManager() or getChildFragmentManager(). Also check this link https://stackoverflow.com/questions/13443811/cannot-call-getsupportfragmentmanager-from-activity

I added a Fragment example in the sample app.

sajorahasan commented 7 years ago

hi, thanks for the quick reply and help. I was using android.app.Fragment; that's why i was unable to call getActivity().getSupportFragmentManager()