Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file added .idea/caches/gradle_models.ser
Binary file not shown.
22 changes: 0 additions & 22 deletions .idea/compiler.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

4 changes: 4 additions & 0 deletions .idea/encodings.xml

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

42 changes: 5 additions & 37 deletions .idea/misc.xml

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

2 changes: 1 addition & 1 deletion .idea/vcs.xml

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

13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Step 1. Add the JitPack repository to your build file
Step 2. Add the dependency

dependencies {
compile 'com.github.MdFarhanRaja:SearchableSpinner:1.2'
compile 'com.github.MdFarhanRaja:SearchableSpinner:2.0'
}

Step 3. Inside JAVA
Expand Down Expand Up @@ -43,8 +43,11 @@ Step 3. Inside JAVA
items.add("Kanpur");


spinnerDialog=new SpinnerDialog(MainActivity.this,items,"Select or Search City");// With No Animation
spinnerDialog=new SpinnerDialog(MainActivity.this,items,"Select or Search City",R.style.DialogAnimations_SmileWindow);// With Animation
spinnerDialog=new SpinnerDialog(MainActivity.this,items,"Select or Search City","Close Button Text");// With No Animation
spinnerDialog=new SpinnerDialog(MainActivity.this,items,"Select or Search City",R.style.DialogAnimations_SmileWindow,"Close Button Text");// With Animation

spinnerDialog.setCancellable(true); // for cancellable
spinnerDialog.setShowKeyboard(false);// for open keyboard by default


spinnerDialog.bindOnSpinerListener(new OnSpinerItemClick() {
Expand All @@ -67,8 +70,8 @@ Step 4. Add custom style in your styles.xml

<style name="DialogAnimations" />
<style name="DialogAnimations.SmileWindow">
<item name="@android:windowEnterAnimation">@anim/slide_in_bottom</item>
<item name="@android:windowExitAnimation">@anim/slide_out_top</item>
<item name="android:windowEnterAnimation">@anim/slide_in_bottom</item>
<item name="android:windowExitAnimation">@anim/slide_out_top</item>
</style>


17 changes: 9 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "in.galaxyofandroid.searchablespinner"
minSdkVersion 14
targetSdkVersion 25
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -20,11 +20,12 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
testCompile 'junit:junit:4.12'
compile project(':spinerdialog')
implementation 'com.android.support:appcompat-v7:27.1.1'
testImplementation 'junit:junit:4.12'
//implementation 'com.github.MdFarhanRaja:SearchableSpinner:2.1'
implementation project(':spinerdialog')
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@
import in.galaxyofandroid.spinerdialog.OnSpinerItemClick;
import in.galaxyofandroid.spinerdialog.SpinnerDialog;

public class MainActivity extends AppCompatActivity
{
ArrayList<String> items=new ArrayList<>();
public class MainActivity extends AppCompatActivity {
ArrayList<String> items = new ArrayList<>();
SpinnerDialog spinnerDialog;

@Override
protected void onCreate(Bundle savedInstanceState)
{
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final TextView selectedItems=(TextView)findViewById(R.id.txt);
final TextView selectedItems = (TextView) findViewById(R.id.txt);


items.add("Mumbai");
Expand All @@ -37,29 +36,33 @@ protected void onCreate(Bundle savedInstanceState)
items.add("Lucknow");
items.add("Kanpur");

spinnerDialog=new SpinnerDialog(MainActivity.this,items,"Select or Search City",R.style.DialogAnimations_SmileWindow);
spinnerDialog = new SpinnerDialog(MainActivity.this, items,
"Select or Search City");

spinnerDialog.setTitleColor(getResources().getColor(R.color.colorAccent));
spinnerDialog.setSearchIconColor(getResources().getColor(R.color.colorAccent));
spinnerDialog.setSearchTextColor(getResources().getColor(R.color.colorAccent));
spinnerDialog.setItemColor(getResources().getColor(R.color.colorAccent));
spinnerDialog.setItemDividerColor(getResources().getColor(R.color.colorAccent));
spinnerDialog.setCloseColor(getResources().getColor(R.color.colorAccent));

spinnerDialog.setCancellable(true);
spinnerDialog.setShowKeyboard(false);

spinnerDialog.bindOnSpinerListener(new OnSpinerItemClick()
{
spinnerDialog.bindOnSpinerListener(new OnSpinerItemClick() {
@Override
public void onClick(String item, int position)
{
Toast.makeText(MainActivity.this, item + " " + position+"", Toast.LENGTH_SHORT).show();
public void onClick(String item, int position) {
Toast.makeText(MainActivity.this, item + " " + position + "", Toast.LENGTH_SHORT).show();
selectedItems.setText(item + " Position: " + position);
}
});

findViewById(R.id.show).setOnClickListener(new View.OnClickListener()
{
findViewById(R.id.show).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
public void onClick(View v) {
spinnerDialog.showSpinerDialog();
}
});
}




}
2 changes: 1 addition & 1 deletion app/src/main/res/anim/slide_in_bottom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:duration="500"
android:fromYDelta="100%p"/>
2 changes: 1 addition & 1 deletion app/src/main/res/anim/slide_out_top.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:duration="500"
android:toYDelta="100%p" />
4 changes: 2 additions & 2 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

<style name="DialogAnimations" />
<style name="DialogAnimations.SmileWindow">
<item name="@android:windowEnterAnimation">@anim/slide_in_bottom</item>
<item name="@android:windowExitAnimation">@anim/slide_out_top</item>
<item name="android:windowEnterAnimation">@anim/slide_in_bottom</item>
<item name="android:windowExitAnimation">@anim/slide_out_top</item>
</style>

</resources>
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
task wrapper(type: Wrapper){
gradleVersion='2.2'
task wrapper(type: Wrapper) {
gradleVersion = '2.2'
}
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -18,6 +19,8 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
maven { url 'https://jitpack.io' }
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu May 04 18:58:59 IST 2017
#Sat Apr 07 15:45:55 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
15 changes: 8 additions & 7 deletions spinerdialog/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
apply plugin: 'com.android.library'
apply plugin: 'android-maven'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig {
minSdkVersion 14
targetSdkVersion 25
targetSdkVersion 27
versionCode 1
versionName "1.0"

Expand All @@ -22,13 +23,13 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
implementation 'com.android.support:appcompat-v7:27.1.1'

apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.MdFarhanRaja'
testCompile 'junit:junit:4.12'
testImplementation 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package in.galaxyofandroid.spinerdialog;

import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;
import android.widget.ArrayAdapter;
import android.widget.Filter;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

public class ArrayAdapterWithContainsFilter<S> extends ArrayAdapter {

private List<String> items = null;
private ArrayList<String> arraylist;

public ArrayAdapterWithContainsFilter(Activity context, int items_view, ArrayList<String> items) {
super(context,items_view,items);
this.items = items;
this.arraylist = new ArrayList<String>();
this.arraylist.addAll(items);
}

@NonNull
@Override
public Filter getFilter() {
return super.getFilter();
}

// Filter Class
public void getContainsFilter(String charText) {
charText = charText.toLowerCase(Locale.getDefault());
items.clear();
if (charText.length() == 0) {
items.addAll(arraylist);
}
else
{
for (String item : arraylist)
{
if (item.toLowerCase(Locale.getDefault()).contains(charText))
{
items.add(item);
}
}
}
notifyDataSetChanged();
}
}
Loading