Giter VIP home page Giter VIP logo

realm-searchview's Introduction

A Search View with Result list powered by Realm

A simple and powerful EditText and RecyclerView UI component. It's build on top of RealmRecyclerView and RealmBasedRecyclerViewAdapter.

It's easily customizable via layout attributes and adapter parameters.

##How To Include It:

	repositories {
        // ...
        maven { url "https://jitpack.io" }
    }
	dependencies {
	        compile 'com.github.thorbenprimke:realm-searchview:0.9.6'
	}

##Demo

Screenshot

How To Get Started:

The RealmSearchView is a wrapper around a EditText and RealmRecyclerView. The RealmSearchAdapter has added functionality for the filtering of the Realm.

##RealmSearchView

The snippet below shows how to include the RealmSearchView in your layout file.

    <co.moonmonkeylabs.realmsearchview.RealmSearchView
        android:id="@+id/search_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:rsvHint="@string/search_hint"
        />

The RealmSearchView can be with two attributes:

  • rsvHint: This is the search box hint. It a string reference.

  • rsvClearDrawable: This is for the clear drawable. It's a drawable reference.

##RealmSearchAdapter

The adapter does all the filtering. The following list of parameters are available to customize the filtering.

  • filterKey: The filterKey is required as it is the columnName that the results are filtered by.

  • useContains: If true, uses contains, otherwise uses beginsWith.

  • useCaseSensitive: If true, ensures that the filter is respecting casing. If false, ignores any casing.

  • sortAscending: If true, ascending, otherwise descending.

  • sortKey: The columnName by which the results should be sorted.

  • basePredicate: The basePredicate is used to filter the results whenever the searchBar is empty.

The RealmSearchAdapter has two constructors. One that only takes the filterKey parameter and one that takes all parameters. In addition, the adapter has to be provided with a valid instance of Realm. It is used throughout the life of view to requery the results.

##Feedback/More Features: I would love to hear your feedback. Do you find the RealmSearchView useful? What functionality are you missing? Open a Github issue and let me know. Thanks!

License

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.

Included dependencies are:
Realm (https://github.com/realm/realm-java)
realm-recyclerview (https://github.com/thorbenprimke/realm-recyclerview)
In Example:
Jackson (https://github.com/FasterXML/jackson-databind/)
Butterknife (https://github.com/JakeWharton/butterknife)

realm-searchview's People

Contributors

sirrah avatar thorbenprimke 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

realm-searchview's Issues

Filter data by property

Hi, I have a question. When I'm populating my data with my Contact model, my filter key is "name". But I want to search only by property isFavorite == true - not all contacts. How can i achieve that with the RealmSearchAdapter?

And how does the basePredicate property works?

Thanks! :)

Unable to access internal EditText

I'm unable as of now to access and change the behavior of the internal EditText. Examples of What usual customizations:
setOnEditorActionListener
addTextChangedListener

Btw, thank you so much for the library. I'm using it as a replacement for AutoCompleteTextView which is broken on realm.

Error:Execution failed for task ':app:transformClassesWithRealmTransformerForDebug'. > javassist.CannotCompileException: [source error] realm$injectObjectContext() not found in io.realm.internal.RealmObjectProxy

I cannot compile my project with the 'com.github.thorbenprimke:realm-searchview:0.9.6' together with BottomNavigationBar. Afaik the searchview compiles with recyclerviews from the 23 release, and the BottomNavigationBar was released in the 25 library.

This is my gradle:

apply plugin: 'com.android.application'
apply plugin: 'realm-android'

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.admin.realmtest"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
}
}

realm{
syncEnabled = true;
}

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

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support:support-vector-drawable:26.+'
compile 'com.android.support:support-v4:26.+'
testCompile 'junit:junit:4.12'
androidTestCompile('com.google.code.findbugs:jsr305:3.0.1')
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'io.realm:android-adapters:2.0.0'
compile 'com.github.thorbenprimke:realm-searchview:0.9.6'
compile 'com.android.support:recyclerview-v7:26.+'

}

Dublicate file exeption

Hey Torben.

Iam using your searchview ( compile 'com.github.thorbenprimke:realm-searchview:0.9.4' ) in my app project, while also using the Realm plugin.
Iam using the Realm plugin 1.1.0 like the version in searchview?.

When building the apk iam getting the DublicateFileExpetion due to multible .so files.
If i use
packagingOptions {
pickFirst("lib/armeabi/librealm-jni.so")
...
}
I can build the apk, but during runtime i get a java.lang.AbstractMethodError: abstract method "io.realm.RealmObject io.realm.internal.RealmProxyMediator.copyOrUpdate(io.realm.Realm, io.realm.RealmObject, boolean, java.util.Map)".

Have any clues to why this happens? Iam assuming that i should still use the plugin while importing searchview?

Support for of Model subset

Thanks for this great library.

It would be great if you could consider the following use case for inclusion in an upcoming release.

For example: take a Realm model Vehicles, with an Attribute Type which says if the object is a Car, Motorcycle, Truck.

We would like to display an activity containing a RealmSearchView to allow searching only the Cars from this model. To do this there would need to be a way of adding another condition to the RealmQuery for the required attribute.

I have created a fork with the changes that I have made for my own project to satisfy this use case.
HarvestYield@3ccd3ee
(please ignore the deletion of RealmSearchView.java in that commit)

How to use it without a filter key

HI Thorben,

You mentioned in your readme that realmsearchadapter can accept without any filter key. I've tried checking around and even asked SO but I didn't see how I can instantiate that adapter without the filter key. Is it possible to do it without filter key?

Search on multiple columnnames

First of all, great work! It's a pleasure to work with!
Maybe in a next update you can add an option so users are able to search in multiple columns at the same time? Looked into your source code and saw it doesn't work, but it can come in very handy I think.

For example, I have a realm database with stores (store names, addresses,...) and I want one search field where users can simultaneously search for names and cities for example.

ClassCastException when scrolling fast

If I scroll slowly, all works fine. When I scroll quickly, I get the following exception:

java.lang.ClassCastException: io.realm.RealmViewHolder cannot be cast to usmaan.myapp.fragment.question.mine.SelectBackgroundsActivity$BackgroundRecyclerViewAdapter$ViewHolder at usmaan.myapp.fragment.question.mine.SelectBackgroundsActivity$BackgroundRecyclerViewAdapter.onBindRealmViewHolder(SelectBackgroundsActivity.java:312)

And line 312 is simply the class signature:

public class BackgroundRecyclerViewAdapter extends RealmSearchAdapter<BackgroundString, BackgroundRecyclerViewAdapter.ViewHolder>

Allow automatic updates from Realm

Currently, the RealmSearchAdapter overrides RealmBasedRecyclerViewAdapter and always passes false to autoUpdate (third parameter).

public RealmSearchAdapter(@NonNull Context context, @NonNull Realm realm, @NonNull String filterKey, boolean useContains, Case casing, Sort sortOrder, String sortKey, String basePredicate) {
        super(context, (RealmResults)null, false, false);
        ...
    }

It would be nice to add this as another customizable feature.

How to cancel alphabetical sorting?

I have tried to pass null parameter to a couple of methods like setSortKey, setFilterKey, setSortOrder but it made no difference. I want to show data in the order i am adding it to my Realm data base.

I want to add RTL support

I want to make searchview RTL . should I modify library and recreate the library or is it possible
to do in my code without touching library

Filter follow many columns

i saw it very useful lib but how about filter many columns and sort it by some conditions such as firstColumn is "DESC" and secondColumn is "ASC".

Customisability

I would like my search input to be a separate element to the results element.

I need input to come from a text view at the top of my fragment, and the results to be displayed underneath a header in a different part of the view.

From what I can tell the input / results elements are tightly joined, I have been unable to customise them so far.

Make it sort by their position in the database (chronologically).

I want the results sorted chronologically. I've not specified a sorting parameter, this seems to be happening either on default, or based on the filterKey specified for search. Is it possible to make it sort by position? The workaround I'm currently using is to make a position column in the database and sort it by that column,. Although it's 100% guaranteed to work, I'd rather not do that.

Edit: just looked into the source code. Seems like it's sorting by the filterKey indeed.

can't search inside realmobject with different properties values

i have realm object
contains different categories

class Category extends RealmObject {
    @PrimaryKey
   int id ;
   String title ;
   RealmList<Category>subcategories;
   int parentID ;
}

how can i search inside a Category Class with specific parentID value using searchview adapter ?

Failed to resolve: annotationProcessor

I am unable to sync gradle dependencies after adding jitpack to the Project build.gradle and compile 'com.github.thorbenprimke:realm-searchview:0.9.6' to the Module build.gradle file. I get and error: Failed to resolve: annotationProcessor.

I'm using gradle 2.2.2 and realm plugin 2.2.1

Thanks!

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.