All Projects → mirrajabi → Search Dialog

mirrajabi / Search Dialog

Licence: apache-2.0
An easy to use, yet very customizable search dialog

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Search Dialog

CustomPermissionsDialogue
Custom Permissions Dialogue is the only permissions library that supports ALL permission request scenarios. This library handles multiple edge cases such as not enabling all permissions or permanently rejecting a permission request.
Stars: ✭ 51 (-89.86%)
Mutual labels:  dialog, popup
Instantsearch Ios
⚡️ A library of widgets and helpers to build instant-search applications on iOS.
Stars: ✭ 498 (-0.99%)
Mutual labels:  search, search-interface
BalloonPopup
Forget Android Toast! BalloonPopup displays a round or squared popup and attaches it to a View, like a callout. Uses the Builder pattern for maximum ease. The popup can automatically hide and can persist when the value is updated.
Stars: ✭ 32 (-93.64%)
Mutual labels:  dialog, popup
react-redux-modal-flex
[DEPRECATED] Make easy a modal/popup with Redux
Stars: ✭ 14 (-97.22%)
Mutual labels:  dialog, popup
Popupdialog
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.
Stars: ✭ 3,709 (+637.38%)
Mutual labels:  dialog, popup
mac-ibm-notifications
macOS agent used to display custom notifications and alerts to the end user.
Stars: ✭ 206 (-59.05%)
Mutual labels:  dialog, popup
Longpresspopup
Make a Popup appear long pressing on a view and handle drag-release events on its elements
Stars: ✭ 256 (-49.11%)
Mutual labels:  dialog, popup
react-spring-bottom-sheet
Accessible ♿️, Delightful ✨, & Fast 🚀
Stars: ✭ 604 (+20.08%)
Mutual labels:  dialog, popup
Aestheticdialogs
📱 An Android Library for 💫fluid, 😍beautiful, 🎨custom Dialogs.
Stars: ✭ 352 (-30.02%)
Mutual labels:  dialog, popup
Calaca
Search UI for Elasticsearch
Stars: ✭ 318 (-36.78%)
Mutual labels:  search, search-interface
eins-modal
Simple to use modal / alert / dialog / popup. Created with pure JS. No javascript knowledge required! Works on every browser and device! IE9
Stars: ✭ 30 (-94.04%)
Mutual labels:  dialog, popup
React Native Awesome Alerts
Awesome alerts for React Native, works with iOS and Android.
Stars: ✭ 391 (-22.27%)
Mutual labels:  dialog, popup
vue-dialog
A drag-able dialog for Vue.js
Stars: ✭ 21 (-95.83%)
Mutual labels:  dialog, popup
plain-modal
The simple library for customizable modal window.
Stars: ✭ 21 (-95.83%)
Mutual labels:  dialog, popup
vue-modal
A customizable, stackable, and lightweight modal component for Vue.
Stars: ✭ 96 (-80.91%)
Mutual labels:  dialog, popup
Razor.SweetAlert2
A Razor class library for interacting with SweetAlert2
Stars: ✭ 98 (-80.52%)
Mutual labels:  dialog, popup
LSDialogViewController
Custom Dialog for iOS written in Swift
Stars: ✭ 74 (-85.29%)
Mutual labels:  dialog, popup
vue-modal
Reusable Modal component, supports own custom HTML, text and classes.
Stars: ✭ 29 (-94.23%)
Mutual labels:  dialog, popup
Vue Ydui
A mobile components Library with Vue2.js. 一只基于Vue2.x的移动端组件库。
Stars: ✭ 2,798 (+456.26%)
Mutual labels:  dialog, popup
Open Semantic Search
Open Source research tool to search, browse, analyze and explore large document collections by Semantic Search Engine and Open Source Text Mining & Text Analytics platform (Integrates ETL for document processing, OCR for images & PDF, named entity recognition for persons, organizations & locations, metadata management by thesaurus & ontologies, search user interface & search apps for fulltext search, faceted search & knowledge graph)
Stars: ✭ 386 (-23.26%)
Mutual labels:  search, search-interface

search-dialog

An awesome and customizable search dialog with built-in search options.

search_dialog

Usage

First add jitpack to your projects build.gradle file

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
   	}
}

Then add the dependency in modules build.gradle file

dependencies {
    implementation 'com.github.mirrajabi:search-dialog:1.2.4'
}

Simple usage

if you just want to use the simple search dialog first you need to provide searchable items. to achieve this you should implement Searchable in your model.

you can see the SampleSearchModel for example :

public class SampleSearchModel implements Searchable {
    private String mTitle;

    public SampleSearchModel(String title) {
        mTitle = title;
    }

    @Override
    public String getTitle() {
        return mTitle;
    }

    public SampleSearchModel setTitle(String title) {
        mTitle = title;
        return this;
    }
}

now generate some search options in your activity :

    private ArrayList<SampleSearchModel> createSampleData(){
        ArrayList<SampleSearchModel> items = new ArrayList<>();
        items.add(new SampleSearchModel("First item"));
        items.add(new SampleSearchModel("Second item"));
        items.add(new SampleSearchModel("Third item"));
        items.add(new SampleSearchModel("The ultimate item"));
        items.add(new SampleSearchModel("Last item"));
        items.add(new SampleSearchModel("Lorem ipsum"));
        items.add(new SampleSearchModel("Dolor sit"));
        items.add(new SampleSearchModel("Some random word"));
        items.add(new SampleSearchModel("guess who's back"));
        return items;
    }

then you just need to add the below lines where you want to show the dialog :

new SimpleSearchDialogCompat(MainActivity.this, "Search...",
                        "What are you looking for...?", null, createSampleData(),
                        new SearchResultListener<SampleSearchModel>() {
                            @Override
                            public void onSelected(BaseSearchDialogCompat dialog,
                                                   SampleSearchModel item, int position) {
                                // If filtering is enabled, [position] is the index of the item in the filtered result, not in the unfiltered source
                                Toast.makeText(MainActivity.this, item.getTitle(),
                                        Toast.LENGTH_SHORT).show();
                                dialog.dismiss();
                            }
                        }).show();

The constructor parameters are

SimpleSearchDialogCompat(Context context, String title, String searchHint,
                                    @Nullable Filter filter, ArrayList<T> items,
                                    SearchResultListener<T> searchResultListener)

Loading view(added to SimpleSearchDialogCompat in v1.1)

Just use setLoading(true) for showing and setLoading(false) for hiding it on an instance of SimpleSearchDialogCompat

Changing default adapters text colors(added in v1.2.1)

If you want to change the default colors just override these colors in your colors.xml or wherever you want like this.

    <color name="searchDialogResultColor"/>
    <color name="searchDialogResultHighlightColor"/>

Advanced usage

The layout

I used this layout for simple search dialog but you can use anything else. Of course your layout should have thse two views :

  • An EditText to use as search key input
  • A RecyclerView for showing the results in it

The search dialog

You can use your custom layouts, adapters and search options by creating a class inheriting the BaseSearchDialogCompat take a look at SimpleSearchDialogCompat to see an example of how it can be done You should implement the BaseSearchDialogCompat methods :

    // handle your view with this one
    protected abstract void getView(View view);
    // Id of your custom layout
    @LayoutRes protected abstract int getLayoutResId();
    // Id of the search edittext you used in your custom layout
    @IdRes protected abstract int getSearchBoxId();
    // Id of the recyclerview you used in your custom layout
    @IdRes protected abstract int getRecyclerViewId();

The search filter

You can use your custom filters for text searching. The one used in SimpleSearchDialogCompat is SimpleSearchFilter. It checks the search key and if an item and the key had partially exact same letters it will add that item to results and also if the CheckLCS was set to true, it will check if the amount of matching letters was bigger than the given AccuracyPercentage the item will be added to results

The adapter

the one used in SimpleSearchDialogCompat is so simple despite its too long. the main functionality is in initializeViews method. you can create your custom adapters and use it instead of this one

The StringsHelper

it has two methods which you can use for highlighting the results.

/*
 * Returns a SpannableString with 
 * highlighted LCS(Longest Common Subsequence)
 * of two strings with the givven color
 */
SpannableStringBuilder highlightLCS(String text1, String text2, int highlightColor);

// Returns the LCS(Longest Common Subsequence) of two strings
String lcs(String text1, String text2) 

See the sample app to get a better understanding of the advanced usage

Used in sample app

Changelog

1.2.4 - Added an option to SimpleSearchDialogCompat so that the dialog cancellation on touching outside the dialog can be customized.

1.2.3 - Changed minSdkVersion to 14. Added getter for the title textview of simple search dialog. Improved results sorting.

1.2.2 - Gradle tools version and dependencies were updated.

1.2.1 - Added an option for changing text color and highlight color of default adapter.

1.2 - Added getter for views in simple search dialog and an option to turn off the auto filtering on search edittext.

1.1.1 - Fixes drawable overriding issue.

1.1 - Added loading feature.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].