SearchView


Source link: https://github.com/lapism/SearchView

SearchView

Persistent SearchView Library from Play Store.
Features: Material Design, Toolbar/MenuItem version, History, Styling.

Google Material Design Pattern:
https://material.io/guidelines/patterns/search.html

Version History:
https://bintray.com/lapism/maven/searchview/view

Material colors in the project:
https://gist.github.com/lapism/3b417142300d9dbde3b4

Donations:

Please support me!


Apps using this library:
Because I have done firstly this library as a private project, I would like to know if someone of you use my library in your application. If yes, please send me the name of your app and the link to Play Store and I will promote your app in ReadMe.

Service Notes
Business Card Reader
Toiletto
Zikobot
AllWeather
Karaoke Online Sing & Record
Playbuzz
MovieTracker
MaxTorz
RealTime Subscriber YouTube
Lucidity - Lucid Dream Journal
Guide COC


Usage

Add the dependencies to your gradle file:

dependencies {

  implementation 'com.lapism:searchview:5.0.0-alpha7'

 implementation 'com.android.support:cardview-v7:26.1.0'
  implementation 'com.google.android:flexbox:0.3.1' 
}

Versions:

SearchView identifies its layout style through versions. Currently, there are two values, namely SearchView.Version.TOOLBAR for the persistent view, and SearchView.Version.MENU_ITEM for the view that appears on a MenuItem press. The version can be defined through setVersion.

SearchView.Version.MENU_ITEM and SearchView.Version.TOOLBAR:

SearchHistoryTable mHistoryDatabase = new SearchHistoryTable(this);
  SearchView mSearchView = (SearchView) findViewById(R.id.searchView);
 // to API 25 SearchView mSearchView = findViewById(R.id.searchView);
 // from API 26 if (mSearchView != null) {

  mSearchView.setVersionMargins(SearchView.VersionMargins.TOOLBAR_SMALL);

  mSearchView.setHint(R.string.search);

  mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

@Override

public boolean onQueryTextSubmit(String query) {

 mHistoryDatabase.addItem(new SearchItem(query));

 mSearchView.close(false);

 return true;

}

 @Override

public boolean onQueryTextChange(String newText) {

 return false;

}

  
}
);

  mSearchView.setOnOpenCloseListener(new SearchView.OnOpenCloseListener() {

@Override

public boolean onOpen() {

 if (mFab != null) {

  mFab.hide();

 
}

 return true;

}

 @Override

public boolean onClose() {

 if (mFab != null && !mDrawerLayout.isDrawerOpen(GravityCompat.START)) {

  mFab.show();

 
}

 return true;

}

  
}
);

  mSearchView.setVoiceText("Set permission on Android 6.0+ !");

  searchView.setOnVoiceIconClickListener(new SearchView.OnVoiceIconClickListener() {

@Override

public void onVoiceIconClick() {

 // permission

}

  
}
);

List<SearchItem> suggestionsList = new ArrayList<>();

  suggestionsList.add(new SearchItem("search1"));

  suggestionsList.add(new SearchItem("search2"));

  suggestionsList.add(new SearchItem("search3"));

SearchAdapter searchAdapter = new SearchAdapter(this, suggestionsList);

  searchAdapter.setOnSearchItemClickListener(new SearchAdapter.OnSearchItemClickListener() {

@Override

public void onSearchItemClick(View view, int position, String text) {

 mHistoryDatabase.addItem(new SearchItem(text));

 mSearchView.close(false);

}

  
}
);

  mSearchView.setAdapter(searchAdapter);

suggestionsList.add(new SearchItem("search1"));

  suggestionsList.add(new SearchItem("search2"));

  suggestionsList.add(new SearchItem("search3"));

  searchAdapter.notifyDataSetChanged();

List<SearchFilter> filter = new ArrayList<>();

  filter.add(new SearchFilter("Filter1", true));

  filter.add(new SearchFilter("Filter2", true));

  mSearchView.setFilters(filter);

  //use mSearchView.getFiltersStates() to consider filter when performing search 
}

SearchView.Version.MENU_ITEM:

@Override public boolean onOptionsItemSelected(MenuItem item) {

  switch (item.getItemId()) {

case R.id.action_search: {

 mSearchView.open(true/false);
 // enable or disable animation

 return true;

}

default:

 return super.onOptionsItemSelected(item);

  
}
 
}

XML:

<com.lapism.searchview.SearchView
  android:id="@+id/searchView"
  android:layout_width="match_parent"
  android:layout_height="match_parent" />

 // will be new

XML with CoordinatorLayout:

<com.lapism.searchview.SearchView
  android:id="@+id/searchView"
  android:layout_width="match_parent"
  android:layout_height="match_parent"

app:layout_behavior="com.lapism.searchview.SearchBehavior" />

// will be new

Styling SearchView:

<attr name="search_version" format="enum">
  <enum name="toolbar" value="1000" />
  <enum name="menu_item" value="1001" /> </attr> <attr name="search_version_margins" format="enum">
  <enum name="toolbar_small" value="2000" />
  <enum name="toolbar_big" value="2001" />
  <enum name="menu_item" value="2002" /> </attr> <attr name="search_theme" format="enum">
  <enum name="light" value="3000" />
  <enum name="dark" value="3001" />
  <enum name="play_store" value="3002" /> </attr> <attr name="search_height" format="dimension" /> <attr name="search_navigation_icon" format="integer" /> <attr name="search_icon_color" format="color" /> <attr name="search_background_color" format="color" /> <attr name="search_text_color" format="color" /> <attr name="search_text_highlight_color" format="color" /> <attr name="search_text_size" format="dimension" /> <attr name="search_text_style" format="enum">
  <enum name="normal" value="0" />
  <enum name="bold" value="1" />
  <enum name="italic" value="2" />
  <enum name="bold_italic" value="3" /> </attr> <attr name="search_hint" format="string" /> <attr name="search_hint_color" format="color" /> <attr name="search_voice" format="boolean" /> <attr name="search_voice_text" format="string" /> <attr name="search_animation_duration" format="integer" /> <attr name="search_shadow" format="boolean" /> <attr name="search_shadow_color" format="boolean" /> <attr name="search_elevation" format="dimension" /> <attr name="search_clear_on_open" format="boolean" /> <attr name="search_clear_on_close" format="boolean" /> <attr name="search_hide_on_keyboard_close" format="boolean" /> <attr name="search_show_progress" format="boolean" /> <attr name="search_cursor_drawable" format="integer" />

Resources

Chameleon is a CSS like framework for Android. Chameleon can read styles in JSON format and apply them on views in Android. Not only can you choose from the variety of styles provided by the library but also add your own styles by changing just one file.

The icing on the cake is, once set up, themes can be updated without pushing a new version of your app to the playstore. So, your users can see your changes on the fly.

An android wrapper for openweathermap that uses Retrofit 2 under the hood.

You need an API Key to use the OpenWeatherMap API. Head on over to their website if you don't already have one.

Features

Get Current weather by:

  1. City Name
  2. City ID
  3. Geographic Coordinates
  4. Zip Code

Custom views of NestedScrollingChild class.

Logging value of object in a short and pretty way.

  • Don't need to define TAG, It is automatically generated by FileName - ClassName - Method - [Message] Object (Value)
  • Log all field and value of given object

This is small library with few annotations and processors that will generate all RecyclerView.Adapters stuff that you need with only few lines of annotations.

Advanced Sms Manager is library for sending sms for single and two sim-card phones. it is very handy and usefull.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes