-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4523df
commit 9ac0af8
Showing
59 changed files
with
1,860 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,142 @@ | ||
# SearchableSpinner | ||
# Searchable Spinner | ||
|
||
![](SampleImages/gif_01.gif) ![](SampleImages/gif_02.gif) | ||
![](SampleImages/image_01.png) ![](SampleImages/image_02.png) | ||
|
||
## Installation | ||
|
||
#### 1). Add it in your root build.gradle: | ||
``` | ||
allprojects { | ||
repositories { | ||
... | ||
maven { url 'https://jitpack.io' } | ||
} | ||
} | ||
``` | ||
#### 2). Add this to your module's build.gradle: | ||
``` | ||
dependencies { | ||
implementation 'com.github.leoncydsilva:SearchableSpinner:$latestSearchableSpinnerVesion' | ||
} | ||
``` | ||
##### Latest MaterialSearchVeiw version is [![](https://jitpack.io/v/leoncydsilva/SearchableSpinner.svg)](https://jitpack.io/#leoncydsilva/SearchableSpinner) | ||
|
||
## Usage Kotlin | ||
|
||
```kotlin | ||
val materialSearchView = MaterialSearchView(this) | ||
|
||
//Optional Parameters | ||
materialSearchView.setBackButtonTint(R.color.colorAccent) | ||
materialSearchView.animationDuration = 1000 | ||
materialSearchView.searchHint = "Search" | ||
materialSearchView.backButtonDrawable = getDrawable(R.drawable.ic_arrow_back) | ||
materialSearchView.clearSearchOnDismiss = false | ||
materialSearchView.showKeyBoardDefault = false | ||
|
||
materialSearchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener { | ||
override fun onQueryTextSubmit(query: String?): Boolean { | ||
Toast.makeText(this@KotlinActivity, query, Toast.LENGTH_SHORT).show() | ||
return false | ||
} | ||
|
||
override fun onQueryTextChange(newText: String?): Boolean { | ||
Toast.makeText(this@KotlinActivity, newText, Toast.LENGTH_SHORT).show() | ||
return false | ||
} | ||
|
||
}) | ||
``` | ||
``` | ||
//Sample usage with toolbar menu | ||
val menu = materialToolbar.menu | ||
menu.findItem(R.id.searchMenuIcon).setOnMenuItemClickListener { | ||
Toast.makeText(this, "Showing Search from ToolbarMenu", Toast.LENGTH_LONG).show() | ||
//The method call where magic happens. | ||
materialSearchView.show(findViewById(R.id.searchMenuIcon));false | ||
} | ||
``` | ||
``` | ||
//Sample usage with ImageView | ||
imageViewSearch.setOnClickListener { | ||
Toast.makeText(this, "Showing Search from ImageView", Toast.LENGTH_LONG).show() | ||
//The method call where magic happens. | ||
materialSearchView.show(it) | ||
} | ||
``` | ||
|
||
## Usage Java | ||
|
||
``` | ||
MaterialToolbar materialToolbar = findViewById(R.id.materialToolbar); | ||
ImageView imageView = findViewById(R.id.imageViewSearch); | ||
final MaterialSearchView materialSearchView = new MaterialSearchView(this); | ||
//Optional Parameters | ||
materialSearchView.setBackButtonTint(R.color.colorAccent); | ||
materialSearchView.setAnimationDuration(1000); | ||
materialSearchView.setSearchHint("Search"); | ||
materialSearchView.setBackButtonDrawable(getDrawable(R.drawable.ic_arrow_back)); | ||
materialSearchView.setClearSearchOnDismiss(false); | ||
materialSearchView.setShowKeyBoardDefault(false); | ||
materialSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { | ||
@Override | ||
public boolean onQueryTextSubmit(String query) { | ||
Toast.makeText(JavaActivity.this, query, Toast.LENGTH_SHORT).show(); | ||
return false; | ||
} | ||
@Override | ||
public boolean onQueryTextChange(String newText) { | ||
Toast.makeText(JavaActivity.this, newText, Toast.LENGTH_SHORT).show(); | ||
return false; | ||
} | ||
}); | ||
``` | ||
``` | ||
//Simple usage with toolbar menu | ||
Menu menu = materialToolbar.getMenu(); | ||
menu.findItem(R.id.searchMenuIcon).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { | ||
@Override | ||
public boolean onMenuItemClick(MenuItem item) { | ||
Toast.makeText(JavaActivity.this, "Showing Search from ToolbarMenu", Toast.LENGTH_LONG).show(); | ||
//The method call where magic happens. | ||
materialSearchView.show(findViewById(R.id.searchMenuIcon)); | ||
return false; | ||
} | ||
}); | ||
``` | ||
``` | ||
//Sample usage with ImageView | ||
imageView.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Toast.makeText(JavaActivity.this, "Showing Search from ImageView", Toast.LENGTH_LONG).show(); | ||
//The method call where magic happens. | ||
materialSearchView.show(v); | ||
} | ||
}); | ||
} | ||
``` | ||
|
||
## Public Methods | ||
|
||
#### Kotlin and Java | ||
```java | ||
setBackButtonTint(@ColorRes Int color); | ||
setAnimationDuration(Int animationDuration); | ||
setSearchHint(String string); | ||
setBackButtonDrawable(Drawable drawable); | ||
setClearSearchOnDismiss(Boolean isClearSearchNeeded); | ||
setShowKeyBoardDefault(Bolean showKeyboardDefalut); | ||
setOnQueryTextListener(SearchView.OnQueryTextListener listener); | ||
``` | ||
## License | ||
[MIT](https://github.com/leoncydsilva/SearchableSpinner/blob/master/LICENSE) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'kotlin-android-extensions' | ||
|
||
android { | ||
compileSdkVersion 29 | ||
buildToolsVersion "29.0.2" | ||
|
||
defaultConfig { | ||
applicationId "com.leo.searchablespinnerexample" | ||
minSdkVersion 21 | ||
targetSdkVersion 29 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation 'androidx.appcompat:appcompat:1.1.0' | ||
implementation 'androidx.core:core-ktx:1.1.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
implementation 'com.google.android.material:material:1.2.0-alpha02' | ||
|
||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.1' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
implementation project(path: ':searchablespinner') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/com/leo/searchablespinnerexample/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.leo.searchablespinnerexample | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.leo.searchablespinnerexample", appContext.packageName) | ||
} | ||
} |
Oops, something went wrong.