├── .gitignore ├── CONTRIBUTING.md ├── 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 │ │ │ ├── AppDataManager.java │ │ │ ├── DataManager.java │ │ │ ├── db │ │ │ │ ├── AppDbHelper.java │ │ │ │ ├── DbHelper.java │ │ │ │ ├── DbOpenHelper.java │ │ │ │ └── model │ │ │ │ │ ├── Option.java │ │ │ │ │ ├── Question.java │ │ │ │ │ └── User.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 │ │ │ └── SyncService.java │ │ │ ├── ui │ │ │ ├── about │ │ │ │ ├── AboutFragment.java │ │ │ │ ├── AboutMvpPresenter.java │ │ │ │ ├── AboutMvpView.java │ │ │ │ └── AboutPresenter.java │ │ │ ├── base │ │ │ │ ├── BaseActivity.java │ │ │ │ ├── BaseDialog.java │ │ │ │ ├── BaseFragment.java │ │ │ │ ├── BasePresenter.java │ │ │ │ ├── BaseSubView.java │ │ │ │ ├── BaseViewHolder.java │ │ │ │ ├── DialogMvpView.java │ │ │ │ ├── MvpPresenter.java │ │ │ │ ├── MvpView.java │ │ │ │ └── SubMvpView.java │ │ │ ├── custom │ │ │ │ └── RoundedImageView.java │ │ │ ├── feed │ │ │ │ ├── FeedActivity.java │ │ │ │ ├── FeedMvpPresenter.java │ │ │ │ ├── FeedMvpView.java │ │ │ │ ├── FeedPagerAdapter.java │ │ │ │ ├── FeedPresenter.java │ │ │ │ ├── blogs │ │ │ │ │ ├── BlogAdapter.java │ │ │ │ │ ├── BlogFragment.java │ │ │ │ │ ├── BlogMvpPresenter.java │ │ │ │ │ ├── BlogMvpView.java │ │ │ │ │ └── BlogPresenter.java │ │ │ │ └── opensource │ │ │ │ │ ├── OpenSourceAdapter.java │ │ │ │ │ ├── OpenSourceFragment.java │ │ │ │ │ ├── OpenSourceMvpPresenter.java │ │ │ │ │ ├── OpenSourceMvpView.java │ │ │ │ │ └── OpenSourcePresenter.java │ │ │ ├── login │ │ │ │ ├── LoginActivity.java │ │ │ │ ├── LoginMvpPresenter.java │ │ │ │ ├── LoginMvpView.java │ │ │ │ └── LoginPresenter.java │ │ │ ├── main │ │ │ │ ├── MainActivity.java │ │ │ │ ├── MainMvpPresenter.java │ │ │ │ ├── MainMvpView.java │ │ │ │ ├── MainPresenter.java │ │ │ │ ├── QuestionCard.java │ │ │ │ └── rating │ │ │ │ │ ├── RateUsDialog.java │ │ │ │ │ ├── RatingDialogMvpPresenter.java │ │ │ │ │ ├── RatingDialogMvpView.java │ │ │ │ │ └── RatingDialogPresenter.java │ │ │ └── splash │ │ │ │ ├── SplashActivity.java │ │ │ │ ├── SplashMvpPresenter.java │ │ │ │ ├── SplashMvpView.java │ │ │ │ └── SplashPresenter.java │ │ │ └── utils │ │ │ ├── AppConstants.java │ │ │ ├── AppLogger.java │ │ │ ├── AppUtils.java │ │ │ ├── CommonUtils.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 └── template ├── How_to_use_template.gif ├── MVPActivity ├── activity_layout_recipe.xml.ftl ├── globals.xml.ftl ├── recipe.xml.ftl ├── root │ └── src │ │ └── app_package │ │ ├── Activity.java.ftl │ │ ├── MvpPresenter.java.ftl │ │ ├── Presenter.java.ftl │ │ ├── View.java.ftl │ │ └── activity_layout.xml.ftl ├── template.xml └── template_blank_activity.png └── how_to_install.gif /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | /projectFilesBackup 10 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | 1. Fork it! 4 | 2. Checkout the development branch: `git checkout development` 5 | 3. Create your feature branch: `git checkout -b my-new-feature` 6 | 4. Add your changes to the index: `git add .` 7 | 5. Commit your changes: `git commit -m 'Add some feature'` 8 | 6. Push to the branch: `git push origin my-new-feature` 9 | 7. Submit a pull request against the `development` branch 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.data.DataManager; 21 | import com.mindorks.framework.mvp.di.component.DaggerTestComponent; 22 | import com.mindorks.framework.mvp.di.component.TestComponent; 23 | import com.mindorks.framework.mvp.di.module.ApplicationTestModule; 24 | 25 | import org.junit.rules.TestRule; 26 | import org.junit.runner.Description; 27 | import org.junit.runners.model.Statement; 28 | 29 | /** 30 | * Created by amitshekhar on 03/02/17. 31 | */ 32 | 33 | public class TestComponentRule implements TestRule { 34 | 35 | private TestComponent mTestComponent; 36 | private Context mContext; 37 | 38 | public TestComponentRule(Context context) { 39 | mContext = context; 40 | } 41 | 42 | public Context getContext() { 43 | return mContext; 44 | } 45 | 46 | public DataManager getDataManager() { 47 | return mTestComponent.getDataManager(); 48 | } 49 | 50 | private void setupDaggerTestComponentInApplication() { 51 | MvpApp application = ((MvpApp) mContext.getApplicationContext()); 52 | mTestComponent = DaggerTestComponent.builder() 53 | .applicationTestModule(new ApplicationTestModule(application)) 54 | .build(); 55 | application.setComponent(mTestComponent); 56 | } 57 | 58 | @Override 59 | public Statement apply(final Statement base, Description description) { 60 | return new Statement() { 61 | @Override 62 | public void evaluate() throws Throwable { 63 | try { 64 | setupDaggerTestComponentInApplication(); 65 | base.evaluate(); 66 | } finally { 67 | mTestComponent = null; 68 | } 69 | } 70 | }; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /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 amitshekhar on 03/02/17. 26 | */ 27 | @Singleton 28 | @Component(modules = ApplicationTestModule.class) 29 | public interface TestComponent extends ApplicationComponent { 30 | } 31 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/mindorks/framework/mvp/ui/login/LoginActivityTest.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.ui.login; 17 | 18 | import android.support.test.InstrumentationRegistry; 19 | import android.support.test.espresso.intent.rule.IntentsTestRule; 20 | import android.support.test.runner.AndroidJUnit4; 21 | 22 | import com.mindorks.framework.mvp.R; 23 | import com.mindorks.framework.mvp.TestComponentRule; 24 | 25 | import org.junit.Before; 26 | import org.junit.Rule; 27 | import org.junit.Test; 28 | import org.junit.rules.RuleChain; 29 | import org.junit.rules.TestRule; 30 | import org.junit.runner.RunWith; 31 | 32 | import static android.support.test.espresso.Espresso.onView; 33 | import static android.support.test.espresso.assertion.ViewAssertions.matches; 34 | import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; 35 | import static android.support.test.espresso.matcher.ViewMatchers.withId; 36 | import static android.support.test.espresso.matcher.ViewMatchers.withText; 37 | 38 | /** 39 | * Created by amitshekhar on 03/02/17. 40 | */ 41 | @RunWith(AndroidJUnit4.class) 42 | public class LoginActivityTest { 43 | 44 | public final TestComponentRule component = 45 | new TestComponentRule(InstrumentationRegistry.getTargetContext()); 46 | 47 | public final IntentsTestRule main = 48 | new IntentsTestRule<>(LoginActivity.class, false, false); 49 | 50 | @Rule 51 | public TestRule chain = RuleChain.outerRule(component).around(main); 52 | 53 | @Before 54 | public void setup() { 55 | 56 | } 57 | 58 | @Test 59 | public void checkViewsDisplay() { 60 | main.launchActivity(LoginActivity.getStartIntent(component.getContext())); 61 | 62 | onView(withId(R.id.et_email)) 63 | .check(matches(isDisplayed())); 64 | 65 | onView(withId(R.id.et_password)) 66 | .check(matches(isDisplayed())); 67 | 68 | onView(withId(R.id.btn_server_login)) 69 | .check(matches(isDisplayed())); 70 | 71 | onView(withText(R.string.login)) 72 | .check(matches(isDisplayed())); 73 | 74 | onView(withId(R.id.ib_google_login)) 75 | .check(matches(isDisplayed())); 76 | 77 | onView(withId(R.id.ib_fb_login)) 78 | .check(matches(isDisplayed())); 79 | } 80 | } -------------------------------------------------------------------------------- /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-architecture/2499fb2ba3aa65125a39999b2b2013bce75c9059/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-architecture/2499fb2ba3aa65125a39999b2b2013bce75c9059/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-architecture/2499fb2ba3aa65125a39999b2b2013bce75c9059/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-architecture/2499fb2ba3aa65125a39999b2b2013bce75c9059/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.data.DataManager; 23 | import com.mindorks.framework.mvp.di.component.ApplicationComponent; 24 | import com.mindorks.framework.mvp.di.component.DaggerApplicationComponent; 25 | import com.mindorks.framework.mvp.di.module.ApplicationModule; 26 | import com.mindorks.framework.mvp.utils.AppLogger; 27 | 28 | import javax.inject.Inject; 29 | 30 | import uk.co.chrisjenx.calligraphy.CalligraphyConfig; 31 | 32 | 33 | /** 34 | * Created by janisharali on 27/01/17. 35 | */ 36 | 37 | public class MvpApp extends Application { 38 | 39 | @Inject 40 | DataManager mDataManager; 41 | 42 | @Inject 43 | CalligraphyConfig mCalligraphyConfig; 44 | 45 | private ApplicationComponent mApplicationComponent; 46 | 47 | @Override 48 | public void onCreate() { 49 | super.onCreate(); 50 | 51 | mApplicationComponent = DaggerApplicationComponent.builder() 52 | .applicationModule(new ApplicationModule(this)).build(); 53 | 54 | mApplicationComponent.inject(this); 55 | 56 | AppLogger.init(); 57 | 58 | AndroidNetworking.initialize(getApplicationContext()); 59 | if (BuildConfig.DEBUG) { 60 | AndroidNetworking.enableLogging(Level.BODY); 61 | } 62 | 63 | CalligraphyConfig.initDefault(mCalligraphyConfig); 64 | } 65 | 66 | public ApplicationComponent getComponent() { 67 | return mApplicationComponent; 68 | } 69 | 70 | 71 | // Needed to replace the component with a test specific one 72 | public void setComponent(ApplicationComponent applicationComponent) { 73 | mApplicationComponent = applicationComponent; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/com/mindorks/framework/mvp/data/DataManager.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; 17 | 18 | 19 | import com.mindorks.framework.mvp.data.db.DbHelper; 20 | import com.mindorks.framework.mvp.data.network.ApiHelper; 21 | import com.mindorks.framework.mvp.data.prefs.PreferencesHelper; 22 | 23 | import io.reactivex.Observable; 24 | 25 | /** 26 | * Created by janisharali on 27/01/17. 27 | */ 28 | 29 | public interface DataManager extends DbHelper, PreferencesHelper, ApiHelper { 30 | 31 | void updateApiHeader(Long userId, String accessToken); 32 | 33 | void setUserAsLoggedOut(); 34 | 35 | Observable seedDatabaseQuestions(); 36 | 37 | Observable seedDatabaseOptions(); 38 | 39 | void updateUserInfo( 40 | String accessToken, 41 | Long userId, 42 | LoggedInMode loggedInMode, 43 | String userName, 44 | String email, 45 | String profilePicPath); 46 | 47 | enum LoggedInMode { 48 | 49 | LOGGED_IN_MODE_LOGGED_OUT(0), 50 | LOGGED_IN_MODE_GOOGLE(1), 51 | LOGGED_IN_MODE_FB(2), 52 | LOGGED_IN_MODE_SERVER(3); 53 | 54 | private final int mType; 55 | 56 | LoggedInMode(int type) { 57 | mType = type; 58 | } 59 | 60 | public int getType() { 61 | return mType; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/java/com/mindorks/framework/mvp/data/db/DbHelper.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 com.mindorks.framework.mvp.data.db.model.Option; 19 | import com.mindorks.framework.mvp.data.db.model.Question; 20 | import com.mindorks.framework.mvp.data.db.model.User; 21 | 22 | import java.util.List; 23 | 24 | import io.reactivex.Observable; 25 | 26 | 27 | /** 28 | * Created by janisharali on 08/12/16. 29 | */ 30 | 31 | public interface DbHelper { 32 | 33 | Observable insertUser(final User user); 34 | 35 | Observable> getAllUsers(); 36 | 37 | Observable> getAllQuestions(); 38 | 39 | Observable isQuestionEmpty(); 40 | 41 | Observable isOptionEmpty(); 42 | 43 | Observable saveQuestion(Question question); 44 | 45 | Observable saveOption(Option option); 46 | 47 | Observable saveQuestionList(List questionList); 48 | 49 | Observable saveOptionList(List