Android library to animate Floating Action Button to Bottom Sheet Dialog and vice-versa

Overview

FabulousFilter

API Android Arsenal Material Up

Show some ❤️ and star the repo to support the project

GitHub stars GitHub forks GitHub watchers GitHub followers
Twitter Follow

This library is the implementation of filter-concept posted on MaterialUp.com.

It makes animation of FloatingActionButton to BottomSheetDialog easy to implement.

Concept

fabulousfilter concept

Demo

fabulousfilter demo 1 fabulousfilter demo 1

Download

Gradle

Step 1. Add the jCenter repository to your project-level build.gradle file

allprojects {
	repositories {
		jcenter()
	}
}

Step 2. Add the dependency to your app-level build.gradle file:

dependencies {
	 compile 'com.allattentionhere:fabulousfilter:0.0.5'
}

Usage

Create a Fragment that extends AAH_FabulousFragment:

public class MySampleFabFragment extends AAH_FabulousFragment {

    public static MySampleFabFragment newInstance() {
        MySampleFabFragment f = new MySampleFabFragment();
        return f;
    }

    @Override

    public void setupDialog(Dialog dialog, int style) {
        View contentView = View.inflate(getContext(), R.layout.filter_sample_view, null);
        RelativeLayout rl_content = (RelativeLayout) contentView.findViewById(R.id.rl_content);
        LinearLayout ll_buttons = (LinearLayout) contentView.findViewById(R.id.ll_buttons);
        contentView.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                closeFilter("closed");
            }
        });

        //params to set
        setAnimationDuration(600); //optional; default 500ms
        setPeekHeight(300); // optional; default 400dp
        setCallbacks((Callbacks) getActivity()); //optional; to get back result
	setAnimationListener((AnimationListener) getActivity()); //optional; to get animation callbacks
        setViewgroupStatic(ll_buttons); // optional; layout to stick at bottom on slide
        setViewPager(vp_types); //optional; if you use viewpager that has scrollview
        setViewMain(rl_content); //necessary; main bottomsheet view
        setMainContentView(contentView); // necessary; call at end before super
        super.setupDialog(dialog, style); //call super at last
    }

}

Create view for the fragment which has parent element AAH_FilterView:

<com.allattentionhere.fabulousfilter.AAH_FilterView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/rl_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:background="@color/orange"
        android:visibility="invisible"
        tools:ignore="MissingPrefix"
        tools:visibility="visible">

        <LinearLayout
            android:id="@+id/ll_buttons"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:layout_alignParentBottom="true"
            android:background="@color/brown"
            android:orientation="horizontal"
            android:weightSum="2">
        </LinearLayout>

    </RelativeLayout>

</com.allattentionhere.fabulousfilter.AAH_FilterView>

Start the fragment on click of FloatingActionButton as below:

fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MySampleFabFragment dialogFrag = MySampleFabFragment.newInstance();
                dialogFrag.setParentFab(fab);
                dialogFrag.show(getSupportFragmentManager(), dialogFrag.getTag());
            }
        });

Parameters

  • Main View (Required)

This parameter specifies the ViewGroup of the bottom sheet to be shown after animation ends. It can be any ViewGroup(LinearLayout/FrameLayout etc):

setViewMain(relativelayout_content);
  • Inflated Dialog View (Required)

This parameter specifies the inflated view for the dialog:

setMainContentView(contentDialogView);
  • Animation duration (Optional)

This parameter sets animation duration of translate and scale animation in milliseconds:

setAnimationDuration(600); // default 500ms
  • Peek Height (Optional)

This parameter sets the peek height of the bottom sheet in dp:

setPeekHeight(300); // default 400dp
  • Callback (Optional)

This paramter is used to get callback from AAH_FabulousFragment to the component that called it:

setCallbacks((Callbacks) getActivity());

To use it, implement the callback in the calling component(Activity/Fragment etc), example:

public class MainSampleActivity extends AppCompatActivity implements AAH_FabulousFragment.Callbacks {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_sample);
    }

    @Override
    public void onResult(Object result) {
        Log.d("k9res", "onResult: " + result.toString());
        if (result.toString().equalsIgnoreCase("swiped_down")) {
            //do something or nothing
        } else {
            //handle result
        }
    }
}

  • Animation Listener (Optional)

