-
Notifications
You must be signed in to change notification settings - Fork 1
Core Concepts
Understanding the core concepts of the Quran API SDK is essential for effectively using its features and integrating it into your Android application. This section covers the key components and their roles, providing insight into the SDK’s modular and flexible architecture.
The Quran API SDK is designed with modularity and efficiency in mind, making it easy for developers to access and manage Quranic data. The SDK is built around several core components:
- QuranAPI Singleton
- Repository Classes
- Interfaces
- Data Models
- JNI Integration
Each component plays a specific role in organizing, retrieving, and managing Quranic data. Let’s go through each in detail.
The QuranAPI
singleton is the main entry point for accessing all data and services provided by the SDK. Once initialized, it provides access to core repositories and interfaces required for working with Quranic data. This centralizes all data access, making it easy to retrieve information without needing to initialize multiple classes.
- Unified Access: Provides a single access point for all SDK services, including Surahs, Juz, Pages, and translations.
- Initialization: Manages data setup and configuration upon initialization.
- Service Handling: Ensures all data-related services are ready to use as soon as the application starts.
Repository classes are responsible for managing data retrieval and manipulation for specific types of Quranic content. They interact with the underlying data storage, providing efficient access to Quranic data.
- RepositoryJuz: Handles data related to Juz (sections) in the Quran.
- RepositorySurah: Manages data retrieval for Surahs, including metadata and related Ayahs.
- RepositoryQuran: Provides access to detailed Quranic content, including specific Ayahs.
- RepositoryTranslation: Facilitates downloading, updating, and managing translations in multiple languages.
Each repository implements an interface that defines its primary functionalities, ensuring a consistent approach to data retrieval across the SDK.
The SDK is designed with interfaces to provide a flexible and extensible architecture. Each repository class implements an interface that defines the contract for data access and management, enabling developers to:
- Customize Behavior: Extend or replace components without modifying the core SDK.
- Consistent API: Ensure a standard structure for querying data across different components.
- BaseJuz: Interface for Juz-related data access and management.
- BaseSurah: Interface for retrieving and managing Surah-specific data.
- BaseQuran: Interface for querying Quranic content such as Ayahs.
- BaseTranslation: Interface for managing translations, including downloading and updating.
Data models represent the core structure of Quranic data within the SDK. These models encapsulate the data fields and properties required for each type of Quranic content. Some of the main data models include:
-
ModelIndex
- Represents an index entry containing metadata such as the ID, Surah number, Juz, page number, and Ayah position within a Surah.
- Fields:
-
id
: Unique identifier. -
surah
: Surah number. -
juz
: Juz number. -
page
: Page number in the Quran. -
ayahInSurah
: Position of the Ayah within the Surah.
-
-
ModelJuz
- Contains information about a specific Juz, including its number, starting ID, Surah, and total number of Ayahs.
- Fields:
-
number
: Juz number. -
startId
: ID where the Juz starts. -
startSurah
: Surah number where the Juz begins. -
totalAyah
: Total number of Ayahs in this Juz.
-
-
ModelQuran
- Represents an Ayah along with related information like Surah, Juz, page, and translations.
- Fields:
-
id
: Unique identifier (default is 0). -
surah
: Surah number. -
juz
: Juz number. -
page
: Page number. -
ayahInSurah
: Position of the Ayah within the Surah. -
arabic
: Arabic text of the Ayah. -
translation
: List of translations associated with the Ayah.
-
-
ModelSurah
- Represents a Surah in the Quran, including its name, translation, revelation type, and total Ayah count.
- Fields:
-
number
: Surah number. -
startId
: Starting ID for this Surah. -
arabicName
: Arabic name of the Surah. -
englishName
: English name of the Surah. -
englishTranslation
: English translation of the name. -
revelationType
: Revelation type (e.g., Meccan or Medinan). -
numberOfAyahs
: Total number of Ayahs in the Surah.
-
-
ModelTranslator
- Represents a translator, including the translation code, language, and translator’s name.
- Fields:
-
code
: Translation code (e.g., “en_saheeh”). -
name
: Translation name. -
language
: Language of the translation. -
translator
: Name of the translator.
-
Data models enable easy access to structured Quranic information, providing developers with a standard format for displaying or manipulating data in their applications.
The Quran API SDK uses JNI (Java Native Interface) to efficiently manage large datasets. JNI allows the SDK to perform low-level data operations directly in native code, which improves performance and minimizes memory usage.
- Optimized Performance: Accesses Quranic data stored in binary format, speeding up retrieval times.
- Memory Efficiency: Reduces the memory footprint by using native storage for large datasets like translations.
- Direct Data Access: Enables fast loading and retrieval of Quranic text without overloading the main application memory.
The JNI integration is implemented in the NativeUtils
class, which provides utility methods for data reading and retrieval.
These core components work together to provide a flexible and powerful foundation for accessing and managing Quranic data. Understanding how each part interacts with the others will help you make the most of the Quran API SDK in your projects.
In the next sections, we’ll dive deeper into specific features and usage patterns, showing you how to retrieve Quranic data, manage translations, and customize the SDK for your specific needs.