Skip to content

Commit

Permalink
Implement New API Class + Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
j-schwar committed Aug 22, 2020
1 parent c3da28c commit b8d076e
Show file tree
Hide file tree
Showing 21 changed files with 437 additions and 681 deletions.
23 changes: 6 additions & 17 deletions app/src/main/java/com/cradle/neptune/dagger/DataModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import androidx.preference.PreferenceManager
import androidx.room.Room
import com.cradle.neptune.database.CradleDatabase
import com.cradle.neptune.manager.HealthCentreManager
import com.cradle.neptune.manager.MarshalManager
import com.cradle.neptune.manager.PatientManager
import com.cradle.neptune.manager.ReadingManager
import com.cradle.neptune.manager.UrlManager
import com.cradle.neptune.manager.VolleyRequestManager
import com.cradle.neptune.network.Api
import com.cradle.neptune.net.Http
import com.cradle.neptune.network.VolleyRequestQueue
import dagger.Module
import dagger.Provides
Expand All @@ -35,10 +33,7 @@ class DataModule {

@Provides
@Singleton
fun provideReadingService(
database: CradleDatabase,
marshalManager: MarshalManager?
): ReadingManager {
fun provideReadingService(database: CradleDatabase): ReadingManager {
return ReadingManager(database.readingDaoAccess())
}

Expand All @@ -60,6 +55,10 @@ class DataModule {
return PreferenceManager.getDefaultSharedPreferences(application)
}

@Provides
@Singleton
fun providesHttp(application: Application?): Http = Http()

@Provides
@Singleton
fun provideVolleyRequestQueue(application: Application?): VolleyRequestQueue {
Expand All @@ -71,14 +70,4 @@ class DataModule {
fun provideVolleyRequestManager(application: Application?): VolleyRequestManager {
return VolleyRequestManager(application!!)
}

@Provides
@Singleton
fun provideApi(
sharedPreferences: SharedPreferences?,
urlManager: UrlManager?,
volleyRequestQueue: VolleyRequestQueue?
): Api {
return Api(sharedPreferences!!, urlManager!!, volleyRequestQueue!!)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import androidx.room.TypeConverter
import com.cradle.neptune.model.Assessment
import com.cradle.neptune.model.BloodPressure
import com.cradle.neptune.model.GestationalAge
import com.cradle.neptune.model.JsonObject
import com.cradle.neptune.model.ReadingMetadata
import com.cradle.neptune.model.Referral
import com.cradle.neptune.model.Sex
import com.cradle.neptune.model.UrineTest
import com.google.gson.Gson
import com.google.gson.JsonArray
import org.json.JSONObject

/**
* A list of [TypeConverter] to save objects into room database
Expand All @@ -23,7 +23,7 @@ class DatabaseTypeConverters {

@TypeConverter
fun stringToGestationalAge(string: String?): GestationalAge? =
string?.let { GestationalAge.unmarshal(JsonObject(it)) }
string?.let { GestationalAge.unmarshal(JSONObject(it)) }

@TypeConverter
fun stringToSex(string: String): Sex = enumValueOf(string)
Expand Down
Loading

0 comments on commit b8d076e

Please sign in to comment.