-
-
Notifications
You must be signed in to change notification settings - Fork 728
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove context dependency from EventAdapter
- Introduce IResourceManager to provide resource contract, move towards a more testable code base - Add type safety in WebServer and Adapter Signed-off-by: Arka Prava Basu <[email protected]>
- Loading branch information
Showing
6 changed files
with
56 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,4 @@ interface EventDAO { | |
|
||
@Query("SELECT COUNT(*) FROM EVENT") | ||
fun count() : Int | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/org/havenapp/main/resources/IResourceManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.havenapp.main.resources | ||
|
||
/** | ||
* A Resource Manager Contract. | ||
* Created by Arka Prava Basu <[email protected]> on 1/9/18. | ||
*/ | ||
interface IResourceManager { | ||
fun getString(id: Int): String | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/org/havenapp/main/resources/ResourceManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.havenapp.main.resources | ||
|
||
import android.content.Context | ||
|
||
/** | ||
* An implementation of [IResourceManager] which requires [Context] for providing resources. | ||
* <p> | ||
* Created by Arka Prava Basu <[email protected]> on 1/9/18. | ||
*/ | ||
class ResourceManager(private val context: Context): IResourceManager { | ||
|
||
override fun getString(id: Int): String { | ||
return context.getString(id) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters