Karamunting.Android.ArchitShah248.CalendarDateRangePicker 1.0.1

An Android Library to pick dates range, that helps user to select range from future dates.

Install-Package Karamunting.Android.ArchitShah248.CalendarDateRangePicker -Version 1.0.1
dotnet add package Karamunting.Android.ArchitShah248.CalendarDateRangePicker --version 1.0.1
<PackageReference Include="Karamunting.Android.ArchitShah248.CalendarDateRangePicker" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Karamunting.Android.ArchitShah248.CalendarDateRangePicker --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Sample Usage

// Created by Rofiq Setiawan (rofiqsetiawan@gmail.com)

using System;
using Android.App;
using Android.Graphics;
using Android.OS;
using Android.Support.V7.App;
using Android.Util;
using Android.Widget;
using Com.Archit.CalendarDateRangePicker.CustomViews;
using R = CalendarDateRangePickerDemo.Resource;

namespace CalendarDateRangePickerDemo
{
    [Activity(Label = "@string/app_name", MainLauncher = true)]
    public sealed class MainActivity : AppCompatActivity
    {
        private const string MyTag = "CalendarDateRangePickerDemo";

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(R.Layout.activity_main);

            var typeface1 = Typeface.CreateFromAsset(Assets, "JosefinSans-Regular.ttf");
            var typeface2 = Typeface.CreateFromAsset(Assets, "LobsterTwo-Regular.ttf");

            var calendar = FindViewById<DateRangeCalendarView>(R.Id.calendar);
            calendar.SetFonts(typeface1);
        }

        private void ToastMe(string message)
        {
            if (string.IsNullOrEmpty(message)) return;

            Toast.MakeText(this, message, ToastLength.Short).Show();
        }
    }
}

Listen to Calendar's Change

With Listener

// With Listener
calendar.SetCalendarListener(
    new DateRangeCalendarView.CalendarListener(
        onDateRangeSelectedAction: (DateTime startDate, DateTime endDate) =>
        {
            var msg = $"OnDateRangeSelectedAction: from {startDate.ToString("yyyyMMdd")} to {endDate.ToString("yyyyMMdd")}";
            Log.Debug(MyTag, msg);
            ToastMe(msg);
        },
        onCancelAction: () =>
        {
            const string msg = "OnCancelAction";
            Log.Debug(MyTag, msg);
            ToastMe(msg);
        }
    )
);

With EventHandler

// With EventHandler
calendar.DateRangeSelected += (s, e) =>
{
    var msg = $"DateRangeSelectedEventHandler: from {e.StartDate:yyyyMMdd} to {e.EndDate:yyyyMMdd}";
    Log.Debug(MyTag, msg);
    ToastMe(msg);
};
calendar.CancelSelection += (s, e) =>
{
    const string msg = "CancelSelectionEventHandler";
    Log.Debug(MyTag, msg);
    ToastMe(msg);
};

Sample Usage

// Created by Rofiq Setiawan (rofiqsetiawan@gmail.com)

using System;
using Android.App;
using Android.Graphics;
using Android.OS;
using Android.Support.V7.App;
using Android.Util;
using Android.Widget;
using Com.Archit.CalendarDateRangePicker.CustomViews;
using R = CalendarDateRangePickerDemo.Resource;

namespace CalendarDateRangePickerDemo
{
    [Activity(Label = "@string/app_name", MainLauncher = true)]
    public sealed class MainActivity : AppCompatActivity
    {
        private const string MyTag = "CalendarDateRangePickerDemo";

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(R.Layout.activity_main);

            var typeface1 = Typeface.CreateFromAsset(Assets, "JosefinSans-Regular.ttf");
            var typeface2 = Typeface.CreateFromAsset(Assets, "LobsterTwo-Regular.ttf");

            var calendar = FindViewById<DateRangeCalendarView>(R.Id.calendar);
            calendar.SetFonts(typeface1);
        }

        private void ToastMe(string message)
        {
            if (string.IsNullOrEmpty(message)) return;

            Toast.MakeText(this, message, ToastLength.Short).Show();
        }
    }
}

Listen to Calendar's Change

With Listener

// With Listener
calendar.SetCalendarListener(
    new DateRangeCalendarView.CalendarListener(
        onDateRangeSelectedAction: (DateTime startDate, DateTime endDate) =>
        {
            var msg = $"OnDateRangeSelectedAction: from {startDate.ToString("yyyyMMdd")} to {endDate.ToString("yyyyMMdd")}";
            Log.Debug(MyTag, msg);
            ToastMe(msg);
        },
        onCancelAction: () =>
        {
            const string msg = "OnCancelAction";
            Log.Debug(MyTag, msg);
            ToastMe(msg);
        }
    )
);

With EventHandler

// With EventHandler
calendar.DateRangeSelected += (s, e) =>
{
    var msg = $"DateRangeSelectedEventHandler: from {e.StartDate:yyyyMMdd} to {e.EndDate:yyyyMMdd}";
    Log.Debug(MyTag, msg);
    ToastMe(msg);
};
calendar.CancelSelection += (s, e) =>
{
    const string msg = "CancelSelectionEventHandler";
    Log.Debug(MyTag, msg);
    ToastMe(msg);
};

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.1 453 5/13/2018