Popularity
0.5
Growing
Activity
2.3
-
5
0
1

Description

An Android UI library that allows easy implementation of (text) input suggestion popup windows.

Programming language: Kotlin
License: GNU General Public License v3.0 only
Tags: Kotlin     Adapter     RecyclerView     Android     Views     Autocomplete     Suggestions    

Suggestive ๐ŸŒ alternatives and similar packages

Based on the "Adapter" category.
Alternatively, view Suggestive ๐ŸŒ alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Suggestive ๐ŸŒ or a related project?

Add another 'Adapter' Package

README

Suggestive ๐ŸŒ

An Android UI library that allows easy implementation of (text) input suggestion popup windows.

  • Implement filtering using the onQuery callback
  • Creates suggestion popups from RecyclerView adapters
  • Creates suggestion popups from any View
  • Works and animates well with soft keyboard visibility changes
  • Automatically closes on back press if hosted in an AppCompatActivity

Gradle

Include the Bintray JCenter repository in the root build.gradle:

allprojects {
    repositories {
        maven {
            url  "https://jcenter.bintray.com"
        }
    }
}

Add the dependency to app build.gradle:

dependencies {
    implementation 'dev.xtr.suggestive:suggestive:1.0.3'
}

Sample

Create a suggestion popup from a recycler adapter
To create a popup window of a RecyclerView use Suggestive.recycler().
All named arguments are optional and set to their default in this sample.

// Create a suggestion popup containing a recycler view
Suggestive.recycler(

    // anchor to queryEditText
    queryEditText,

    // use the recycler view adapter
    adapter,

    // only invoke onQuery at a minimum input of 3 characters
    minCharacters = 3,

    // attaches the text change listener that invokes [onQuery]
    attachTextChangeListener = true,

    // invoke onQuery with a minimum delay of 200 ms
    onQueryThrottle = 200,

    // align the popup to the start of the anchor view
    gravity = Gravity.START,

    // use the background drawable for the popup window background
    backgroundDrawable = ContextCompat.getDrawable(this, R.drawable.popup_rounded_bg)!!,

    // constrains the popup windows width to the width of anchor
    constrainWidthToAnchorBounds = true,

    // hide the popup window when anchor loses focus
    hideOnBlur = true,

    // show the popup above or below anchor based on available space around anchor
    preferredPosition = SuggestionWindow.PreferredPosition.BEST_FIT,

    // dismisses the popup when the back button is pressed
    dismissOnBackPress = true,

    // the input query callback, called for every text change event on anchor
    //  (with exclusions as mandated by the minCharacters and onQueryThrottle options)
    onQuery = { query ->
    vm.search(query)
})

Create a suggestion popup from a view
To create a popup window of a view use Suggestive.view(), this method takes the same arguments as recycler().

val view: View = //...
Suggestive.view(anchorView, view)

Manipulate the popup manually
Both factory methods on the Suggestive object return instances of SuggestionWindow.
Use methods on this object to manipulate the popup manually:

val popup = Suggestive.view(anchorView, view)
popup.show() // popup.isHidden = true
popup.hide() // popup.isHidden = false
popup.requestLayout() // relayout the popup content view

Demo

See the demo gif below or try it out on Google Play:

[Suggestive Demo GIF](demo.gif)

Used By

Stockfix - Notification Drawer Stock Monitor