Git Product home page Git Product logo

fabulousfilter's Introduction

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

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

dependencies {
	 implementation 'io.github.krupen:fabulousfilter:0.0.6'
}

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
        setInterpolator(new AccelerateDecelerateInterpolator()); // optional
        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
  • Interpolator (Optional)

This parameter is used to set interpolator for fab animation:

setInterpolator(new AccelerateDecelerateInterpolator());
  • Peek Height (Optional)

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

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

This parameter 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) {
        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 Dota Picker Pro

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.

fabulousfilter's People

Contributors

scrusader avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fabulousfilter's Issues

Lower API version

Isn't it possible to lower API version to 14 or 15 like the latest support libraries? I tried it on Android SDK 15 and it worked fine..

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

Static view disapper in some conditions

Static view (reset and apply buttons) disappear on samsung galaxy s8 if using device in full screen (there is no physyical button, but only soft on screen home/back buttons)

I checked source code and seems that in the ViewPagerBottomSheetBehavior:onLayoutChild method there is some issue in recalculate heights during the operation of show/hide.

20180510_124935
20180510_125002

Getting " Fragment does not have a view" error

java.lang.IllegalStateException: Fragment does not have a view
at android.support.v4.app.Fragment$2.onFindViewById(Fragment.java:2308)

I am getting above error every time when i try to open fragment dialog with viewpager

I have used 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.

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

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>

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.

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)

could not import project

Maybe version difference is the problem... need to update versions in you project from your side

Custom fragmet

how can add to viewpager custom fragmets ?
i've added some framgent but give me some error:
java.lang.IllegalStateException: Fragment does not have a view ...

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)

Remove Fab button dependency

Hi, I am trying to use this inside a fragment and I have tried setting the peek height like this -

dialogFrag = SelectItemsBottomSheetFragment.newInstance();
dialogFrag.setParentFab(filterFab);
filterFab.setVisibility(View.GONE);
dialogFrag.setPeekHeight(600);
dialogFrag.setAnimationDuration(100);
@Override
    public void setupDialog(Dialog dialog, int style) {
        View contentView = View.inflate(getContext(), R.layout.select_board_requirement, null);
        RelativeLayout rl_content = (RelativeLayout) contentView.findViewById(R.id.rl_content);
        LinearLayout ll_buttons = (LinearLayout) contentView.findViewById(R.id.ll_buttons);
        ....
        try {
            setAnimationDuration(100); //optional; default 500ms
            setPeekHeight(600); // optional; default 400dp
            setCallbacks((Callbacks) getActivity()); //optional; to get back result
            setViewgroupStatic(ll_buttons);
            setViewMain(rl_content); //necessary; main bottomsheet view
            setMainContentView(contentView); // necessary; call at end before super
        } catch(Exception ignored){}
        super.setupDialog(dialog, style); //call super at last
}

But, I am not observing any change in the initial height of the opened dialog.
Does the peek height has any restrictions w.r.t screen / viewport height.

Also, I wanted to use this with other form elements instead of simple dropdowns, but I don't understand why there is a requirement to setup the fab button to open it. I think with minimal refactoring we can open it from any View class.

----- Update ------

I tried again with peek height as 450 again and found it working so I guess it was a viewport height issue.

But, still I think the fab button dependency can be removed. I am not sure about what purpose does it serve in your library but if it is just to get the animation start position then I can submit a pull request for the same if you want.

java.lang.IllegalStateException: Fragment already added

Hello! I get this exception, if i press FAB twice:

Fatal Exception: java.lang.IllegalStateException: Fragment already added: FilterFragment{a78520b #7}
       at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1886)
       at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:760)
       at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2591)
       at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2378)
       at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2333)
       at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2240)
       at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:703)
       at android.os.Handler.handleCallback(Handler.java:836)
       at android.os.Handler.dispatchMessage(Handler.java:103)
       at android.os.Looper.loop(Looper.java:203)
       at android.app.ActivityThread.main(ActivityThread.java:6564)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1134)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)

In the example project it's the same. What can i do about it?

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

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

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.