Permalink
Browse files

In-memory version of data stores (#135)

  • Loading branch information...
tehmou authored and apoi committed Oct 10, 2016
1 parent 32f9718 commit 46a824674fe4aef1ccc665879f1788833113eea4
Showing with 2,906 additions and 495 deletions.
  1. +5 −21 app/build.gradle
  2. +2 −2 .../androidTest/java/io/reark/rxgithubapp/{ → advanced}/activities/ChooseRepositoryActivityTest.java
  3. +2 −2 app/src/androidTest/java/io/reark/rxgithubapp/{ → advanced}/activities/MainActivityTest.java
  4. +8 −8 app/src/main/AndroidManifest.xml
  5. +4 −4 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/RxGitHubApp.java
  6. +2 −2 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/activities/ChooseRepositoryActivity.java
  7. +6 −6 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/activities/MainActivity.java
  8. +1 −1 ...ark/rxgithubapp → main/java/io/reark/rxgithubapp/advanced}/activities/utils/SystemAnimations.java
  9. +78 −0 app/src/main/java/io/reark/rxgithubapp/advanced/data/DataLayer.java
  10. +15 −14 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/data/DataStoreModule.java
  11. +1 −1 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/data/schematicProvider/GitHubDatabase.java
  12. +6 −2 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/data/schematicProvider/GitHubProvider.java
  13. +1 −1 .../main/java/io/reark/rxgithubapp/{ → advanced}/data/schematicProvider/GitHubRepositoryColumns.java
  14. +1 −1 ...java/io/reark/rxgithubapp/{ → advanced}/data/schematicProvider/GitHubRepositorySearchColumns.java
  15. +1 −1 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/data/schematicProvider/JsonIdColumns.java
  16. +1 −1 ...n/java/io/reark/rxgithubapp/{ → advanced}/data/schematicProvider/NetworkRequestStatusColumns.java
  17. +1 −1 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/data/schematicProvider/UserSettingsColumns.java
  18. +5 −5 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/data/stores/GitHubRepositorySearchStore.java
  19. +52 −0 app/src/main/java/io/reark/rxgithubapp/advanced/data/stores/GitHubRepositoryStore.java
  20. +4 −4 .../java/io/reark/rxgithubapp/{data/stores/StoreBase.java → advanced/data/stores/GsonStoreBase.java}
  21. +5 −5 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/data/stores/NetworkRequestStatusStore.java
  22. +1 −1 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/data/stores/StoreModule.java
  23. +8 −8 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/data/stores/UserSettingsStore.java
  24. +21 −27 ...ta/stores/GitHubRepositoryStore.java → advanced/data/stores/cores/GitHubRepositoryStoreCore.java}
  25. +51 −0 app/src/main/java/io/reark/rxgithubapp/advanced/data/stores/cores/GsonStoreCoreBase.java
  26. +6 −6 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/fragments/RepositoriesFragment.java
  27. +6 −6 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/fragments/RepositoryFragment.java
  28. +66 −0 app/src/main/java/io/reark/rxgithubapp/advanced/injections/ApplicationModule.java
  29. +12 −11 ...elease/java/io/reark/rxgithubapp → main/java/io/reark/rxgithubapp/advanced}/injections/Graph.java
  30. +8 −6 app/src/main/java/io/reark/rxgithubapp/{network/fetchers → advanced/network}/FetcherModule.java
  31. +2 −2 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/network/NetworkService.java
  32. +7 −8 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/network/ServiceDataLayer.java
  33. +1 −1 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/widget/WidgetProvider.java
  34. +1 −1 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/widget/WidgetRemoteViewFactory.java
  35. +6 −6 app/src/main/java/io/reark/rxgithubapp/{ → advanced}/widget/WidgetService.java
  36. +1 −0 appbasic/.gitignore
  37. +123 −0 appbasic/build.gradle
  38. +17 −0 appbasic/proguard-rules.pro
  39. +38 −0 appbasic/src/androidTest/java/io/reark/rxgithubapp/basic/ApplicationTest.java
  40. +20 −0 appbasic/src/main/AndroidManifest.xml
  41. +65 −0 appbasic/src/main/java/io/reark/rxgithubapp/basic/RxGitHubApp.java
  42. +55 −0 appbasic/src/main/java/io/reark/rxgithubapp/basic/activities/ChooseRepositoryActivity.java
  43. +92 −0 appbasic/src/main/java/io/reark/rxgithubapp/basic/activities/MainActivity.java
  44. +94 −0 appbasic/src/main/java/io/reark/rxgithubapp/basic/data/DataLayer.java
  45. +84 −0 appbasic/src/main/java/io/reark/rxgithubapp/basic/data/DataStoreModule.java
  46. +35 −0 appbasic/src/main/java/io/reark/rxgithubapp/basic/data/stores/GitHubRepositorySearchStore.java
  47. +36 −0 appbasic/src/main/java/io/reark/rxgithubapp/basic/data/stores/GitHubRepositoryStore.java
  48. +51 −0 appbasic/src/main/java/io/reark/rxgithubapp/basic/data/stores/NetworkRequestStatusStore.java
  49. +60 −0 appbasic/src/main/java/io/reark/rxgithubapp/basic/data/stores/StoreModule.java
  50. +35 −0 appbasic/src/main/java/io/reark/rxgithubapp/basic/data/stores/UserSettingsStore.java
  51. +103 −0 appbasic/src/main/java/io/reark/rxgithubapp/basic/fragments/RepositoriesFragment.java
  52. +102 −0 appbasic/src/main/java/io/reark/rxgithubapp/basic/fragments/RepositoryFragment.java
  53. +2 −1 ...xgithubapp → appbasic/src/main/java/io/reark/rxgithubapp/basic}/injections/ApplicationModule.java
  54. +18 −20 ...a/io/reark/rxgithubapp → appbasic/src/main/java/io/reark/rxgithubapp/basic}/injections/Graph.java
  55. +76 −0 appbasic/src/main/java/io/reark/rxgithubapp/basic/network/FetcherModule.java
  56. BIN appbasic/src/main/res/mipmap-hdpi/ic_launcher.png
  57. BIN appbasic/src/main/res/mipmap-mdpi/ic_launcher.png
  58. BIN appbasic/src/main/res/mipmap-xhdpi/ic_launcher.png
  59. BIN appbasic/src/main/res/mipmap-xxhdpi/ic_launcher.png
  60. BIN appbasic/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  61. 0 {app → appbasic}/src/main/res/values-w820dp/dimens.xml
  62. +6 −0 appbasic/src/main/res/values/colors.xml
  63. +5 −0 appbasic/src/main/res/values/dimens.xml
  64. +4 −0 appbasic/src/main/res/values/strings.xml
  65. +11 −0 appbasic/src/main/res/values/styles.xml
  66. +1 −0 appshared/.gitignore
  67. +75 −0 appshared/build.gradle
  68. +21 −0 appshared/proguard-rules.pro
  69. +8 −8 ...java → appshared/src/debug/java/io/reark/rxgithubapp/shared/injections/InstrumentationModule.java
  70. +1 −1 ... appshared/src/debug/java/io/reark/rxgithubapp/shared}/utils/DebugApplicationInstrumentation.java
  71. +1 −1 .../rxgithubapp → appshared/src/debug/java/io/reark/rxgithubapp/shared}/utils/LeakCanaryTracing.java
  72. +2 −2 ...ithubapp → appshared/src/debug/java/io/reark/rxgithubapp/shared}/utils/StethoInstrumentation.java
  73. +3 −0 appshared/src/main/AndroidManifest.xml
  74. +31 −70 ...ataLayer.java → appshared/src/main/java/io/reark/rxgithubapp/shared/data/ClientDataLayerBase.java
  75. +59 −0 appshared/src/main/java/io/reark/rxgithubapp/shared/data/DataFunctions.java
  76. +11 −10 .../reark/rxgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/data/DataLayerBase.java
  77. +1 −1 ...rk/rxgithubapp/utils → appshared/src/main/java/io/reark/rxgithubapp/shared}/glide/NullTarget.java
  78. +1 −1 .../rxgithubapp/utils → appshared/src/main/java/io/reark/rxgithubapp/shared}/glide/SerialTarget.java
  79. +1 −1 ...rxgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/injections/ForApplication.java
  80. +3 −2 ...ark/rxgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/network/GitHubService.java
  81. +3 −2 .../reark/rxgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/network/NetworkApi.java
  82. +2 −2 ...hubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/network/NetworkInstrumentation.java
  83. +1 −1 ...ark/rxgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/network/NetworkModule.java
  84. +2 −2 ...ubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/network/fetchers/AppFetcherBase.java
  85. +13 −8 ...ppshared/src/main/java/io/reark/rxgithubapp/shared}/network/fetchers/GitHubRepositoryFetcher.java
  86. +16 −12 ...ed/src/main/java/io/reark/rxgithubapp/shared}/network/fetchers/GitHubRepositorySearchFetcher.java
  87. +1 −1 ...io/reark/rxgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/pojo/GitHubOwner.java
  88. +9 −1 ...ark/rxgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/pojo/GitHubRepository.java
  89. +1 −1 ...githubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/pojo/GitHubRepositorySearch.java
  90. +1 −2 ...rk → appshared/src/main/java/io/reark/rxgithubapp/shared/pojo}/GitHubRepositorySearchResults.java
  91. +1 −1 ...o/reark/rxgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/pojo/UserSettings.java
  92. +1 −1 ...bapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/utils/ApplicationInstrumentation.java
  93. +1 −1 ...ark/rxgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/utils/Instrumentation.java
  94. +1 −1 ...o/reark/rxgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/utils/LeakTracing.java
  95. +2 −2 ...bapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/utils/NullNetworkInstrumentation.java
  96. +1 −1 ...k/rxgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/utils/SubscriptionUtils.java
  97. +3 −3 .../rxgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/view/RepositoriesAdapter.java
  98. +5 −5 ...ark/rxgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/view/RepositoriesView.java
  99. +5 −5 ...reark/rxgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/view/RepositoryView.java
  100. +11 −9 ...bapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/viewmodels/RepositoriesViewModel.java
  101. +8 −8 ...hubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/viewmodels/RepositoryViewModel.java
  102. +6 −9 ...xgithubapp → appshared/src/main/java/io/reark/rxgithubapp/shared}/viewmodels/ViewModelModule.java
  103. +0 −1 {app → appshared}/src/main/res/layout/activity_main.xml
  104. +9 −11 {app → appshared}/src/main/res/layout/repositories_fragment.xml
  105. +2 −2 {app → appshared}/src/main/res/layout/repository_fragment.xml
  106. 0 {app → appshared}/src/main/res/layout/repository_item.xml
  107. 0 {app → appshared}/src/main/res/layout/widget_layout.xml
  108. +6 −0 appshared/src/main/res/values-w820dp/dimens.xml
  109. 0 {app → appshared}/src/main/res/values/dimens.xml
  110. 0 {app → appshared}/src/main/res/values/strings.xml
  111. +6 −5 ...p → appshared/src/release/java/io/reark/rxgithubapp/shared}/injections/InstrumentationModule.java
  112. +1 −1 ...ithubapp → appshared/src/release/java/io/reark/rxgithubapp/shared}/utils/NullInstrumentation.java
  113. +1 −1 .../rxgithubapp → appshared/src/release/java/io/reark/rxgithubapp/shared}/utils/NullLeakTracing.java
  114. +1 −1 ... → appshared/src/test/java/io/reark/rxgithubapp/shared}/utils/NullNetworkInstrumentationTest.java
  115. +1 −1 ...githubapp → appshared/src/test/java/io/reark/rxgithubapp/shared}/utils/SubscriptionUtilsTest.java
  116. +10 −10 ... → appshared/src/test/java/io/reark/rxgithubapp/shared}/viewmodels/RepositoriesViewModelTest.java
  117. +4 −4 ...pp → appshared/src/test/java/io/reark/rxgithubapp/shared}/viewmodels/RepositoryViewModelTest.java
  118. +5 −1 ...c/testDebug/java/io/reark/rxgithubapp/shared/injections}/DebugApplicationInstrumentationTest.java
  119. +1 −1 ... → appshared/src/testDebug/java/io/reark/rxgithubapp/shared}/utils/StethoInstrumentationTest.java
  120. +3 −0 reark/build.gradle
  121. +8 −9 ...reark/reark/data/stores/{SingleItemContentProviderStoreTest.java → ContentProviderStoreTest.java}
  122. +10 −5 reark/src/main/java/io/reark/reark/data/DataStreamNotification.java
  123. +16 −11 ...o/reark/reark/data/{store/SingleItemContentProviderStore.java → stores/ContentProviderStore.java}
  124. +71 −0 reark/src/main/java/io/reark/reark/data/stores/DefaultStore.java
  125. +47 −0 reark/src/main/java/io/reark/reark/data/stores/MemoryStore.java
  126. +63 −0 reark/src/main/java/io/reark/reark/data/stores/StoreGetInterface.java
  127. +38 −0 reark/src/main/java/io/reark/reark/data/stores/StoreInterface.java
  128. +20 −15 reark/src/main/java/io/reark/reark/data/{store → stores}/StoreItem.java
  129. +43 −0 reark/src/main/java/io/reark/reark/data/stores/StorePutInterface.java
  130. +140 −0 reark/src/main/java/io/reark/reark/data/stores/cores/ContentProviderStoreCore.java
  131. +8 −8 ...ark/reark/data/{store/ContentProviderStore.java → stores/cores/ContentProviderStoreCoreBase.java}
  132. +113 −0 reark/src/main/java/io/reark/reark/data/stores/cores/MemoryStoreCore.java
  133. +78 −0 reark/src/main/java/io/reark/reark/data/stores/cores/StoreCoreInterface.java
  134. +17 −15 reark/src/main/java/io/reark/reark/data/utils/DataLayerUtils.java
  135. +6 −4 reark/src/main/java/io/reark/reark/network/fetchers/FetcherManagerBase.java
  136. +46 −27 reark/src/main/java/io/reark/reark/pojo/NetworkRequestStatus.java
  137. +144 −0 reark/src/test/java/io/reark/reark/data/stores/MemoryStoreTest.java
  138. +144 −0 reark/src/test/java/io/reark/reark/data/stores/cores/MemoryStoreCoreTest.java
  139. +1 −1 settings.gradle
View
@@ -71,36 +71,20 @@ retrolambda {
dependencies {
compile project(':reark')
compile project(':appshared')
compile 'com.android.support:appcompat-v7:23.3.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'javax.annotation:jsr250-api:1.0'
compile 'com.squareup.okhttp:okhttp:2.7.5'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
// RxJava
compile 'io.reactivex:rxjava:1.1.3'
compile 'io.reactivex:rxandroid:1.1.0'
// Dagger
apt 'com.google.guava:guava:19.0'
compile 'com.google.dagger:dagger:2.3'
apt 'com.google.dagger:dagger-compiler:2.3'
// Stetho
debugCompile 'com.facebook.stetho:stetho:1.3.1'
debugCompile 'com.facebook.stetho:stetho-okhttp:1.3.1'
// Schematic
apt 'net.simonvt.schematic:schematic-compiler:0.6.7'
compile 'net.simonvt.schematic:schematic:0.6.7'
// Leak tracing
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
// Dagger
apt 'com.google.guava:guava:19.0'
apt 'com.google.dagger:dagger-compiler:2.3'
// Unit test build
testCompile 'junit:junit:4.12'
@@ -121,7 +105,7 @@ dependencies {
// Get the path to ADB. Required when running tests directly from Android Studio.
// Source: http://stackoverflow.com/a/26771087/112705
def adb = android.getAdbExe().toString()
def packageName = 'io.reark.rxgithubapp'
def packageName = 'io.reark.rxgithubapp.advanced'
def command = "$adb shell pm grant $packageName android.permission.SET_ANIMATION_SCALE".split(' ')
task grantAnimationPermission(type: Exec, dependsOn: 'installDebug') {
@@ -23,7 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.reark.rxgithubapp.activities;
package io.reark.rxgithubapp.advanced.activities;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
@@ -37,7 +37,7 @@
import org.junit.runner.RunWith;
import io.reark.rxgithubapp.R;
import io.reark.rxgithubapp.activities.utils.SystemAnimations;
import io.reark.rxgithubapp.advanced.activities.utils.SystemAnimations;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
@@ -23,7 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.reark.rxgithubapp.activities;
package io.reark.rxgithubapp.advanced.activities;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
@@ -37,7 +37,7 @@
import org.junit.runner.RunWith;
import io.reark.rxgithubapp.R;
import io.reark.rxgithubapp.activities.utils.SystemAnimations;
import io.reark.rxgithubapp.advanced.activities.utils.SystemAnimations;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
@@ -5,40 +5,40 @@
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".RxGitHubApp"
android:name=".advanced.RxGitHubApp"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".activities.MainActivity"
android:name=".advanced.activities.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activities.ChooseRepositoryActivity" />
<activity android:name=".advanced.activities.ChooseRepositoryActivity" />
<provider
android:name=".data.schematicProvider.generated.GitHubProvider"
android:authorities="io.reark.rxgithubapp.data.schematicProvider.GitHubProvider"
android:name=".advanced.data.schematicProvider.generated.GitHubProvider"
android:authorities="io.reark.rxgithubapp.advanced.data.schematicProvider.GitHubProvider"
android:exported="false">
</provider>
<receiver android:name=".widget.WidgetProvider" >
<receiver android:name=".advanced.widget.WidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/appwidget_info" />
</receiver>
<service android:name=".widget.WidgetService"
<service android:name=".advanced.widget.WidgetService"
android:process=":widgetservice" />
<service android:name=".network.NetworkService"
<service android:name=".advanced.network.NetworkService"
android:process=":networkservice" />
</application>
@@ -23,7 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.reark.rxgithubapp;
package io.reark.rxgithubapp.advanced;
import android.app.Application;
import android.appwidget.AppWidgetManager;
@@ -36,9 +36,9 @@
import javax.inject.Inject;
import io.reark.reark.utils.Log;
import io.reark.rxgithubapp.injections.Graph;
import io.reark.rxgithubapp.utils.ApplicationInstrumentation;
import io.reark.rxgithubapp.widget.WidgetProvider;
import io.reark.rxgithubapp.advanced.injections.Graph;
import io.reark.rxgithubapp.advanced.widget.WidgetProvider;
import io.reark.rxgithubapp.shared.utils.ApplicationInstrumentation;
public class RxGitHubApp extends Application {
private static final String TAG = RxGitHubApp.class.getSimpleName();
@@ -23,14 +23,14 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.reark.rxgithubapp.activities;
package io.reark.rxgithubapp.advanced.activities;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import io.reark.rxgithubapp.R;
import io.reark.rxgithubapp.fragments.RepositoriesFragment;
import io.reark.rxgithubapp.advanced.fragments.RepositoriesFragment;
public class ChooseRepositoryActivity extends AppCompatActivity {
private static final String TAG = ChooseRepositoryActivity.class.getSimpleName();
@@ -23,7 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.reark.rxgithubapp.activities;
package io.reark.rxgithubapp.advanced.activities;
import android.content.Intent;
import android.os.Bundle;
@@ -33,16 +33,16 @@
import io.reark.reark.utils.Log;
import io.reark.rxgithubapp.R;
import io.reark.rxgithubapp.RxGitHubApp;
import io.reark.rxgithubapp.data.DataLayer;
import io.reark.rxgithubapp.fragments.RepositoryFragment;
import io.reark.rxgithubapp.pojo.UserSettings;
import io.reark.rxgithubapp.advanced.RxGitHubApp;
import io.reark.rxgithubapp.advanced.fragments.RepositoryFragment;
import io.reark.rxgithubapp.shared.data.DataFunctions;
import io.reark.rxgithubapp.shared.pojo.UserSettings;
public class MainActivity extends AppCompatActivity {
private static final String TAG = MainActivity.class.getSimpleName();
@Inject
DataLayer.SetUserSettings setUserSettings;
DataFunctions.SetUserSettings setUserSettings;
public MainActivity() {
RxGitHubApp.getInstance().getGraph().inject(this);
@@ -1,4 +1,4 @@
package io.reark.rxgithubapp.activities.utils;
package io.reark.rxgithubapp.advanced.activities.utils;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -0,0 +1,78 @@
/*
* The MIT License
*
* Copyright (c) 2013-2016 reark project contributors
*
* https://github.com/reark/reark/graphs/contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.reark.rxgithubapp.advanced.data;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import io.reark.reark.utils.Preconditions;
import io.reark.rxgithubapp.advanced.data.stores.GitHubRepositorySearchStore;
import io.reark.rxgithubapp.advanced.data.stores.GitHubRepositoryStore;
import io.reark.rxgithubapp.advanced.data.stores.NetworkRequestStatusStore;
import io.reark.rxgithubapp.advanced.data.stores.UserSettingsStore;
import io.reark.rxgithubapp.advanced.network.NetworkService;
import io.reark.rxgithubapp.shared.data.ClientDataLayerBase;
import io.reark.rxgithubapp.shared.network.GitHubService;
public class DataLayer extends ClientDataLayerBase {
private static final String TAG = DataLayer.class.getSimpleName();
private final Context context;
public DataLayer(@NonNull Context context,
@NonNull UserSettingsStore userSettingsStore,
@NonNull NetworkRequestStatusStore networkRequestStatusStore,
@NonNull GitHubRepositoryStore gitHubRepositoryStore,
@NonNull GitHubRepositorySearchStore gitHubRepositorySearchStore) {
super(networkRequestStatusStore,
gitHubRepositoryStore,
gitHubRepositorySearchStore,
userSettingsStore);
Preconditions.checkNotNull(context, "Context cannot be null.");
Preconditions.checkNotNull(userSettingsStore, "User Settings Store cannot be null.");
this.context = context;
}
@Override
protected void fetchGitHubRepository(@NonNull Integer repositoryId) {
Intent intent = new Intent(context, NetworkService.class);
intent.putExtra("serviceUriString", GitHubService.REPOSITORY.toString());
intent.putExtra("id", repositoryId);
context.startService(intent);
}
@Override
protected void fetchGitHubRepositorySearch(@NonNull final String searchString) {
Preconditions.checkNotNull(searchString, "Search string Store cannot be null.");
Intent intent = new Intent(context, NetworkService.class);
intent.putExtra("serviceUriString", GitHubService.REPOSITORY_SEARCH.toString());
intent.putExtra("searchString", searchString);
context.startService(intent);
}
}
@@ -23,7 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.reark.rxgithubapp.data;
package io.reark.rxgithubapp.advanced.data;
import android.content.Context;
@@ -32,40 +32,41 @@
import dagger.Module;
import dagger.Provides;
import io.reark.reark.network.fetchers.UriFetcherManager;
import io.reark.rxgithubapp.data.stores.GitHubRepositorySearchStore;
import io.reark.rxgithubapp.data.stores.GitHubRepositoryStore;
import io.reark.rxgithubapp.data.stores.NetworkRequestStatusStore;
import io.reark.rxgithubapp.data.stores.StoreModule;
import io.reark.rxgithubapp.data.stores.UserSettingsStore;
import io.reark.rxgithubapp.injections.ForApplication;
import io.reark.rxgithubapp.network.ServiceDataLayer;
import io.reark.rxgithubapp.network.fetchers.FetcherModule;
import io.reark.rxgithubapp.advanced.data.stores.GitHubRepositorySearchStore;
import io.reark.rxgithubapp.advanced.data.stores.GitHubRepositoryStore;
import io.reark.rxgithubapp.advanced.data.stores.NetworkRequestStatusStore;
import io.reark.rxgithubapp.advanced.data.stores.StoreModule;
import io.reark.rxgithubapp.advanced.data.stores.UserSettingsStore;
import io.reark.rxgithubapp.advanced.network.FetcherModule;
import io.reark.rxgithubapp.advanced.network.ServiceDataLayer;
import io.reark.rxgithubapp.shared.data.DataFunctions;
import io.reark.rxgithubapp.shared.injections.ForApplication;
@Module(includes = { FetcherModule.class, StoreModule.class })
public final class DataStoreModule {
@Provides
public DataLayer.GetUserSettings provideGetUserSettings(DataLayer dataLayer) {
public DataFunctions.GetUserSettings provideGetUserSettings(DataLayer dataLayer) {
return dataLayer::getUserSettings;
}
@Provides
public DataLayer.SetUserSettings provideSetUserSettings(DataLayer dataLayer) {
public DataFunctions.SetUserSettings provideSetUserSettings(DataLayer dataLayer) {
return dataLayer::setUserSettings;
}
@Provides
public DataLayer.FetchAndGetGitHubRepository provideFetchAndGetGitHubRepository(DataLayer dataLayer) {
public DataFunctions.FetchAndGetGitHubRepository provideFetchAndGetGitHubRepository(DataLayer dataLayer) {
return dataLayer::fetchAndGetGitHubRepository;
}
@Provides
public DataLayer.GetGitHubRepositorySearch provideGetGitHubRepositorySearch(DataLayer dataLayer) {
public DataFunctions.GetGitHubRepositorySearch provideGetGitHubRepositorySearch(DataLayer dataLayer) {
return dataLayer::fetchAndGetGitHubRepositorySearch;
}
@Provides
public DataLayer.GetGitHubRepository provideGetGitHubRepository(DataLayer dataLayer) {
public DataFunctions.GetGitHubRepository provideGetGitHubRepository(DataLayer dataLayer) {
return dataLayer::getGitHubRepository;
}
@@ -23,7 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.reark.rxgithubapp.data.schematicProvider;
package io.reark.rxgithubapp.advanced.data.schematicProvider;
import net.simonvt.schematic.annotation.Database;
import net.simonvt.schematic.annotation.Table;
@@ -23,7 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.reark.rxgithubapp.data.schematicProvider;
package io.reark.rxgithubapp.advanced.data.schematicProvider;
import android.net.Uri;
import android.support.annotation.NonNull;
@@ -37,7 +37,7 @@
@ContentProvider(authority = GitHubProvider.AUTHORITY, database = GitHubDatabase.class)
public class GitHubProvider {
public static final String AUTHORITY = "io.reark.rxgithubapp.data.schematicProvider.GitHubProvider";
public static final String AUTHORITY = "io.reark.rxgithubapp.advanced.data.schematicProvider.GitHubProvider";
static final Uri BASE_CONTENT_URI = Uri.parse("content://" + AUTHORITY);
@@ -67,6 +67,10 @@ private static Uri buildUri(@NonNull String... paths) {
public static Uri withId(long id) {
return buildUri(GitHubDatabase.GITHUB_REPOSITORIES, String.valueOf(id));
}
public static long fromUri(Uri uri) {
return Long.valueOf(uri.getLastPathSegment());
}
}
@TableEndpoint(table = GitHubDatabase.GITHUB_REPOSITORY_SEARCHES) public static class GitHubRepositorySearches {
Oops, something went wrong.

0 comments on commit 46a8246

Please sign in to comment.