OfflinePrayerTimes is a powerful, flexible and customizable Offline Prayer Times library used to get current day Prayer Timings.
In your project-level build.gradle or settings.gradle file, add the JitPack repository:
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
Next, include the library in your app-level build.gradle file. Replace x.x.x with the latest version
implementation com.github.hypersoftdev:OfflinePrayerTimes:x.x.x'
- Things app must have before starting implementation
- App must have latitude and longitude value in order to pass these in below code.
class MainActivity : AppCompatActivity() {
private var prayerTimeCoroutine: Job? = null
private var sharedPrefManager: SharedPrefManager? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_main)
//Use Below Functions
setPrayerAttributes()
getTodayPrayerTimes()
}
private fun setPrayerAttributes() {
sharedPrefManager = SharedPrefManager(
getSharedPreferences(
"prayer_preferences",
MODE_PRIVATE
)
)
sharedPrefManager?.prayerLatitude = 33.601921.toBits() //Put your own Latitude value here
sharedPrefManager?.prayerLongitude = 73.038078.toBits() //Put your own Longitude value here
}
private fun getTodayPrayerTimes() {
prayerTimeCoroutine = object : PrayerTimeCoroutine(
sharedPrefManager!!
) {
override fun onPreExecute() {
super.onPreExecute()
}
override fun onPostExecute(
prayerTimeList: ArrayList<PrayerTimeModel>?,
nextDayFajrTime: String?
) {
super.onPostExecute(prayerTimeList, nextDayFajrTime)
if (!prayerTimeList.isNullOrEmpty() && nextDayFajrTime?.isNotEmpty() == true) {
//Write your own logic here
}
clearPrayerResources() //Optional
cancelCoroutine() //Optional
}
}.executeCoroutine()
}
private fun cancelCoroutine() {
if (prayerTimeCoroutine != null && prayerTimeCoroutine?.isActive == true) {
prayerTimeCoroutine?.cancel("coroutineCanceled", null)
}
prayerTimeCoroutine = null
}
//Optional
override fun onDestroy() {
cancelCoroutine()
super.onDestroy()
}
}
Attribute | Format | Description |
---|---|---|
prayerLatitude | long | Set latitude (e.g, 33.601921.toBits()) |
prayerLongitude | long | Set longitude (e.g, 73.038078.toBits()) |
prayerTimeFormat | Int | Set Prayer Time Format. 1 = 12Hour (Default) 0 = 24Hour |
prayerCalMethod | Int | Set Prayer Calculation Method 0 = JAFARI 1 = University of Islamic Sciences, KARACHI (Default) 2 = Islamic Society of North America (ISNA) 3 = Muslim World League (MWL) 4 = Umm al-Qura, MAKKAH 5 = Egyptian General Authority of Survey 6 = Institute of Geophysics, University of TEHRAN |
asrJuristic | Int | Set Asr Juristic. 1 = Hanfi (Default) 0 = Shafi |
prayerHighLats | Int | Adjustment for Higher Altitudes areas. 0 = No Adjustment 1 = Middle of Night 2 = 1/7th of Night 3 = Angle/60th of Night (Default) |
- Offline Prayer Times
- Get All Prayer Timings (Online/Offline).
- Customizable attributes so user can get accurate prayer times based on their location.
- Get next day Fajr prayer time in advance to show it to user for better user experience.
This work would not have been possible without the invaluable contributions of M. Ali Khan. His expertise, dedication, and unwavering support have been instrumental in bringing this project to fruition.
We are deeply grateful for M. Ali Khan's involvement and his belief in the importance of this work. His contributions have made a significant impact, and we are honored to have had the opportunity to collaborate with him.
Copyright 2023 Hypersoft Inc
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.