Giter Site home page Giter Site logo

arimorty / floatingsearchview Goto Github PK

View Code? Open in Web Editor NEW
3.5K 85.0 672.0 7.73 MB

A search view that implements a floating search bar also known as persistent search

Home Page: https://github.com/arimorty/floatingsearchview/blob/master/README.md

License: Apache License 2.0

Java 99.72% Kotlin 0.28%
android material-design material-ui floatingsearchview persistent-search

floatingsearchview's Introduction

Floating Search View Android Arsenal

An implementation of a floating search box with search suggestions, also called persistent search bar.

Alt text Alt text Alt text

Note

This project is not being actively maintained. Have a look here for information that might help you make changes to your own copy of the code base.

...

Usage

  1. In your dependencies, add
         compile 'com.github.arimorty:floatingsearchview:2.1.1'
    
  2. Add a FloatingSearchView to your view hierarchy, and make sure that it takes up the full width and height of the screen
  3. Listen to query changes and provide suggestion items that implement SearchSuggestion

Example:

       <com.arlib.floatingsearchview.FloatingSearchView
                android:id="@+id/floating_search_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:floatingSearch_searchBarMarginLeft="@dimen/search_view_inset"
                app:floatingSearch_searchBarMarginTop="@dimen/search_view_inset"
                app:floatingSearch_searchBarMarginRight="@dimen/search_view_inset"
                app:floatingSearch_searchHint="Search..."
                app:floatingSearch_suggestionsListAnimDuration="250"
                app:floatingSearch_showSearchKey="false"
                app:floatingSearch_leftActionMode="showHamburger"
                app:floatingSearch_menu="@menu/menu_main"
                app:floatingSearch_close_search_on_keyboard_dismiss="true"/>
  mSearchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() {
              @Override
              public void onSearchTextChanged(String oldQuery, final String newQuery) {

                  //get suggestions based on newQuery

                  //pass them on to the search view
                  mSearchView.swapSuggestions(newSuggestions);
              }
          });

Left action mode:

The left action can be configured as follows:

Add

   app:floatingSearch_leftActionMode="[insert one of the options from table below]"
showHamburger
showSearch
showHome
noLeftAction

Listen to hamburger button clicks:

 mSearchView.setOnLeftMenuClickListener(
        new FloatingSearchView.OnLeftMenuClickListener() { ...} );          

To quickly connect your NavigationDrawer to the hamburger button:

   mSearchView.attachNavigationDrawerToMenuButton(mDrawerLayout);

Listen to home (back arrow) button clicks:

  mSearchView.setOnHomeActionClickListener(
         new FloatingSearchView.OnHomeActionClickListener() { ... });       

Configure menu items:

Alt text

Add a menu resource

    app:floatingSearch_menu="@menu/menu_main"

In the menu resource, set items' app:showAsAction="[insert one of the options described in the table below]"

never Puts the menu item in the overflow options popup
ifRoom Shows an action icon for the menu if the following conditions are met: 1. The search is not focused. 2. There is enough room for it.
always Shows an action icon for the menu if there is room, regardless of whether the search is focused or not.

Listen for item selections

   mSearchView.setOnMenuItemClickListener(new FloatingSearchView.OnMenuItemClickListener() {
      @Override
      public void onMenuItemSelected(MenuItem item) {                  
            
      }
   });

Configure suggestion item:

First, implement SearchSuggestion

Optional:

Set a callback for when a given suggestion is bound to the suggestion list.

For the history icons to show, you would need to implement this. Refer to the sample app for an example implementation.

   mSearchView.setOnBindSuggestionCallback(new SearchSuggestionsAdapter.OnBindSuggestionCallback() {
            @Override
            public void onBindSuggestion(View suggestionView, ImageView leftIcon, TextView textView, SearchSuggestion item, int itemPosition) {

                       //here you can set some attributes for the suggestion's left icon and text. For example,
                       //you can choose your favorite image-loading library for setting the left icon's image. 
            }

        });

Styling:

Available styling:

   <style name="SearchView">
           <item name="floatingSearch_backgroundColor"></item>
           <item name="floatingSearch_viewSearchInputTextColor"></item>
           <item name="floatingSearch_viewSuggestionItemTextColor"></item>
           <item name="floatingSearch_hintTextColor"></item>
           <item name="floatingSearch_dividerColor"></item>
           <item name="floatingSearch_clearBtnColor"></item>
           <item name="floatingSearch_leftActionColor"></item>
           <item name="floatingSearch_menuItemIconColor"></item>
           <item name="floatingSearch_suggestionRightIconColor"></item>
           <item name="floatingSearch_actionMenuOverflowColor"></item>
   </style>

RxBinding Extension

The RxBinding library allows you to listen for query changes using RxJava Obervables.

Observable<CharSequence> queryObservable = RxFloatingSearchView.queryChanges(view);
queryObservable.doOnNext { query -> Toast.makeText(this, "Query is %s".format(query), Toast.LENGTH_LONG).show() }.subscribe();

The Kotlin Extension

The Kotlin extension adds an extension function to the view for more goodness.

view.queryChanges(5).doOnNext { query -> Toast.makeText(this, "Query is %s".format(query), Toast.LENGTH_LONG).show() }.subscribe()

License

Copyright (C) 2015 Ari C.

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.

floatingsearchview's People

Contributors

arimorty avatar aulisius avatar cillianmyles avatar gloix avatar permusoft avatar robbypond 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  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

floatingsearchview's Issues

getQuery() is null

mSearchInput.setOnKeyListener(new OnKeyListener() {

        public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {

            if (mShowSearchKey && keyCode == KeyEvent.KEYCODE_ENTER) {
                if (mSearchListener != null)
                    mSearchListener.onSearchAction();

                setSearchFocusedInternal(false);
                return true;
            }
            return false;
        }
    });

change it like this.

No way for search suggestion customization

I can't find any way of changing the layout of the search suggestion item. I tried the following:

  • providing a custom suggestions adapter - not possible
  • providing a custom layout for the adapter - not possible
  • setting a custom text in onBindSuggestion(...) method - not possible
  • returning a styled text from the SearchSuggestion#getBody() method - not possible (the returned type is String)

Could you change the library API to allow for any customization from the list above?

Manifest conflicts in AutoFitTextView

Hi! I'm trying to implement this awesome library in my project, but right after I added FloatingSearchView to my gradle dependencies, I've faced error:

Error:Execution failed for task ':app:myprocess'.
 Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:33:9-36
    is also present at [me.grantland:autofittextview:0.2.0] AndroidManifest.xml:11:18-44 value=(true).

It's pretty self-explanatory. I've checked AutoFitTextView library, and they have removed allowBackup=true from their manifest in this commit. So, please, update it in your project.

Need a way to get the focus on search filed

Is there a way to open the keyboard and have the focus by default / programatically. ?
If not can you please expose a way to get the editor / edit text so that we can have some control over it.

Thanks!
Manju

Clear button

Hi,

First of all, nice work.

I see a problem with the clear button. It shows only after writing or deleting something on the search view, and not when clicking on it while something is displayed.

I have looked at other issues. I set a custom clear button as menu item and hide the usual clear button with setClearBtnColor(Color.TRANSPARENT);. In this case, the white place for the usual clear button is still here, removing place for text.

Is there something else I can do?

(Sorry for my english)

Can I get query string when call OnSearchListener.onSearchAction()

Hi, I see this code:
mSearchInput.setOnKeyListener(new OnKeyListener() {

        public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {

            if (mShowSearchKey && keyCode == KeyEvent.KEYCODE_ENTER) {

                setSearchFocusedInternal(false);

                if (mSearchListener != null)
                    mSearchListener.onSearchAction();

                return true;
            }
            return false;
        }
    });

the EditText will clear text at "setSearchFocusedInternal(false);", and I can't get the query string at onSearchAction(), because I want toggle a search action when user click the search action key at keyboard :(

java.lang.NoClassDefFoundError

Missing proguard-rules?

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/bartoszlipinski/viewpropertyobjectanimator/ViewPropertyObjectAnimator; at com.arlib.floatingsearchview.FloatingSearchView.transitionInLeftSection(FloatingSearchView.java:1406) at com.arlib.floatingsearchview.FloatingSearchView.setSearchFocusedInternal(FloatingSearchView.java:1319) at com.arlib.floatingsearchview.FloatingSearchView.access$1500(FloatingSearchView.java:87) at com.arlib.floatingsearchview.FloatingSearchView$7.onFocusChange(FloatingSearchView.java:609) at android.view.View.onFocusChanged(View.java:5723) at android.widget.TextView.onFocusChanged(TextView.java:8224) at android.view.View.handleFocusGainInternal(View.java:5478) at android.view.View.requestFocusNoSearch(View.java:8476) at android.view.View.requestFocus(View.java:8455) at android.view.View.requestFocus(View.java:8422) at android.view.View.requestFocus(View.java:8401) at android.view.View.onTouchEvent(View.java:10305) at android.widget.TextView.onTouchEvent(TextView.java:8300) at android.view.View.dispatchTouchEvent(View.java:9300) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2403) at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1737) at android.app.Activity.dispatchTouchEvent(Activity.java:2771) at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60) at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2364) at android.view.View.dispatchPointerEvent(View.java:9520) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4238) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4104) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3650) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3703) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3669) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3795) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3677) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3852) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3650) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3703) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3669) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3677) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3650) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5932) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5906) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5867) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6035) at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185) at android.os.MessageQueue.nativePollOnce(Native Method) at android.os.MessageQueue.next(MessageQueue.java:323) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5422) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.bartoszlipinski.viewpropertyobjectanimator.ViewProp ertyObjectAnimator" on path: DexPathList[[zip file "/data/app/net.zedge.snakk-2/base.apk"],nativeLibraryDirectories=[/d ata/app/net.zedge.snakk-2/lib/arm64, /vendor/lib64, /system/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) ... 71 more Suppressed: java.lang.ClassNotFoundException: com.bartoszlipinski.viewpropertyobjectanimator.ViewPropertyObjectAnim ator at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 72 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available FlurryAgent W Error logged: uncaught Flurry session ended

Add Suggestion

How can i add suggestion to this persistent search? for example i want to add array of string and icons

sorry for my english

Search view should be closed on back key

  1. Open the demo app
  2. Tap on the search view to open it
  3. Tap back - keyboard is closed
  4. Tap back again - the application is closed

Expected behaviour:
tapping back when the search view is opened should close the search view, not the application

java.lang.RuntimeException: Parcel android.os.Parcel@3b13f01: Unmarshalling unknown type code 7471204 at offset 944

I'm getting the following error adding the library, can anyone please help me with this? I have not yet implemented any code other than the XML

java.lang.RuntimeException: Unable to start activity ComponentInfo{package.V1.BaseClasses.MainActivity}: java.lang.RuntimeException: Parcel android.os.Parcel@3b13f01: Unmarshalling unknown type code 7471204 at offset 944 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5443) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@3b13f01: Unmarshalling unknown type code 7471204 at offset 944 at android.os.Parcel.readValue(Parcel.java:2340) at android.os.Parcel.readSparseArrayInternal(Parcel.java:2675) at android.os.Parcel.readSparseArray(Parcel.java:1967) at android.os.Parcel.readValue(Parcel.java:2321) at android.os.Parcel.readArrayMapInternal(Parcel.java:2614) at android.os.BaseBundle.unparcel(BaseBundle.java:221) at android.os.Bundle.getSparseParcelableArray(Bundle.java:856) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:997) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1234) at android.support.v4.app.FragmentManagerImpl.dispatchCreate(FragmentManager.java:2041) at android.support.v4.app.FragmentController.dispatchCreate(FragmentController.java:163) at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:331) at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:85) at package.V1.BaseClasses.MainActivity.onCreate(MainActivity.java:58) at android.app.Activity.performCreate(Activity.java:6245) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5443)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 

FloatingSearchView text is white

Hi!

I am trying to implement this cool FloatingSearchView but it just shows me white text when writting! Hint is shown correctly but it seems that the edittext text is in white color. I have tried to styled it without success. Any help?

Thanks very much!

getQuery() not working.

Hi there,

I tried to searchView.getQuery() in FloatingSearchView.OnSearchListener. But it's not working (returns an empty String ""), which is wired. I looked into the source code and can't figure out why.

Some suggestions

Hi again @arimorty!

Just 2 suggestions for some common uses:

  • Could you add the possibility to maintain the query done in the search input, with the X right icon?
    Right now, when you do a search, it clears the input box and I would like to maintain what I searched
  • Could you add also the possibility to avoid the "shadow" when searchbox gain the focus?

Thanks very much!

FloatingSearchView in Toolbar (Google Play like)

Is there a way i can achieve the same behaviour as in the new Google Play Store?
Tried every XML variant but it isnt working for me ( cause it needs to take full height in order to work with suggestions. But then the Toolbar height is full height (cause Search is nested in it))

My concern is on stackoverflow too, but no answers yet. If it is not a productive issue/concern, you can close it. Just curious if someone got it working somehow.

http://stackoverflow.com/questions/34311630/android-floatingsearchview-inside-toolbar

Dynamic leftActionMode

Why is the setLeftActionMode in FloatingSearchView not exposed?
I have a single Activity with Fragments and would be nice if i can use "Home-up/ back arrow" as the left action mode for navigation back to the previous Fragment.

Floating Search View causes RuntimeException when inflating NavigationView in the same activity

I get this error when combining the new material design support library for navigation drawer (Navigation View) with the floating Search View.

Here's my stack trace:

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.robocoders.sampleapp/com.robocoders.sampleapp.ui.activity.MainActivity}: android.view.InflateException: Binary XML file line #242: Error inflating class android.support.design.widget.NavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2521)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
Caused by android.view.InflateException: Binary XML file line #242: Error inflating class android.support.design.widget.NavigationView
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at com.robocoders.sampleapp.ui.activity.MainActivity.onCreate(MainActivity.java:101)
at android.app.Activity.performCreate(Activity.java:6092)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
Caused by java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at com.robocoders.sampleapp.ui.activity.MainActivity.onCreate(MainActivity.java:101)
at android.app.Activity.performCreate(Activity.java:6092)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
Caused by java.lang.NoClassDefFoundError: android.support.design.internal.NavigationMenuPresenter
at android.support.design.widget.NavigationView.(NavigationView.java:80)
at android.support.design.widget.NavigationView.(NavigationView.java:92)
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at com.iconway.padi.ui.activity.MainActivity.onCreate(MainActivity.java:101)
at android.app.Activity.performCreate(Activity.java:6092)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)

Keyboard covers whole screen in landscape mode

  1. Open the demo app in landscape mode
  2. Open the keyboard

Result: Keyboard covers the whole screen and no suggestions are visible.
Cause: the EditText doesn't have the flag EditorInfo.IME_FLAG_NO_EXTRACT_UI (it should be set in xml: android:imeOptions="actionSearch|flagNoExtractUi")

Fix weird log

I saw a weird log showing up in my LogCat and traced it on your repo to FloatingSearchView:1156

    int fiveDp = Util.dpToPx(6);
    int threeDp = Util.dpToPx(3);
    ViewCompat.animate(mSuggestionListContainer).cancel();
    float translationY = (-mSuggestionListContainer.getHeight())+getVisibleItemsHeight(newSearchSuggestions);

    Log.d("dfsdfsdff", translationY+"");
    //todo refactor go over and make more clear
    final float newTranslationY = (translationY+fiveDp)<0 ?
            newSearchSuggestions.size()==0 ? translationY : translationY+threeDp
            : -fiveDp;

I would make a PR but this seems like something you can change on your local development branch and it can be pushed whenever you push next. Doesn't seem troubling enough to hurry.

SearchView crashes when the activity is restored

  1. Turn on the developer option "don't keep activities"
  2. Open the demo app
  3. Type "a"
  4. Press the home key to return to the home screen
  5. Go back to the demo app

The app crashes:

Process: com.arlib.floatingsearchviewdemo, PID: 31704 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.arlib.floatingsearchviewdemo/com.arlib.floatingsearchviewdemo.MainActivity}: java.lang.RuntimeException: Parcel android.os.Parcel@de9ab18: Unmarshalling unknown type code 6619246 at offset 972 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@de9ab18: Unmarshalling unknown type code 6619246 at offset 972 at android.os.Parcel.readValue(Parcel.java:2340) at android.os.Parcel.readSparseArrayInternal(Parcel.java:2675) at android.os.Parcel.readSparseArray(Parcel.java:1967) at android.os.Parcel.readValue(Parcel.java:2321) at android.os.Parcel.readArrayMapInternal(Parcel.java:2614) at android.os.BaseBundle.unparcel(BaseBundle.java:221) at android.os.Bundle.getSparseParcelableArray(Bundle.java:856) at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2033) at android.app.Activity.onRestoreInstanceState(Activity.java:1008) at android.app.Activity.performRestoreInstanceState(Activity.java:963) at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1163) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2389) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

Array index out of bounds exception

Hi! I've implemented your library in my proj and when I click somewhere outside of search box, it crashes with ArrayIndexOutOfBoundsException in MenuView. Here is the stacktrace:

java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
                   at android.animation.AnimatorSet.playTogether(AnimatorSet.java:142)
                   at com.arlib.floatingsearchview.util.view.MenuView.showIfRoomItems(MenuView.java:506)
                   at com.arlib.floatingsearchview.FloatingSearchView.setSearchFocusedInternal(FloatingSearchView.java:1361)
                   at com.arlib.floatingsearchview.FloatingSearchView.access$1500(FloatingSearchView.java:87)
                   at com.arlib.floatingsearchview.FloatingSearchView$23.onTouch(FloatingSearchView.java:1657)
                   at android.view.View.dispatchTouchEvent(View.java:8382)

onSearchAction() not working

Hello,
I love your project and i'm using it. I have a big issue, i cannot search by onSearchAction listener it never enters in it. Therefore, i have to use onFocusCleared method but it gives me lots of bugs such as, if i give up to search and click anywhere it still search on it because of the focusClear can you help me about this issue.

Thank you so much.

Question

Hi,

There is a way to hide the suggestion panel ? Because I don't want to use it and click on it remove my current query. Can we avoid this and keep the query ?

Samy

Is menu open?

It would be nice to have an mySearchView.isMenuOpen() function, thanks in advance for the attention ;)

Right to left support

Hello,Tnx for your nice library. I've got a question.
The library is working is right in left to right languages.
But if the input language is changed to a rtl language like Persian, although text goes to right,

But the query is shown under the clear button. I submit a screen shot for you.
How do I solve this problem.

device-2016-03-12-191337

Menu item voice showAsAction="always" icon disappears(alpha = 0)

Somehow after clicking on voice action item, clearing focus from searchView, showing suggestions, clearing suggestions and clicking again on voice action menu item the menu item disappears.
The button is there because when I click on it the selector appears but the button doesn't because it has alpha = 0.
How can I circumvent this problem?
Thanks.

Floating search view assumes that view is always called from activity

Hey Airmorty,

Your lib looks great! I want to use it in my upcoming project work.
However I am not able to use your lib as of now as It crashes on me when I try to inflate the view. When I looked into your source code its accessing activity. I feel custom view should be activity / fragment agnostic!
In my opinion if the custom view is doing more than a view should do then that responsibility should be given back to caller of this custom view.
Let me know your thoughts!

Caused by: java.lang.ClassCastException: android.view.ContextThemeWrapper cannot be cast to android.app.Activity at
com.arlib.floatingsearchview.FloatingSearchView.setupQueryBar(FloatingSearchView.java:454)

Thanks!
Manju

crash while playing with menu items

Hey Ari,

Take a look at this crash whenever you can. Crashed on me while playing around with menu item configurations.

java.lang.NullPointerException: Attempt to invoke virtual method 'float android.view.View.getTranslationX()' on a null object reference at com.arlib.floatingsearchview.util.view.MenuView.showIfRoomItems(MenuView.java:422) at com.arlib.floatingsearchview.FloatingSearchView.setSearchFocusedInternal(FloatingSearchView.java:1353) at com.arlib.floatingsearchview.FloatingSearchView.access$1500(FloatingSearchView.java:87) at com.arlib.floatingsearchview.FloatingSearchView$13.onItemSelected(FloatingSearchView.java:1095) at com.arlib.floatingsearchview.suggestions.SearchSuggestionsAdapter$1.onItemClicked(SearchSuggestionsAdapter.java:186) at com.arlib.floatingsearchview.suggestions.SearchSuggestionsAdapter$SearchSuggestionViewHolder$2.onClick(SearchSuggestionsAdapter.java:145) at android.view.View.performClick(View.java:4780)

Thanks!
Manju

How to Handle Voice Search?

Thank you for the great SearchView.

I am having a problem with Voice Search. Your sample application does not include its working. Could you please explain its implementation?

Search Results not correct

I somehow editted your sample code and used it with ArrayList and its working fine. But my problem is that, its not showing suggestions if I start typing a word from in between of it.
For Example...
ArrayList contains "abc", "abcd", "bcd" (without inverted commas)
Now, if I type "bc" its showing me only "bcd" and not the 1st two
How can I fix this ?

showSearchHintWhenNotFocused attribute is missing

It seems that the attribute "app:floatingSearch_showSearchHintWhenNotFocused" does not exist anymore. How can I set hint text hidden when searchview is not focused? I still want to see my search text even when focus is gone.

Touch problem in Microphone and X icons

Hi!

Just to let you know that I am seeing a weird behaviour in those icons when setting a floating search view like this:

<com.arlib.floatingsearchview.FloatingSearchView
android:id="@+id/floating_search_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:floatingSearch_searchBarMarginLeft="10dp"
app:floatingSearch_searchBarMarginTop="10dp"
app:floatingSearch_searchBarMarginRight="10dp"
app:floatingSearch_showMenuAction="false"
app:floatingSearch_searchHint="Search..."
app:floatingSearch_voiceRecHint="Say something..."
app:floatingSearch_showSearchHintWhenNotFocused="true"
app:floatingSearch_showVoiceInput="true"
app:floatingSearch_showOverFlowMenu="false"
app:floatingSearch_hideOverflowMenuWhenFocused="false"
app:floatingSearch_showSearchKey="true"
app:floatingSearch_dismissOnOutsideTouch="true"/>

The problem is that the right icon (microphone or x icon if you have written something) are very difficult to click. Something weird I think but sure you can solved it for next version ;)

Keep the good work!

Thanks!

Allow for scrolling suggestions without closing the keyboard

  1. Open the demo app
  2. Type "s"
  3. Start scrolling suggestions

Result: keyboard is closed.

I think that this is not a desired behaviour. On modern devices a user has usually enough space for suggestions even if the keyboard is opened and closing it adds an additional step if a user wants to continue typing.
If you don't agree with it, I think there should be at least an option for configuring this feature in the library, so that the client app can decide which behaviour is preferred.

Question: FloatingSearchView behavior with RecyclerView

Hi, Good Morning. I'm using the FloatingSearchView on a Activity that has a RecyclerView. I'm having trouble doing two things:

  1. Defining a behavior to hide it when an user scroll the RecyclerView?
  2. How to separate a space at the top of the screen so that the SearchView not get over the first item in the list? And allow to scroll to the items to be played below the SearchView?

Sorry for my English. Thanks!

After click search button, attr "showSearchKey" back to "false"

Hi guy,
I set "showSearchKey" attr = "true". But it only effects on first typing, but when I clicked search action button, seem it back to "false". Because I found that when I focus on edit-text, current typing text was not shown and back to empty.
Why not?
I want to set showSearchKey attr always effect. Why can I do that? Please help.

lefe menu color not change

DrawableCompat.setTint(mIconBackArrow.mutate(), color);
DrawableCompat.setTint(mIconSearch.mutate(), color);

fix this work

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.