Android Spinner Dialog Library supported on both Java and Kotlin, Use for single or multi selection of choice

Overview

SpinnerDialog

Android Spinner Dialog Library, Use for single or multi selection of choice

Download

Android UI

Download

To include SpinnerDialog in your project, add the following to your dependencies:

app/build.gradle

dependencies {
        implementation 'com.github.hamzaahmedkhan:SpinnerDialog:v1.2.3'
}

Usage

The following snippet shows how you can use Spinner Dialog in your project.

In Kotlin

class MainActivity : AppCompatActivity() {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // INITIALZE DATA
        val arraySpinnerModel: ArrayList<SpinnerModel> = ArrayList()

        for (i in 1..9) {
            val spinnerModel = SpinnerModel(
                "Number $i"
            )
            spinnerModel.id = i
            arraySpinnerModel.add(
                spinnerMode
            )
        }


    // EXTRA PROPERTIES OF SPINNER MODEL

        // User can set ImageType as Circle or Square
        spinnerModel.imageType = ImageType.IMAGE_CIRCLE
        spinnerModel.imageType = ImageType.IMAGE_SQUARE

        // User can set Description text
        spinnerModel.description = "This is Description of $i"

        // To set Image Path (Either URL or from Drawable Resources), priority will be given to Res ID. If resID not provided then it will load image from URL
        spinnerModel.imagePath("https://homepages.cae.wisc.edu/~ece533/images/airplane.png")
        spinnerModel.imagePath(R.drawable.img_bird)







        // Init single select Fragment
        val spinnerSingleSelectDialogFragment =
            SpinnerDialogFragment.newInstance(
                SpinnerSelectionType.SINGLE_SELECTION,"Spinner Dialog", arraySpinnerModel,
                object :
                    OnSpinnerOKPressedListener {
                    override fun onSingleSelection(data: SpinnerModel, selectedPosition: Int) {
                        Toast.makeText(applicationContext, data.text, Toast.LENGTH_LONG).show()
                    }

                    override fun onMultiSelection(
                        data: List<SpinnerModel>,
                        selectedPosition: Int
                    ) {
                        // It will never send Multi selection data in SINGLE_SELECTION Mode
                    }

                }, 0
            )


        // Init multi select Fragment
        val spinnerMultiSelectDialogFragment =
            SpinnerDialogFragment.newInstance(
                SpinnerSelectionType.MULTI_SELECTION,"Spinner Dialog", arraySpinnerModel,
                object :
                    OnSpinnerOKPressedListener {
                    override fun onSingleSelection(data: SpinnerModel, selectedPosition: Int) {
                        Toast.makeText(applicationContext, data.text, Toast.LENGTH_LONG).show()
                    }

                    override fun onMultiSelection(
                        data: List<SpinnerModel>,
                        selectedPosition: Int
                    ) {
                        Toast.makeText(applicationContext, data.map { it.text }.joinToString(" - "), Toast.LENGTH_LONG).show()
                    }

                }, 0
            )



        txtShowSingleChoiceSpinner.setOnClickListener { spinnerSingleSelectDialogFragment.show(supportFragmentManager, "SpinnerDialogFragmentSingle") }
        txtShowMultiChoiceSpinner.setOnClickListener { spinnerMultiSelectDialogFragment.show(supportFragmentManager, "SpinnerDialogFragmentMulti") }
    }
}

EXTRA ATTRIBUTES

        // Using optional features for single select dialog
        spinnerSingleSelectDialogFragment.buttonText = "SAVE"
        spinnerSingleSelectDialogFragment.themeColorResId = resources.getColor(R.color.material_pink500)
        spinnerSingleSelectDialogFragment.showSearchBar = true
        spinnerSingleSelectDialogFragment.searchbarHint = "type here to search.."
        spinnerSingleSelectDialogFragment.setDialogHeight(ViewGroup.LayoutParams.MATCH_PARENT) // for dynamic height you can use Integer.dp e.g setDialogHeight(500.dp) or ViewGroup.LayoutParams.WRAP_CONTENT
        spinnerSingleSelectDialogFragment.showDescription(true)
        spinnerSingleSelectDialogFragment.showImage(true)


        // Using optional features for multi select dialog
        spinnerMultiSelectDialogFragment.buttonText = "SAVE"
        spinnerMultiSelectDialogFragment.themeColorResId = resources.getColor(R.color.material_pink500)
        spinnerMultiSelectDialogFragment.showSearchBar = true
        spinnerMultiSelectDialogFragment.searchbarHint = "type here to search.."
        spinnerMultiSelectDialogFragment.setDialogHeight(ViewGroup.LayoutParams.MATCH_PARENT) // for dynamic height you can use Integer.dp e.g setDialogHeight(500.dp) or ViewGroup.LayoutParams.WRAP_CONTENT
        spinnerMultiSelectDialogFragment.showDescription(true)
        spinnerMultiSelectDialogFragment.showImage(true)

