Giter Club home page Giter Club logo

merocalendar's Introduction

MeroCalendar

Android Calendar Library With AD and Bikram Sambat event calendar, Date converter, Both english and nepali language support with several configuration.

License

Features

  • AD, BS Calendar (with or without event)
  • Date Conversion from AD to BS and vice versa
  • Horizontal Calendar (Both AD , BS)
  • Highly Customized
  • Nepali And English language Full support

Installation

Add jitack repo on your project build.gradle

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

Then add MeroCalendar Library to your app build.gradle

   dependencies {
	        implementation 'com.github.puskal-khadka:MeroCalendar:1.0.3'
	}

Using Event Calendar (For AD or BS)

  • Add MeroCalendarView to your layout file
   <com.puskal.merocalendar.MeroCalendarView
    android:id="@+id/mCalendarView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp"
   />
  • Then in your activity or Fragment add Configuration as your requirement as below
  • 1.1 Setup DateClick Listener
   val dateClickListener = object : DateClickListener {
            override fun onDateClick(dateModel: DateModel) {
                Log.d("d", "clicked date is ${dateModel.formattedAdDate}")
            }
        }
  • 1.2 Setup MonthChange Listener
   val monthChangeListener = object : MonthChangeListener {
            override fun onMonthChange( startDateOfThisMonth: DateModel, endDateOfThisMonth: DateModel, adYear: Int, adMonth: Int) {
            //perform action or set event of corresponding month from here
          }
        }   
  • 1.3 Set Calendar Type
   val calendarType=CalendarType.BS 
   //for Ad calendar use,  val calendarType=CalendarType.AD
  • 1.4 Set Language
   val language=LocalizationType.NEPALI_NP
   //for english language use, val language=LocalizationType.ENGLISH_US
  • 1.5 Finally Build calendar using above configuraion as follow
   mCalendarView.setCalendarType(calendarType)
            .setLanguage(language)
            .setOnDateClickListener(dateClickListener)
            .setOnMonthChangeListener(monthChangeListener)
            .setEvent(fakeEventList)
            .build()


Using Date Converter (AD to BS and vice versa)

To convert AD to BS

  • Get (AD) year, month, day and pass to the converter of the library as given below
   val year:Int=2021
   val month=7  //month number should be from 1 to 12 (eg: 1=jan, 12=dec)
   val day=12
   val convertedAdDate=MeroDateConverter.convertAdToBs(year, month, day)

To convert BS to Ad

  • Get (nepali/BS) year, month, day and pass to the converter of the library as below
   val year=2078
   val month=3 //from 1 to 12 (eg: 1=baishakh, 12=chaitra_
   val day=28
   val convertedBsDate=MeroDateConverter.convertBsToAd(year, month, day)


Using Horizontal Calendar

  • Add MeroHorizontalCalendarView on xml layout
   <com.puskal.merocalendar.HorizontalMeroCalendarView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/horizontalCalendarView"
    />
  • After that in your activity or fragment, add configuration

  • Set up Date click listener to observe clicked date

   val dateClickListener = object : DateClickListener {
            override fun onDateClick(dateModel: DateModel) {
                Log.d("d","data is ${dateModel.localizedFormattedDate}")
            }
        }
  • build horizontal calendar
   var calendarType = CalendarType.AD  //for bs use, CalendarType.BS
   var language = LocalizationType.ENGLISH_US //for nepali language use, LocalizationType.ENGLISH_US
   binding.horizontalCalendarView.setCalendarType(calendarType)
                    .setLanguage(language)
                    .setOnDateClickListener(dateClickListener)
                    .build()
  • Additional Things on Horizontal Calendar View
  • To get previous and next month horizontal calendar, if ivNext is view for getting next month, then on clicking this button perform following action
   ivNext.setOnClickListener {
                horizontalCalendarView.setNextMonthDate()
            }
  • Similarly on clicking previous button, perform following action
   ivPrevious.setOnClickListener {
                horizontalCalendarView.setPreviousMonthDate()
            }

Contribution

  • Feel free to submit pull request. Also if you have any issue (on latest version) or want some other features on this library, kindly open an issue.

Credit

  • Miti

License

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

Copyright 2021 MeroCalendar Author

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.

merocalendar's People

Contributors

puskal-khadka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

merocalendar's Issues

I want to build with custom initial date

Calendar.getInstance() is used inside fun initCalendar() which just builds calendar for this month

what if I want to build initial calendar not for this month ?

I recommend something like:
private fun initCalendar(calendar: Calendar)

fun build(calendar: Calendar = Calendar.getInstance())

@puskal-khadka sir

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.