├── .gitignore ├── LICENSE ├── README.md ├── android └── FIUBAPP │ ├── .gitignore │ ├── .idea │ ├── .name │ ├── compiler.xml │ ├── copyright │ │ └── profiles_settings.xml │ ├── gradle.xml │ ├── misc.xml │ ├── modules.xml │ ├── runConfigurations.xml │ └── vcs.xml │ ├── LICENSE │ ├── QA │ ├── findbugs │ │ └── findbugs-filter.xml │ └── quality.gradle │ ├── README.md │ ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── clean │ │ │ └── ApplicationTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── clean │ │ │ │ ├── AndroidApplication.java │ │ │ │ ├── data │ │ │ │ ├── mapper │ │ │ │ │ ├── JsonToCourseMapper.java │ │ │ │ │ └── JsonToSubjectMapper.java │ │ │ │ └── repository │ │ │ │ │ ├── HardCodedResponses.java │ │ │ │ │ └── LocalDataBase.java │ │ │ │ ├── domain │ │ │ │ ├── executor │ │ │ │ │ ├── Executor.java │ │ │ │ │ ├── MainThread.java │ │ │ │ │ └── impl │ │ │ │ │ │ └── ThreadExecutor.java │ │ │ │ ├── interactors │ │ │ │ │ ├── AbstractInteractor.java │ │ │ │ │ ├── Interactor.java │ │ │ │ │ ├── enroll_to_course │ │ │ │ │ │ ├── EnrollToCourse.java │ │ │ │ │ │ └── EnrollToCourseImpl.java │ │ │ │ │ ├── show_available_subjects │ │ │ │ │ │ ├── ShowAvailableSubjects.java │ │ │ │ │ │ └── ShowAvailableSubjectsImpl.java │ │ │ │ │ ├── show_courses │ │ │ │ │ │ ├── ShowCourses.java │ │ │ │ │ │ └── ShowCoursesImpl.java │ │ │ │ │ └── show_enrolled_courses │ │ │ │ │ │ ├── ShowEnrolledCourses.java │ │ │ │ │ │ └── ShowEnrolledCoursesImpl.java │ │ │ │ ├── model │ │ │ │ │ ├── Course.java │ │ │ │ │ └── Subject.java │ │ │ │ └── repository │ │ │ │ │ └── StudentRepository.java │ │ │ │ ├── presentation │ │ │ │ ├── UniquePointOfInstanciation.java │ │ │ │ ├── mapper │ │ │ │ │ ├── CourseModelMapper.java │ │ │ │ │ └── SubjectModelMapper.java │ │ │ │ ├── model │ │ │ │ │ ├── CourseModel.java │ │ │ │ │ └── SubjectModel.java │ │ │ │ ├── presenters │ │ │ │ │ ├── AbstractPresenter.java │ │ │ │ │ ├── BasePresenter.java │ │ │ │ │ ├── courses │ │ │ │ │ │ ├── CoursesPresenter.java │ │ │ │ │ │ └── CoursesPresenterImpl.java │ │ │ │ │ ├── enroll_to_course │ │ │ │ │ │ ├── EnrollToCoursePresenter.java │ │ │ │ │ │ └── EnrollToCoursePresenterImpl.java │ │ │ │ │ ├── enrolled_courses │ │ │ │ │ │ ├── EnrolledCoursesPresenter.java │ │ │ │ │ │ └── EnrolledCoursesPresenterImpl.java │ │ │ │ │ └── main │ │ │ │ │ │ ├── MainPresenter.java │ │ │ │ │ │ └── MainPresenterImpl.java │ │ │ │ └── ui │ │ │ │ │ ├── BaseView.java │ │ │ │ │ ├── activities │ │ │ │ │ ├── CoursesActivity.java │ │ │ │ │ ├── EnrollToCourseActivity.java │ │ │ │ │ ├── EnrolledCoursesActivity.java │ │ │ │ │ ├── Main2Activity.java │ │ │ │ │ └── MainActivity.java │ │ │ │ │ ├── adapters │ │ │ │ │ ├── CoursesNamesRecyclerAdapter.java │ │ │ │ │ ├── SimpleStringRecyclerViewAdapter.java │ │ │ │ │ └── SubjectModelRecyclerViewAdapter.java │ │ │ │ │ ├── dialogs │ │ │ │ │ ├── EnrollToCourseDialog.java │ │ │ │ │ └── NotifyDialog.java │ │ │ │ │ └── viewholders │ │ │ │ │ └── ViewHolder.java │ │ │ │ └── threading │ │ │ │ └── MainThreadImpl.java │ │ └── res │ │ │ ├── layout │ │ │ ├── activity_courses.xml │ │ │ ├── activity_enrolled_courses.xml │ │ │ ├── activity_main.xml │ │ │ ├── activity_main2.xml │ │ │ ├── list_item.xml │ │ │ └── recycler_view.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── kodelabs │ │ └── boilerplate │ │ └── ExampleUnitTest.java │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── api ├── courses.json └── subjects.json ├── ios ├── .gitignore ├── .swiftlint.yml ├── FIUBA.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── FIUBA.xcworkspace │ └── contents.xcworkspacedata ├── FIUBA │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── icon120-1.png │ │ │ ├── icon120.png │ │ │ ├── icon180.png │ │ │ ├── icon58.png │ │ │ ├── icon80.png │ │ │ └── icon87.png │ │ ├── Contents.json │ │ └── Logo.imageset │ │ │ ├── Contents.json │ │ │ ├── FIUBALogo.png │ │ │ ├── FIUBALogo2x.png │ │ │ └── FIUBALogo3x.png │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── Models │ │ ├── Course.swift │ │ └── Subject.swift │ ├── Resources │ │ └── Json │ │ │ ├── courses.json │ │ │ └── subjects.json │ ├── Scenes │ │ ├── ListCourses │ │ │ ├── ListCoursesConfigurator.swift │ │ │ ├── ListCoursesInteractor.swift │ │ │ ├── ListCoursesModels.swift │ │ │ ├── ListCoursesPresenter.swift │ │ │ ├── ListCoursesRouter.swift │ │ │ ├── ListCoursesViewController.swift │ │ │ └── ListCoursesWorker.swift │ │ ├── ListEnrolledCourses │ │ │ ├── ListEnrolledCoursesConfigurator.swift │ │ │ ├── ListEnrolledCoursesInteractor.swift │ │ │ ├── ListEnrolledCoursesModels.swift │ │ │ ├── ListEnrolledCoursesPresenter.swift │ │ │ ├── ListEnrolledCoursesRouter.swift │ │ │ ├── ListEnrolledCoursesViewController.swift │ │ │ └── ListEnrolledCoursesWorker.swift │ │ ├── ListSubjects │ │ │ ├── ListSubjectsConfigurator.swift │ │ │ ├── ListSubjectsInteractor.swift │ │ │ ├── ListSubjectsModels.swift │ │ │ ├── ListSubjectsPresenter.swift │ │ │ ├── ListSubjectsRouter.swift │ │ │ ├── ListSubjectsViewController.swift │ │ │ └── ListSubjectsWorker.swift │ │ └── ShowOptions │ │ │ ├── ShowOptionsConfigurator.swift │ │ │ ├── ShowOptionsInteractor.swift │ │ │ ├── ShowOptionsModels.swift │ │ │ ├── ShowOptionsPresenter.swift │ │ │ ├── ShowOptionsRouter.swift │ │ │ ├── ShowOptionsViewController.swift │ │ │ └── ShowOptionsWorker.swift │ ├── Services │ │ ├── CoursesJsonStore.swift │ │ ├── CoursesRealmStore.swift │ │ ├── Json │ │ │ └── DataManager.swift │ │ ├── Realm │ │ │ ├── CourseRLM.swift │ │ │ └── SubjectRLM.swift │ │ ├── SubjectsJsonStore.swift │ │ └── SubjectsRealmStore.swift │ └── Workers │ │ ├── CoursesWorker.swift │ │ └── SubjectsWorker.swift ├── FIUBATests │ ├── FIUBATests.swift │ ├── Info.plist │ └── ListCoursesInteractorTests.swift ├── FIUBAUITests │ ├── FIUBAUITests.swift │ └── Info.plist ├── Podfile └── Podfile.lock └── resources ├── BalsamiqMockup.png ├── clean1.png ├── clean10.png ├── clean11.png ├── clean12.png ├── clean13.png ├── clean2.png ├── clean3.png ├── clean4.png ├── clean5.png ├── clean6.png ├── clean7.png ├── clean8.png └── clean9.png /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # Linux 3 | # 4 | # https://github.com/github/gitignore/blob/master/Global/Linux.gitignore 5 | # 6 | 7 | *~ 8 | 9 | # temporary files which can be created if a process still has a handle open of a deleted file 10 | .fuse_hidden* 11 | 12 | # KDE directory preferences 13 | .directory 14 | 15 | # Linux trash folder which might appear on any partition or disk 16 | .Trash-* 17 | 18 | # 19 | # OS X 20 | # 21 | # https://github.com/github/gitignore/blob/master/Global/OSX.gitignore 22 | # 23 | 24 | *.DS_Store 25 | .AppleDouble 26 | .LSOverride 27 | 28 | # Icon must end with two \r 29 | Icon 30 | 31 | 32 | # Thumbnails 33 | ._* 34 | 35 | # Files that might appear in the root of a volume 36 | .DocumentRevisions-V100 37 | .fseventsd 38 | .Spotlight-V100 39 | .TemporaryItems 40 | .Trashes 41 | .VolumeIcon.icns 42 | .com.apple.timemachine.donotpresent 43 | 44 | # Directories potentially created on remote AFP share 45 | .AppleDB 46 | .AppleDesktop 47 | Network Trash Folder 48 | Temporary Items 49 | .apdisk 50 | 51 | # 52 | # Windows 53 | # 54 | # https://github.com/github/gitignore/blob/master/Global/Windows.gitignore 55 | # 56 | 57 | # Windows image file caches 58 | Thumbs.db 59 | ehthumbs.db 60 | 61 | # Folder config file 62 | Desktop.ini 63 | 64 | # Recycle Bin used on file shares 65 | $RECYCLE.BIN/ 66 | 67 | # Windows Installer files 68 | *.cab 69 | *.msi 70 | *.msm 71 | *.msp 72 | 73 | # Windows shortcuts 74 | *.lnk 75 | 76 | # 77 | # JetBrains 78 | # 79 | # https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore 80 | # 81 | 82 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 83 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 84 | 85 | # User-specific stuff: 86 | .idea/workspace.xml 87 | .idea/tasks.xml 88 | .idea/dictionaries 89 | .idea/vcs.xml 90 | .idea/jsLibraryMappings.xml 91 | 92 | # Sensitive or high-churn files: 93 | .idea/dataSources.ids 94 | .idea/dataSources.xml 95 | .idea/dataSources.local.xml 96 | .idea/sqlDataSources.xml 97 | .idea/dynamic.xml 98 | .idea/uiDesigner.xml 99 | 100 | # Gradle: 101 | .idea/gradle.xml 102 | .idea/libraries 103 | 104 | # Mongo Explorer plugin: 105 | .idea/mongoSettings.xml 106 | 107 | ## File-based project format: 108 | *.iws 109 | 110 | ## Plugin-specific files: 111 | 112 | # IntelliJ 113 | /out/ 114 | 115 | # mpeltonen/sbt-idea plugin 116 | .idea_modules/ 117 | 118 | # JIRA plugin 119 | atlassian-ide-plugin.xml 120 | 121 | # Crashlytics plugin (for Android Studio and IntelliJ) 122 | com_crashlytics_export_strings.xml 123 | crashlytics.properties 124 | crashlytics-build.properties 125 | fabric.properties 126 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Ezequiel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /android/FIUBAPP/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | ======= 10 | # Built application files 11 | *.apk 12 | *.ap_ 13 | 14 | # Files for the Dalvik VM 15 | *.dex 16 | 17 | # Java class files 18 | *.class 19 | 20 | # Generated files 21 | bin/ 22 | gen/ 23 | 24 | # Gradle files 25 | .gradle/ 26 | build/ 27 | 28 | # Local configuration file (sdk path, etc) 29 | local.properties 30 | 31 | # Proguard folder generated by Eclipse 32 | proguard/ 33 | 34 | # Log Files 35 | *.log 36 | 37 | # Android Studio Navigation editor temp files 38 | .navigation/ 39 | 40 | # Android Studio captures folder 41 | captures/ 42 | -------------------------------------------------------------------------------- /android/FIUBAPP/.idea/.name: -------------------------------------------------------------------------------- 1 | FIUBAPP -------------------------------------------------------------------------------- /android/FIUBAPP/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /android/FIUBAPP/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /android/FIUBAPP/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /android/FIUBAPP/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 1.7 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /android/FIUBAPP/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/FIUBAPP/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /android/FIUBAPP/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /android/FIUBAPP/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Dario Miličić 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /android/FIUBAPP/QA/findbugs/findbugs-filter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /android/FIUBAPP/QA/quality.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'findbugs' 2 | 3 | task findbugs(type: FindBugs) { 4 | ignoreFailures = true 5 | effort = "default" 6 | reportLevel = "medium" 7 | excludeFilter = new File("${project.rootDir}/QA/findbugs/findbugs-filter.xml") 8 | classes = files("${project.rootDir}/app/build/intermediates/classes") 9 | source = fileTree('src/main/java/') 10 | classpath = files() 11 | reports { 12 | xml.enabled = false 13 | html.enabled = true 14 | html { 15 | destination "${project.buildDir}/reports/findbugs/findbugs-output.html" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /android/FIUBAPP/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply from: "${project.rootDir}/QA/quality.gradle" 3 | 4 | 5 | android { 6 | compileSdkVersion 23 7 | buildToolsVersion "23.0.2" 8 | 9 | defaultConfig { 10 | applicationId "com.clean" 11 | minSdkVersion 15 12 | targetSdkVersion 23 13 | versionCode 1 14 | versionName "1.0" 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | compile fileTree(dir: 'libs', include: ['*.jar']) 26 | 27 | // general 28 | compile 'com.android.support:appcompat-v7:23.1.1' 29 | compile 'com.android.support:design:23.1.1' 30 | compile 'com.jakewharton:butterknife:7.0.1' 31 | compile 'com.jakewharton.timber:timber:4.1.0' 32 | compile 'com.colintmiller:simplenosql:0.5.1' 33 | 34 | // network 35 | compile 'com.squareup.retrofit2:retrofit:2.0.0' 36 | 37 | // tests 38 | testCompile 'junit:junit:4.12' 39 | testCompile "org.mockito:mockito-core:1.+" 40 | } 41 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/dmilicic/Documents/android-sdk-macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/androidTest/java/com/clean/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.clean; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 23 | 24 | 25 | 26 | 27 | 30 | 33 | 34 | 35 | 36 | 37 | 40 | 43 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/AndroidApplication.java: -------------------------------------------------------------------------------- 1 | package com.clean; 2 | 3 | import android.app.Application; 4 | 5 | import com.clean.presentation.UniquePointOfInstanciation; 6 | 7 | import timber.log.Timber; 8 | import timber.log.Timber.DebugTree; 9 | 10 | public class AndroidApplication extends Application { 11 | @Override 12 | public void onCreate() { 13 | UniquePointOfInstanciation.setContext(getApplicationContext()); 14 | super.onCreate(); 15 | // initiate Timber 16 | Timber.plant(new DebugTree()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/data/mapper/JsonToCourseMapper.java: -------------------------------------------------------------------------------- 1 | package com.clean.data.mapper; 2 | 3 | import com.clean.domain.model.Course; 4 | 5 | import org.json.JSONArray; 6 | import org.json.JSONException; 7 | import org.json.JSONObject; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by fabrizio on 31/05/16. 14 | */ 15 | public class JsonToCourseMapper { 16 | 17 | public static Course transform(JSONObject json) { 18 | Course course = new Course(); 19 | try { 20 | course.setId(json.getInt("id")); 21 | JSONArray teachers = json.getJSONArray("teachers"); 22 | List teacherList = new ArrayList<>(); 23 | for (int i = 0; i < teachers.length(); i++) { 24 | teacherList.add(teachers.getString(i)); 25 | } 26 | course.setTeachers(teacherList); 27 | course.setSchedule(json.getString("schedule")); 28 | course.setClassroom(json.getString("classroom")); 29 | course.setVacancy(json.getInt("vacancy")); 30 | return course; 31 | } catch (JSONException e) { 32 | return null; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/data/mapper/JsonToSubjectMapper.java: -------------------------------------------------------------------------------- 1 | package com.clean.data.mapper; 2 | 3 | import com.clean.domain.model.Subject; 4 | 5 | import org.json.JSONException; 6 | import org.json.JSONObject; 7 | 8 | /** 9 | * Created by fabrizio on 29/05/16. 10 | */ 11 | public class JsonToSubjectMapper { 12 | 13 | 14 | public static Subject transform(JSONObject json) { 15 | Subject subject = new Subject(); 16 | try { 17 | subject.setName(json.getString("name")); 18 | subject.setCode(json.getInt("code")); 19 | subject.setDepartament(json.getString("departament")); 20 | return subject; 21 | } catch (JSONException e) { 22 | return null; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/data/repository/HardCodedResponses.java: -------------------------------------------------------------------------------- 1 | package com.clean.data.repository; 2 | 3 | /** 4 | * Created by fabrizio on 29/05/16. 5 | */ 6 | public class HardCodedResponses { 7 | 8 | public static String SUBJECTS_KEY = "subjects"; 9 | public static String COURSES_KEY = "courses"; 10 | 11 | public static String SUBJECTS = "{'subjects': [" + 12 | " {'name': 'Análisis Matemático IIA', 'code': 6103, 'departament': 'Matemática'},"+ 13 | " {'name': 'Algebra II', 'code': 6108, 'departament': 'Matemática'},"+ 14 | " {'name': 'Análisis Matemático IIIA', 'code': 6110, 'departament': 'Matemática'},"+ 15 | " {'name': 'Probabilidad', 'code': 6109, 'departament': 'Matemática'},"+ 16 | " {'name': 'Algoritmos y Programación I', 'code': 7540, 'departament': 'Computación'},"+ 17 | " {'name': 'Algoritmos y Programación II', 'code': 7541, 'departament': 'Computación'},"+ 18 | " {'name': 'Algoritmos y Programación III', 'code': 7507, 'departament': 'Computación'},"+ 19 | " {'name': 'Análisis Numérico', 'code': 7512, 'departament': 'Computación'},"+ 20 | " {'name': 'Organización de Datos', 'code': 7506, 'departament': 'Computación'},"+ 21 | " {'name': 'Taller de Programación I', 'code': 7542, 'departament': 'Computación'},"+ 22 | " {'name': 'Taller de Programación II', 'code': 7552, 'departament': 'Computación'},"+ 23 | " {'name': 'Base de Datos', 'code': 7515, 'departament': 'Computación'},"+ 24 | " {'name': 'Técnicas de Diseño', 'code': 7510, 'departament': 'Computación'},"+ 25 | " {'name': 'Análisis de la Información', 'code': 7509, 'departament': 'Computación'},"+ 26 | " {'name': 'Sistemas Operativos', 'code': 7540, 'departament': 'Computación'},"+ 27 | " {'name': 'Introducción a los Sistemas Distribuidos', 'code': 7543, 'departament': 'Computación'},"+ 28 | " {'name': 'Laboratorio', 'code': 6602, 'departament': 'Electrónica'},"+ 29 | " {'name': 'Estructura del Computador', 'code': 6670, 'departament': 'Electrónica'},"+ 30 | " {'name': 'Organización de Computadoras', 'code': 6620, 'departament': 'Electrónica'},"+ 31 | " {'name': 'Quimica', 'code': 6301, 'departament': 'Quimica'}"+ 32 | " ]"+ 33 | "}"; 34 | 35 | public static String COURSES = "{'courses': [" + 36 | "{'id': 1, 'teachers': ['profesor1'], 'schedule': 'Lun y Mie 18 a 19', 'classroom': '1', 'vacancy': 20}," + 37 | "{'id': 2, 'teachers': ['proffesor2'], 'schedule': 'Mar y Mie 18 a 19', 'classroom': '2', 'vacancy': 20}," + 38 | "{'id': 3, 'teachers': ['proffesor3'], 'schedule': 'Lun y Jue 18 a 19', 'classroom': '3', 'vacancy': 20}," + 39 | "{'id': 4, 'teachers': ['proffesor4'], 'schedule': 'Mar y Vie 18 a 19', 'classroom': '4', 'vacancy': 20}," + 40 | "{'id': 5, 'teachers': ['proffesor5'], 'schedule': 'Lun y Vie 18 a 19', 'classroom': '5', 'vacancy': 10}," + 41 | "{'id': 6, 'teachers': ['proffesor6'], 'schedule': 'Mar y Jue 18 a 19', 'classroom': '6', 'vacancy': 5}," + 42 | "{'id': 7, 'teachers': ['proffesor7'], 'schedule': 'Lun y Mie 10 a 12', 'classroom': '7', 'vacancy': 10}" + 43 | "]" + 44 | "}"; 45 | } 46 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/executor/Executor.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.executor; 2 | 3 | import com.clean.domain.interactors.AbstractInteractor; 4 | 5 | /** 6 | * This executor is responsible for running interactors on background threads. 7 | *

8 | */ 9 | public interface Executor { 10 | 11 | /** 12 | * This method should call the interactor's run method and thus start the interactor. This should be called 13 | * on a background thread as interactors might do lengthy operations. 14 | * 15 | * @param interactor The interactor to run. 16 | */ 17 | void execute(final AbstractInteractor interactor); 18 | } 19 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/executor/MainThread.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.executor; 2 | 3 | /** 4 | * This interface will define a class that will enable interactors to run certain operations on the main (UI) thread. For example, 5 | * if an interactor needs to show an object to the UI this can be used to make sure the show method is called on the UI 6 | * thread. 7 | *

8 | */ 9 | public interface MainThread { 10 | 11 | /** 12 | * Make runnable operation run in the main thread. 13 | * 14 | * @param runnable The runnable to run. 15 | */ 16 | void post(final Runnable runnable); 17 | } 18 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/executor/impl/ThreadExecutor.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.executor.impl; 2 | 3 | import com.clean.domain.executor.Executor; 4 | import com.clean.domain.interactors.AbstractInteractor; 5 | 6 | import java.util.concurrent.BlockingQueue; 7 | import java.util.concurrent.LinkedBlockingQueue; 8 | import java.util.concurrent.ThreadPoolExecutor; 9 | import java.util.concurrent.TimeUnit; 10 | 11 | /** 12 | * This singleton class will make sure that each interactor operation gets a background thread. 13 | *

14 | */ 15 | public class ThreadExecutor implements Executor { 16 | 17 | // This is a singleton 18 | private static volatile ThreadExecutor sThreadExecutor; 19 | 20 | private static final int CORE_POOL_SIZE = 3; 21 | private static final int MAX_POOL_SIZE = 5; 22 | private static final int KEEP_ALIVE_TIME = 120; 23 | private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS; 24 | private static final BlockingQueue WORK_QUEUE = new LinkedBlockingQueue(); 25 | 26 | private ThreadPoolExecutor mThreadPoolExecutor; 27 | 28 | private ThreadExecutor() { 29 | long keepAlive = KEEP_ALIVE_TIME; 30 | mThreadPoolExecutor = new ThreadPoolExecutor( 31 | CORE_POOL_SIZE, 32 | MAX_POOL_SIZE, 33 | keepAlive, 34 | TIME_UNIT, 35 | WORK_QUEUE); 36 | } 37 | 38 | @Override 39 | public void execute(final AbstractInteractor interactor) { 40 | mThreadPoolExecutor.submit(new Runnable() { 41 | @Override 42 | public void run() { 43 | // run the main logic 44 | interactor.run(); 45 | 46 | // mark it as finished 47 | interactor.onFinished(); 48 | } 49 | }); 50 | } 51 | 52 | /** 53 | * Returns a singleton instance of this executor. If the executor is not initialized then it initializes it and returns 54 | * the instance. 55 | */ 56 | public static Executor getInstance() { 57 | if (sThreadExecutor == null) { 58 | sThreadExecutor = new ThreadExecutor(); 59 | } 60 | 61 | return sThreadExecutor; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/interactors/AbstractInteractor.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.interactors; 2 | 3 | import com.clean.domain.executor.Executor; 4 | import com.clean.domain.executor.MainThread; 5 | import com.clean.domain.interactors.Interactor; 6 | 7 | /** 8 | * Created by dmilicic on 8/4/15. 9 | *

10 | * This abstract class implements some common methods for all interactors. Cancelling an interactor, check if its running 11 | * and finishing an interactor has mostly the same code throughout so that is why this class was created. Field methods 12 | * are declared volatile as we might use these methods from different threads (mainly from UI). 13 | *

14 | * For example, when an activity is getting destroyed then we should probably cancel an interactor 15 | * but the request will come from the UI thread unless the request was specifically assigned to a background thread. 16 | */ 17 | public abstract class AbstractInteractor implements Interactor { 18 | 19 | protected Executor mThreadExecutor; 20 | protected MainThread mMainThread; 21 | 22 | protected volatile boolean mIsCanceled; 23 | protected volatile boolean mIsRunning; 24 | 25 | public AbstractInteractor(Executor threadExecutor, MainThread mainThread) { 26 | mThreadExecutor = threadExecutor; 27 | mMainThread = mainThread; 28 | } 29 | 30 | /** 31 | * This method contains the actual business logic of the interactor. It SHOULD NOT BE USED DIRECTLY but, instead, a 32 | * developer should call the execute() method of an interactor to make sure the operation is done on a background thread. 33 | *

34 | * This method should only be called directly while doing unit/integration tests. That is the only reason it is declared 35 | * public as to help with easier testing. 36 | */ 37 | public abstract void run(); 38 | 39 | public void cancel() { 40 | mIsCanceled = true; 41 | mIsRunning = false; 42 | } 43 | 44 | public boolean isRunning() { 45 | return mIsRunning; 46 | } 47 | 48 | public void onFinished() { 49 | mIsRunning = false; 50 | mIsCanceled = false; 51 | } 52 | 53 | public void execute() { 54 | 55 | // mark this interactor as running 56 | this.mIsRunning = true; 57 | 58 | // start running this interactor in a background thread 59 | mThreadExecutor.execute(this); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/interactors/Interactor.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.interactors; 2 | 3 | 4 | /** 5 | * This is the main interface of an interactor. Each interactor serves a specific use case. 6 | */ 7 | public interface Interactor { 8 | 9 | /** 10 | * This is the main method that starts an interactor. It will make sure that the interactor operation is done on a 11 | * background thread. 12 | */ 13 | void execute(); 14 | } 15 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/interactors/enroll_to_course/EnrollToCourse.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.interactors.enroll_to_course; 2 | 3 | import com.clean.domain.interactors.Interactor; 4 | 5 | /** 6 | * Created by fabrizio on 26/05/16. 7 | */ 8 | public interface EnrollToCourse extends Interactor { 9 | 10 | interface Callback { 11 | 12 | void onSubjectAlreadyEnrolled(); 13 | 14 | void onMoreThanSevenCoursesEnrolled(); 15 | 16 | void onCourseEnrolled(); 17 | 18 | void onRetrievalFailed(String error); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/interactors/enroll_to_course/EnrollToCourseImpl.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.interactors.enroll_to_course; 2 | 3 | import com.clean.domain.executor.Executor; 4 | import com.clean.domain.executor.MainThread; 5 | import com.clean.domain.interactors.AbstractInteractor; 6 | import com.clean.domain.model.Course; 7 | import com.clean.domain.repository.StudentRepository; 8 | 9 | import java.util.Map; 10 | 11 | 12 | /** 13 | * Created by fabrizio on 26/05/16. 14 | */ 15 | public class EnrollToCourseImpl extends AbstractInteractor implements EnrollToCourse { 16 | 17 | private StudentRepository mRepository; 18 | private int mSubjectCode; 19 | private int mCourseId; 20 | private EnrollToCourse.Callback mCallback; 21 | 22 | 23 | public EnrollToCourseImpl(Executor threadExecutor, MainThread mainThread, EnrollToCourse.Callback callback, 24 | StudentRepository repository, int subjectCode, int courseId) { 25 | super(threadExecutor, mainThread); 26 | mSubjectCode = subjectCode; 27 | mCourseId = courseId; 28 | mRepository = repository; 29 | mCallback = callback; 30 | } 31 | 32 | /**********************************************************************************************/ 33 | /**********************************************************************************************/ 34 | 35 | private void notifyError() { 36 | mMainThread.post(new Runnable() { 37 | @Override 38 | public void run() { 39 | mCallback.onRetrievalFailed("Nothing to welcome you with :("); 40 | } 41 | }); 42 | } 43 | 44 | /**********************************************************************************************/ 45 | /**********************************************************************************************/ 46 | 47 | private void notifySubjectAlreadyEnrolled() { 48 | mMainThread.post(new Runnable() { 49 | @Override 50 | public void run() { 51 | mCallback.onSubjectAlreadyEnrolled(); 52 | } 53 | }); 54 | } 55 | 56 | /**********************************************************************************************/ 57 | /**********************************************************************************************/ 58 | 59 | private void notifyEnrolledInSevenCourses() { 60 | mMainThread.post(new Runnable() { 61 | @Override 62 | public void run() { 63 | mCallback.onMoreThanSevenCoursesEnrolled(); 64 | } 65 | }); 66 | } 67 | 68 | /**********************************************************************************************/ 69 | /**********************************************************************************************/ 70 | 71 | private void notifyEnrolled() { 72 | mMainThread.post(new Runnable() { 73 | @Override 74 | public void run() { 75 | mCallback.onCourseEnrolled(); 76 | } 77 | }); 78 | } 79 | 80 | /**********************************************************************************************/ 81 | /**********************************************************************************************/ 82 | 83 | 84 | @Override 85 | public void run() { 86 | Integer subjectCode = mSubjectCode; 87 | Map enrolledCourses = mRepository.getEnrolledCourses(); 88 | if (enrolledCourses.containsKey(subjectCode)) { 89 | notifySubjectAlreadyEnrolled(); 90 | return; 91 | } 92 | if (enrolledCourses.size() >= 7) { 93 | notifyEnrolledInSevenCourses(); 94 | return; 95 | } 96 | Course course = mRepository.getCourse(mSubjectCode, mCourseId); 97 | mRepository.enrollCourse(mSubjectCode, course); 98 | notifyEnrolled(); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/interactors/show_available_subjects/ShowAvailableSubjects.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.interactors.show_available_subjects; 2 | 3 | import com.clean.domain.interactors.Interactor; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by fabrizio on 26/05/16. 8 | */ 9 | public interface ShowAvailableSubjects extends Interactor { 10 | 11 | interface Callback { 12 | 13 | void onSubjectsRetrieved(List subjects); 14 | 15 | void onRetrievalFailed(String error); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/interactors/show_available_subjects/ShowAvailableSubjectsImpl.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.interactors.show_available_subjects; 2 | 3 | import com.clean.domain.executor.Executor; 4 | import com.clean.domain.executor.MainThread; 5 | import com.clean.domain.interactors.AbstractInteractor; 6 | import com.clean.domain.model.Subject; 7 | import com.clean.domain.repository.StudentRepository; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by fabrizio on 26/05/16. 12 | */ 13 | public class ShowAvailableSubjectsImpl extends AbstractInteractor implements ShowAvailableSubjects { 14 | 15 | StudentRepository mRepository; 16 | ShowAvailableSubjects.Callback mCallback; 17 | 18 | /**********************************************************************************************/ 19 | /**********************************************************************************************/ 20 | 21 | public ShowAvailableSubjectsImpl(Executor threadExecutor, MainThread mainThread, 22 | ShowAvailableSubjects.Callback callback, StudentRepository repo) { 23 | super(threadExecutor, mainThread); 24 | mRepository = repo; 25 | mCallback = callback; 26 | } 27 | 28 | /**********************************************************************************************/ 29 | /**********************************************************************************************/ 30 | 31 | private void notifyError() { 32 | mMainThread.post(new Runnable() { 33 | @Override 34 | public void run() { 35 | mCallback.onRetrievalFailed("Nothing to welcome you with :("); 36 | } 37 | }); 38 | } 39 | 40 | /**********************************************************************************************/ 41 | /**********************************************************************************************/ 42 | 43 | private void postSubjects(final List subjects) { 44 | mMainThread.post(new Runnable() { 45 | @Override 46 | public void run() { 47 | mCallback.onSubjectsRetrieved(subjects); 48 | } 49 | }); 50 | } 51 | 52 | /**********************************************************************************************/ 53 | /**********************************************************************************************/ 54 | 55 | @Override 56 | public void run() { 57 | // retrieve the message 58 | final List subjects = mRepository.getAvailableSubjects(); 59 | 60 | // check if we have failed to retrieve our message 61 | if (subjects == null || subjects.size() == 0) { 62 | // notify the failure on the main thread 63 | notifyError(); 64 | return; 65 | } 66 | 67 | // we have retrieved our message, notify the UI on the main thread 68 | postSubjects(subjects); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/interactors/show_courses/ShowCourses.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.interactors.show_courses; 2 | 3 | import com.clean.domain.interactors.Interactor; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by fabrizio on 26/05/16. 8 | */ 9 | public interface ShowCourses extends Interactor { 10 | 11 | interface Callback { 12 | 13 | void onCoursesRetrieved(List courses); 14 | 15 | void onRetrievalFailed(String error); 16 | } 17 | 18 | public void setSubjectCode(int subjectCode); 19 | } 20 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/interactors/show_courses/ShowCoursesImpl.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.interactors.show_courses; 2 | 3 | import com.clean.domain.executor.Executor; 4 | import com.clean.domain.executor.MainThread; 5 | import com.clean.domain.interactors.AbstractInteractor; 6 | import com.clean.domain.model.Course; 7 | import com.clean.domain.repository.StudentRepository; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by fabrizio on 26/05/16. 12 | */ 13 | public class ShowCoursesImpl extends AbstractInteractor implements ShowCourses { 14 | 15 | private StudentRepository mRepository; 16 | private ShowCourses.Callback mCallback; 17 | private Integer mSubjectCode; 18 | 19 | /**********************************************************************************************/ 20 | /**********************************************************************************************/ 21 | 22 | public ShowCoursesImpl(Executor threadExecutor, MainThread mainThread, 23 | ShowCourses.Callback callback, StudentRepository repo) { 24 | super(threadExecutor, mainThread); 25 | mRepository = repo; 26 | mCallback = callback; 27 | } 28 | 29 | /**********************************************************************************************/ 30 | /**********************************************************************************************/ 31 | 32 | public void setSubjectCode(int subjectCode) { 33 | mSubjectCode = subjectCode; 34 | } 35 | 36 | /**********************************************************************************************/ 37 | /**********************************************************************************************/ 38 | 39 | private void notifyError() { 40 | mMainThread.post(new Runnable() { 41 | @Override 42 | public void run() { 43 | mCallback.onRetrievalFailed("Nothing to welcome you with :("); 44 | } 45 | }); 46 | } 47 | 48 | /**********************************************************************************************/ 49 | /**********************************************************************************************/ 50 | 51 | private void postCourses(final List courses) { 52 | mMainThread.post(new Runnable() { 53 | @Override 54 | public void run() { 55 | mCallback.onCoursesRetrieved(courses); 56 | } 57 | }); 58 | } 59 | 60 | /**********************************************************************************************/ 61 | /**********************************************************************************************/ 62 | 63 | @Override 64 | public void run() { 65 | // retrieve the message 66 | if (mSubjectCode == null) { 67 | return; 68 | } 69 | final List courses = mRepository.getCourses(mSubjectCode); 70 | 71 | // check if we have failed to retrieve our message 72 | if (courses == null || courses.size() == 0) { 73 | // notify the failure on the main thread 74 | notifyError(); 75 | return; 76 | } 77 | 78 | // we have retrieved our message, notify the UI on the main thread 79 | postCourses(courses); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/interactors/show_enrolled_courses/ShowEnrolledCourses.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.interactors.show_enrolled_courses; 2 | 3 | import com.clean.domain.interactors.Interactor; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by fabrizio on 26/05/16. 8 | */ 9 | public interface ShowEnrolledCourses extends Interactor { 10 | 11 | interface Callback { 12 | 13 | void onCoursesRetrieved(List courses); 14 | 15 | void onRetrievalFailed(String error); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/interactors/show_enrolled_courses/ShowEnrolledCoursesImpl.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.interactors.show_enrolled_courses; 2 | 3 | import com.clean.domain.executor.Executor; 4 | import com.clean.domain.executor.MainThread; 5 | import com.clean.domain.interactors.AbstractInteractor; 6 | import com.clean.domain.model.Course; 7 | import com.clean.domain.model.Subject; 8 | import com.clean.domain.repository.StudentRepository; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.Map; 13 | import java.util.Set; 14 | 15 | /** 16 | * Created by fabrizio on 26/05/16. 17 | */ 18 | public class ShowEnrolledCoursesImpl extends AbstractInteractor implements ShowEnrolledCourses { 19 | 20 | private StudentRepository mRepository; 21 | private Callback mCallback; 22 | 23 | /**********************************************************************************************/ 24 | /**********************************************************************************************/ 25 | 26 | public ShowEnrolledCoursesImpl(Executor threadExecutor, MainThread mainThread, 27 | Callback callback, StudentRepository repo) { 28 | super(threadExecutor, mainThread); 29 | mRepository = repo; 30 | mCallback = callback; 31 | } 32 | 33 | /**********************************************************************************************/ 34 | /**********************************************************************************************/ 35 | 36 | private void notifyError() { 37 | mMainThread.post(new Runnable() { 38 | @Override 39 | public void run() { 40 | mCallback.onRetrievalFailed("Nothing to welcome you with :("); 41 | } 42 | }); 43 | } 44 | 45 | /**********************************************************************************************/ 46 | /**********************************************************************************************/ 47 | 48 | private void postCourses(final List courses) { 49 | mMainThread.post(new Runnable() { 50 | @Override 51 | public void run() { 52 | mCallback.onCoursesRetrieved(courses); 53 | } 54 | }); 55 | } 56 | 57 | /**********************************************************************************************/ 58 | /**********************************************************************************************/ 59 | 60 | @Override 61 | public void run() { 62 | // retrieve the message 63 | final Map courses = mRepository.getEnrolledCourses(); 64 | 65 | // check if we have failed to retrieve our message 66 | if (courses == null || courses.size() == 0) { 67 | // notify the failure on the main thread 68 | notifyError(); 69 | return; 70 | } 71 | 72 | Set keys = courses.keySet(); 73 | List enrolledCourses = new ArrayList<>(); 74 | 75 | for (Integer key : keys) { 76 | String courseString = "Curso " + Integer.toString(courses.get(key).getId()); 77 | Subject subject = mRepository.getSubject(key.intValue()); 78 | String enrolledCourse = subject.getName() + ", " + courseString; 79 | enrolledCourses.add(enrolledCourse); 80 | } 81 | 82 | // we have retrieved our message, notify the UI on the main thread 83 | postCourses(enrolledCourses); 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/model/Course.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.model; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Class that represents a Course in the domain layer. 7 | */ 8 | public class Course { 9 | 10 | private Integer mId; 11 | private List mTeachers; 12 | private String mSchedule; 13 | private String mClassroom; 14 | private int mVacancy; 15 | 16 | public Course() {} 17 | 18 | public void setId(int id) { 19 | mId = id; 20 | } 21 | 22 | public void setTeachers(List teachers) { 23 | mTeachers = teachers; 24 | } 25 | 26 | public void setSchedule(String schedule) { 27 | mSchedule = schedule; 28 | } 29 | 30 | public void setClassroom(String classroom) { 31 | mClassroom = classroom; 32 | } 33 | 34 | public void setVacancy(int vacancy) { 35 | mVacancy = vacancy; 36 | } 37 | 38 | public Integer getId() { 39 | return mId; 40 | } 41 | 42 | public List getTeachers() { 43 | return mTeachers; 44 | } 45 | 46 | public String getSchedule() { 47 | return mSchedule; 48 | } 49 | 50 | public String getClassroom() { 51 | return mClassroom; 52 | } 53 | 54 | public int getVacancy() { 55 | return mVacancy; 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/model/Subject.java: -------------------------------------------------------------------------------- 1 | package com.clean.domain.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * Class that represents a SubjectModel in the domain layer. 8 | */ 9 | public class Subject { 10 | 11 | private String mName; 12 | private Integer mCode; 13 | private String mDepartament; 14 | private int mCredits; 15 | private List mCourses; 16 | 17 | public Subject() { 18 | mCourses = new ArrayList<>(); 19 | } 20 | 21 | public void setName(String name) { 22 | mName = name; 23 | } 24 | 25 | public void setCode(int code) { 26 | mCode = code; 27 | } 28 | 29 | public void setDepartament(String departament) { 30 | mDepartament = departament; 31 | } 32 | 33 | public void setCredits(int credits) { 34 | mCredits = credits; 35 | } 36 | 37 | public void addCourse(Course course) { 38 | mCourses.add(course); 39 | } 40 | 41 | public void setCourses(List courses) { 42 | for (int i = 0; i < courses.size(); i++) { 43 | addCourse(courses.get(i)); 44 | } 45 | } 46 | 47 | public Integer getCode() { 48 | return mCode; 49 | } 50 | 51 | public String getName() { 52 | return mName; 53 | } 54 | 55 | public List getCourses() { 56 | return mCourses; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/domain/repository/StudentRepository.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Fernando Cejas Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.clean.domain.repository; 17 | 18 | import com.clean.domain.model.Course; 19 | import com.clean.domain.model.Subject; 20 | 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | 25 | /** 26 | * Interface that represents a repository for getting student related data. 27 | */ 28 | public interface StudentRepository { 29 | 30 | /** 31 | * Get a List of {@link Subject}. 32 | */ 33 | List getAvailableSubjects(); 34 | 35 | /** 36 | * Get a Map of {@link Course} as value, and the subject code as key. 37 | */ 38 | Map getEnrolledCourses(); 39 | 40 | /** 41 | * Get a list of {@link Course}. 42 | * @param subjectCode The subject code used to retrieve the courses of the subject. 43 | */ 44 | List getCourses(final int subjectCode); 45 | 46 | /** 47 | * Get a {@link Course}. 48 | * @param subjectCode The subject code used to retrieve the courses of the subject. 49 | * @param courseId The course id used to retrieve the course. 50 | */ 51 | Course getCourse(final int subjectCode, final int courseId); 52 | 53 | /** 54 | * Get a {@link Subject}. 55 | */ 56 | Subject getSubject(final int subjectCode); 57 | 58 | /** 59 | * Save the enrolled {@link Course}. 60 | * @param subjectCode The subject code of the subject from wich is the course. 61 | * @param course The course enrolled. 62 | */ 63 | void enrollCourse(final int subjectCode, Course course); 64 | 65 | } -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/UniquePointOfInstanciation.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation; 2 | 3 | import android.content.Context; 4 | 5 | import com.clean.data.repository.LocalDataBase; 6 | import com.clean.domain.executor.impl.ThreadExecutor; 7 | import com.clean.domain.repository.StudentRepository; 8 | import com.clean.presentation.presenters.courses.CoursesPresenter; 9 | import com.clean.presentation.presenters.courses.CoursesPresenterImpl; 10 | import com.clean.presentation.presenters.enroll_to_course.EnrollToCoursePresenter; 11 | import com.clean.presentation.presenters.enroll_to_course.EnrollToCoursePresenterImpl; 12 | import com.clean.presentation.presenters.enrolled_courses.EnrolledCoursesPresenter; 13 | import com.clean.presentation.presenters.enrolled_courses.EnrolledCoursesPresenterImpl; 14 | import com.clean.presentation.presenters.main.MainPresenter; 15 | import com.clean.presentation.presenters.main.MainPresenterImpl; 16 | import com.clean.threading.MainThreadImpl; 17 | 18 | /** 19 | * Created by fabrizio on 29/05/16. 20 | */ 21 | public class UniquePointOfInstanciation { 22 | 23 | public static Context CONTEXT; 24 | public static StudentRepository REPOSITORY; 25 | 26 | /**********************************************************************************************/ 27 | /**********************************************************************************************/ 28 | 29 | public static void setContext(Context context) { 30 | CONTEXT = context; 31 | REPOSITORY = new LocalDataBase(CONTEXT); 32 | 33 | } 34 | 35 | /**********************************************************************************************/ 36 | /**********************************************************************************************/ 37 | 38 | public static MainPresenter initializeGetAvailableSubjects(MainPresenter.View context) { 39 | return new MainPresenterImpl( 40 | ThreadExecutor.getInstance(), 41 | MainThreadImpl.getInstance(), 42 | context, 43 | REPOSITORY 44 | ); 45 | } 46 | 47 | /**********************************************************************************************/ 48 | /**********************************************************************************************/ 49 | 50 | public static CoursesPresenter initializeCourses(CoursesPresenter.View context, int subjectCode) { 51 | return new CoursesPresenterImpl( 52 | ThreadExecutor.getInstance(), 53 | MainThreadImpl.getInstance(), 54 | context, 55 | REPOSITORY, 56 | subjectCode 57 | ); 58 | } 59 | 60 | /**********************************************************************************************/ 61 | /**********************************************************************************************/ 62 | 63 | public static EnrollToCoursePresenter initializeEnrollToCourse(EnrollToCoursePresenter.View context, 64 | int subjectCode, int courseId) { 65 | return new EnrollToCoursePresenterImpl( 66 | ThreadExecutor.getInstance(), 67 | MainThreadImpl.getInstance(), 68 | context, 69 | REPOSITORY, 70 | subjectCode, 71 | courseId 72 | ); 73 | } 74 | 75 | /**********************************************************************************************/ 76 | /**********************************************************************************************/ 77 | 78 | public static EnrolledCoursesPresenter initializeEnrolledCourses(EnrolledCoursesPresenter.View context) { 79 | 80 | return new EnrolledCoursesPresenterImpl( 81 | ThreadExecutor.getInstance(), 82 | MainThreadImpl.getInstance(), 83 | context, 84 | REPOSITORY 85 | ); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/mapper/CourseModelMapper.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.mapper; 2 | 3 | import com.clean.domain.model.Course; 4 | import com.clean.presentation.model.CourseModel; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by fabrizio on 06/06/16. 11 | */ 12 | public class CourseModelMapper { 13 | 14 | public static List transform(List courses) { 15 | List courseList = new ArrayList<>(); 16 | for (Course course : courses) { 17 | courseList.add(CourseModel.buildCourseModel(). 18 | addTeachers(course.getTeachers()). 19 | addId(course.getId()). 20 | addClassroom(course.getClassroom()). 21 | addSchedule(course.getSchedule()). 22 | addVacancy(course.getVacancy()) 23 | ); 24 | } 25 | return courseList; 26 | } 27 | 28 | /**********************************************************************************************/ 29 | /**********************************************************************************************/ 30 | 31 | public static List transformToStrings(List courses) { 32 | List courseList = new ArrayList<>(); 33 | for (Course course : courses) { 34 | courseList.add(Integer.toString(course.getId())); 35 | } 36 | return courseList; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/mapper/SubjectModelMapper.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.mapper; 2 | 3 | import com.clean.domain.model.Subject; 4 | import com.clean.presentation.model.SubjectModel; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by fabrizio on 31/05/16. 11 | */ 12 | public class SubjectModelMapper { 13 | 14 | public static List transform(List subjects) { 15 | List subjectList = new ArrayList<>(); 16 | for (Subject subject : subjects) { 17 | subjectList.add(SubjectModel.buildSubjectModel(). 18 | addName(subject.getName()). 19 | addCode(subject.getCode())); 20 | } 21 | return subjectList; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/model/CourseModel.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.model; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by fabrizio on 06/06/16. 7 | */ 8 | public class CourseModel { 9 | 10 | private Integer mId; 11 | private List mTeachers; 12 | private String mSchedule; 13 | private String mClassroom; 14 | private int mVacancy; 15 | 16 | private CourseModel() { 17 | } 18 | 19 | public static CourseModel buildCourseModel(){ 20 | return new CourseModel(); 21 | } 22 | 23 | 24 | public CourseModel addId(int id) { 25 | mId = id; 26 | return this; 27 | } 28 | 29 | public CourseModel addTeachers(List teachers) { 30 | mTeachers = teachers; 31 | return this; 32 | } 33 | 34 | public CourseModel addSchedule(String schedule) { 35 | mSchedule = schedule; 36 | return this; 37 | } 38 | 39 | public CourseModel addClassroom(String classroom) { 40 | mClassroom = classroom; 41 | return this; 42 | } 43 | 44 | public CourseModel addVacancy(int vacancy) { 45 | mVacancy = vacancy; 46 | return this; 47 | } 48 | 49 | public Integer getId() { 50 | return mId; 51 | } 52 | 53 | public List getTeachers() { 54 | return mTeachers; 55 | } 56 | 57 | public String getSchedule() { 58 | return mSchedule; 59 | } 60 | 61 | public String getClassroom() { 62 | return mClassroom; 63 | } 64 | 65 | public int getVacancy() { 66 | return mVacancy; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/model/SubjectModel.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.model; 2 | 3 | /** 4 | * Class that represents a SubjectModel in the domain layer. 5 | */ 6 | public class SubjectModel { 7 | 8 | private String mName; 9 | private Integer mCode; 10 | 11 | private SubjectModel() {} 12 | 13 | public static SubjectModel buildSubjectModel(){ 14 | return new SubjectModel(); 15 | } 16 | 17 | public SubjectModel addName(String name) { 18 | mName = name; 19 | return this; 20 | } 21 | 22 | public SubjectModel addCode(int code) { 23 | mCode = code; 24 | return this; 25 | } 26 | 27 | public Integer getCode() { 28 | return mCode; 29 | } 30 | 31 | public String getName() { 32 | return mName; 33 | } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/presenters/AbstractPresenter.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.presenters; 2 | 3 | 4 | import com.clean.domain.executor.Executor; 5 | import com.clean.domain.executor.MainThread; 6 | 7 | /** 8 | * This is a base class for all presenters which are communicating with interactors. This base class will hold a 9 | * reference to the Executor and MainThread objects that are needed for running interactors in a background thread. 10 | */ 11 | public abstract class AbstractPresenter { 12 | protected Executor mExecutor; 13 | protected MainThread mMainThread; 14 | 15 | public AbstractPresenter(Executor executor, MainThread mainThread) { 16 | mExecutor = executor; 17 | mMainThread = mainThread; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/presenters/BasePresenter.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.presenters; 2 | 3 | public interface BasePresenter { 4 | /** 5 | * Method that control the lifecycle of the view. It should be called in the view's 6 | * (Activity or Fragment) onResume() method. 7 | */ 8 | void resume(); 9 | 10 | /** 11 | * Method that controls the lifecycle of the view. It should be called in the view's 12 | * (Activity or Fragment) onPause() method. 13 | */ 14 | void pause(); 15 | 16 | /** 17 | * Method that controls the lifecycle of the view. It should be called in the view's 18 | * (Activity or Fragment) onStop() method. 19 | */ 20 | void stop(); 21 | 22 | /** 23 | * Method that control the lifecycle of the view. It should be called in the view's 24 | * (Activity or Fragment) onDestroy() method. 25 | */ 26 | void destroy(); 27 | 28 | 29 | /** 30 | * Method that should signal the appropriate view to show the appropriate error with the provided message. 31 | */ 32 | void onError(String message); 33 | } 34 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/presenters/courses/CoursesPresenter.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.presenters.courses; 2 | 3 | import com.clean.presentation.presenters.BasePresenter; 4 | import com.clean.presentation.ui.BaseView; 5 | 6 | import java.util.List; 7 | 8 | 9 | public interface CoursesPresenter extends BasePresenter { 10 | 11 | interface View extends BaseView { 12 | void displayCourses(List courses); 13 | // TODO: Add your view methods 14 | } 15 | 16 | // TODO: Add your presenter methods 17 | 18 | } 19 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/presenters/courses/CoursesPresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.presenters.courses; 2 | 3 | import com.clean.domain.executor.Executor; 4 | import com.clean.domain.executor.MainThread; 5 | import com.clean.domain.interactors.show_courses.ShowCourses; 6 | import com.clean.domain.interactors.show_courses.ShowCoursesImpl; 7 | import com.clean.domain.repository.StudentRepository; 8 | import com.clean.presentation.presenters.AbstractPresenter; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Created by dmilicic on 12/13/15. 14 | */ 15 | public class CoursesPresenterImpl extends AbstractPresenter implements CoursesPresenter, 16 | ShowCourses.Callback { 17 | 18 | private View mView; 19 | private StudentRepository mRepository; 20 | private int mSubjectCode; 21 | 22 | /**********************************************************************************************/ 23 | /**********************************************************************************************/ 24 | 25 | public CoursesPresenterImpl(Executor executor, 26 | MainThread mainThread, 27 | View view, 28 | StudentRepository repository, 29 | int subjectCode) { 30 | super(executor, mainThread); 31 | mView = view; 32 | mRepository = repository; 33 | mSubjectCode = subjectCode; 34 | } 35 | 36 | /**********************************************************************************************/ 37 | /**********************************************************************************************/ 38 | 39 | @Override 40 | public void resume() { 41 | mView.showProgress(); 42 | 43 | // initialize the interactor 44 | ShowCourses interactor = new ShowCoursesImpl( 45 | mExecutor, 46 | mMainThread, 47 | this, 48 | mRepository 49 | ); 50 | 51 | interactor.setSubjectCode(mSubjectCode); 52 | // run the interactor 53 | interactor.execute(); 54 | } 55 | 56 | /**********************************************************************************************/ 57 | /**********************************************************************************************/ 58 | 59 | @Override 60 | public void pause() { 61 | 62 | } 63 | 64 | /**********************************************************************************************/ 65 | /**********************************************************************************************/ 66 | 67 | @Override 68 | public void stop() { 69 | 70 | } 71 | 72 | /**********************************************************************************************/ 73 | /**********************************************************************************************/ 74 | 75 | @Override 76 | public void destroy() { 77 | 78 | } 79 | 80 | /**********************************************************************************************/ 81 | /**********************************************************************************************/ 82 | 83 | @Override 84 | public void onError(String message) { 85 | 86 | } 87 | 88 | /**********************************************************************************************/ 89 | /**********************************************************************************************/ 90 | 91 | @Override 92 | public void onCoursesRetrieved(List courses) { 93 | mView.displayCourses(courses); 94 | } 95 | 96 | /**********************************************************************************************/ 97 | /**********************************************************************************************/ 98 | 99 | @Override 100 | public void onRetrievalFailed(String error) { 101 | 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/presenters/enroll_to_course/EnrollToCoursePresenter.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.presenters.enroll_to_course; 2 | 3 | import com.clean.presentation.presenters.BasePresenter; 4 | import com.clean.presentation.ui.BaseView; 5 | 6 | 7 | public interface EnrollToCoursePresenter extends BasePresenter { 8 | 9 | interface View extends BaseView { 10 | void notifyAlreadyEnrolledSubject(); 11 | void notifyEnrolledInSevenCourses(); 12 | void notifyEnrolled(); 13 | // TODO: Add your view methods 14 | } 15 | 16 | // TODO: Add your presenter methods 17 | 18 | } 19 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/presenters/enrolled_courses/EnrolledCoursesPresenter.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.presenters.enrolled_courses; 2 | 3 | import com.clean.presentation.presenters.BasePresenter; 4 | import com.clean.presentation.ui.BaseView; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | 10 | public interface EnrolledCoursesPresenter extends BasePresenter { 11 | 12 | interface View extends BaseView { 13 | void displayCourses(List courses); 14 | // TODO: Add your view methods 15 | } 16 | 17 | // TODO: Add your presenter methods 18 | 19 | } 20 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/presenters/enrolled_courses/EnrolledCoursesPresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.presenters.enrolled_courses; 2 | 3 | import com.clean.domain.executor.Executor; 4 | import com.clean.domain.executor.MainThread; 5 | import com.clean.domain.interactors.show_enrolled_courses.ShowEnrolledCourses; 6 | import com.clean.domain.interactors.show_enrolled_courses.ShowEnrolledCoursesImpl; 7 | import com.clean.domain.repository.StudentRepository; 8 | import com.clean.presentation.presenters.AbstractPresenter; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Created by dmilicic on 12/13/15. 14 | */ 15 | public class EnrolledCoursesPresenterImpl extends AbstractPresenter implements EnrolledCoursesPresenter, 16 | ShowEnrolledCourses.Callback { 17 | 18 | private View mView; 19 | private StudentRepository mRepository; 20 | 21 | /**********************************************************************************************/ 22 | /**********************************************************************************************/ 23 | 24 | public EnrolledCoursesPresenterImpl(Executor executor, 25 | MainThread mainThread, 26 | View view, 27 | StudentRepository repository) { 28 | super(executor, mainThread); 29 | mView = view; 30 | mRepository = repository; 31 | } 32 | 33 | /**********************************************************************************************/ 34 | /**********************************************************************************************/ 35 | 36 | @Override 37 | public void resume() { 38 | mView.showProgress(); 39 | 40 | // initialize the interactor 41 | ShowEnrolledCourses interactor = new ShowEnrolledCoursesImpl( 42 | mExecutor, 43 | mMainThread, 44 | this, 45 | mRepository 46 | ); 47 | 48 | // run the interactor 49 | interactor.execute(); 50 | } 51 | 52 | /**********************************************************************************************/ 53 | /**********************************************************************************************/ 54 | 55 | @Override 56 | public void pause() { 57 | 58 | } 59 | 60 | /**********************************************************************************************/ 61 | /**********************************************************************************************/ 62 | 63 | @Override 64 | public void stop() { 65 | 66 | } 67 | 68 | /**********************************************************************************************/ 69 | /**********************************************************************************************/ 70 | 71 | @Override 72 | public void destroy() { 73 | 74 | } 75 | 76 | /**********************************************************************************************/ 77 | /**********************************************************************************************/ 78 | 79 | @Override 80 | public void onError(String message) { 81 | 82 | } 83 | 84 | /**********************************************************************************************/ 85 | /**********************************************************************************************/ 86 | 87 | @Override 88 | public void onCoursesRetrieved(List courses) { 89 | mView.displayCourses(courses); 90 | } 91 | 92 | /**********************************************************************************************/ 93 | /**********************************************************************************************/ 94 | 95 | @Override 96 | public void onRetrievalFailed(String error) { 97 | 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/presenters/main/MainPresenter.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.presenters.main; 2 | 3 | import com.clean.presentation.presenters.BasePresenter; 4 | import com.clean.presentation.ui.BaseView; 5 | 6 | import java.util.List; 7 | 8 | 9 | public interface MainPresenter extends BasePresenter { 10 | 11 | interface View extends BaseView { 12 | void displaySubjects(List subjects); 13 | // TODO: Add your view methods 14 | } 15 | 16 | // TODO: Add your presenter methods 17 | 18 | } 19 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/presenters/main/MainPresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.presenters.main; 2 | 3 | import com.clean.domain.executor.Executor; 4 | import com.clean.domain.executor.MainThread; 5 | import com.clean.domain.interactors.show_available_subjects.ShowAvailableSubjects; 6 | import com.clean.domain.interactors.show_available_subjects.ShowAvailableSubjectsImpl; 7 | import com.clean.domain.repository.StudentRepository; 8 | import com.clean.presentation.presenters.AbstractPresenter; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Created by dmilicic on 12/13/15. 14 | */ 15 | public class MainPresenterImpl extends AbstractPresenter implements MainPresenter, 16 | ShowAvailableSubjects.Callback { 17 | 18 | private MainPresenter.View mView; 19 | private StudentRepository mRepository; 20 | 21 | /**********************************************************************************************/ 22 | /**********************************************************************************************/ 23 | 24 | public MainPresenterImpl(Executor executor, 25 | MainThread mainThread, 26 | View view, 27 | StudentRepository repository) { 28 | super(executor, mainThread); 29 | mView = view; 30 | mRepository = repository; 31 | } 32 | 33 | /**********************************************************************************************/ 34 | /**********************************************************************************************/ 35 | 36 | @Override 37 | public void resume() { 38 | mView.showProgress(); 39 | 40 | // initialize the interactor 41 | ShowAvailableSubjects interactor = new ShowAvailableSubjectsImpl( 42 | mExecutor, 43 | mMainThread, 44 | this, 45 | mRepository 46 | ); 47 | 48 | // run the interactor 49 | interactor.execute(); 50 | } 51 | 52 | /**********************************************************************************************/ 53 | /**********************************************************************************************/ 54 | 55 | @Override 56 | public void pause() { 57 | 58 | } 59 | 60 | /**********************************************************************************************/ 61 | /**********************************************************************************************/ 62 | 63 | @Override 64 | public void stop() { 65 | 66 | } 67 | 68 | /**********************************************************************************************/ 69 | /**********************************************************************************************/ 70 | 71 | @Override 72 | public void destroy() { 73 | 74 | } 75 | 76 | /**********************************************************************************************/ 77 | /**********************************************************************************************/ 78 | 79 | @Override 80 | public void onError(String message) { 81 | 82 | } 83 | 84 | /**********************************************************************************************/ 85 | /**********************************************************************************************/ 86 | 87 | @Override 88 | public void onSubjectsRetrieved(List subjects) { 89 | mView.displaySubjects(subjects); 90 | } 91 | 92 | /**********************************************************************************************/ 93 | /**********************************************************************************************/ 94 | 95 | @Override 96 | public void onRetrievalFailed(String error) { 97 | 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/ui/BaseView.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.ui; 2 | 3 | /** 4 | *

5 | * This interface represents a basic view. All views should implement these common methods. 6 | *

7 | */ 8 | public interface BaseView { 9 | 10 | /** 11 | * This is a general method used for showing some kind of progress during a background task. For example, this 12 | * method should show a progress bar and/or disable buttons before some background work starts. 13 | */ 14 | void showProgress(); 15 | 16 | /** 17 | * This is a general method used for hiding progress information after a background task finishes. 18 | */ 19 | void hideProgress(); 20 | 21 | /** 22 | * This method is used for showing error messages on the UI. 23 | * 24 | * @param message The error message to be displayed. 25 | */ 26 | void showError(String message); 27 | } 28 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/ui/activities/CoursesActivity.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.ui.activities; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.util.Log; 8 | import android.widget.Toast; 9 | 10 | import com.clean.R; 11 | import com.clean.presentation.UniquePointOfInstanciation; 12 | import com.clean.presentation.mapper.CourseModelMapper; 13 | import com.clean.presentation.model.CourseModel; 14 | import com.clean.presentation.presenters.BasePresenter; 15 | import com.clean.presentation.presenters.courses.CoursesPresenter; 16 | import com.clean.presentation.ui.adapters.CoursesNamesRecyclerAdapter; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import butterknife.ButterKnife; 22 | 23 | public class CoursesActivity extends AppCompatActivity implements CoursesPresenter.View { 24 | 25 | public static final String SUBJECT_CODE = "code"; 26 | public static final String SUBJECT_NAME = "name"; 27 | private BasePresenter mPresenter; 28 | private RecyclerView mCoursesView; 29 | private List mCourses; 30 | private int mSubjectCode; 31 | 32 | /**********************************************************************************************/ 33 | /**********************************************************************************************/ 34 | 35 | @Override 36 | protected void onCreate(Bundle savedInstanceState) { 37 | super.onCreate(savedInstanceState); 38 | setContentView(R.layout.activity_courses); 39 | ButterKnife.bind(this); 40 | getSupportActionBar().setTitle(getIntent().getStringExtra(SUBJECT_NAME)); 41 | 42 | mCourses = new ArrayList<>(); 43 | mCoursesView = (RecyclerView) findViewById(R.id.recyclerview); 44 | mCoursesView.setLayoutManager(new LinearLayoutManager(mCoursesView.getContext())); 45 | mCoursesView.setAdapter(new CoursesNamesRecyclerAdapter(this, mCourses)); 46 | this.initialize(); 47 | } 48 | 49 | /**********************************************************************************************/ 50 | /**********************************************************************************************/ 51 | 52 | private void initialize() { 53 | // create a presenter for this view 54 | mSubjectCode = getSubjectCode(); 55 | ((CoursesNamesRecyclerAdapter) mCoursesView.getAdapter()).setSubjectCode(mSubjectCode); 56 | mPresenter = UniquePointOfInstanciation.initializeCourses(this, mSubjectCode); 57 | mPresenter.resume(); 58 | } 59 | 60 | /**********************************************************************************************/ 61 | /**********************************************************************************************/ 62 | 63 | public int getSubjectCode() { 64 | Toast.makeText(this, getIntent().getStringExtra(SUBJECT_NAME),Toast.LENGTH_SHORT).show(); 65 | return getIntent().getIntExtra(SUBJECT_CODE, 0); 66 | } 67 | 68 | /**********************************************************************************************/ 69 | /**********************************************************************************************/ 70 | 71 | @Override 72 | public void showProgress() { 73 | 74 | } 75 | 76 | /**********************************************************************************************/ 77 | /**********************************************************************************************/ 78 | 79 | @Override 80 | public void hideProgress() { 81 | 82 | } 83 | 84 | /**********************************************************************************************/ 85 | /**********************************************************************************************/ 86 | 87 | @Override 88 | public void showError(String message) { 89 | 90 | } 91 | 92 | /**********************************************************************************************/ 93 | /**********************************************************************************************/ 94 | 95 | @Override 96 | public void displayCourses(List courses) { 97 | mCourses = CourseModelMapper.transform(courses); 98 | Log.e("dsada", courses.toString()); 99 | Log.e("dsada", courses.toString()); 100 | mCoursesView.setAdapter(new CoursesNamesRecyclerAdapter(this, mCourses)); 101 | ((CoursesNamesRecyclerAdapter) mCoursesView.getAdapter()).setSubjectCode(mSubjectCode); 102 | mCoursesView.getAdapter().notifyDataSetChanged(); 103 | mCoursesView.invalidate(); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/ui/activities/EnrollToCourseActivity.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.ui.activities; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | 6 | import com.clean.R; 7 | import com.clean.presentation.UniquePointOfInstanciation; 8 | import com.clean.presentation.presenters.enroll_to_course.EnrollToCoursePresenter; 9 | import com.clean.presentation.ui.dialogs.NotifyDialog; 10 | 11 | /** 12 | * Created by fabrizio on 07/06/16. 13 | */ 14 | public class EnrollToCourseActivity extends AppCompatActivity implements EnrollToCoursePresenter.View{ 15 | 16 | public static String COURSE_ID = "course_id"; 17 | public static String SUBJECT_CODE = "subject_code"; 18 | private EnrollToCoursePresenter mPresenter; 19 | 20 | /**********************************************************************************************/ 21 | /**********************************************************************************************/ 22 | 23 | @Override 24 | protected void onCreate(Bundle savedInstance) { 25 | super.onCreate(savedInstance); 26 | int subjectCode = getSubjectCode(); 27 | int courseId = getCourseId(); 28 | mPresenter = UniquePointOfInstanciation.initializeEnrollToCourse(this, subjectCode, courseId); 29 | mPresenter.resume(); 30 | } 31 | 32 | /**********************************************************************************************/ 33 | /**********************************************************************************************/ 34 | 35 | public int getSubjectCode() { 36 | return getIntent().getIntExtra(SUBJECT_CODE, 0); 37 | } 38 | 39 | /**********************************************************************************************/ 40 | /**********************************************************************************************/ 41 | 42 | public int getCourseId() { 43 | return getIntent().getIntExtra(COURSE_ID, 0); 44 | } 45 | 46 | /**********************************************************************************************/ 47 | /**********************************************************************************************/ 48 | 49 | @Override 50 | public void showProgress() { 51 | 52 | } 53 | 54 | /**********************************************************************************************/ 55 | /**********************************************************************************************/ 56 | 57 | @Override 58 | public void hideProgress() { 59 | 60 | } 61 | 62 | /**********************************************************************************************/ 63 | /**********************************************************************************************/ 64 | 65 | @Override 66 | public void showError(String message) { 67 | 68 | } 69 | 70 | /**********************************************************************************************/ 71 | /**********************************************************************************************/ 72 | 73 | @Override 74 | public void notifyAlreadyEnrolledSubject() { 75 | NotifyDialog.build(this, getString(R.string.error_title), getString(R.string.same_subject)).show(); 76 | } 77 | 78 | /**********************************************************************************************/ 79 | /**********************************************************************************************/ 80 | 81 | @Override 82 | public void notifyEnrolledInSevenCourses() { 83 | NotifyDialog.build(this, getString(R.string.error_title), getString(R.string.limit)).show(); 84 | } 85 | 86 | /**********************************************************************************************/ 87 | /**********************************************************************************************/ 88 | 89 | @Override 90 | public void notifyEnrolled() { 91 | NotifyDialog.build(this, getString(R.string.sucess_title), getString(R.string.sucess_enroll)).show(); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/ui/activities/EnrolledCoursesActivity.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.ui.activities; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.util.Log; 8 | 9 | import com.clean.R; 10 | import com.clean.presentation.UniquePointOfInstanciation; 11 | import com.clean.presentation.presenters.BasePresenter; 12 | import com.clean.presentation.presenters.enrolled_courses.EnrolledCoursesPresenter; 13 | import com.clean.presentation.ui.adapters.SimpleStringRecyclerViewAdapter; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | import butterknife.ButterKnife; 19 | 20 | public class EnrolledCoursesActivity extends AppCompatActivity implements EnrolledCoursesPresenter.View { 21 | 22 | private BasePresenter mPresenter; 23 | private RecyclerView mInscriptionsView; 24 | private List mInscriptions; 25 | 26 | /**********************************************************************************************/ 27 | /**********************************************************************************************/ 28 | 29 | @Override 30 | protected void onCreate(Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | setContentView(R.layout.activity_enrolled_courses); 33 | ButterKnife.bind(this); 34 | getSupportActionBar().setTitle(getString(R.string.inscriptions)); 35 | 36 | mInscriptions = new ArrayList<>(); 37 | mInscriptionsView = (RecyclerView) findViewById(R.id.recyclerview); 38 | mInscriptionsView.setLayoutManager(new LinearLayoutManager(mInscriptionsView.getContext())); 39 | mInscriptionsView.setAdapter(new SimpleStringRecyclerViewAdapter(this, mInscriptions)); 40 | this.initialize(); 41 | } 42 | 43 | /**********************************************************************************************/ 44 | /**********************************************************************************************/ 45 | 46 | private void initialize() { 47 | // create a presenter for this view 48 | mPresenter = UniquePointOfInstanciation.initializeEnrolledCourses(this); 49 | mPresenter.resume(); 50 | } 51 | 52 | /**********************************************************************************************/ 53 | /**********************************************************************************************/ 54 | 55 | @Override 56 | public void showProgress() { 57 | 58 | } 59 | 60 | /**********************************************************************************************/ 61 | /**********************************************************************************************/ 62 | 63 | @Override 64 | public void hideProgress() { 65 | 66 | } 67 | 68 | /**********************************************************************************************/ 69 | /**********************************************************************************************/ 70 | 71 | @Override 72 | public void showError(String message) { 73 | 74 | } 75 | 76 | /**********************************************************************************************/ 77 | /**********************************************************************************************/ 78 | 79 | @Override 80 | public void displayCourses(List courses) { 81 | //mInscriptions = CourseModelMapper.transform(courses); 82 | Log.e("dsada", courses.toString()); 83 | Log.e("dsada", courses.toString()); 84 | mInscriptions = courses; 85 | mInscriptionsView.setAdapter(new SimpleStringRecyclerViewAdapter(this, mInscriptions)); 86 | mInscriptionsView.getAdapter().notifyDataSetChanged(); 87 | mInscriptionsView.invalidate(); 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/ui/activities/Main2Activity.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.ui.activities; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.Button; 8 | 9 | import com.clean.R; 10 | import butterknife.ButterKnife; 11 | 12 | public class Main2Activity extends AppCompatActivity { 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_main2); 18 | ButterKnife.bind(this); 19 | 20 | Button seeEnrolled = (Button) findViewById(R.id.see_enrolled); 21 | Button enroll = (Button) findViewById(R.id.enroll); 22 | setSeeEnrolledBehavior(seeEnrolled); 23 | setEnrollBehavior(enroll); 24 | 25 | } 26 | 27 | /**********************************************************************************************/ 28 | /**********************************************************************************************/ 29 | 30 | private void setSeeEnrolledBehavior(Button seeEnrolled) { 31 | seeEnrolled.setOnClickListener(new View.OnClickListener() { 32 | @Override 33 | public void onClick(View v) { 34 | Intent intent = new Intent(Main2Activity.this, EnrolledCoursesActivity.class); 35 | startActivity(intent); 36 | } 37 | }); 38 | } 39 | 40 | /**********************************************************************************************/ 41 | /**********************************************************************************************/ 42 | 43 | private void setEnrollBehavior(Button enroll) { 44 | enroll.setOnClickListener(new View.OnClickListener() { 45 | @Override 46 | public void onClick(View v) { 47 | Intent intent = new Intent(Main2Activity.this, MainActivity.class); 48 | startActivity(intent); 49 | } 50 | }); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/ui/activities/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.ui.activities; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.util.Log; 8 | 9 | import com.clean.R; 10 | import com.clean.presentation.UniquePointOfInstanciation; 11 | import com.clean.presentation.model.SubjectModel; 12 | import com.clean.presentation.presenters.main.MainPresenter; 13 | import com.clean.presentation.presenters.main.MainPresenter.View; 14 | import com.clean.presentation.mapper.SubjectModelMapper; 15 | import com.clean.presentation.ui.adapters.SubjectModelRecyclerViewAdapter; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | import butterknife.ButterKnife; 21 | 22 | public class MainActivity extends AppCompatActivity implements View { 23 | 24 | private MainPresenter mPresenter; 25 | private RecyclerView mSubjectsView; 26 | private List mSubjects; 27 | 28 | /**********************************************************************************************/ 29 | /**********************************************************************************************/ 30 | 31 | @Override 32 | protected void onCreate(Bundle savedInstanceState) { 33 | super.onCreate(savedInstanceState); 34 | setContentView(R.layout.activity_main); 35 | ButterKnife.bind(this); 36 | 37 | mSubjects = new ArrayList<>(); 38 | mSubjectsView = (RecyclerView) findViewById(R.id.recyclerview); 39 | mSubjectsView.setLayoutManager(new LinearLayoutManager(mSubjectsView.getContext())); 40 | mSubjectsView.setAdapter(new SubjectModelRecyclerViewAdapter(this, mSubjects)); 41 | this.initialize(); 42 | } 43 | 44 | /**********************************************************************************************/ 45 | /**********************************************************************************************/ 46 | 47 | private void initialize() { 48 | // create a presenter for this view 49 | mPresenter = UniquePointOfInstanciation.initializeGetAvailableSubjects(this); 50 | mPresenter.resume(); 51 | } 52 | 53 | /**********************************************************************************************/ 54 | /**********************************************************************************************/ 55 | 56 | @Override 57 | public void showProgress() { 58 | 59 | } 60 | 61 | /**********************************************************************************************/ 62 | /**********************************************************************************************/ 63 | 64 | @Override 65 | public void hideProgress() { 66 | 67 | } 68 | 69 | /**********************************************************************************************/ 70 | /**********************************************************************************************/ 71 | 72 | @Override 73 | public void showError(String message) { 74 | 75 | } 76 | 77 | /**********************************************************************************************/ 78 | /**********************************************************************************************/ 79 | 80 | @Override 81 | public void displaySubjects(List subjects) { 82 | mSubjects = SubjectModelMapper.transform(subjects); 83 | Log.e("dsada", subjects.toString()); 84 | Log.e("dsada", mSubjects.toString()); 85 | mSubjectsView.setAdapter(new SubjectModelRecyclerViewAdapter(this, mSubjects)); 86 | mSubjectsView.getAdapter().notifyDataSetChanged(); 87 | mSubjectsView.invalidate(); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/ui/adapters/CoursesNamesRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.ui.adapters; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.util.TypedValue; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.clean.R; 11 | import com.clean.presentation.model.CourseModel; 12 | import com.clean.presentation.ui.dialogs.EnrollToCourseDialog; 13 | import com.clean.presentation.ui.viewholders.ViewHolder; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * Created by fabrizio on 06/06/16. 19 | */ 20 | public class CoursesNamesRecyclerAdapter extends RecyclerView.Adapter { 21 | 22 | private final TypedValue mTypedValue = new TypedValue(); 23 | private int mBackground; 24 | private List mValues; 25 | private int mSubjectCode; 26 | 27 | /**********************************************************************************************/ 28 | /**********************************************************************************************/ 29 | 30 | public CourseModel getValueAt(int position) { 31 | return mValues.get(position); 32 | } 33 | 34 | /**********************************************************************************************/ 35 | /**********************************************************************************************/ 36 | 37 | public CoursesNamesRecyclerAdapter(Context context, List items) { 38 | context.getTheme().resolveAttribute(R.attr.selectableItemBackground, mTypedValue, true); 39 | mBackground = mTypedValue.resourceId; 40 | mValues = items; 41 | } 42 | 43 | /**********************************************************************************************/ 44 | /**********************************************************************************************/ 45 | 46 | @Override 47 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 48 | View view = LayoutInflater.from(parent.getContext()) 49 | .inflate(R.layout.list_item, parent, false); 50 | view.setBackgroundResource(mBackground); 51 | return new ViewHolder(view); 52 | } 53 | 54 | /**********************************************************************************************/ 55 | /**********************************************************************************************/ 56 | 57 | @Override 58 | public void onBindViewHolder(final ViewHolder holder, int position) { 59 | //holder.mBoundString = mValues.get(position).get; 60 | final CourseModel course = mValues.get(position); 61 | holder.mTextView.setText("Curso " + course.getId()); 62 | final String courseInfo = "Docentes: " + getTeachers(course) + "\n" 63 | + "Horario: " + course.getSchedule() + "\n" 64 | + "Vacantes: " + course.getVacancy(); 65 | 66 | 67 | holder.mView.setOnClickListener(new View.OnClickListener() { 68 | @Override 69 | public void onClick(View v) { 70 | Context context = v.getContext(); 71 | EnrollToCourseDialog.build(context, courseInfo, course.getId(), mSubjectCode).show(); 72 | } 73 | }); 74 | } 75 | 76 | /**********************************************************************************************/ 77 | /**********************************************************************************************/ 78 | 79 | private String getTeachers(CourseModel course) { 80 | String teachers = ""; 81 | List teachersList = course.getTeachers(); 82 | for (String teacher : teachersList) { 83 | teachers += teacher + ", "; 84 | } 85 | return teachers.substring(0, teachers.length()-2); 86 | } 87 | 88 | /**********************************************************************************************/ 89 | /**********************************************************************************************/ 90 | 91 | @Override 92 | public int getItemCount() { 93 | return mValues.size(); 94 | } 95 | 96 | /**********************************************************************************************/ 97 | /**********************************************************************************************/ 98 | 99 | public void setSubjectCode(int subjectCode) { 100 | mSubjectCode = subjectCode; 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/ui/adapters/SimpleStringRecyclerViewAdapter.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.ui.adapters; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.util.TypedValue; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | 11 | 12 | import com.clean.R; 13 | import com.clean.presentation.ui.activities.CoursesActivity; 14 | import com.clean.presentation.ui.viewholders.ViewHolder; 15 | 16 | import java.util.List; 17 | 18 | /** 19 | * Created by fabrizio on 26/05/16. 20 | */ 21 | 22 | public class SimpleStringRecyclerViewAdapter 23 | extends RecyclerView.Adapter { 24 | 25 | private final TypedValue mTypedValue = new TypedValue(); 26 | private int mBackground; 27 | private List mValues; 28 | 29 | /**********************************************************************************************/ 30 | /**********************************************************************************************/ 31 | 32 | public String getValueAt(int position) { 33 | return mValues.get(position); 34 | } 35 | 36 | /**********************************************************************************************/ 37 | /**********************************************************************************************/ 38 | 39 | public SimpleStringRecyclerViewAdapter(Context context, List items) { 40 | context.getTheme().resolveAttribute(R.attr.selectableItemBackground, mTypedValue, true); 41 | mBackground = mTypedValue.resourceId; 42 | mValues = items; 43 | } 44 | 45 | /**********************************************************************************************/ 46 | /**********************************************************************************************/ 47 | 48 | @Override 49 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 50 | View view = LayoutInflater.from(parent.getContext()) 51 | .inflate(R.layout.list_item, parent, false); 52 | view.setBackgroundResource(mBackground); 53 | return new ViewHolder(view); 54 | } 55 | 56 | /**********************************************************************************************/ 57 | /**********************************************************************************************/ 58 | 59 | @Override 60 | public void onBindViewHolder(final ViewHolder holder, int position) { 61 | holder.mBoundString = mValues.get(position); 62 | holder.mTextView.setText(mValues.get(position)); 63 | 64 | /*holder.mView.setOnClickListener(new View.OnClickListener() { 65 | @Override 66 | public void onClick(View v) { 67 | Context context = v.getContext(); 68 | Intent intent = new Intent(context, CoursesActivity.class); 69 | intent.putExtra(CoursesActivity.SUBJECT_CODE, holder.mBoundString); 70 | context.startActivity(intent); 71 | } 72 | });*/ 73 | } 74 | 75 | /**********************************************************************************************/ 76 | /**********************************************************************************************/ 77 | 78 | @Override 79 | public int getItemCount() { 80 | return mValues.size(); 81 | } 82 | } 83 | 84 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/ui/adapters/SubjectModelRecyclerViewAdapter.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.ui.adapters; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.util.Log; 7 | import android.util.TypedValue; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | 12 | import com.clean.R; 13 | import com.clean.presentation.model.SubjectModel; 14 | import com.clean.presentation.ui.activities.CoursesActivity; 15 | import com.clean.presentation.ui.viewholders.ViewHolder; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | * Created by fabrizio on 31/05/16. 21 | */ 22 | public class SubjectModelRecyclerViewAdapter extends RecyclerView.Adapter { 23 | 24 | private final TypedValue mTypedValue = new TypedValue(); 25 | private int mBackground; 26 | private List mValues; 27 | 28 | /**********************************************************************************************/ 29 | /**********************************************************************************************/ 30 | 31 | public SubjectModel getValueAt(int position) { 32 | return mValues.get(position); 33 | } 34 | 35 | /**********************************************************************************************/ 36 | /**********************************************************************************************/ 37 | 38 | public SubjectModelRecyclerViewAdapter(Context context, List items) { 39 | context.getTheme().resolveAttribute(R.attr.selectableItemBackground, mTypedValue, true); 40 | mBackground = mTypedValue.resourceId; 41 | mValues = items; 42 | } 43 | 44 | /**********************************************************************************************/ 45 | /**********************************************************************************************/ 46 | 47 | @Override 48 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 49 | View view = LayoutInflater.from(parent.getContext()) 50 | .inflate(R.layout.list_item, parent, false); 51 | view.setBackgroundResource(mBackground); 52 | return new ViewHolder(view); 53 | } 54 | 55 | /**********************************************************************************************/ 56 | /**********************************************************************************************/ 57 | 58 | @Override 59 | public void onBindViewHolder(final ViewHolder holder, int position) { 60 | holder.mBoundString = mValues.get(position).getName(); 61 | holder.mBoundInt = mValues.get(position).getCode(); 62 | holder.mTextView.setText(mValues.get(position).getName()); 63 | Log.e("NAME", mValues.get(position).getName()); 64 | 65 | holder.mView.setOnClickListener(new View.OnClickListener() { 66 | @Override 67 | public void onClick(View v) { 68 | Context context = v.getContext(); 69 | Intent intent = new Intent(context, CoursesActivity.class); 70 | intent.putExtra(CoursesActivity.SUBJECT_NAME, holder.mBoundString); 71 | intent.putExtra(CoursesActivity.SUBJECT_CODE, holder.mBoundInt); 72 | context.startActivity(intent); 73 | } 74 | }); 75 | } 76 | 77 | /**********************************************************************************************/ 78 | /**********************************************************************************************/ 79 | 80 | @Override 81 | public int getItemCount() { 82 | return mValues.size(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/ui/dialogs/EnrollToCourseDialog.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.ui.dialogs; 2 | 3 | 4 | import android.content.Context; 5 | import android.content.DialogInterface; 6 | import android.content.Intent; 7 | import android.support.v7.app.AlertDialog; 8 | 9 | import com.clean.R; 10 | import com.clean.presentation.ui.activities.EnrollToCourseActivity; 11 | 12 | /** 13 | * Created by fabrizio on 06/06/16. 14 | */ 15 | public class EnrollToCourseDialog { 16 | 17 | 18 | private EnrollToCourseDialog() {} 19 | 20 | public static AlertDialog build(final Context context, String courseInfo, 21 | final int id, final int subjectCode) { 22 | 23 | return new AlertDialog.Builder(context) 24 | .setTitle(R.string.enroll_title) 25 | .setMessage(courseInfo) 26 | .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { 27 | public void onClick(DialogInterface dialog, int which) { 28 | Intent intent = new Intent(context, EnrollToCourseActivity.class); 29 | intent.putExtra(EnrollToCourseActivity.COURSE_ID, id); 30 | intent.putExtra(EnrollToCourseActivity.SUBJECT_CODE, subjectCode); 31 | context.startActivity(intent); 32 | } 33 | }) 34 | .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { 35 | public void onClick(DialogInterface dialog, int which) { 36 | // do nothing 37 | } 38 | }) 39 | .setCancelable(false) 40 | .create(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/ui/dialogs/NotifyDialog.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.ui.dialogs; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.support.v7.app.AlertDialog; 7 | import android.support.v7.app.AppCompatActivity; 8 | 9 | import com.clean.R; 10 | import com.clean.presentation.ui.activities.EnrollToCourseActivity; 11 | 12 | /** 13 | * Created by fabrizio on 08/06/16. 14 | */ 15 | public class NotifyDialog { 16 | 17 | 18 | private NotifyDialog() {} 19 | 20 | public static AlertDialog build(final AppCompatActivity context, String title, String message) { 21 | 22 | return new AlertDialog.Builder(context) 23 | .setTitle(title) 24 | .setMessage(message) 25 | .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { 26 | public void onClick(DialogInterface dialog, int which) { 27 | context.finish(); 28 | } 29 | }) 30 | .setCancelable(false) 31 | .create(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/presentation/ui/viewholders/ViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.clean.presentation.ui.viewholders; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.View; 5 | import android.widget.ImageView; 6 | import android.widget.TextView; 7 | 8 | import com.clean.R; 9 | 10 | /** 11 | * Created by fabrizio on 26/05/16. 12 | */ 13 | public class ViewHolder extends RecyclerView.ViewHolder { 14 | public String mBoundString; 15 | public int mBoundInt; 16 | 17 | public final View mView; 18 | //public final ImageView mImageView; 19 | public final TextView mTextView; 20 | 21 | public ViewHolder(View view) { 22 | super(view); 23 | mView = view; 24 | //mImageView = (ImageView) view.findViewById(R.id.avatar); 25 | mTextView = (TextView) view.findViewById(android.R.id.text1); 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return super.toString() + " '" + mTextView.getText(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/java/com/clean/threading/MainThreadImpl.java: -------------------------------------------------------------------------------- 1 | package com.clean.threading; 2 | 3 | import android.os.Handler; 4 | import android.os.Looper; 5 | 6 | import com.clean.domain.executor.MainThread; 7 | 8 | 9 | /** 10 | * This class makes sure that the runnable we provide will be run on the main UI thread. 11 | */ 12 | public class MainThreadImpl implements MainThread { 13 | 14 | private static MainThread sMainThread; 15 | 16 | private Handler mHandler; 17 | 18 | private MainThreadImpl() { 19 | mHandler = new Handler(Looper.getMainLooper()); 20 | } 21 | 22 | @Override 23 | public void post(Runnable runnable) { 24 | mHandler.post(runnable); 25 | } 26 | 27 | public static MainThread getInstance() { 28 | if (sMainThread == null) { 29 | sMainThread = new MainThreadImpl(); 30 | } 31 | 32 | return sMainThread; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/res/layout/activity_courses.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/res/layout/activity_enrolled_courses.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /android/FIUBAPP/app/src/main/res/layout/activity_main2.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 19 | 20 |