Filter Dialog Activity

Additional

Language
Java
Version
1.0.21 (Oct 22, 2019)
Created
Jan 12, 2018
Updated
Oct 22, 2019 (Retired)
Owner
Barış ATALAY (barisatalay)
Contributor
Barış ATALAY (barisatalay)
1
Activity
Badge
Generate
Download
Source code

filter-dialog-activity

Filter Dialog Activity for Android Projects

Whos uses this library?

Paximum

Sejour Mobile

Tarım Simsari

TourVisio 2 Mobile

Screen Shots

Usage

Step 1

allprojects {
  repositories {
   ...
   maven { url 'https://jitpack.io' }
  }
 }

Step 2

Add dependencies in build.gradle.

    dependencies {
       compile 'com.github.barisatalay:filter-dialog-activity:1.0.18'
    }

Step 3 (Use of library)

Create FilterDialog for Custom class;

   List<mdlPerson> personList = new ArrayList<>();

   personList.add(new mdlPerson("1","Bir"));
   personList.add(new mdlPerson("2","İki"));
   personList.add(new mdlPerson("3","Üç"));
   personList.add(new mdlPerson("4","Dört"));
   
   final FilterDialog filterDialog = new FilterDialog(MainActivity.this);
   filterDialog.setToolbarTitle("Model Filter");
   filterDialog.setSearchBoxHint("You can search");
   filterDialog.setList(personList);
   
   /*
   * nameField : model's is the part that will appear on the screen.
   * idField : id section in the model.
   * dialogListener : when any row item selected, selected item will be return from interface
   */
   filterDialog.show("code", "name", new DialogListener.Single() {
    @Override
    public void onResult(FilterItem selectedItem) {
     Toast.makeText(MainActivity.this, "Selected is: " + selectedItem.getName(), Toast.LENGTH_SHORT).show();
  filterDialog.dispose();
    }
   });

Step 3 (Use of library)

Create FilterDialog for String class;

   List<String> stringList = new ArrayList<>();
   stringList.add("Item 1");
   stringList.add("Item 2");
   stringList.add("Item 3");
   stringList.add("Item 4");
   stringList.add("Item 5");
   stringList.add("Item 6");
   stringList.add("Item 7");
   
   final FilterDialog filterDialog = new FilterDialog(MainActivity.this);
   filterDialog.setToolbarTitle("String Filter");
   filterDialog.setSearchBoxHint("You can search");
   filterDialog.setList(stringList);
   
   filterDialog.backPressedEnabled(false);
   filterDialog.setOnCloseListener(new View.OnClickListener() {
    @Override
        public void onClick(View view) {
         filterDialog.dispose();
        }
   });
   
   /*
   * When you have List<String,Integer,Boolean,Double,Float> should be use this method
   */
   filterDialog.show(new DialogListener.Single() {
    @Override
    public void onResult(FilterItem selectedItem) {
     Toast.makeText(MainActivity.this, "Selected is: " + selectedItem.getName(), Toast.LENGTH_SHORT).show();
  filterDialog.dispose();
    }
   });

Step 3 (Use of library for multiple select)

Create FilterDialog for Custom class;

   List<mdlHotel> personList = new ArrayList<>();
   List<String> selectedList = new ArrayList<>();
   
   selectedList.add("2");
   selectedList.add("4");

   personList.add(new mdlHotel("1","Bir"));
   personList.add(new mdlHotel("2","İki"));
   personList.add(new mdlHotel("3","Üç"));
   personList.add(new mdlHotel("4","Dört"));

   final FilterDialog filterDialog = new FilterDialog(MainActivity.this);

   filterDialog.setToolbarTitle("Model Filter");
   filterDialog.setSearchBoxHint("You can search");
   filterDialog.setSelectButtonText("Select");
   filterDialog.setSelected(selectedList);
   filterDialog.setList(personList);
   filterDialog.setSelectableCount(2);
   
   filterDialog.setSelectDrawable(R.drawable.ic_check);


   filterDialog.show("Otel", "Adi", new DialogListener.Multiple() {
       @Override
       public void onResult(List<FilterItem> selectedItems) {
           for (int i=0;i<selectedItems.size();i++)
               Toast.makeText(MainActivity.this, "Selected is: " + selectedItems.get(i).getName(), Toast.LENGTH_SHORT).show();
           filterDialog.dispose();
       }
   });

Step 4 - Customizing Filter Dialog Activity is very simple

Just define your own project

Color customization

<color name="filterdialog_background">#eae7e7</color>
<color name="filterdialog_toolbar">#163645</color>
<color name="filterdialog_toolbar_text">@color/white</color>
<color name="filterdialog_searchbox_border">@color/white</color>
<color name="filterdialog_searchbox_background">#DDD4D4</color>
<color name="filterdialog_searchbox_text">@color/colorTextStandart</color>
<color name="filterdialog_searchbox_hint">#747373</color>
<color name="filterdialog_searchbox_icon">#0e242e</color>
<color name="filterdialog_row_text">@color/colorTextStandart</color>

Text customization

<string name="filterdialog_back">Back</string>
<string name="filterdialog_clear">Clear</string>

Thanks

Contact me

If you have a better idea or way on this project, please let me know, thanks :)

Email

My Blog

My Linkedin