Tutorial Membuat Aplikasi Al-Quran dengan API |
Perbedaannya adalah, jika di tutorial sebelumnya hanya menggunakan database lokal atau SQLite. Kali ini saya menggunakan API dengan Retrofit untuk menampilkan datanya. Jadi kali ini kalian harus menggunakan koneksi internet untuk menjalankan sampel ini. Sampel ini juga bisa kalian jadikan referensi untuk yang lagi skripsi bagi yang membutuhkan.
Jika kalian ingin SOURCE CODE sample aplikasi ini, silahkan download di GITHUB saya DISINI. Tetapi jika kalian ingin tahu cara mengaplikasikannya, silahkan lanjut baca artikel ini sampai selesai.
Untuk kalian yang ingin mencoba tutorial aplikasi ini dengan versi video, berikut saya berikan Videonya:
Jangan lupa subscribe Channel Youtube saya juga ya Azhar Rivaldi, karena disana ada banyak tutorial-tutorial untuk membuat aplikasi lainnya. Oke langsung saja tanpa basa-basi lagi kita langsung ke langkah pertama :
1. Buat project baru di Android Studio dengan cara klik File ⇒ Project Baru. Ketika diminta untuk memilih Default Activity, pilih Empty Activity dan klik next. Untuk minSDK, disini saya set API 21 ya.
2. Tambahkan library Retrofit di build.gradle untuk Rest API :
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.squareup.retrofit2:retrofit:2.6.2'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:okhttp:3.12.0'
}
3. Ubah activity_main.xml dan MainActivity.java menjadi seperti ini :
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/mToolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:background="@drawable/design_header"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp">
<TextView
android:id="@+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginStart="10dp"
android:text="@string/app_name"
android:textColor="@android:color/white"
android:textSize="20sp" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/surah_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
package com.azhar.quranretrofit.activities;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.azhar.quranretrofit.R;
import com.azhar.quranretrofit.adapter.SurahAdapter;
import com.azhar.quranretrofit.model.Cek;
import com.azhar.quranretrofit.model.Data;
import com.azhar.quranretrofit.model.Surah;
import com.azhar.quranretrofit.api.ApiClient;
import com.azhar.quranretrofit.api.ApiInterface;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class MainActivity extends AppCompatActivity {
private static final String arabic = "quran-uthmani";
private static final String indo = "id.indonesian";
private List surahsArabic = new ArrayList<>();
private List surahsIndo = new ArrayList<>();
ProgressDialog loadingData;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
loadingData = new ProgressDialog(this);
loadingData.setTitle("Mohon tunggu...");
loadingData.setCancelable(false);
loadingData.setMessage("Sedang mengambil data dari API");
RecyclerView recyclerSurah = findViewById(R.id.surah_list);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
recyclerSurah.setHasFixedSize(true);
recyclerSurah.setLayoutManager(layoutManager);
ApiInterface apiInterface = ApiClient.getRetrofit().create(ApiInterface.class);
Call call = apiInterface.getCek(arabic);
Call callIndo = apiInterface.getCek(indo);
getDataListArabic(recyclerSurah, call);
getDataTarjim(callIndo);
}
private void getDataTarjim(Call callIndo) {
callIndo.enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) {
Data data = response.body().getData();
surahsIndo = data.getSurahs();
}
@Override
public void onFailure(Call call, Throwable t) {
Toast.makeText(MainActivity.this, "gagal", Toast.LENGTH_SHORT).show();
Log.d("error", t.getMessage());
}
});
}
private void getDataListArabic(final RecyclerView recyclerSurah, Call call) {
loadingData.show();
call.enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) {
Data data = response.body().getData();
surahsArabic = data.getSurahs();
SurahAdapter surahAdapter = new SurahAdapter(MainActivity.this, surahsArabic, surahsIndo);
recyclerSurah.setAdapter(surahAdapter);
loadingData.dismiss();
}
@Override
public void onFailure(Call call, Throwable t) {
loadingData.dismiss();
Toast.makeText(MainActivity.this, "gagal", Toast.LENGTH_SHORT).show();
Log.d("error", t.getMessage());
}
});
}
}
4. Buat activity_surah_content.xml dan SurahActivity.java, langsung copy saja :
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.SurahActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/mToolbarSurah"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:background="@drawable/design_header"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp">
<TextView
android:id="@+id/txtTitleSurah"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginStart="10dp"
android:text="Title Surah"
android:textColor="@android:color/white"
android:textSize="20sp" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/ayat_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
package com.azhar.quranretrofit.activities;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.azhar.quranretrofit.R;
import com.azhar.quranretrofit.adapter.AyatAdapter;
import com.azhar.quranretrofit.model.Ayat;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.List;
public class SurahActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_surah_content);
Toolbar mToolbarSurah = findViewById(R.id.mToolbarSurah);
setSupportActionBar(mToolbarSurah);
assert getSupportActionBar() != null;
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
String json = getIntent().getStringExtra("jsonlist");
String jsonIndo = getIntent().getStringExtra("jsonlistIndo");
String jsonTitle = getIntent().getStringExtra("jsonTitle");
Type type = new TypeToken>() {
}.getType();
TextView txtTitleSurah = findViewById(R.id.txtTitleSurah);
txtTitleSurah.setText(jsonTitle);
txtTitleSurah.findViewById(R.id.txtTitleSurah);
txtTitleSurah.setText(jsonTitle);
Gson gson = new Gson();
List ayatList = gson.fromJson(json, type);
List ayatListIndo = gson.fromJson(jsonIndo, type);
RecyclerView recyclerAyat = findViewById(R.id.ayat_list);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
AyatAdapter ayatAdapter = new AyatAdapter(this, ayatList, ayatListIndo);
recyclerAyat.setLayoutManager(layoutManager);
recyclerAyat.setHasFixedSize(true);
recyclerAyat.setAdapter(ayatAdapter);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (item.getItemId() == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}
5. Buat item_ayat.xml dan AyatAdapter.java untuk menampilkan List Ayat :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="2sp"
app:cardCornerRadius="10dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<LinearLayout
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="@drawable/shape"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/number_ayat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="99"
android:textColor="@color/colorAccent"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="8"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_marginEnd="1dp"
android:layout_marginBottom="10dp">
<TextView
android:id="@+id/arabic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Ayat"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="1dp">
<TextView
android:id="@+id/tarjim"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Arti"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>
package com.azhar.quranretrofit.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.azhar.quranretrofit.R;
import com.azhar.quranretrofit.model.Ayat;
import java.util.List;
public class AyatAdapter extends RecyclerView.Adapter {
private Context context;
private List list;
private List listIndo;
public AyatAdapter(Context context, List list, List listIndo) {
this.context = context;
this.list = list;
this.listIndo = listIndo;
}
@NonNull
@Override
public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
context = parent.getContext();
View view = LayoutInflater.from(context).inflate(R.layout.item_ayat, parent, false);
return new Holder(view);
}
@Override
public void onBindViewHolder(@NonNull Holder holder, int position) {
Ayat ayat = list.get(position);
Ayat ayatIndo = listIndo.get(position);
holder.nomorAyat.setText(ayat.getNumberInSurah());
holder.arabic.setText(ayat.getText());
holder.tarjim.setText(ayatIndo.getText());
}
@Override
public int getItemCount() {
return list.size();
}
public class Holder extends RecyclerView.ViewHolder {
TextView nomorAyat, arabic, tarjim;
public Holder(View itemView) {
super(itemView);
nomorAyat = itemView.findViewById(R.id.number_ayat);
arabic = itemView.findViewById(R.id.arabic);
tarjim = itemView.findViewById(R.id.tarjim);
}
}
}
6. Buat item_row.xml dan SurahAdapter.java untuk menampilkan List Surah :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="2sp"
app:cardCornerRadius="10dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<LinearLayout
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="@drawable/shape"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/number_surah"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="99"
android:textColor="@color/colorAccent"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="8"
android:orientation="vertical">
<TextView
android:id="@+id/translation_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:lines="1"
android:singleLine="true"
android:text="Arti"
android:textColor="#000000"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="1dp"
android:orientation="horizontal">
<TextView
android:id="@+id/ayat_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Jumlah Ayat"
android:textColor="#616161"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="1dp"
android:orientation="horizontal">
<TextView
android:id="@+id/type_surah"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tipe Surah"
android:textColor="#616161"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingStart="10sp">
<TextView
android:id="@+id/title_surah"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nama Surah"
android:textColor="#000000"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>
package com.azhar.quranretrofit.adapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.azhar.quranretrofit.R;
import com.azhar.quranretrofit.activities.SurahActivity;
import com.azhar.quranretrofit.model.Surah;
import com.google.gson.Gson;
import java.util.List;
public class SurahAdapter extends RecyclerView.Adapter {
private Context context;
private List list;
private List listIndo;
private View view;
public SurahAdapter(Context context, List list, List listIndo) {
this.context = context;
this.list = list;
this.listIndo = listIndo;
}
public SurahAdapter(Context context, List list) {
this.context = context;
this.list = list;
}
@NonNull
@Override
public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
context = parent.getContext();
view = LayoutInflater.from(context).inflate(R.layout.item_row, parent, false);
return new Holder(view);
}
@SuppressLint("SetTextI18n")
@Override
public void onBindViewHolder(@NonNull Holder holder, final int position) {
final Surah surah = list.get(position);
final Surah surahIndo = listIndo.get(position);
holder.numberSurah.setText(surah.getNumber());
holder.titleSurah.setText(surah.getName());
holder.translationTitle.setText(surah.getTranslateName());
holder.typeTitle.setText(surah.getType());
holder.ayatSize.setText(surah.getAyatList().size() +" ayat");
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Gson gson = new Gson();
String json = gson.toJson(surah.getAyatList());
String jsonIndo = gson.toJson(surahIndo.getAyatList());
Intent intent = new Intent(context, SurahActivity.class);
intent.putExtra("jsonlist", json);
intent.putExtra("jsonlistIndo", jsonIndo);
intent.putExtra("jsonTitle", surah.getEnglishName());
context.startActivity(intent);
}
});
}
@Override
public int getItemCount() {
return list.size();
}
public class Holder extends RecyclerView.ViewHolder {
private TextView numberSurah, titleSurah, translationTitle, typeTitle, ayatSize;
public Holder(View itemView) {
super(itemView);
numberSurah = itemView.findViewById(R.id.number_surah);
titleSurah = itemView.findViewById(R.id.title_surah);
translationTitle = itemView.findViewById(R.id.translation_title);
typeTitle = itemView.findViewById(R.id.type_surah);
ayatSize = itemView.findViewById(R.id.ayat_size);
}
}
}
7. Buat Class ApiClient.java dan ApiInterface.java untuk API :
package com.azhar.quranretrofit.api;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class ApiClient {
private static final String BASEURL = "http://api.alquran.cloud/";
private static Retrofit retrofit = null;
public static Retrofit getRetrofit() {
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.connectTimeout(100, TimeUnit.SECONDS)
.readTimeout(100, TimeUnit.SECONDS)
.build();
if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(BASEURL)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
}
package com.azhar.quranretrofit.api;
import com.azhar.quranretrofit.model.Cek;
import com.azhar.quranretrofit.model.Data;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
public interface ApiInterface {
@GET("quran/id.indonesian")
Call getData();
@GET("quran/quran-uthmani")
Call getDataArabic();
@GET("quran/{lang}")
Call getCek(@Path("lang") String lang);
@GET("surah/1/id.indonesian")
Call getSurahTranslation(/*@Path("id")int id*/);
// id.indonesian
}
8. Yang terakhir buat Class Ayat.java, Surah.java, Edition.java, Data.java dan Cek.java sebagai modelnya :
package com.azhar.quranretrofit.model;
import com.google.gson.annotations.SerializedName;
public class Ayat {
@SerializedName("number")
private int numberAyat;
@SerializedName("text")
private String text;
@SerializedName("numberInSurah")
private String numberInSurah;
@SerializedName("juz")
private int juz;
public Ayat(int numberAyat, String text, String numberInSurah, int juz) {
this.numberAyat = numberAyat;
this.text = text;
this.numberInSurah = numberInSurah;
this.juz = juz;
}
public int getNumberAyat() {
return numberAyat;
}
public void setNumberAyat(int numberAyat) {
this.numberAyat = numberAyat;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getNumberInSurah() {
return numberInSurah;
}
public void setNumberInSurah(String numberInSurah) {
this.numberInSurah = numberInSurah;
}
public int getJuz() {
return juz;
}
public void setJuz(int juz) {
this.juz = juz;
}
}
package com.azhar.quranretrofit.model;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class Surah {
@SerializedName("name")
private String name;
@SerializedName("number")
private String number;
@SerializedName("englishName")
private String englishName;
@SerializedName("englishNameTranslation")
private String translateName;
@SerializedName("revelationType")
private String type;
@SerializedName("ayahs")
private List ayatList;
public Surah(String name, String number, String englishName, String translateName, String type, List ayatList) {
this.name = name;
this.number = number;
this.englishName = englishName;
this.translateName = translateName;
this.type = type;
this.ayatList = ayatList;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getEnglishName() {
return englishName;
}
public void setEnglishName(String englishName) {
this.englishName = englishName;
}
public String getTranslateName() {
return translateName;
}
public void setTranslateName(String translateName) {
this.translateName = translateName;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List getAyatList() {
return ayatList;
}
public void setAyatList(List ayatList) {
this.ayatList = ayatList;
}
}
package com.azhar.quranretrofit.model;
import com.google.gson.annotations.SerializedName;
public class Edition {
@SerializedName("identifier")
private String identifier;
@SerializedName("language")
private String lang;
@SerializedName("name")
private String name;
@SerializedName("englishName")
private String englishName;
@SerializedName("format")
private String format;
@SerializedName("type")
private String type;
public Edition(){
super();
}
public Edition(String identifier, String lang, String name, String englishName, String format, String type) {
this.identifier = identifier;
this.lang = lang;
this.name = name;
this.englishName = englishName;
this.format = format;
this.type = type;
}
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public String getLang() {
return lang;
}
public void setLang(String lang) {
this.lang = lang;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEnglishName() {
return englishName;
}
public void setEnglishName(String englishName) {
this.englishName = englishName;
}
public String getFormat() {
return format;
}
public void setFormat(String format) {
this.format = format;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package com.azhar.quranretrofit.model;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class Data {
@SerializedName("surahs")
private List surahs;
private List ayats;
private Edition edition;
public Data(List surahs, Edition edition) {
this.surahs = surahs;
this.edition = edition;
}
public Data(List surahs, List ayats, Edition edition) {
this.surahs = surahs;
this.ayats = ayats;
this.edition = edition;
}
public List getSurahs() {
return surahs;
}
public void setSurahs(List surahs) {
this.surahs = surahs;
}
public Edition getEdition() {
return edition;
}
public void setEdition(Edition edition) {
this.edition = edition;
}
public List getAyats() {
return ayats;
}
public void setAyats(List ayats) {
this.ayats = ayats;
}
}
package com.azhar.quranretrofit.model;
import com.google.gson.annotations.SerializedName;
public class Cek {
@SerializedName("data")
private Data data;
public Cek(Data data) {
this.data = data;
}
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
}
9. Selesai dan kalian Run. Jika kalian mengikuti langkah-langkah diatas dengan baik, pasti aplikasi yang kalian buat akan berjalan sebagaimana mestinya. Namun jika mengalami Error, silahkan berikan komentar dan kita diskusikan bersama.
Demikian informasi yang saya bagikan untuk kalian. Jangan lupa bagikan artikel ini ke teman-teman kalian agar ikut membaca Tutorial Membuat Aplikasi Al-Quran dengan Retrofit menggunakan Android Studio ini. Subscribe juga blog Rivaldi 48 ini agar kalian mendapatkan notifikasi saat Admin update artikel terbaru. Semoga kalian lebih nyaman dan mudah dalam mengakses Blog Rivaldi 48 dimanapun kalian berada. Terima Kasih. Follow Instagram Admin @azhardvls_