Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #117 from schul-cloud/116-add-support-for-resource…
Browse files Browse the repository at this point in the history
…s-used-in-courses

116 add support for resources used in courses
  • Loading branch information
kremer-io authored Jul 2, 2018
2 parents a124f01 + c622758 commit 811bd97
Show file tree
Hide file tree
Showing 70 changed files with 2,085 additions and 541 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ dependencies {
compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile "com.android.support:customtabs:$SUPPORT_LIBRARY_VERSION"
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta5'

compile "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
compile "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import android.app.Application;
import android.content.Context;

import javax.inject.Singleton;
import com.google.gson.Gson;

import org.schulcloud.mobile.data.datamanagers.CourseDataManager;
import org.schulcloud.mobile.data.datamanagers.EventDataManager;
Expand All @@ -17,6 +17,9 @@
import org.schulcloud.mobile.data.datamanagers.UserDataManager;
import org.schulcloud.mobile.data.remote.RestService;
import org.schulcloud.mobile.injection.ApplicationContext;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;
import io.realm.Realm;
Expand Down Expand Up @@ -54,6 +57,12 @@ Realm provideRealm() {

/************* MOCKS *************/

@Provides
@Singleton
Gson provideGson() {
return mock(Gson.class);
}

@Provides
@Singleton
UserDataManager provideUserDataManager() {
Expand Down
32 changes: 30 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="org.schulcloud.mobile">

<uses-permission android:name="android.permission.INTERNET" />
Expand Down Expand Up @@ -33,7 +34,34 @@

<activity
android:name=".ui.main.MainActivity"
android:label="@string/app_name" />
android:label="@string/app_name"
android:launchMode="singleTask">

<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="schulcloud.org" />
<data android:host="schul-cloud.org" />
<!-- Edit and others are not yet supported, therefore more precise matching -->
<data android:pathPrefix="/dashboard" />
<data android:path="/news/" />
<data android:pathPattern="/news/........................" />
<data android:pathPattern="/courses/........................" />
<data android:pathPattern="/courses/......................../topics/........................" />
<data android:pathPattern="/courses/......................../topics/......................../" />
<data android:path="/homework/" />
<data android:pathPattern="/homework/........................" />
<data android:path="/files/my" />
<data android:path="/files/courses" />
<data android:path="/files/file" />
</intent-filter>

</activity>

<activity
android:name=".ui.settings.SettingsActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.schulcloud.mobile.data.local.CourseDatabaseHelper;
import org.schulcloud.mobile.data.local.PreferencesHelper;
import org.schulcloud.mobile.data.model.Course;
import org.schulcloud.mobile.data.model.responseBodies.FeathersResponse;
import org.schulcloud.mobile.data.remote.RestService;

import java.util.List;
Expand All @@ -12,7 +11,6 @@
import javax.inject.Singleton;

import rx.Observable;
import rx.functions.Func1;

@Singleton
public class CourseDataManager {
Expand All @@ -26,7 +24,7 @@ public class CourseDataManager {

@Inject
public CourseDataManager(RestService restService, PreferencesHelper preferencesHelper,
CourseDatabaseHelper databaseHelper) {
CourseDatabaseHelper databaseHelper) {
mRestService = restService;
mPreferencesHelper = preferencesHelper;
mDatabaseHelper = databaseHelper;
Expand All @@ -38,18 +36,15 @@ public PreferencesHelper getPreferencesHelper() {

public Observable<Course> syncCourses() {
return mRestService.getCourses(userDataManager.getAccessToken())
.concatMap(new Func1<FeathersResponse<Course>, Observable<Course>>() {
@Override
public Observable<Course> call(FeathersResponse<Course> courses) {
mDatabaseHelper.clearTable(Course.class);
return mDatabaseHelper.setCourses(courses.data);
}
.concatMap(courses -> {
mDatabaseHelper.clearTable(Course.class);
return mDatabaseHelper.setCourses(courses.data);
})
.doOnError(Throwable::printStackTrace);
}

public Observable<List<Course>> getCourses() {
return mDatabaseHelper.getCourses().distinct();
return mDatabaseHelper.getCourses();
}

public Course getCourseForId(String courseId) {
Expand Down
Loading

0 comments on commit 811bd97

Please sign in to comment.