This parameter is used to get animation callbacks.

setAnimationListener((AnimationListener) getActivity());

To use it, implement the AnimationListener in the calling component(Activity/Fragment etc), example:

public class MainSampleActivity extends AppCompatActivity implements AAH_FabulousFragment.AnimationListener {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_sample);
    }
    
   @Override
    public void onOpenAnimationStart() {
        //do something on open animation start
    }

    @Override
    public void onOpenAnimationEnd() {
        //do something on open animation end
    }

    @Override
    public void onCloseAnimationStart() {
        //do something on close animation start
    }

    @Override
    public void onCloseAnimationEnd() {
        //do something on close animation start
    }
}

  • Static View (Optional)

This parameter is used to make view in Bottom Sheet static when user slides it. It can be any ViewGroup(LinearLayout/FrameLayout etc):

setViewgroupStatic(linearlayout_buttons);
  • ViewPager (Optional)

This parameter is used to support scrolling in ViewPager as BottomSheetDialog does not support multiple views with scroll:

setViewPager(viewPager);

Libraries by developer

Apps by developer

Price Stalker Show Card Game Safio chat

License

Copyright 2017 Krupen Ghetiya

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Comments
  • NullPointerException in ViewPagerBottomSheetBehavior for sdk version 27

    NullPointerException in ViewPagerBottomSheetBehavior for sdk version 27

    Hello, I tried to execute the fragment code exemple with the sdk version 27 and I get a crash although it works perfectly with sdk version 26.

    May be I could try to fix it I i get enough free time ;-) This lib rocks, great work . 👍

    Here's the stacktrace :

    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v4.widget.ViewDragHelper.processTouchEvent(android.view.MotionEvent)' on a null object reference at com.allattentionhere.fabulousfilter.viewpagerbottomsheet.ViewPagerBottomSheetBehavior.onTouchEvent(ViewPagerBottomSheetBehavior.java:274) at android.support.design.widget.CoordinatorLayout.resetTouchBehaviors(CoordinatorLayout.java:389) at android.support.design.widget.CoordinatorLayout.onAttachedToWindow(CoordinatorLayout.java:235) at android.view.View.dispatchAttachedToWindow(View.java:15543) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2955) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2962) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2962) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2962) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2962) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2962) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1650) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1366) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6768) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:926) at android.view.Choreographer.doCallbacks(Choreographer.java:735) at android.view.Choreographer.doFrame(Choreographer.java:667) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:912) at android.os.Handler.handleCallback(Handler.java:761) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:156) at android.app.ActivityThread.main(ActivityThread.java:6523) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)

    opened by agicquel 15
  • Null Pointer Exception on Screen Rotation

    Null Pointer Exception on Screen Rotation

    Hi ;). I notice an error while playing with your library. Nice work by the way !

    To Reproduce, Just Launch "Top Fab Demo" and while the Filters Fragment is open, rotate your phone. The app Crash with a Null Pointer Exception due to the Floating Action Button

    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.design.widget.FloatingActionButton.getLocationInWindow(int[])' on a null object reference at com.allattentionhere.fabulousfilter.AAH_FabulousFragment.setupDialog(AAH_FabulousFragment.java:129)

    Bye ;)

    opened by ProgrammationAndroid 5
  • App crashes

    App crashes

    I'm getting the following error each time I run the app. I followed usage instructions but I'm not sure where I'm going wrong:

    java.lang.NullPointerException at com.allattentionhere.fabulousfilter.AAH_FabulousFragment.onStart(AAH_FabulousFragment.java:98)

    opened by kyndaqtepammy 4
  • Can't implement this in fragment

    Can't implement this in fragment

    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()

    opened by sajorahasan 4
  • Crashes when using ViewPager with FragmentStatePagerAdapter

    Crashes when using ViewPager with FragmentStatePagerAdapter

    Hello,

    I am using this library for Filtering in my application. And it's fantastic in look and use. I am getting a crash when I use ViewPager with FragmentStatePagerAdapter in this library. Here is crash : java.lang.IllegalStateException: Fragment does not have a view And I can't find any solution to stop crashing and make this work. Can you help me make it run ?

    Thanks in Advance.

    opened by darshanpopat 2
  • Prevent scroll down past peek height

    Prevent scroll down past peek height

    Hi. Thanks for the amazing work done so far. I was wondering if there was a way to prevent the view from scrolling past the peeking height and to not be cancelled when clicking outside the view. I am setting up two buttons on the bottom, one is Save and the other Cancel, which I want to use to close the view so that each time the closing animation is displayed. Thanks in advance

    opened by TheCodeN00b 1
  • Scroll up bug

    Scroll up bug

    Hello! In the layout of the fragment, the daughter element is ScrollView. The problem is that when you scroll down to the bottom and try to scroll up the fold. How can I fix this?

    ` <com.allattentionhere.fabulousfilter.AAH_FilterView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/aah_container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">

    <RelativeLayout
        android:isScrollContainer="true"
        android:id="@+id/rl_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:background="@color/transBlackPlus"
        android:visibility="invisible"
        tools:ignore="MissingPrefix"
        tools:visibility="visible">
        
        <ScrollView
            android:id="@+id/settings_scroll_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true">
    
            ...
    
        </ScrollView>
    </RelativeLayout>
    

    </com.allattentionhere.fabulousfilter.AAH_FilterView>`

    Link to video

    opened by PikselNsk 1
  • Released my app using fabulous filter

    Released my app using fabulous filter

    Hi,

    It's not an issue ;).

    I just release my app using your library : You can check it here : https://play.google.com/store/apps/details?id=justme.application.com.newconfapp

    Thanks again for your work !

    Bye and have a nice day

    opened by ProgrammationAndroid 1
  • Button style is not changing in the AAH_FilterView

    Button style is not changing in the AAH_FilterView

    I can change the background and other attributes but setting a whole style is not working for the button and it keeps displaying the default android button style:

    <?xml version="1.0" encoding="utf-8"?>
    <com.allattentionhere.fabulousfilter.AAH_FilterView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <RelativeLayout
            android:background="@color/fancy_btn"
            android:id="@+id/rl_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentBottom="true"
            android:visibility="invisible"
            tools:ignore="MissingPrefix"
            tools:visibility="visible">
    
            <LinearLayout
                android:background="@color/white"
                android:id="@+id/ll_buttons"
                android:layout_width="match_parent"
                android:layout_height="56dp"
                android:layout_alignParentBottom="true"
                android:orientation="horizontal">
                <androidx.appcompat.widget.AppCompatButton
                    android:text="@string/ok_got_it"
                    android:id="@+id/btn_close"
                    style="@style/ButtonCloseStyle" /> <!-- NOT WORKING -->
            </LinearLayout>
    
        </RelativeLayout>
    
    </com.allattentionhere.fabulousfilter.AAH_FilterView>
    
    opened by JagarYousef 0
  • Issue in sdk 28

    Issue in sdk 28

    I have error while fab.setVisibility(View.VISIBLE); ( compileSdkVersion 28)

    error:- VisibilityAwareImageButton.setVisibility can only be called from within the same library group (groupId=com.android.support) less... (Ctrl+F1) This API has been flagged with a restriction that has not been met. Examples of API restrictions: * Method can only be invoked by a subclass * Method can only be accessed from within the same library (defined by the Gradle library group id) .* Method can only be accessed from tests. . You can add your own API restrictions with the @RestrictTo annotation.

    Screenshot: error1

    opened by pravinkorepk94 0
  • About AndroidX compatibility problem

    About AndroidX compatibility problem

    Hello! I got this problem : this lib needs FAB of android support, but androidX is update to google...FAB, so it can't compatibility. thanks for check.

    opened by bladeofgod 1
Owner
Krupen Ghetiya
Krupen Ghetiya
Backarrow-animation-example - Animate back arrow to close button in Compose using animated drawables

Animate Back Arrow to Close Icon in Compose This is a simple demo for animated v

Jose Mateo 3 Feb 17, 2022
💪 Rich Android Path. 🤡 Draw as you want. 🎉 Animate much as you can.

?? Rich Android Path. ?? Draw as you want. ?? Animate much as you can. Download sample app: Features Full Animation Control on Paths and VectorDrawabl

Ahmed Tarek 2.3k Dec 20, 2022
Simple way to animate your views on Android with Rx 🚀

This is an Android library to make a simple way to animate your views on Android with Rx.

Lopez Mikhael 583 Dec 9, 2022
Animate a strike over any image to indicate on/off states. As seen in the Material Guidelines.

StrikedImageView Animate a strike over any image to indicate on/off states. As seen in the Material Guidelines. Gradle allprojects { repositories

null 9 Sep 21, 2022
POC of how you can animate LazyColumn insertions/deletions/moving

Animated LazyColumn/LazyRow POC of how you can animate LazyColumn/LazyRow insertions/deletions/moving Note, this is not production ready or a library,

Roudi Korkis Kanaan 33 Dec 24, 2022
Animated-splash-screen - Animate your Splash Screen using Lottie files.

Animated Splash Screen This small project shows how you can add animation into your android projects or create beautiful looking Splash Screen or Laun

Aashish Ace 0 Jan 2, 2022
Trying to play with Jetpack compose low level animations APIs, which are animate*AsState APIs.

ComposeSimpleAnimation Trying to play with Jetpack compose low level animations APIs, which are animate*AsState APIs that I needed in another project.

Mustafa Ibrahim 39 Dec 10, 2022
Continuous speech recognition library for Android with options to use GoogleVoiceIme dialog and offline mode.

Android Speech Recognition This library lets you perform continuous voice recognition in your android app with options to either use Google Voice Ime

Maxwell Obi 75 May 21, 2022
Android Library to create Lottie animation view dialog easily with a lot of customization

LottieDialog Android Library to create Lottie animation view dialog easily with a lot of customization Why you should use Lottie Dialog You have no li

Amr Hesham 39 Oct 7, 2022
Android Library to create Lottie animation view dialog easily with a lot of customization

Android Library to create Lottie animation view dialog easily with a lot of customization

Amr Hesham 39 Oct 7, 2022
Android Library To Create Button With Multi Reactions like Facebook or Linkedin

ReactButton Android Library written in Java to Create ReactButton with Multi Reactions like Facebook or Linkedin ?? Default Reactions ?? Custom Reacti

Amr Hesham 103 Dec 15, 2022
Animated Loader or Animated Progress Dialog android code.

AnimatedLoadingIndicator LoadingIndicator This is a simple but effective animated Loading Indicator which can easily ready to use integrated few lines

Yash Agarwal 95 Nov 15, 2022
A Toggling Add/Remove button

Cross View Add a CrossView to your layout <cdflynn.android.library.crossview.CrossView android:id="@+id/sample_cross_view" android

Collin Flynn 321 Nov 25, 2022
Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. The library is based on the code of Mario Klingemann.

Android StackBlur Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. Th

Enrique López Mañas 3.6k Dec 29, 2022
Postman is a reactive One-tap SMS verification library. This library allows the usage of RxJava with The SMS User Consent API

What is Postman? Postman is a reactive One-tap SMS verification library. This library allows the usage of RxJava with The SMS User Consent API Usage P

Cafer Mert Ceyhan 129 Dec 24, 2022
Chandrasekar Kuppusamy 799 Nov 14, 2022
FilePicker is a small and fast file selector library that is constantly evolving with the goal of rapid integration, high customization, and configurability~

Android File Picker ??️ 中文简体 Well, it doesn't have a name like Rocky, Cosmos or Fish. Android File Picker, like its name, is a local file selector fra

null 786 Jan 6, 2023
Android Country Picker is a Kotlin-first, flexible and powerful Android library that allows to integrate Country Picker with just a few lines.

1. Add dependency dependencies { implementation 'com.hbb20:android-country-picker:X.Y.Z' } For latest version, 2. Decide your use-case

Harsh B. Bhakta 65 Dec 6, 2022
Android library. Flexible components for chat UI implementation with flexible possibilities for styling, customizing and data management. Made by Stfalcon

ChatKit for Android ChatKit is a library designed to simplify the development of UI for such a trivial task as chat. It has flexible possibilities for

Stfalcon LLC 3.6k Jan 5, 2023