├── app ├── .gitignore ├── src │ ├── main │ │ ├── assets │ │ │ ├── 1.png │ │ │ ├── 2.png │ │ │ ├── 3.png │ │ │ ├── 4.png │ │ │ └── mlsdev-logo.png │ │ ├── res │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_plus.png │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── layout │ │ │ │ ├── content_students.xml │ │ │ │ ├── content_universities.xml │ │ │ │ ├── activity_students.xml │ │ │ │ ├── layout_item_university.xml │ │ │ │ ├── activity_universities.xml │ │ │ │ ├── dialog_add_university.xml │ │ │ │ ├── layout_item_student.xml │ │ │ │ └── dialog_add_student.xml │ │ │ └── values-v21 │ │ │ │ └── styles.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── cook │ │ │ │ └── simplerealmandroid │ │ │ │ ├── realm │ │ │ │ ├── repository │ │ │ │ │ ├── IBaseRepository.java │ │ │ │ │ ├── IUniversityRepository.java │ │ │ │ │ ├── IStudentRepository.java │ │ │ │ │ └── impl │ │ │ │ │ │ ├── UniversityRepository.java │ │ │ │ │ │ └── StudentRepository.java │ │ │ │ ├── module │ │ │ │ │ └── SimpleRealmModule.java │ │ │ │ └── table │ │ │ │ │ └── RealmTable.java │ │ │ │ ├── presenters │ │ │ │ ├── IBasePresenter.java │ │ │ │ ├── IUniversityPresenter.java │ │ │ │ ├── IStudentPresenter.java │ │ │ │ └── impl │ │ │ │ │ ├── UniversityPresenter.java │ │ │ │ │ └── StudentPresenter.java │ │ │ │ ├── tools │ │ │ │ └── DateFormatter.java │ │ │ │ ├── view │ │ │ │ ├── activity │ │ │ │ │ ├── base │ │ │ │ │ │ └── BaseActivity.java │ │ │ │ │ ├── StudentsActivity.java │ │ │ │ │ └── UniversityActivity.java │ │ │ │ ├── adapters │ │ │ │ │ ├── StudentsAdapter.java │ │ │ │ │ └── UniversityAdapter.java │ │ │ │ └── dialogs │ │ │ │ │ ├── AddUniversityDialog.java │ │ │ │ │ └── AddStudentDialog.java │ │ │ │ ├── app │ │ │ │ └── SimpleRealmApp.java │ │ │ │ └── model │ │ │ │ ├── University.java │ │ │ │ └── Student.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── cook │ │ │ └── simplerealmandroid │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── cook │ │ └── simplerealmandroid │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | *.iml 3 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app/src/main/assets/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MLSDev/example-realm-android/HEAD/app/src/main/assets/1.png -------------------------------------------------------------------------------- /app/src/main/assets/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MLSDev/example-realm-android/HEAD/app/src/main/assets/2.png -------------------------------------------------------------------------------- /app/src/main/assets/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MLSDev/example-realm-android/HEAD/app/src/main/assets/3.png -------------------------------------------------------------------------------- /app/src/main/assets/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MLSDev/example-realm-android/HEAD/app/src/main/assets/4.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MLSDev/example-realm-android/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/assets/mlsdev-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MLSDev/example-realm-android/HEAD/app/src/main/assets/mlsdev-logo.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | *.iml 9 | .idea -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MLSDev/example-realm-android/HEAD/app/src/main/res/mipmap-xxhdpi/ic_plus.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MLSDev/example-realm-android/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MLSDev/example-realm-android/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MLSDev/example-realm-android/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MLSDev/example-realm-android/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MLSDev/example-realm-android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/java/com/cook/simplerealmandroid/realm/repository/IBaseRepository.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid.realm.repository; 2 | 3 | /** 4 | * Created by roma on 16.10.15. 5 | */ 6 | public interface IBaseRepository { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Oct 13 16:22:59 EEST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/cook/simplerealmandroid/presenters/IBasePresenter.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid.presenters; 2 | 3 | /** 4 | * Created by roma on 03.11.15. 5 | */ 6 | public interface IBasePresenter { 7 | void subscribeCallbacks(); 8 | void unSubscribeCallbacks(); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/test/java/com/cook/simplerealmandroid/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/main/java/com/cook/simplerealmandroid/realm/module/SimpleRealmModule.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid.realm.module; 2 | 3 | import com.cook.simplerealmandroid.model.Student; 4 | import com.cook.simplerealmandroid.model.University; 5 | 6 | import io.realm.annotations.RealmModule; 7 | 8 | /** 9 | * Created by roma on 15.10.15. 10 | */ 11 | @RealmModule(classes = {Student.class, University.class}) 12 | public class SimpleRealmModule { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/cook/simplerealmandroid/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid; 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 | } -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFF 4 | #00BCD4 5 | #0097A7 6 | #FFEB3B 7 | #212121 8 | 9 | #FFEB3B 10 | #8f852c 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/cook/simplerealmandroid/tools/DateFormatter.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid.tools; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | /** 7 | * Created by roma on 04.11.15. 8 | */ 9 | public class DateFormatter { 10 | 11 | private static String DATE_PATTERN = "dd/MM/yyyy"; 12 | 13 | public static String convertDateToString(Date date){ 14 | return new SimpleDateFormat(DATE_PATTERN).format(date); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/cook/simplerealmandroid/presenters/IUniversityPresenter.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid.presenters; 2 | 3 | /** 4 | * Created by roma on 19.10.15. 5 | */ 6 | public interface IUniversityPresenter extends IBasePresenter { 7 | 8 | void addUniversity(String universityName); 9 | 10 | void deleteUniversity(int position); 11 | 12 | void deleteUniversityById(String Id); 13 | 14 | void getUniversityById(String id); 15 | 16 | void getAllUniversities(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/cook/simplerealmandroid/view/activity/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid.view.activity.base; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.widget.Toast; 5 | 6 | /** 7 | * Created by roma on 16.10.15. 8 | */ 9 | public abstract class BaseActivity extends AppCompatActivity { 10 | 11 | abstract protected void initComponents(); 12 | 13 | public void showMessage(String message){ 14 | Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/cook/simplerealmandroid/realm/table/RealmTable.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid.realm.table; 2 | 3 | /** 4 | * Created by roma on 16.10.15. 5 | */ 6 | public interface RealmTable { 7 | 8 | String ID = "id"; 9 | 10 | interface University { 11 | String STUDENTS = "students"; 12 | String NAME = "name"; 13 | } 14 | 15 | interface Student{ 16 | String NAME = "name"; 17 | String AGE = "age"; 18 | String EMAIL = "email"; 19 | String BOOKS = "books"; 20 | String LESSONS = "lessons"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_students.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_universities.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | -------------------------------------------------------------------------------- /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 /home/romakukhar/Tools/Android/Sdk/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 | -------------------------------------------------------------------------------- /app/src/main/java/com/cook/simplerealmandroid/presenters/IStudentPresenter.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid.presenters; 2 | 3 | import com.cook.simplerealmandroid.model.Student; 4 | 5 | /** 6 | * Created by roma on 03.11.15. 7 | */ 8 | public interface IStudentPresenter extends IBasePresenter{ 9 | 10 | void addStudent(Student student); 11 | 12 | void addStudentByUniversityId(Student student, String universityId); 13 | 14 | void deleteStudentByPosition(int position); 15 | 16 | void deleteStudentById(String studentId); 17 | 18 | void getAllStudents(); 19 | 20 | void getAllStudentsByUniversityId(String id); 21 | 22 | void getStudentById(String id); 23 | 24 | void getUniversityById(String id); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/cook/simplerealmandroid/app/SimpleRealmApp.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid.app; 2 | 3 | import android.app.Application; 4 | 5 | import com.cook.simplerealmandroid.realm.module.SimpleRealmModule; 6 | 7 | import io.realm.Realm; 8 | import io.realm.RealmConfiguration; 9 | 10 | /** 11 | * Created by roma on 15.10.15. 12 | */ 13 | public class SimpleRealmApp extends Application { 14 | 15 | private static SimpleRealmApp instance; 16 | 17 | @Override 18 | public void onCreate() { 19 | super.onCreate(); 20 | instance = this; 21 | RealmConfiguration config = new RealmConfiguration.Builder(getApplicationContext()).setModules(new SimpleRealmModule()).build(); 22 | Realm.setDefaultConfiguration(config); 23 | } 24 | 25 | public static SimpleRealmApp getInstance() { 26 | return instance; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_students.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 18 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_item_university.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 12 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 14 | 15 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 16 | 17 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/cook/simplerealmandroid/model/University.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid.model; 2 | 3 | 4 | import io.realm.RealmList; 5 | import io.realm.RealmObject; 6 | import io.realm.annotations.PrimaryKey; 7 | 8 | /** 9 | * Created by roma on 14.10.15. 10 | */ 11 | public class University extends RealmObject { 12 | 13 | @PrimaryKey 14 | private String id; 15 | private String name; 16 | private RealmList students; 17 | 18 | public University() { 19 | } 20 | 21 | public University(String name) { 22 | this.name = name; 23 | } 24 | 25 | public String getId() { 26 | return id; 27 | } 28 | 29 | public void setId(String id) { 30 | this.id = id; 31 | } 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | 41 | public RealmList getStudents() { 42 | return students; 43 | } 44 | 45 | public void setStudents(RealmList students) { 46 | this.students = students; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.1" 6 | 7 | defaultConfig { 8 | applicationId "com.cook.simplerealmandroid" 9 | minSdkVersion 16 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.1.0' 26 | // Recycler View 27 | compile 'com.android.support:recyclerview-v7:23.1.0' 28 | // Card View 29 | compile 'com.android.support:cardview-v7:23.1.0' 30 | // Support Design 31 | compile 'com.android.support:design:23.1.0' 32 | // Realm 33 | compile 'io.realm:realm-android:0.83.0' 34 | 35 | // material datePicker 36 | compile 'com.wdullaer:materialdatetimepicker:1.3.1' 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/cook/simplerealmandroid/model/Student.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid.model; 2 | 3 | import java.util.Date; 4 | 5 | import io.realm.RealmObject; 6 | import io.realm.annotations.PrimaryKey; 7 | import io.realm.annotations.Required; 8 | 9 | /** 10 | * Created by roma on 14.10.15. 11 | */ 12 | public class Student extends RealmObject { 13 | 14 | @PrimaryKey 15 | private String id; 16 | @Required 17 | private String name; 18 | @Required 19 | private Date birthday; 20 | @Required 21 | private String email; 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | 31 | public Date getBirthday() { 32 | return birthday; 33 | } 34 | 35 | public void setBirthday(Date birthday) { 36 | this.birthday = birthday; 37 | } 38 | 39 | public String getId() { 40 | return id; 41 | } 42 | 43 | public void setId(String id) { 44 | this.id = id; 45 | } 46 | 47 | public String getEmail() { 48 | return email; 49 | } 50 | 51 | public void setEmail(String email) { 52 | this.email = email; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SimpleRealmAndroid 3 | Settings 4 | Add University 5 | Add Student 6 | Add Book 7 | 8 | 9 | Add University 10 | Universitie\'s name 11 | name 12 | 13 | 14 | 15 | Add Student 16 | Birthday : 17 | Email : 18 | 19 | 20 | Name 21 | Email 22 | Birthday 23 | Add 24 | 25 | 26 | Okь 27 | Cancel 28 | 29 | 30 | Universities 31 | Students 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/cook/simplerealmandroid/realm/repository/IUniversityRepository.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid.realm.repository; 2 | 3 | import com.cook.simplerealmandroid.model.University; 4 | 5 | import io.realm.RealmResults; 6 | 7 | /** 8 | * Created by roma on 16.10.15. 9 | */ 10 | public interface IUniversityRepository extends IBaseRepository { 11 | 12 | interface OnAddUniversityCallback { 13 | void onSuccess(); 14 | void onError(String message); 15 | } 16 | 17 | interface OnGetAllUniversityCallback { 18 | void onSuccess(RealmResults universities); 19 | void onError(String message); 20 | } 21 | 22 | interface OnGetUniversityByIdCallback { 23 | void onSuccess(University university); 24 | void onError(String message); 25 | } 26 | 27 | interface OnDeleteUniversityCallback { 28 | void onSuccess(); 29 | void onError(String message); 30 | } 31 | 32 | void addUniversity(University university, OnAddUniversityCallback callback); 33 | 34 | void deleteUniversityById(String Id, OnDeleteUniversityCallback callback); 35 | 36 | void deleteUniversityByPosition(int position, OnDeleteUniversityCallback callback); 37 | 38 | void getAllUniversities(OnGetAllUniversityCallback callback); 39 | 40 | void getUniversityById(String id, OnGetUniversityByIdCallback callback); 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_universities.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/cook/simplerealmandroid/realm/repository/IStudentRepository.java: -------------------------------------------------------------------------------- 1 | package com.cook.simplerealmandroid.realm.repository; 2 | 3 | import com.cook.simplerealmandroid.model.Student; 4 | 5 | import io.realm.RealmList; 6 | import io.realm.RealmResults; 7 | 8 | /** 9 | * Created by roma on 16.10.15. 10 | */ 11 | public interface IStudentRepository { 12 | 13 | interface OnSaveStudentCallback { 14 | void onSuccess(); 15 | void onError(String message); 16 | } 17 | 18 | interface OnDeleteStudentCallback { 19 | void onSuccess(); 20 | void onError(String message); 21 | } 22 | 23 | interface OnGetStudentByIdCallback { 24 | void onSuccess(Student student); 25 | void onError(String message); 26 | } 27 | 28 | interface OnGetAllStudentsCallback { 29 | void onSuccess(RealmResults students); 30 | void onError(String message); 31 | } 32 | 33 | interface OnGetStudentsCallback{ 34 | void onSuccess(RealmList students); 35 | void onError(String message); 36 | } 37 | 38 | void addStudent(Student student, OnSaveStudentCallback callback); 39 | 40 | void addStudentByUniversityId(Student student, String universityId, OnSaveStudentCallback callback); 41 | 42 | void deleteStudentById(String id, OnDeleteStudentCallback callback); 43 | 44 | void deleteStudentByPosition(int position, OnDeleteStudentCallback callback); 45 | 46 | void getAllStudents(OnGetAllStudentsCallback callback); 47 | 48 | void getAllStudentsByUniversityId(String id, OnGetStudentsCallback callback); 49 | 50 | void getStudentById(String id, OnGetStudentByIdCallback callback); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dialog_add_university.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 18 | 19 | 30 | 31 |