├── .gitignore
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── mindorks
│ │ └── framework
│ │ └── mvp
│ │ ├── TestComponentRule.java
│ │ ├── di
│ │ ├── component
│ │ │ └── TestComponent.java
│ │ └── module
│ │ │ └── ApplicationTestModule.java
│ │ └── ui
│ │ └── login
│ │ └── LoginActivityTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ ├── fonts
│ │ │ └── source-sans-pro
│ │ │ │ ├── SourceSansPro-Bold.ttf
│ │ │ │ ├── SourceSansPro-Italic.ttf
│ │ │ │ ├── SourceSansPro-Light.ttf
│ │ │ │ └── SourceSansPro-Regular.ttf
│ │ └── seed
│ │ │ ├── options.json
│ │ │ └── questions.json
│ ├── java
│ │ └── com
│ │ │ └── mindorks
│ │ │ └── framework
│ │ │ └── mvp
│ │ │ ├── MvpApp.java
│ │ │ ├── data
│ │ │ ├── db
│ │ │ │ ├── DbOpenHelper.java
│ │ │ │ ├── model
│ │ │ │ │ ├── Option.java
│ │ │ │ │ ├── Question.java
│ │ │ │ │ └── User.java
│ │ │ │ └── repository
│ │ │ │ │ ├── OptionRepository.java
│ │ │ │ │ ├── QuestionRepository.java
│ │ │ │ │ └── UserRepository.java
│ │ │ ├── network
│ │ │ │ ├── ApiEndPoint.java
│ │ │ │ ├── ApiHeader.java
│ │ │ │ ├── ApiHelper.java
│ │ │ │ ├── AppApiHelper.java
│ │ │ │ └── model
│ │ │ │ │ ├── ApiError.java
│ │ │ │ │ ├── BlogResponse.java
│ │ │ │ │ ├── LoginRequest.java
│ │ │ │ │ ├── LoginResponse.java
│ │ │ │ │ ├── LogoutResponse.java
│ │ │ │ │ └── OpenSourceResponse.java
│ │ │ └── prefs
│ │ │ │ ├── AppPreferencesHelper.java
│ │ │ │ └── PreferencesHelper.java
│ │ │ ├── di
│ │ │ ├── ActivityContext.java
│ │ │ ├── ApiInfo.java
│ │ │ ├── ApplicationContext.java
│ │ │ ├── DatabaseInfo.java
│ │ │ ├── PerActivity.java
│ │ │ ├── PerService.java
│ │ │ ├── PreferenceInfo.java
│ │ │ ├── component
│ │ │ │ ├── ActivityComponent.java
│ │ │ │ ├── ApplicationComponent.java
│ │ │ │ └── ServiceComponent.java
│ │ │ └── module
│ │ │ │ ├── ActivityModule.java
│ │ │ │ ├── ApplicationModule.java
│ │ │ │ └── ServiceModule.java
│ │ │ ├── service
│ │ │ ├── SyncInteractor.java
│ │ │ ├── SyncMvpInteractor.java
│ │ │ └── SyncService.java
│ │ │ ├── ui
│ │ │ ├── about
│ │ │ │ ├── AboutFragment.java
│ │ │ │ ├── AboutInteractor.java
│ │ │ │ ├── AboutMvpInteractor.java
│ │ │ │ ├── AboutMvpPresenter.java
│ │ │ │ ├── AboutMvpView.java
│ │ │ │ └── AboutPresenter.java
│ │ │ ├── base
│ │ │ │ ├── BaseActivity.java
│ │ │ │ ├── BaseDialog.java
│ │ │ │ ├── BaseFragment.java
│ │ │ │ ├── BaseInteractor.java
│ │ │ │ ├── BasePresenter.java
│ │ │ │ ├── BaseSubView.java
│ │ │ │ ├── BaseViewHolder.java
│ │ │ │ ├── DialogMvpView.java
│ │ │ │ ├── MvpInteractor.java
│ │ │ │ ├── MvpPresenter.java
│ │ │ │ ├── MvpView.java
│ │ │ │ └── SubMvpView.java
│ │ │ ├── custom
│ │ │ │ └── RoundedImageView.java
│ │ │ ├── feed
│ │ │ │ ├── FeedActivity.java
│ │ │ │ ├── FeedInteractor.java
│ │ │ │ ├── FeedMvpInteractor.java
│ │ │ │ ├── FeedMvpPresenter.java
│ │ │ │ ├── FeedMvpView.java
│ │ │ │ ├── FeedPagerAdapter.java
│ │ │ │ ├── FeedPresenter.java
│ │ │ │ ├── blogs
│ │ │ │ │ ├── BlogAdapter.java
│ │ │ │ │ ├── BlogFragment.java
│ │ │ │ │ ├── BlogInteractor.java
│ │ │ │ │ ├── BlogMvpInteractor.java
│ │ │ │ │ ├── BlogMvpPresenter.java
│ │ │ │ │ ├── BlogMvpView.java
│ │ │ │ │ └── BlogPresenter.java
│ │ │ │ └── opensource
│ │ │ │ │ ├── OpenSourceAdapter.java
│ │ │ │ │ ├── OpenSourceFragment.java
│ │ │ │ │ ├── OpenSourceInteractor.java
│ │ │ │ │ ├── OpenSourceMvpInteractor.java
│ │ │ │ │ ├── OpenSourceMvpPresenter.java
│ │ │ │ │ ├── OpenSourceMvpView.java
│ │ │ │ │ └── OpenSourcePresenter.java
│ │ │ ├── login
│ │ │ │ ├── LoginActivity.java
│ │ │ │ ├── LoginInteractor.java
│ │ │ │ ├── LoginMvpInteractor.java
│ │ │ │ ├── LoginMvpPresenter.java
│ │ │ │ ├── LoginMvpView.java
│ │ │ │ └── LoginPresenter.java
│ │ │ ├── main
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── MainInteractor.java
│ │ │ │ ├── MainMvpInteractor.java
│ │ │ │ ├── MainMvpPresenter.java
│ │ │ │ ├── MainMvpView.java
│ │ │ │ ├── MainPresenter.java
│ │ │ │ ├── QuestionCard.java
│ │ │ │ └── rating
│ │ │ │ │ ├── RateUsDialog.java
│ │ │ │ │ ├── RatingDialogInteractor.java
│ │ │ │ │ ├── RatingDialogMvpInteractor.java
│ │ │ │ │ ├── RatingDialogMvpPresenter.java
│ │ │ │ │ ├── RatingDialogMvpView.java
│ │ │ │ │ └── RatingDialogPresenter.java
│ │ │ └── splash
│ │ │ │ ├── SplashActivity.java
│ │ │ │ ├── SplashInteractor.java
│ │ │ │ ├── SplashMvpInteractor.java
│ │ │ │ ├── SplashMvpPresenter.java
│ │ │ │ ├── SplashMvpView.java
│ │ │ │ └── SplashPresenter.java
│ │ │ └── utils
│ │ │ ├── AppConstants.java
│ │ │ ├── AppLogger.java
│ │ │ ├── AppUtils.java
│ │ │ ├── CommonUtils.java
│ │ │ ├── FileUtils.java
│ │ │ ├── KeyboardUtils.java
│ │ │ ├── NetworkUtils.java
│ │ │ ├── ScreenUtils.java
│ │ │ ├── ViewUtils.java
│ │ │ └── rx
│ │ │ ├── AppSchedulerProvider.java
│ │ │ └── SchedulerProvider.java
│ └── res
│ │ ├── anim
│ │ ├── fade_in.xml
│ │ ├── fade_out.xml
│ │ ├── slide_left.xml
│ │ └── slide_right.xml
│ │ ├── drawable-v21
│ │ ├── button_bg.xml
│ │ ├── button_primary_bg.xml
│ │ └── button_secondary_bg.xml
│ │ ├── drawable
│ │ ├── avd_copy.xml
│ │ ├── avd_cut.xml
│ │ ├── avd_delete.xml
│ │ ├── avd_share.xml
│ │ ├── bg_design.xml
│ │ ├── border_dark_color.xml
│ │ ├── bottom_border_shadow.xml
│ │ ├── button_bg.xml
│ │ ├── button_negative_text_drawable.xml
│ │ ├── button_positive_text_drawable.xml
│ │ ├── button_primary_bg.xml
│ │ ├── button_secondary_bg.xml
│ │ ├── corner_border_gray.xml
│ │ ├── corner_border_rect_gray.xml
│ │ ├── ic_add_white_24px.xml
│ │ ├── ic_arrow_back_white_24px.xml
│ │ ├── ic_copy_white_24dp.xml
│ │ ├── ic_cut_white_24dp.xml
│ │ ├── ic_delete_white_24dp.xml
│ │ ├── ic_facebook.xml
│ │ ├── ic_google_plus.xml
│ │ ├── ic_info_24px.xml
│ │ ├── ic_keyboard_backspace_24px.xml
│ │ ├── ic_mindorks_logo.png
│ │ ├── ic_power_settings_new_24px.xml
│ │ ├── ic_rabbit.xml
│ │ ├── ic_rss_symbol.xml
│ │ ├── ic_share_white_24px.xml
│ │ ├── ic_star.xml
│ │ ├── input_border_bottom.xml
│ │ └── picture_frame_profile.xml
│ │ ├── layout
│ │ ├── activity_feed.xml
│ │ ├── activity_login.xml
│ │ ├── activity_main.xml
│ │ ├── activity_splash.xml
│ │ ├── card_layout.xml
│ │ ├── dialog_rate_us.xml
│ │ ├── drawer_header.xml
│ │ ├── fragment_about.xml
│ │ ├── fragment_blog.xml
│ │ ├── fragment_open_source.xml
│ │ ├── item_blog_view.xml
│ │ ├── item_empty_view.xml
│ │ ├── item_repo_view.xml
│ │ └── progress_dialog.xml
│ │ ├── menu
│ │ ├── drawer.xml
│ │ └── main.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
│ └── mindorks
│ └── framework
│ └── mvp
│ ├── ui
│ └── login
│ │ └── LoginPresenterTest.java
│ └── utils
│ └── rx
│ └── TestSchedulerProvider.java
├── build.gradle
├── config
└── quality
│ ├── checkstyle
│ └── checkstyle-config.xml
│ ├── findbugs
│ └── android-exclude-filter.xml
│ ├── pmd
│ └── pmd-ruleset.xml
│ └── quality.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | /projectFilesBackup
10 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/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/janisharali/Library/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/androidTest/java/com/mindorks/framework/mvp/TestComponentRule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * https://mindorks.com/license/apache-v2
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License
14 | */
15 |
16 | package com.mindorks.framework.mvp;
17 |
18 | import android.content.Context;
19 |
20 | import com.mindorks.framework.mvp.di.component.DaggerTestComponent;
21 | import com.mindorks.framework.mvp.di.component.TestComponent;
22 | import com.mindorks.framework.mvp.di.module.ApplicationTestModule;
23 |
24 | import org.junit.rules.TestRule;
25 | import org.junit.runner.Description;
26 | import org.junit.runners.model.Statement;
27 |
28 | /**
29 | * Created by janisharali on 21/07/17.
30 | */
31 |
32 | public class TestComponentRule implements TestRule {
33 |
34 | private TestComponent mTestComponent;
35 | private Context mContext;
36 |
37 | public TestComponentRule(Context context) {
38 | mContext = context;
39 | }
40 |
41 | public Context getContext() {
42 | return mContext;
43 | }
44 |
45 | private void setupDaggerTestComponentInApplication() {
46 | MvpApp application = ((MvpApp) mContext.getApplicationContext());
47 | mTestComponent = DaggerTestComponent.builder()
48 | .applicationTestModule(new ApplicationTestModule(application))
49 | .build();
50 | application.setComponent(mTestComponent);
51 | }
52 |
53 | @Override
54 | public Statement apply(final Statement base, Description description) {
55 | return new Statement() {
56 | @Override
57 | public void evaluate() throws Throwable {
58 | try {
59 | setupDaggerTestComponentInApplication();
60 | base.evaluate();
61 | } finally {
62 | mTestComponent = null;
63 | }
64 | }
65 | };
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/mindorks/framework/mvp/di/component/TestComponent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * https://mindorks.com/license/apache-v2
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License
14 | */
15 |
16 | package com.mindorks.framework.mvp.di.component;
17 |
18 | import com.mindorks.framework.mvp.di.module.ApplicationTestModule;
19 |
20 | import javax.inject.Singleton;
21 |
22 | import dagger.Component;
23 |
24 | /**
25 | * Created by janisharali on 21/07/17.
26 | */
27 | @Singleton
28 | @Component(modules = ApplicationTestModule.class)
29 | public interface TestComponent extends ApplicationComponent {
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
15 |
16 |
18 |
19 |
20 |
21 |
28 |
29 |
30 |
31 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
46 |
47 |
51 |
52 |
57 |
58 |
59 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/source-sans-pro/SourceSansPro-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/janishar/android-mvp-interactor-architecture/72cad6028a757c666daa224bbfef40a8fb4c0bee/app/src/main/assets/fonts/source-sans-pro/SourceSansPro-Bold.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/source-sans-pro/SourceSansPro-Italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/janishar/android-mvp-interactor-architecture/72cad6028a757c666daa224bbfef40a8fb4c0bee/app/src/main/assets/fonts/source-sans-pro/SourceSansPro-Italic.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/source-sans-pro/SourceSansPro-Light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/janishar/android-mvp-interactor-architecture/72cad6028a757c666daa224bbfef40a8fb4c0bee/app/src/main/assets/fonts/source-sans-pro/SourceSansPro-Light.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/source-sans-pro/SourceSansPro-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/janishar/android-mvp-interactor-architecture/72cad6028a757c666daa224bbfef40a8fb4c0bee/app/src/main/assets/fonts/source-sans-pro/SourceSansPro-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/seed/options.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "option_text": "MVVM",
4 | "question_id": 1,
5 | "is_correct": false
6 | },
7 | {
8 | "option_text": "MVP",
9 | "question_id": 1,
10 | "is_correct": true
11 | },
12 | {
13 | "option_text": "MVC",
14 | "question_id": 1,
15 | "is_correct": false
16 | },
17 | {
18 | "option_text": "Data Manager",
19 | "question_id": 2,
20 | "is_correct": true
21 | },
22 | {
23 | "option_text": "View",
24 | "question_id": 2,
25 | "is_correct": false
26 | },
27 | {
28 | "option_text": "Presenter",
29 | "question_id": 2,
30 | "is_correct": false
31 | },
32 | {
33 | "option_text": "Yes",
34 | "question_id": 3,
35 | "is_correct": false
36 | },
37 | {
38 | "option_text": "Never",
39 | "question_id": 3,
40 | "is_correct": true
41 | },
42 | {
43 | "option_text": "Sometimes",
44 | "question_id": 3,
45 | "is_correct": false
46 | },
47 | {
48 | "option_text": "It fetches the data from the database.",
49 | "question_id": 4,
50 | "is_correct": false
51 | },
52 | {
53 | "option_text": "It delegates View's requirements to Data Manager.",
54 | "question_id": 4,
55 | "is_correct": true
56 | },
57 | {
58 | "option_text": "It instructs the View to perform actions.",
59 | "question_id": 4,
60 | "is_correct": true
61 | },
62 | {
63 | "option_text": "It created a readable code.",
64 | "question_id": 5,
65 | "is_correct": true
66 | },
67 | {
68 | "option_text": "It is highly testable.",
69 | "question_id": 5,
70 | "is_correct": true
71 | },
72 | {
73 | "option_text": "It provides reusable code.",
74 | "question_id": 5,
75 | "is_correct": true
76 | },
77 | {
78 | "option_text": "Linus Torvalds",
79 | "question_id": 6,
80 | "is_correct": true
81 | },
82 | {
83 | "option_text": "Janishar Ali",
84 | "question_id": 6,
85 | "is_correct": false
86 | },
87 | {
88 | "option_text": "Amit Shekhar",
89 | "question_id": 6,
90 | "is_correct": false
91 | },
92 | {
93 | "option_text": "None",
94 | "question_id": 7,
95 | "is_correct": false
96 | },
97 | {
98 | "option_text": "Mindorks",
99 | "question_id": 7,
100 | "is_correct": true
101 | },
102 | {
103 | "option_text": "Google",
104 | "question_id": 7,
105 | "is_correct": false
106 | }
107 | ]
--------------------------------------------------------------------------------
/app/src/main/assets/seed/questions.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": 1,
4 | "question_text": "What is the architecture of this app?",
5 | "question_img_url": null
6 | },
7 | {
8 | "id": 2,
9 | "question_text": "Which component of the MVP controls the data flow?",
10 | "question_img_url": null
11 | },
12 | {
13 | "id": 3,
14 | "question_text": "Can a View ask for data from a Data Manager?",
15 | "question_img_url": null
16 | },
17 | {
18 | "id": 4,
19 | "question_text": "What is the role of a Presenter?",
20 | "question_img_url": null
21 | },
22 | {
23 | "id": 5,
24 | "question_text": "Why should we follow MVP?",
25 | "question_img_url": null
26 | },
27 | {
28 | "id": 6,
29 | "question_text": "Who is this person?",
30 | "question_img_url": "https://avatars3.githubusercontent.com/u/1024025"
31 | },
32 | {
33 | "id": 7,
34 | "question_text": "Which company's logo is this?",
35 | "question_img_url": "https://janishar.github.io/images/mindorks-logo-small.png"
36 | }
37 | ]
--------------------------------------------------------------------------------
/app/src/main/java/com/mindorks/framework/mvp/MvpApp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * https://mindorks.com/license/apache-v2
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License
14 | */
15 |
16 | package com.mindorks.framework.mvp;
17 |
18 | import android.app.Application;
19 |
20 | import com.androidnetworking.AndroidNetworking;
21 | import com.androidnetworking.interceptors.HttpLoggingInterceptor.Level;
22 | import com.mindorks.framework.mvp.di.component.ApplicationComponent;
23 | import com.mindorks.framework.mvp.di.component.DaggerApplicationComponent;
24 | import com.mindorks.framework.mvp.di.module.ApplicationModule;
25 | import com.mindorks.framework.mvp.utils.AppLogger;
26 |
27 | import javax.inject.Inject;
28 |
29 | import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
30 |
31 |
32 | /**
33 | * Created by janisharali on 27/01/17.
34 | */
35 |
36 | public class MvpApp extends Application {
37 |
38 | @Inject
39 | CalligraphyConfig mCalligraphyConfig;
40 |
41 | private ApplicationComponent mApplicationComponent;
42 |
43 | @Override
44 | public void onCreate() {
45 | super.onCreate();
46 |
47 | mApplicationComponent = DaggerApplicationComponent.builder()
48 | .applicationModule(new ApplicationModule(this)).build();
49 |
50 | mApplicationComponent.inject(this);
51 |
52 | AppLogger.init();
53 |
54 | AndroidNetworking.initialize(getApplicationContext());
55 | if (BuildConfig.DEBUG) {
56 | AndroidNetworking.enableLogging(Level.BODY);
57 | }
58 |
59 | CalligraphyConfig.initDefault(mCalligraphyConfig);
60 | }
61 |
62 | public ApplicationComponent getComponent() {
63 | return mApplicationComponent;
64 | }
65 |
66 |
67 | // Needed to replace the component with a test specific one
68 | public void setComponent(ApplicationComponent applicationComponent) {
69 | mApplicationComponent = applicationComponent;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mindorks/framework/mvp/data/db/DbOpenHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * https://mindorks.com/license/apache-v2
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License
14 | */
15 |
16 | package com.mindorks.framework.mvp.data.db;
17 |
18 | import android.content.Context;
19 |
20 | import com.mindorks.framework.mvp.data.db.model.DaoMaster;
21 | import com.mindorks.framework.mvp.di.ApplicationContext;
22 | import com.mindorks.framework.mvp.di.DatabaseInfo;
23 | import com.mindorks.framework.mvp.utils.AppLogger;
24 |
25 | import org.greenrobot.greendao.database.Database;
26 |
27 | import javax.inject.Inject;
28 | import javax.inject.Singleton;
29 |
30 | /**
31 | * Created by janisharali on 08/12/16.
32 | */
33 |
34 | @Singleton
35 | public class DbOpenHelper extends DaoMaster.OpenHelper {
36 |
37 | @Inject
38 | public DbOpenHelper(@ApplicationContext Context context, @DatabaseInfo String name) {
39 | super(context, name);
40 | }
41 |
42 | @Override
43 | public void onUpgrade(Database db, int oldVersion, int newVersion) {
44 | super.onUpgrade(db, oldVersion, newVersion);
45 | AppLogger.d("DEBUG", "DB_OLD_VERSION : " + oldVersion + ", DB_NEW_VERSION : " + newVersion);
46 | switch (oldVersion) {
47 | case 1:
48 | case 2:
49 | //db.execSQL("ALTER TABLE " + UserDao.TABLENAME + " ADD COLUMN "
50 | // + UserDao.Properties.Name.columnName + " TEXT DEFAULT 'DEFAULT_VAL'");
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mindorks/framework/mvp/data/db/model/User.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * https://mindorks.com/license/apache-v2
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License
14 | */
15 |
16 | package com.mindorks.framework.mvp.data.db.model;
17 |
18 | import org.greenrobot.greendao.annotation.Entity;
19 | import org.greenrobot.greendao.annotation.Generated;
20 | import org.greenrobot.greendao.annotation.Id;
21 | import org.greenrobot.greendao.annotation.Property;
22 |
23 | /**
24 | * Created by janisharali on 08/12/16.
25 | */
26 |
27 | @Entity(nameInDb = "user")
28 | public class User {
29 |
30 | @Id(autoincrement = true)
31 | private Long id;
32 |
33 | @Property(nameInDb = "name")
34 | private String name;
35 |
36 | @Property(nameInDb = "created_at")
37 | private String createdAt;
38 |
39 | @Property(nameInDb = "updated_at")
40 | private String updatedAt;
41 |
42 |
43 | @Generated(hash = 1543916479)
44 | public User(Long id, String name, String createdAt, String updatedAt) {
45 | this.id = id;
46 | this.name = name;
47 | this.createdAt = createdAt;
48 | this.updatedAt = updatedAt;
49 | }
50 |
51 | @Generated(hash = 586692638)
52 | public User() {
53 | }
54 |
55 |
56 | public Long getId() {
57 | return this.id;
58 | }
59 |
60 | public void setId(Long id) {
61 | this.id = id;
62 | }
63 |
64 | public String getName() {
65 | return this.name;
66 | }
67 |
68 | public void setName(String name) {
69 | this.name = name;
70 | }
71 |
72 | public String getCreatedAt() {
73 | return this.createdAt;
74 | }
75 |
76 | public void setCreatedAt(String createdAt) {
77 | this.createdAt = createdAt;
78 | }
79 |
80 | public String getUpdatedAt() {
81 | return this.updatedAt;
82 | }
83 |
84 | public void setUpdatedAt(String updatedAt) {
85 | this.updatedAt = updatedAt;
86 | }
87 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mindorks/framework/mvp/data/db/repository/OptionRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * https://mindorks.com/license/apache-v2
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License
14 | */
15 |
16 | package com.mindorks.framework.mvp.data.db.repository;
17 |
18 | import com.mindorks.framework.mvp.data.db.model.DaoSession;
19 | import com.mindorks.framework.mvp.data.db.model.Option;
20 |
21 | import java.util.List;
22 | import java.util.concurrent.Callable;
23 |
24 | import javax.inject.Inject;
25 |
26 | import io.reactivex.Observable;
27 |
28 | /**
29 | * Created by janisharali on 20/07/17.
30 | */
31 |
32 | public class OptionRepository {
33 |
34 | private final DaoSession mDaoSession;
35 |
36 | @Inject
37 | public OptionRepository(DaoSession daoSession) {
38 | mDaoSession = daoSession;
39 | }
40 |
41 | public Observable isOptionEmpty() {
42 | return Observable.fromCallable(new Callable() {
43 | @Override
44 | public Boolean call() throws Exception {
45 | return !(mDaoSession.getOptionDao().count() > 0);
46 | }
47 | });
48 | }
49 |
50 | public Observable saveOption(final Option option) {
51 | return Observable.fromCallable(new Callable() {
52 | @Override
53 | public Boolean call() throws Exception {
54 | mDaoSession.getOptionDao().insertInTx(option);
55 | return true;
56 | }
57 | });
58 | }
59 |
60 | public Observable saveOptionList(final List