If you want to use enums list in Enums.

// Declare enums and override toString
enum class TestEnum {

    ENUM1 {
        override fun toString(): String {
            return "enum1"
        }
    },

    ENUM2 {
        override fun toString(): String {
            return "enum2"
        }
    }

}


// initialize spinner ArrayList
val spinnerData: ArrayList<SpinnerModel> = ArrayList()

// If you want to set enum individually
val choice1 = TestEnum.ENUM1
val choice2 = TestEnum.ENUM2

spinnerData.add(SpinnerModel(choice1.toString()))
spinnerData.add(SpinnerModel(choice2.toString()))


// If you want to set all enums values in Spinner
TestEnum.values().forEach {
    spinnerData.add(SpinnerModel(it.toString()))
}

FUTURE RELEASE PLANS

-> Open issues for Release 1.3.0

Comments
  • Custom Enum Class Support

    Custom Enum Class Support

    Hi all,

    First of all thanks for the library :)

    I have implemented SpinnerDialog but want to work with my enum classes. What is the best way to do this?

    Thanks in advance!

    documentation 
    opened by brcbydr 3
  • Restrict orientation to portrait mode only

    Restrict orientation to portrait mode only

    The search results got disappeared if the user switches their device orientation to the landscape that's why I have restricted to portrait mode only. Kindly do the handling of data retention that has to be survived on change orientation. I would recommend to use ViewModel for data presentation.

    enhancement 
    opened by muzammilsiddiq 0
  • feature - Give user option to change icon image size

    feature - Give user option to change icon image size

    Is your feature request related to a problem? Please describe. User cannot change default size of image.

    Describe the solution you'd like Expose a property so user can change image icon size.

    enhancement 
    opened by hamzaahmedkhan 0
  • feature - User can provide Placeholder and error images

    feature - User can provide Placeholder and error images

    Is your feature request related to a problem? Please describe. Yes, User cannot change default Placeholder and error images

    Describe the solution you'd like Expose properties for Placeholder and error images.

    enhancement 
    opened by hamzaahmedkhan 0
  • feature - Add color change option for Choice and Description text

    feature - Add color change option for Choice and Description text

    Is your feature request related to a problem? Please describe. I am unable to change color of Choice and description text

    Describe the solution you'd like Expose two properties to change its colors

    enhancement 
    opened by hamzaahmedkhan 0
Releases(v1.2.3)
Owner
Hamza Khan
An experienced and Google Certified Android Developer, passionate about working with organizations, businesses, and individuals to serve the community.
Hamza Khan
Kotlin Multiplatform is an SDK for cross-platform mobile development, which enables teams to use the same business logic in both Android and iOS client applications.

Kotlin Multiplatform is an SDK for cross-platform mobile development, which enables teams to use the same business logic in both Android and iOS client applications.

Chris Russell 1 Feb 11, 2022
A beautiful material calendar with endless scroll, range selection and a lot more!

CrunchyCalendar A light, powerful and easy to use Calendar Widget with a number out of the box features: Infinite vertical scrolling in both direction

CleverPumpkin 483 Dec 25, 2022
A template that utilizes both Scala and Kotlin because why not (And also because I endorse programming hell)

Fabric-Scala-Kotlin-template A template that utilizes both Scala and Kotlin because why not (And also because I endorse programming hell) I don't care

null 1 Dec 25, 2021
A mindustry mod that shuffles both the texture atlas and bundle

ohno amogus Total chaos Mindustry mod that shuffles both the texture atlas and the current bundle, providing an unforgettable gaming experience Comes

Мнемотехник 4 Sep 3, 2022
Modern Calendar View Supporting Both Hijri and Gregorian Calendars but in highly dynamic way

KCalendar-View Modern calendar view supporting both Hijri and Gregorian calendar

Ahmed Ibrahim 8 Oct 29, 2022
Small app to create icon sets for Linux, Windows, OSX, Android and IOS from a single PNG image

FXIconcreator Small app to create icon sets (multi resolution) for Linux, Windows, OSX from a single PNG image Reason for creating such an app was tha

null 18 Aug 4, 2022
API-Annotate - Single annotation to mark API elements

API-Annotate A single annotation for annotating externally-consumed elements in

null 0 Feb 5, 2022
Sample application to demonstrate Multi-module Clean MVVM Architecture and usage of Android Hilt, Kotlin Flow, Navigation Graph, Unit tests etc.

MoneyHeist-Chars Sample application to demonstrate Multi-module Clean MVVM Architecture and usage of Android Hilt, Kotlin Flow, Navigation Graph, Room

Hisham 20 Nov 19, 2022
Workout Journal is a mobile app based on Multi-Module and Clean Architecture for those who want to track their progress over a workout and a calendar period.

Workout-Journal Workout Journal is a mobile app for those who want to track their progress over a workout and a calendar period. The app allows you to

Maxim Smolyakov 4 Oct 23, 2022
A simple Kotlin multi-platform abstraction around the javax.inject annotations.

Inject A simple Kotlin multi-platform abstraction around the javax.inject annotations. This allows using the annotations in Kotlin common code so that

Christopher 43 Aug 17, 2022
A set of highly-opinionated, batteries-included gradle plugins to get you started building delicious multi-module Kotlin projects

Sourdough Gradle What is Sourdough Gradle? Sourdough is a set of highly opinionated gradle plugins that aim to act as the starter for your Kotlin proj

Backbone 0 Oct 3, 2022
Multi module architecture Android template project using MVVM, Dagger-Hilt, and Navigation Components

ModularAppTemplate An Android template project following a multi module approach with clean architecture. It has been built following Clean Architectu

Mbuodile Obiosio 7 May 23, 2022
Example Multi module architecture Android project using MVVM, Dynamic Features, Dagger-Hilt, Coroutines and Navigation Components

ModularDynamicFeatureHilt An Android template project following a multi module approach with clean architecture. It has been built following Clean Arc

Mbuodile Obiosio 25 Nov 23, 2022
Built with Jetpack compose, multi modules MVVM clean architecture, coroutines + flow, dependency injection, jetpack navigation and other jetpack components

RickAndMortyCompose - Work in progress A simple app using Jetpack compose, clean architecture, multi modules, coroutines + flows, dependency injection

Daniel Waiguru 9 Jul 13, 2022
Minecraft 1.18.2 Backport of Petal, a performance-oriented fork of Purpur intended to increase performance for entity-heavy servers by implementing multi-threaded and asynchronous improvements.

Sakura Performance Minecraft JAR Sakura is a performance-oriented fork of Purpur intended to increase performance for entity-heavy servers by implemen

etil.sol 14 Nov 23, 2022
Sample project that shows an approach for designing a multi-module architecture for Jetpack Compose Android applications.

Compose Multi-Module Architecture Sample Sample project that shows an approach for designing a multi-module architecture for Jetpack Compose Android a

Pavlo Stavytskyi 77 Jan 3, 2023
A multi module app, for improve knowledges

MultiModuleApp App multimódulos para estudos Aqui existem vários apps simples (1 em cada módulo) e está sendo construído por: App multi módulos Consum

PLINIO DA SILVA ALENCAR 0 Dec 27, 2021
Course_modularizing_android_apps - Multi-module demo app that gets data from a Dota2 api

Work in progress Multi-module demo app that gets data from a Dota2 api. Module n

Julio Ribeiro 1 Dec 30, 2021
Repository of a multi-platform application running the same Compose source code on all platforms

Compose multiplatform demo demo.mov Using the same compose user interface (UI) from android on all principal platforms ?? ?? App Features This is a si

David Coronel 18 Dec 16, 2022