Skip to content

Instantly share code, notes, and snippets.

@MahmoudMabrok
Created Nov 4, 2019
Embed
What would you like to do?
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor "com.jakewharton:butterknife-compiler:10.1.0"
implementation "com.balsikandar.android:crashreporter:1.0.9"
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.intuit.ssp:ssp-android:1.0.6'
def lifecycle_version = '2.0.0-beta01'
implementation "androidx.room:room-runtime:$lifecycle_version"
annotationProcessor "androidx.room:room-compiler:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
@MahmoudMabrok

This comment has been minimized.

Copy link
Owner Author

@MahmoudMabrok MahmoudMabrok commented Nov 4, 2019

compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

@MahmoudMabrok

This comment has been minimized.

Copy link
Owner Author

@MahmoudMabrok MahmoudMabrok commented Nov 4, 2019

public class ApiClient {

private static final String prayerUrl = "http://api.aladhan.com/v1/";

static Gson gson = new GsonBuilder()
        .setLenient()
        .create();

private static Retrofit retrofitPrayer = null;

public static synchronized Retrofit getRetrofitPrayer() {
    if (retrofitPrayer == null) {
        retrofitPrayer = new Retrofit.Builder()
                .baseUrl(prayerUrl)
                .addConverterFactory(GsonConverterFactory.create(gson))
                .build();
    }
    return retrofitPrayer;
}

}

@MahmoudMabrok

This comment has been minimized.

Copy link
Owner Author

@MahmoudMabrok MahmoudMabrok commented Nov 4, 2019

package utitity.mahmoud.prayertimes.datalayer.local.room;

import android.app.Application;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.TypeConverters;

@database(entities = {DayPrayerItem.class}, version = 2, exportSchema = false)
@TypeConverters({TimingConverter.class})
public abstract class PrayerDB extends RoomDatabase {

static PrayerDB instance;

public static synchronized PrayerDB getInstance(Application application) {
    if (instance == null) {
        instance = Room.databaseBuilder(application, PrayerDB.class, "prayer")
                .allowMainThreadQueries()
                .fallbackToDestructiveMigration()
                .build();
    }
    return instance;
}

public abstract DayPrayerDao getDayPrayerDao();

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment