Skip to content

mosayeb-masoumi/CalendarDialog

Repository files navigation

CalendarDialog

add jitpack to build.gradle(Project)

buildscript {
repositories {
    google()
    jcenter()
    maven { url 'https://jitpack.io' }
  }
}

allprojects {
repositories {
    google()
    jcenter()
    maven { url 'https://jitpack.io' }
 }
}

needed minSdk:

 minSdkVersion 18

libray:

implementation 'com.github.mosayeb-masoumi:CalendarDialog:1.1.0'

implementation in java

how to create simple dialog:

DialogFactory dialogFactory = new DialogFactory(context);
    dialogFactory.createCalendarDialog(new DialogFactory.DialogFactoryInteraction() {
        @Override
        public void onAcceptButtonClicked(String... params) {

            String date = params[0];
            txt_date.setText(date);

        }

        @Override
        public void onDeniedButtonClicked(boolean bool) {

        }
     // layout_root is the id that we set in our layout.xml
    }, layout_root);

how to create customized dialog:

private void openCalendar() {

    CalendarDialog calendarDialog = new CalendarDialog.Builder()

            .setMax_year(2025)
            .setMin_year(2015)

            .setTitle("calendar")
            .setTitleTextColor(getResources().getColor(R.color.white))
            .setTitleTextSize(20)

            .setCloseIconVisibility(true)
            .setCloseIconBackgroundDrawable(getResources().getDrawable(R.drawable.ic_close))

            .setHeaderBackgroundColor(getResources().getColor(R.color.colorAccent))
            .setHeaderBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_header_shape))

            .setDateBackgroundColor(getResources().getColor(R.color.yellow))
            .setDateBackgroundDrawable(getResources().getDrawable(R.drawable.date_background))

            .setButtonRegisterBackgroundColor(getResources().getColor(R.color.colorAccent))
            .setButtonRegisterBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_btn_shape))
            .setButtonRegisterTextColor(getResources().getColor(R.color.blue_dark))
            .setButtonRegisterTextSize(20)

            .setButtonSetTodayBackgroundColor(getResources().getColor(R.color.colorAccent))
            .setButtonSetTodayBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_btn_shape))
            .setButtonSetTodayTextColor(getResources().getColor(R.color.blue_dark))
            .setButtonSetTodayTextSize(20)

            .setDialogBackgroundColor(getResources().getColor(R.color.colorAccent))
            .setDialogBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_btn_shape))

            .build();


    DialogFactory dialogFactory = new DialogFactory(context);
    dialogFactory.createCalendarDialog(new DialogFactory.DialogFactoryInteraction() {
        @Override
        public void onAcceptButtonClicked(String... params) {

            String date = params[0];
            txt_date.setText(date);

        }

        @Override
        public void onDeniedButtonClicked(boolean bool) {

        }
     // layout_root is the id that we set in our layout.xml
    }, layout_root,calendarDialog);
}

implementation in kotlin

class SecondActivity : AppCompatActivity() {

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

    val builder = CalendarDialog.Builder()
            .setMax_year(2025)
            .setMin_year(2015)
            .// and other optional settings
            .build()

    openCalendar(builder)
}

private fun openCalendar(builder: CalendarDialog) {

    val dialogFactory = DialogFactory(this)
    dialogFactory.createCalendarDialog(object : DialogFactory.DialogFactoryInteraction {
        override fun onAcceptButtonClicked(vararg strings: String?) {
              
             val date: String? = strings.get(0)
             text_date.text = date
        }

        override fun onDeniedButtonClicked(cancel_dialog: Boolean) {

        }
      // layout_root is the id that we set in our layout.xml
    }, root_second, builder)
  }
 }

customized CalendarDialog image:

customized

simple CalendarDialog image:

simple

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages