Skip to content

Commit

Permalink
feat: Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
leoncydsilva committed Dec 23, 2019
1 parent c4523df commit 9ac0af8
Show file tree
Hide file tree
Showing 59 changed files with 1,860 additions and 1 deletion.
122 changes: 122 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

143 changes: 142 additions & 1 deletion README.md
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)
Binary file added SampleImages/gif_01.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleImages/gif_02.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleImages/image_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleImages/image_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
40 changes: 40 additions & 0 deletions app/build.gradle
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')
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
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
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)
}
}
Loading

0 comments on commit 9ac0af8

Please sign in to comment.