This repository contains the final project for the Mobile Application Development module offered by the National Institute of Business Management (NIBM). The project is implemented using the Kotlin programming language and is focused on developing a mobile application with a user-friendly interface.
This repository contains a RESTful API developed using the Calendarific API. The API provides information about worldwide holidays and observances for different countries and regions.
This App provides the following features:
- Search holidays by country, year, and type.
- Get information about holidays, including their names, descriptions, dates, and types.
The following technologies and tools were used to implement the project:
- Kotlin Programming Language
- Android Studio IDE
- Volley Library
- Calendarific API
-
Clone the Github repository that contains the Android project. You can do this by navigating to the repository page on Github and clicking on the "Clone or download" button, then copying the repository URL.
-
Open Android Studio on your local machine.
-
Select "File" from the menu bar, then choose "New" > "Project from Version Control" > "Git"
-
In the "Clone Repository" window, paste the repository URL in the "URL" field.
-
Choose the directory where you want to store the project on your local machine.
-
Click the "Clone" button to start the cloning process. Android Studio will download the project from Github and import it into the IDE.
-
Once the project is imported, you can open and run it in Android Studio as you would with any other Android project.
dependencies{
// Lottie Library (Animated Icon)
implementation 'com.airbnb.android:lottie:3.4.0'
// Volley Library
// https://mvnrepository.com/artifact/com.android.volley/volley
implementation("com.android.volley:volley:1.2.1")
// Glide Library for Kotlin
// https://mvnrepository.com/artifact/com.github.bumptech.glide/glide
implementation("com.github.bumptech.glide:glide:4.14.2")
}
The API documentation can be found at https://calendarific.com
. This provides detailed information on how to use each endpoint.
/api/v2/holidays?api_key=<API_KEY>&country=<COUNTRY_CODE>&year=<YEAR>
Parameter | Type | Description |
---|---|---|
api_key |
string |
Required. Your API key |
country |
string |
Your Country Code (US, UK, AU, LK) |
year |
string |
The year you want to return the Holidays |
https://calendarific.com/api/v2/holidays?&api_key=baa9dc110aa712sd3a9fa2a3dwb6c01d4c875950dc32vs&country=US&year=2019
{
"meta": {
"code": 200
},
"response": {
"holidays": [
{
"name": "Name of holiday goes here",
"description": "Description of holiday goes here",
"date": {
"iso": "2018-12-31",
"datetime": {
"year": 2018,
"month": 12,
"day": 31
}
},
"type": [
"Type of Observance goes here"
]
}
]
}
}
@SuppressLint("NotifyDataSetChanged")
private fun getHolidays() {
dialog.show()
val url = resources.getString(R.string.HOLIDAYS_BASE_URL) + resources.getString(R.string.API_KEY) + "&country=LK&year=2023"
val result = StringRequest(Request.Method.GET, url, Response.Listener { response ->
try {
val jsonObject = JSONObject(response)
val jsonObjectResponse = jsonObject.getJSONObject("response")
val jsonArrayHolidays = jsonObjectResponse.getJSONArray("holidays")
for (i in 0 until jsonArrayHolidays.length()){
val jsonObjectHolidayList = jsonArrayHolidays.getJSONObject(i)
val date = jsonObjectHolidayList.getJSONObject("date")
val dateTime = date.getJSONObject("datetime")
val holidays = HolidaysModel()
holidays.holidayName = jsonObjectHolidayList.getString("name")
holidays.holidayDescription = jsonObjectHolidayList.getString("description")
holidays.holidayDate = dateTime.getString("day")
holidays.holidayMonth = dateTime.getString("month")
holidays.holidayYear = dateTime.getString("year")
holidays.holidayPrimaryType = jsonObjectHolidayList.getString("primary_type")
holidays.holidayCountry = jsonObjectHolidayList.getJSONObject("country").getString("name")
holidaysList.add(holidays)
}
// Pass holidays to adapter
val adapter = HolidayAdapter(this, holidaysList)
recyclerViewWorldCalendar.setHasFixedSize(true)
recyclerViewWorldCalendar.layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
recyclerViewWorldCalendar.adapter = adapter
adapter.notifyDataSetChanged()
dialog.dismiss()
}catch (e: Exception){
Toast.makeText(this, e.message, Toast.LENGTH_SHORT).show()
dialog.dismiss()
}
}, Response.ErrorListener { error ->
Toast.makeText(this, error.message, Toast.LENGTH_SHORT).show()
dialog.dismiss()
})
Volley.newRequestQueue(this).add(result)
}
- G D T Karunathilaka
- S D N Perera
- T M L M Weerasinghe
- N A D K K Shaminda