/SelectionDialog

Android library to show selection dialogs

Primary LanguageJavaApache License 2.0Apache-2.0

This project is now archived. If you are looking for an Android library to show selection dialogs, you can try https://github.com/Kamarugo-san/selection-dialog.

Welcome to SelectionDialog!

Release License

A library that helps with showing a selection dialog for the user. Supports selection of a single item with the ability to filter the list and the selection of multiple items.

Setup

Step 1: Add the JitPack repository to your build file.

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

Step 2: Add the SelectionDialog dependency to your build.gradle file.

dependencies {
    implementation 'com.github.Kamarugo-san:SelectionDialog:1.1.2'
}

How do I use Single Selection Dialog?

You can check out the example activity.

Screenshot 1 Screenshot 2 Screenshot 3

Using SelectionDialog is pretty simple.

Step 1: Create object of SingleSelectionDialog with Builder for using the Single Selection.

//First parameter need to pass is current context and then TAG. TAG is to determine if you are using dialog multiple times.
SingleSelectionDialog singleSelectionDialog = new SingleSelectionDialog.Builder(context, "TEST")
        .setTitle("Select Number")
        .setContent(stringArrayList) // Set ArrayList you want to show.
        .setColor(getResources().getColor(R.color.colorPrimaryDark))
        .setSelectedField(currentField)
        .enableSearch(true, "Search your number")
        .setTextColor(getResources().getColor(R.color.colorAccent))
        .setListener(new SingleSelectionListener() {
            @Override
            public void onDialogItemSelected(String s, int position, String tag) {

            }

            @Override
            public void onDialogError(String error, String tag) {
            }
        })
        .build();

Step 2: Call show(); method for showing the dialog.

singleSelectionDialog.show();

Step 3: Set Default value or Current value to Dialog.

singleSelectionDialog.setSelectedField(value); //Default value must be of String type.

How do I use Multi Selection Dialog?

Screenshot 4 Screenshot 5

Using MultiSelection is also not that tough.

**Step 1: ** Create object of MultiSelectionDialog with Builder for using the Multiple Selection.

//First parameter need to pass is current context and then TAG. TAG is for determine if you are using dialog multiple times.
MultiSelectionDialog multipleSelectionDialog = new MultiSelectionDialog.Builder(context, "TEST")
        .setTitle("Select Number")
        .setContent(stringArrayList)
        .setColor(getResources().getColor(R.color.colorPrimaryDark))
        .setSelectedField(currentField)
        .setTextColor(getResources().getColor(R.color.colorAccent))
        .setListener(new MultiSelectionListener() {
            @Override
            public void onMultiDialogItemsSelected(String s, String tag, ArrayList<String> selectedItemList) {
            }

            @Override
            public void onMultiDialogError(String error, String tag) {
            }
        })
        .build();

Step 2: Call show(); method for showing the dialog.

multiSelectionDialog.show();

Step 3: Set Default values or Current values to Dialog.

multiSelectionDialog.setSelectedFields(value); //Default values must be of String type.

Author

Matheus Camargo

Original repo by

Dheeraj Rijhwani (Android Developer)

Licence

Copyright 2021 Matheus Camargo Gomes da Silva

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.